// Změní stav podle parametru private void SetState(EnemyStateType nextState) { switch (nextState) { case EnemyStateType.FollowPathToTarget: _currentState = _followPathToTargetState; break; case EnemyStateType.WaitForNextAction: _currentState = _waitForNextActionState; break; case EnemyStateType.AttackTarget: _currentState = _attackTargetState; break; case EnemyStateType.FollowTarget: _currentState = _followTargetState; break; case EnemyStateType.WalkToRandomPlace: _currentState = _walkToRandomPlaceState; break; case EnemyStateType.FaceRandomDirection: _currentState = _faceRandomDirectionState; break; } }
public EnemyState GetState(EnemyStateType _type) { if (!states.ContainsKey(_type)) { return(null); } return(states[_type]); }
public override void ChangeState(EnemyStateType stateType) { switch (stateType) { case EnemyStateType.Idle: currentState = new Idle(animator, rigidbodyComponent); break; case EnemyStateType.Die: currentState = new Die(animator, DeadTimer, TimeToReturn, new DeadTimerCallback(EndDead)); break; case EnemyStateType.Damage: currentState = new Damage(animator); break; case EnemyStateType.Attack1: if (isAttackable[0]) { currentState = new Boss.Attack(animator, bossPhase, fireballLifeTimer, new TimerCallback(PushFireballTimer), TargetObject, transform, TimeToReturn, ObjectPoolManager.Instance.FireballQueue, FireBallSpeed, LaunchedFireballList, (int)Power); isAttackable[0] = false; Pattern1Timer = GameTimeManager.Instance.PopTimer(); Pattern1Timer.SetTimer(attack1Tick, false); Pattern1Timer.Callback = new TimerCallback(SetAttackable1); Pattern1Timer.StartTimer(); } break; case EnemyStateType.Attack2: if (isAttackable[1]) { currentState = new Boss.UseSkill(animator, explode, explodeLifeTimer, Power, explodeLifeTime, new TimerCallback(UseSkillEnd), bossPhase); isAttackable[1] = false; Pattern1Timer = GameTimeManager.Instance.PopTimer(); Pattern1Timer.SetTimer(attack2Tick, false); Pattern1Timer.Callback = new TimerCallback(SetAttackable2); Pattern1Timer.StartTimer(); } break; case EnemyStateType.Move: currentState = new Move(animator, transform, rigidbodyComponent, destinationPoint, currentPoint, MoveSpeed, currentTile); break; default: break; } base.ChangeState(stateType); }
public void GotoState(EnemyStateType _key) { if (!states.ContainsKey(_key)) { return; } currentState?.Exit(); previousState = currentState; CurrentStateType = _key; currentState = states[CurrentStateType]; currentState.Enter(); }
public void AddState(EnemyStateType _type, IState _state) { states.Add(_type, _state); }
public void SwitchState(EnemyStateType _type) { currentState?.Exit(); currentState = states[_type]; currentState?.Enter(); }
public override void ChangeState(EnemyStateType stateType) { switch (stateType) { case EnemyStateType.Idle: currentState = new Idle(animator, rigidbodyComponent); break; case EnemyStateType.Die: currentState = new Die(animator, DeadTimer, TimeToReturn, new DeadTimerCallback(EndDead)); break; case EnemyStateType.Damage: currentState = new Damage(animator); break; case EnemyStateType.Attack1: if (isAttackable[0]) { currentState = new Normal.AttackPattern1(animator, transform, TargetObject, rigidbodyComponent); isAttackable[0] = false; Pattern1Timer = GameTimeManager.Instance.PopTimer(); Pattern1Timer.SetTimer(attack1Tick, false); Pattern1Timer.Callback = new TimerCallback(SetAttackable1); Pattern1Timer.StartTimer(); } break; case EnemyStateType.Attack2: if (isAttackable[1]) { currentState = new Normal.AttackPattern2( PopFireBall(), FireBallLifeTimer, animator, transform, rigidbodyComponent, TargetObject, currentPoint, FireBallSpeed, new TimerCallback(PushFireBall), new ChangeStateCallback(ChangeState), Power); isAttackable[1] = false; Pattern1Timer = GameTimeManager.Instance.PopTimer(); Pattern1Timer.SetTimer(attack1Tick, false); Pattern1Timer.Callback = new TimerCallback(SetAttackable2); Pattern1Timer.StartTimer(); } break; case EnemyStateType.Move: currentState = new Move( animator, transform, rigidbodyComponent, destinationPoint, currentPoint, MoveSpeed, currentTile); break; default: break; } base.ChangeState(stateType); }
public void AddState(EnemyStateType _newType, EnemyState _newState) { states.Add(_newType, _newState); states[_newType].Initialize(this); }
public EnemyState(EnemyStateType state, EnemyController unit) : base(state.ToString(), unit) { }
// Změní stav a zavolá metodu ukončující starý stav a začínající nový stav public void ChangeState(EnemyStateType nextState) { _currentState.OnExit(); SetState(nextState); _currentState.OnEntered(); }
public virtual void ChangeState(EnemyStateType stateType) { ReQuest(); }
public EnemyStateType GetRandomState() { EnemyStateType e = (EnemyStateType)Random.Range(1, 4); return(e); }