private void Init() { RatAnimator = GetComponent <RatAnimator>(); ratStateMachine.Init(this); idling = new Idle(); walking = new Walk(); jumping = new Jump(); climbing = new Climb(); jumpingOff = new JumpOff(); idling.Init(this, ratStateMachine); walking.Init(this, ratStateMachine); jumping.Init(this, ratStateMachine); climbing.Init(this, ratStateMachine); jumpingOff.Init(this, ratStateMachine); ratStateMachine.AddState(idle, idling); ratStateMachine.AddState(walk, walking); ratStateMachine.AddState(jump, jumping); ratStateMachine.AddState(climb, climbing); ratStateMachine.AddState(jumpOff, jumpingOff); ratStateMachine.ChangeState(idle); //update helpers rotationUpdater.Add(UpdateRotation); }
private void giveRoute() { if (myRoute == null || myRoute.Count < 1) { myBehaviour = new Idle(y); myBehaviour.Init(spriteRenderer, transform, DoneIdle); return; } ((RouteFollower)myBehaviour).giveRoute(myRoute); }
public void Init() { _player = GetComponent <Player>(); IState move = new PlayerMove(); IState idle = new Idle(); IState interaction = new Interaction(); IState skill = new Skill(); IState changeFireMode = new ChangeFireMode(); IState reroad = new Reroad(); IState shoot = new PlayerShoot(); move = gameObject.AddComponent <PlayerMove>(); idle = gameObject.AddComponent <PlayerIdle>(); interaction = gameObject.AddComponent <Interaction>(); skill = gameObject.AddComponent <Skill>(); changeFireMode = gameObject.AddComponent <ChangeFireMode>(); reroad = gameObject.AddComponent <Reroad>(); shoot = gameObject.AddComponent <PlayerShoot>(); move.Init(); idle.Init(); interaction.Init(); skill.Init(); changeFireMode.Init(); reroad.Init(); shoot.Init(); _actionDic.Add(PlayerState.Move, move); _actionDic.Add(PlayerState.Idle, idle); _actionDic.Add(PlayerState.Interaction, interaction); _actionDic.Add(PlayerState.Skill, skill); _actionDic.Add(PlayerState.ChangeFireMode, changeFireMode); _actionDic.Add(PlayerState.Reroad, reroad); _actionDic.Add(PlayerState.Shoot, shoot); }