private void ChangeState(IPlayerState newState) { // use newState to tell player to change state. player should choose when to change it var oldState = state; Debug.Log("ChangeState: " + oldState.GetName() + " -> " + newState.GetName()); oldState.OnDetach(); state = newState; stateName = state.GetName(); if (stateLabel) { stateLabel.text = stateName; } state.OnAttach(); }
void Start() { controller = GetComponent <Controller2D>(); grappleThrower = GetComponent <GrappleThrower>(); replay = FindObjectOfType <BReplay>(); gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2); jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; state = new PlayerStateStop(this); state.OnAttach(); stateName = state.GetName(); if (stateLabel) { stateLabel.text = stateName; } print("Gravity: " + gravity + " Jump Velocity: " + jumpVelocity); fuMouse = new FixedMouseButtons(); }