/// <summary> /// Declaration of references will be used for the states logic goes here /// Eg. /// public ISteer steeringScript; /// public GameObject pathRoute; /// public Queue<GameObject> enemyQueue = new Queue<GameObject>(); /// /// </summary> private void Start() { /// <summary> /// Instantiation of states Instances goes here. /// Eg. /// chaseEnemy = new ChaseState() /// { /// chasingRange = this.chasingRange, /// shootingRange = this.shootingRange, /// alertRange = this.alertRange, /// movementController = this /// }; /// </summary> ////Instantiate the first state fightingState = new FightingState() { gameplayFSMManager = this }; stateTransition = new StateTransition() { gameplayFSMManager = this }; washingState = new WashingState() { gameplayFSMManager = this }; pauseState = new PauseState() { gameplayFSMManager = this }; //push the first state for the player PushState(fightingState); }
private void StartHitting() { Debug.Log("Attack started" + Time.time); _state = FightingState.Attacking; _animator.Play("Attack", -1, 0f); _animator.Update(Time.deltaTime); var currentAnimatorClipInfo = _animator.GetCurrentAnimatorClipInfo(0); var delay = currentAnimatorClipInfo[0].clip.length; Debug.Log("Animation length: " + delay); Invoke(nameof(EndHitting), delay); }
/// <summary> /// Creates a new player object /// </summary> /// <param name="game"></param> public Player(Game game) { this.game = game; timer = new TimeSpan(0); curPosition = new Vector2(2, 352); Bounds = new BoundingRectangle(curPosition.X, curPosition.Y, 32, 45); moving_state = MovingState.Idle; prev_moving_state = MovingState.Idle; fighting_state = FightingState.Idle; powerUpTimer = new TimeSpan(0); bomb = new Bomb(game); keyboard = Keyboard.GetState(); }
public void Initialize(Queue <FightingSystem> targetQueue, int health, int damage, Animator animator) { if (_initialized) { return; } _targetsQueue = targetQueue; _health = health; _damage = damage; _state = FightingState.Idle; _animator = animator; _initialized = true; }
private void MakeFSM() { WanderState wander = new WanderState(); wander.AddTransition(Transition.SawPlayer, StateID.Fighting); FightingState fight = new FightingState(); fight.AddTransition(Transition.LostPlayer, StateID.Wander); fsm = new FSMSystem(); fsm.AddState(wander); fsm.AddState(fight); }
private void EndHitting() { Debug.Log("Attack ended" + Time.time); if (_currentTarget == null) { return; } if (!Alive()) { return; } _currentTarget.GetHit(_damage); _state = FightingState.Idle; }
void Start() { IdleState idle = new IdleState(PlayerState.Idle, this); ReadyState ready = new ReadyState(PlayerState.Ready, this); FightingState fight = new FightingState(PlayerState.Fighting, this); StopState stop = new StopState(PlayerState.Stop, this); SuccessState success = new SuccessState(PlayerState.Success, this); DeathState death = new DeathState(PlayerState.Death, this); Machine = new StateMachine(idle); Machine.AddState(ready); Machine.AddState(fight); Machine.AddState(stop); Machine.AddState(success); Machine.AddState(death); }
private void GetHit(int damage) { if (_state == FightingState.Dying) { return; } _health -= damage; if (!Alive()) { _state = FightingState.Dying; _animator.Play("Death"); var currentAnimatorClipInfo = _animator.GetCurrentAnimatorClipInfo(0); var delay = currentAnimatorClipInfo[0].clip.length; OnDied(); Invoke(nameof(OnAfterAnimationDied), delay); } }
void Awake() { Instance = this; startState = new GameStartState(); globalState = new GlobalState(); mainState = new MainState(); fighterEnterState = new FighterEnterState(); fighterOverState = new FighterOverState(); fighting = new FightingState(); loginState = new LoginState(); startupAuditorState = new StartupAuditorState(); OpenGlobalState(); State = GameStateType.GameStartState; ChangeState(startState); }
public IBehaviorState StateFactory(States state) { IBehaviorState ret = null; switch (state) { case States.Idling: break; case States.Roaming: ret = new RoamingState(host) as IBehaviorState; break; case States.Pursuing: ret = new PursuingState(host) as IBehaviorState; break; case States.Fighting: ret = new FightingState(host) as IBehaviorState; break; case States.Ranged: ret = new RangedCombatState(host) as IBehaviorState; break; case States.Melee: ret = new MeleeCombatState(host) as IBehaviorState; break; } if (ret != null) { ret.Init(this); } return(ret); }