/// <summary> /// Initializes the Finite state machine. /// </summary> protected virtual void MakeFSM() { // Follow behaviour FollowPlayer follow = new FollowPlayer(attackRange, playerAttackLayer, this); follow.AddTransition(Transition.InPlayerAttackRange, StateID.AttackPlayer); follow.AddTransition(Transition.ReachedDestination, StateID.Idle); // Attack behaviour AttackPlayer attack = new AttackPlayer(attackRange, playerAttackLayer, attackInterval, pushAwayForce, this); attack.AddTransition(Transition.LostPlayerAttackRange, StateID.FollowPlayer); attack.AddTransition(Transition.ReachedDestination, StateID.Idle); // Idle behaviour IdleEnemy idle = new IdleEnemy(); idle.AddTransition(Transition.SawPlayer, StateID.FollowPlayer); fsm = new FSMSystem(); fsm.AddState(follow); fsm.AddState(attack); fsm.AddState(idle); }
protected override void MakeFSM() { // Follow behaviour FollowPlayer follow = new FollowPlayer(attackRange, playerAttackLayer, this); follow.AddTransition(Transition.InPlayerAttackRange, StateID.AttackPlayer); follow.AddTransition(Transition.ReachedDestination, StateID.Idle); // Attack behaviour ShootPlayer shoot = new ShootPlayer(attackRange, playerAttackLayer, attackInterval, this); shoot.AddTransition(Transition.LostPlayerAttackRange, StateID.FollowPlayer); shoot.AddTransition(Transition.ReachedDestination, StateID.Idle); // Idle behaviour IdleEnemy idle = new IdleEnemy(); idle.AddTransition(Transition.SawPlayer, StateID.FollowPlayer); fsm = new FSMSystem(); fsm.AddState(follow); fsm.AddState(shoot); fsm.AddState(idle); }