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

        currentState?.Exit();

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

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

        return(e);
    }