Пример #1
0
    private void SetupStateMachine()
    {
        AIAttackTargetState attackState = new AIAttackTargetState(this);
        AIChaseTargetState chaseState = new AIChaseTargetState(this);
        AIEvasiveManeuverState evasiveManeuverState = new AIEvasiveManeuverState(this);
        AIFleeState fleeState = new AIFleeState(this);
        AIPatrolState patrolState = new AIPatrolState(this);

        patrolState.AddTransition(Transition.EnemyAITargetInSight, StateID.EnemyAIChase);

        chaseState.AddTransition(Transition.EnemyAITargetLockAcquired, StateID.EnemyAIAttack);
        chaseState.AddTransition(Transition.EnemyAITargetSightLost, StateID.EnemyAIPatrol);
        chaseState.AddTransition(Transition.EnemyAITargetKilled, StateID.EnemyAIPatrol);
        //        chaseState.AddTransition(Transition.EnemyAIDamageReceived, StateID.EnemyAIEvasiveManeuver);

        attackState.AddTransition(Transition.EnemyAITargetLockLost, StateID.EnemyAIChase);
        attackState.AddTransition(Transition.EnemyAITargetSightLost, StateID.EnemyAIPatrol);
        //        attackState.AddTransition(Transition.EnemyAIDamageReceived, StateID.EnemyAIEvasiveManeuver);

        FSM = new FSMSystem();
        FSM.AddState(patrolState); // Will be the current state (pdcgomes 30.12.2013)
        FSM.AddState(attackState);
        FSM.AddState(chaseState);
        FSM.AddState(evasiveManeuverState);
        FSM.AddState(fleeState);
    }
Пример #2
0
        protected override void Initialized()
        {
            GunClass[] guns = GetComponentsInChildren <GunClass>();
            foreach (GunClass item in guns)
            {
                m_Guns.Add(item);
            }

            m_CurrentlyActiveGun = m_Guns[Random.Range(0, m_Guns.Count)];

            float sqrRange = m_AIGunnerField.AttackbyGunRange * m_AIGunnerField.AttackbyGunRange;

            m_unwareAIState  = new AIUnwareState <AIManager>(this, sqrRange);
            m_patrolAIState  = new AIPatrolState <AIManager>(this, sqrRange);
            m_chaseAIState   = new AIChaseState <AIManager>(this, sqrRange);
            m_searchAIState  = new AISearchState <AIManager>(this, sqrRange);
            m_coverAIState   = new AICoverState <AIManager>(this);
            m_gunFireAIState = new AIGunFireState(this);

            if (m_unwareAIState == null || m_patrolAIState == null ||
                m_chaseAIState == null || m_searchAIState == null ||
                m_gunFireAIState == null)
            {
                Debug.LogError("AI State is null");
            }

            base.Initialized();
        }
Пример #3
0
    /// <summary>
    /// 상태 딕셔너리 추가
    /// **다른 곳에서는 수정이 안됨
    /// **try~catch로는 null값으로 들어가서 catch 잡기가 불가능함
    /// </summary>
    protected override void DictionarySetting()
    {
        base.DictionarySetting();

        patrolState    = GetComponent <AIPatrolState>();
        chaseState     = GetComponent <AIChaseState>();
        attackState    = GetComponent <AIAttackState>();
        knockbackState = GetComponent <AIKnockBackState>();
        deathState     = GetComponent <AIDeathState>();

        dictStateAction.Add(AIController.AIState.IDLE, this);
        dictStateAction.Add(AIController.AIState.PATROL, patrolState);
        dictStateAction.Add(AIController.AIState.CHASE, chaseState);
        dictStateAction.Add(AIController.AIState.ATTACK, attackState);
        dictStateAction.Add(AIController.AIState.KNOCKBACK, knockbackState);
        dictStateAction.Add(AIController.AIState.DEATH, deathState);

        // Debug.Log("접근끝");
        climbState = GetComponent <AIClimbState>();
        if (climbState != null)
        {
            dictStateAction.Add(AIController.AIState.CLIMB, climbState);
        }

        landState = GetComponent <AILandState>();
        if (landState != null)
        {
            dictStateAction.Add(AIController.AIState.LAND, landState);
        }

        jumpState = GetComponent <AIJumpState>();
        if (jumpState != null)
        {
            dictStateAction.Add(AIController.AIState.JUMP, jumpState);
        }

        spitState = GetComponent <AISpitState>();
        if (spitState != null)
        {
            dictStateAction.Add(AIController.AIState.SPIT, spitState);
        }

        leapState = GetComponent <AILeapState>();
        if (leapState != null)
        {
            dictStateAction.Add(AIController.AIState.LEAP, leapState);
        }

        rushState = GetComponent <AIRushState>();
        if (rushState != null)
        {
            dictStateAction.Add(AIController.AIState.RUSH, rushState);
        }
    }
Пример #4
0
    public void StartFSM(Player player)
    {
        this.player = player;
        AIPatrolState patrolState = gameObject.AddComponent <AIPatrolState>();
        AIChaseState  chaseState  = gameObject.AddComponent <AIChaseState>();

        patrolState.SetPlayer(player);
        patrolState.SetOwner(this);

        chaseState.SetPlayer(player);
        chaseState.SetOwner(this);

        AddFSMState(patrolState);
        AddFSMState(chaseState);

        StartCoroutine(StartFSMCoroutine());
    }
Пример #5
0
        protected override void Initialized()
        {
            m_GiveHitColliders = GetComponentsInChildren <GiveHitCollider>();

            float sqrRange = m_AIBoxerField.AttackRange * m_AIBoxerField.AttackRange;

            m_unwareAIState = new AIUnwareState <AIManager>(this, sqrRange);
            m_patrolAIState = new AIPatrolState <AIManager>(this, sqrRange);
            m_chaseAIState  = new AIChaseState <AIManager>(this, sqrRange);
            m_searchAIState = new AISearchState <AIManager>(this, sqrRange);
            m_coverAIState  = new AICoverState <AIManager>(this);

            float sqrKickDist  = m_AIBoxerField.KickRange * m_AIBoxerField.KickRange;
            float sqrPunchDist = m_AIBoxerField.PunchRange * m_AIBoxerField.PunchRange;

            m_boxingAIState = new AIBoxingState(this, m_charRadius, sqrRange, sqrKickDist, sqrPunchDist);

            DisableGiveHitCollider(HitColliderType.LeftAnkle);
            base.Initialized();
        }