You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
49 lines
1.0 KiB
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace Game {
|
|
public class RealPlayer : Player {
|
|
public bool isThisClient;
|
|
|
|
private new void Start() {
|
|
base.Start();
|
|
GameUI.Singleton.buttonDown += (side, direction) => {
|
|
if (!side.Equals(Side))
|
|
return;
|
|
if (direction == "left")
|
|
goingLeft = true;
|
|
else
|
|
goingRight = true;
|
|
};
|
|
GameUI.Singleton.buttonUp += (side, direction) => {
|
|
if (!side.Equals(Side))
|
|
return;
|
|
if (direction == "left")
|
|
goingLeft = false;
|
|
else
|
|
goingRight = false;
|
|
};
|
|
}
|
|
|
|
private void FixedUpdate() {
|
|
if (!isThisClient)
|
|
return;
|
|
|
|
if (Application.isEditor) {
|
|
var keyboard = Keyboard.current;
|
|
switch (Side) {
|
|
case Side.Top:
|
|
goingLeft = keyboard.leftArrowKey.isPressed;
|
|
goingRight = keyboard.rightArrowKey.isPressed;
|
|
break;
|
|
case Side.Bottom:
|
|
goingLeft = keyboard.aKey.isPressed;
|
|
goingRight = keyboard.dKey.isPressed;
|
|
break;
|
|
}
|
|
}
|
|
|
|
TryLinearMove(Time.fixedDeltaTime);
|
|
}
|
|
}
|
|
}
|
|
|