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.
51 lines
1.1 KiB
51 lines
1.1 KiB
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);
|
|
}
|
|
}
|
|
}
|
|
|