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(); }
/// <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); } }
/** * Start should be used to create any states that you want the StateMachine * to run. The states will control the AIs behavior, then ideally all * you have to do is update the machine forever. */ void Start() { //Random.InitState((int)(Time.realtimeSinceStartup * 1000)); machine = new AIStateMachine(player, gameObject); IState wanderState = new AIWanderState(machine); IState chaseState = new AIChaseState(machine); machine.SetInitialState(wanderState); machine.AddTransition(wanderState, chaseState); machine.AddTransition(chaseState, wanderState); }
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()); }
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(); }