private void ChangeStateIfNotNull(AIBaseState newState) { if (newState != null) { ChangeState(newState); } }
void OnDisable() { blackboard.ResetValues(); blinkController.StopPreviousBlinkings(); blackboard.animator.Rebind(); currentState = null; }
// Use this for initialization void Awake () { defaultState = new SpiderAIDefaultState(this); closeState = new AIBaseState(this); attackChipState = new AIBaseState(this); voxelization = GetComponent<VoxelizationClient>(); spiderRenderer = GetComponentInChildren<Renderer>(); }
// 참조하기 void Start() { anim = GetComponent <Animator>(); aiCon = GetComponentInParent <AIController>(); agent = GetComponentInParent <NavMeshAgent>(); aiBaseState = GetComponentInParent <AIBaseState>(); InitSet(); }
void SetBaseState() { //Check if we have somewhere to be if (baseState == AIBaseState.MOVETOPOSITION) { return; } //Defend for now baseState = AIBaseState.DEFENSE; //WantPosition = GetRealisticPosition(new Vector3(-85, 0, 0)); //baseState = AIBaseState.MOVETOPOSITION; }
public override AIBaseState Update() { /*When spider is in this state could happen this: 1-If a barrel of the same color is activated and in range: Go to AttractedToBarrel State 2-If spider is the last in the group and enemies attacking player < threshold: Go to AttackPlayer State 3-Any other case: Loop action list */ if (spiderBlackboard.capacitorController != null && spiderBlackboard.capacitorController.currentColor == spiderBlackboard.spider.color) return spiderBlackboard.attractedToBarrelState; spiderBlackboard.initialCheckDelay += Time.deltaTime; spiderBlackboard.checkAttackingSpidersDelay += Time.deltaTime; spiderBlackboard.checkInfectingChipDelay += Time.deltaTime; if (spiderBlackboard.groupInfo.followersCount == 0 && spiderBlackboard.initialCheckDelay >= 3f) { if ((spiderBlackboard.checkInfectingChipDelay >= spiderBlackboard.spider.checkDeviceEverySeconds)) { if ((rsc.enemyMng.bb.activeDevices.Count > 0) && (rsc.enemyMng.bb.timeRemainingToNextDeviceInfect == 0f)) { return spiderBlackboard.infectingDeviceState; } spiderBlackboard.checkInfectingChipDelay = 0f; } if ((spiderBlackboard.checkAttackingSpidersDelay >= spiderBlackboard.spider.checkAttackEverySeconds) //Check once per second && (rsc.enemyMng.bb.timeRemainingToNextPlayerAttack == 0f)) { if (rsc.enemyMng.bb.attackingPlayerSpiders < rsc.enemyMng.spidersAttackingThreshold) return spiderBlackboard.attackingPlayerState; spiderBlackboard.checkAttackingSpidersDelay = 0f; } } int updateResult = UpdateExecution(); if (updateResult == AIAction.LIST_FINISHED) return spiderBlackboard.attackingPlayerState; //Should not happen because the list has to loop else { AIBaseState result = ProcessUpdateExecutionResult(updateResult); spiderBlackboard.groupInfo.leaderActionIndex = currentActionIndex; return result; } }
protected void ChangeState(AIBaseState newState) { if (currentState != null) { //Debug.Log(this.GetType().Name + " Exiting: " + currentState.GetType().Name); currentState.OnStateExit(); } currentState = newState; if (currentState != null) { //Debug.Log(this.GetType().Name + " Entering: " + currentState.GetType().Name); currentState.OnStateEnter(); } }
void HandleAI() { SetBaseState(); GetPositions(); if (baseState == AIBaseState.DEFENSE) { SetDefensiveState(); } else if (baseState == AIBaseState.MOVETOPOSITION) { if (inPosition) { baseState = AIBaseState.NONE; } } FindPosition(); aiTimer += 0.25f; }
// 컴포넌트 불러오기 private void Awake() { aiAggro = GetComponent <AIAggro>(); aiAnim = transform.GetChild(0).GetComponent <AIAnim>(); anim = aiAnim.GetComponent <Animator>(); baseState = GetComponent <AIBaseState>(); living = GetComponent <AILiving>(); skillProcess = GetComponent <SkillProcess>(); cNetworkIdentity = GetComponent <CNetworkIdentity>(); networkAITransmitor = GetComponent <NetworkAITransmitor>(); networkAISyncor = GetComponent <NetworkAISyncor>(); nav = GetComponent <NavMeshAgent>(); path = nav.path; rd = GetComponent <Rigidbody>(); col = GetComponent <CapsuleCollider>(); SettingLayerMasks(); // 애니메이션 똑같이 안보이게 stateTickCount = UnityEngine.Random.Range(stateTickCount - 1, stateTickCount + 2); // stateCheckCooltime = UnityEngine.Random.Range(stateCheckCooltime - 0.1f, stateCheckCooltime + 0.1f); }
void GoToPosition(Vector3 pos) { inPosition = false; WantPosition = GetRealisticPosition(pos); baseState = AIBaseState.MOVETOPOSITION; }
public void Init(AIBaseState parent) { state = parent; }
private void ChangeState(AIBaseState newState) { if (currentState != null) currentState.OnStateExit(); currentState = newState; if (currentState != null) currentState.OnStateEnter(); }
// Use this for initialization void Awake () { defaultState = new SpiderAIDefaultState(this); closeState = new AIBaseState(this); attackChipState = new AIBaseState(this); }
void HandleAI() { SetBaseState(); GetPositions(); if (baseState == AIBaseState.DEFENSE) { SetDefensiveState(); } else if (baseState == AIBaseState.MOVETOPOSITION) { if(inPosition) baseState = AIBaseState.NONE; } FindPosition(); aiTimer += 0.25f; }
void GoToPosition(Vector3 pos) { inPosition = false; WantPosition = GetRealisticPosition(pos); baseState = AIBaseState.MOVETOPOSITION; }
void SetBaseState() { //Check if we have somewhere to be if (baseState == AIBaseState.MOVETOPOSITION) return; //Defend for now baseState = AIBaseState.DEFENSE; //WantPosition = GetRealisticPosition(new Vector3(-85, 0, 0)); //baseState = AIBaseState.MOVETOPOSITION; }
virtual public void Init(List<AIAction> actions, AIBaseState nextSt) { actionsList = actions; nextState = nextSt; }
public void TransitionToState(AIBaseState state) { currentState = state; currentState.EnterState(this); }