public void Control(IShipMovementBehaviour behaviour) { float x = Input.GetAxisRaw("Horizontal"); float y = Input.GetAxisRaw("Vertical"); if (x != 0) { if (x > 0) { behaviour.TurnRight(); } else { behaviour.TurnLeft(); } } if (y != 0) { if (y > 0) { behaviour.MoveForward(); } else { behaviour.MoveBackwards(); } } }
private void Awake() { thisRB = GetComponent <Rigidbody2D>(); behaviour = new ShipMovementBehaviourRigidBody2D(thisRB, transform).SetSpeed(speed) .SetThrust(thrust).SetTurnRate(turnRate); controller = new ShipMovementControllerPlayer(); }