|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
|
|
namespace Game {
|
|
|
|
public class RealPlayer : Player {
|
|
|
|
public bool isThisClient;
|
|
|
|
|
|
|
|
private new void Start() {
|
|
|
|
base.Start();
|
|
|
|
if (!isThisClient)
|
|
|
|
return;
|
|
|
|
GameUI.Singleton.buttonDown += (side, direction) => {
|
|
|
|
if (!side.Equals(Side))
|
|
|
|
return;
|
|
|
|
if (direction == "left")
|
|
|
|
goingLeftLinear = true;
|
|
|
|
else
|
|
|
|
goingRightLinear = true;
|
|
|
|
};
|
|
|
|
GameUI.Singleton.buttonUp += (side, direction) => {
|
|
|
|
if (!side.Equals(Side))
|
|
|
|
return;
|
|
|
|
if (direction == "left")
|
|
|
|
goingLeftLinear = false;
|
|
|
|
else
|
|
|
|
goingRightLinear = false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private void FixedUpdate() {
|
|
|
|
if (!isThisClient)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (Application.isEditor) {
|
|
|
|
var keyboard = Keyboard.current;
|
|
|
|
switch (Side) {
|
|
|
|
case Side.Top:
|
|
|
|
goingLeftLinear = keyboard.leftArrowKey.isPressed;
|
|
|
|
goingRightLinear = keyboard.rightArrowKey.isPressed;
|
|
|
|
break;
|
|
|
|
case Side.Bottom:
|
|
|
|
goingLeftLinear = keyboard.aKey.isPressed;
|
|
|
|
goingRightLinear = keyboard.dKey.isPressed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TryLinearMove(Time.fixedDeltaTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|