Esempio n. 1
0
    // 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;
        }
    }
Esempio n. 2
0
 public EnemyState GetState(EnemyStateType _type)
 {
     if (!states.ContainsKey(_type))
     {
         return(null);
     }
     return(states[_type]);
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
    public void GotoState(EnemyStateType _key)
    {
        if (!states.ContainsKey(_key))
        {
            return;
        }

        currentState?.Exit();

        previousState    = currentState;
        CurrentStateType = _key;
        currentState     = states[CurrentStateType];

        currentState.Enter();
    }
Esempio n. 5
0
 public void AddState(EnemyStateType _type, IState _state)
 {
     states.Add(_type, _state);
 }
Esempio n. 6
0
 public void SwitchState(EnemyStateType _type)
 {
     currentState?.Exit();
     currentState = states[_type];
     currentState?.Enter();
 }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 public void AddState(EnemyStateType _newType, EnemyState _newState)
 {
     states.Add(_newType, _newState);
     states[_newType].Initialize(this);
 }
Esempio n. 9
0
 public EnemyState(EnemyStateType state, EnemyController unit) : base(state.ToString(), unit)
 {
 }
Esempio n. 10
0
 // 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();
 }
Esempio n. 11
0
 public virtual void ChangeState(EnemyStateType stateType)
 {
     ReQuest();
 }
Esempio n. 12
0
    public EnemyStateType GetRandomState()
    {
        EnemyStateType e = (EnemyStateType)Random.Range(1, 4);

        return(e);
    }