private void InitialiseFSM() { _fsm = new FSM.FSM(); State idleState = new IdleState(this); State rollingState = new RollingState(this); State mountedState = new MountedState(this); _fsm.AddTransition(idleState, rollingState, () => { return(_currentHeading != Vector3.zero); }); _fsm.AddTransition(rollingState, idleState, () => { return(_currentHeading == Vector3.zero); }); _fsm.AddTransition(idleState, mountedState, () => { if (Input.GetKeyDown(KeyCode.F)) { return(EnterGolem()); } return(false); }); _fsm.AddTransition(mountedState, idleState, () => { return(Input.GetKeyDown(KeyCode.F)); }); _fsm.SetDefaultState(idleState); }
void Update() { GetInputs(); GetSwimDirection(); if (inWater) { GetWaterlevel(); } if (mount) { // if (MountType == MountType.ground) // { // if (mountedState != MountedState.mounted) // mountedState = MountedState.mounted; // } // else if (MountType == MountType.flying) // { // if (mountedState != MountedState.mountedFlying) // mountedState = MountedState.mountedFlying; // } } else { if (mountedState != MountedState.unmounted) { mountedState = MountedState.unmounted; } } if (moveState == MoveState.locomotion) { Locomotion(); } else if (moveState == MoveState.swimming) { Swimming(); } else if (moveState == MoveState.flying) { Flying(); } else { Debug.Log("WAIT"); } GameObject theCamera = Camera.main.gameObject; // AudioAnalyser audioAnalyse = theCamera.GetComponent<AudioAnalyser>(); // ppos = new Vector2(transform.position.x, audioAnalyse.pitchValue / 50); // transform.position = ppos; }
void Update() { GetInputs(); GetSwimDirection(); if (inWater) { GetWaterlevel(); } if (mount) { if (mountType == MountType.ground) { if (mountedState != MountedState.mounted) { mountedState = MountedState.mounted; } } else if (mountType == MountType.flying) { if (mountedState != MountedState.mountedFlying) { mountedState = MountedState.mountedFlying; } } } else { if (mountedState != MountedState.unmounted) { mountedState = MountedState.unmounted; } } switch (moveState) { case MoveState.locomotion: Locomotion(); break; case MoveState.swimming: Swimming(); break; case MoveState.flying: Flying(); break; } }