Exemplo n.º 1
0
 private void ChangeStateIfNotNull(AIBaseState newState)
 {
     if (newState != null)
     {
         ChangeState(newState);
     }
 }
Exemplo n.º 2
0
 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>();
    }
Exemplo n.º 4
0
    // 참조하기
    void Start()
    {
        anim        = GetComponent <Animator>();
        aiCon       = GetComponentInParent <AIController>();
        agent       = GetComponentInParent <NavMeshAgent>();
        aiBaseState = GetComponentInParent <AIBaseState>();

        InitSet();
    }
Exemplo n.º 5
0
    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;
        }
    }
Exemplo n.º 7
0
 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();
     }
 }
Exemplo n.º 8
0
    void HandleAI()
    {
        SetBaseState();
        GetPositions();

        if (baseState == AIBaseState.DEFENSE)
        {
            SetDefensiveState();
        }
        else if (baseState == AIBaseState.MOVETOPOSITION)
        {
            if (inPosition)
            {
                baseState = AIBaseState.NONE;
            }
        }

        FindPosition();

        aiTimer += 0.25f;
    }
Exemplo n.º 9
0
    // 컴포넌트 불러오기
    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);
    }
Exemplo n.º 10
0
 void GoToPosition(Vector3 pos)
 {
     inPosition   = false;
     WantPosition = GetRealisticPosition(pos);
     baseState    = AIBaseState.MOVETOPOSITION;
 }
Exemplo n.º 11
0
 public void Init(AIBaseState parent)
 {
     state = parent;
 }
Exemplo n.º 12
0
 private void ChangeState(AIBaseState newState)
 {
     if (currentState != null) currentState.OnStateExit();
     currentState = newState;
     if (currentState != null) currentState.OnStateEnter();
 }
Exemplo n.º 13
0
	// Use this for initialization
	void Awake ()
    {
        defaultState = new SpiderAIDefaultState(this);
        closeState = new AIBaseState(this);
        attackChipState = new AIBaseState(this);
	}
Exemplo n.º 14
0
    void HandleAI()
    {
        SetBaseState();
        GetPositions();

        if (baseState == AIBaseState.DEFENSE)
        {
            SetDefensiveState();
        } 
        else if (baseState == AIBaseState.MOVETOPOSITION)
        {
            if(inPosition)
                baseState = AIBaseState.NONE;
        }

        FindPosition();

        aiTimer += 0.25f;
    }
Exemplo n.º 15
0
 void GoToPosition(Vector3 pos)
 {
     inPosition = false;
     WantPosition = GetRealisticPosition(pos);
     baseState = AIBaseState.MOVETOPOSITION;
 }
Exemplo n.º 16
0
    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;
    }
Exemplo n.º 17
0
 virtual public void Init(List<AIAction> actions, AIBaseState nextSt)
 {
     actionsList = actions;
     nextState = nextSt;
 }
Exemplo n.º 18
0
 public void TransitionToState(AIBaseState state)
 {
     currentState = state;
     currentState.EnterState(this);
 }