예제 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == this.transform.root.gameObject)
        {
            return;
        }

        if (other.CompareTag("Player"))
        {
            CharacterTypeOfGameObject         ch     = new CharacterTypeOfGameObject(other.gameObject, CharacterType.Player);
            CharacterTypeAndTimerOfGameObject chType = new CharacterTypeAndTimerOfGameObject(ch, 0f);
            m_aiManager.m_charWithTypeAndTimer.Add(chType);
        }
        else if (other.CompareTag("PlayerCampanion"))
        {
            if (other.gameObject.GetComponent <PlayerBoxerCampanion>() != null)
            {
                CharacterTypeOfGameObject         ch     = new CharacterTypeOfGameObject(other.gameObject, CharacterType.PlayerBoxerCampanion);
                CharacterTypeAndTimerOfGameObject chType = new CharacterTypeAndTimerOfGameObject(ch, 0f);
                m_aiManager.m_charWithTypeAndTimer.Add(chType);
            }
            else
            {
                CharacterTypeOfGameObject         ch     = new CharacterTypeOfGameObject(other.gameObject, CharacterType.PlayerGunnerCampanion);
                CharacterTypeAndTimerOfGameObject chType = new CharacterTypeAndTimerOfGameObject(ch, 0f);
                m_aiManager.m_charWithTypeAndTimer.Add(chType);
            }
        }
        else if (other.CompareTag("Enemy"))
        {
            if (other.gameObject.GetComponent <EnemyGunner>() != null)
            {
                CharacterTypeOfGameObject         ch     = new CharacterTypeOfGameObject(other.gameObject, CharacterType.EnemyGunner);
                CharacterTypeAndTimerOfGameObject chType = new CharacterTypeAndTimerOfGameObject(ch, 0f);
                m_aiManager.m_charWithTypeAndTimer.Add(chType);
            }
            else
            {
                CharacterTypeOfGameObject         ch     = new CharacterTypeOfGameObject(other.gameObject, CharacterType.EnemyBoxer);
                CharacterTypeAndTimerOfGameObject chType = new CharacterTypeAndTimerOfGameObject(ch, 0f);
                m_aiManager.m_charWithTypeAndTimer.Add(chType);
            }
        }
    }
예제 #2
0
        private void VisualPerception(CharacterTypeAndTimerOfGameObject item, string tag)
        {
            Vector3 dir = item.CharacterGameObjectWithType.characterGameObject.transform.position - transform.position;

            bool isVisible = CheckVisibility(dir, tag);

            if (isVisible)
            {
                if (item.VisibilityTimer >= m_AIVisibleTime)
                {
                    item.VisibilityTimer = m_AIVisibleTime;
                    return;
                }

                float vt = item.IncrementOrDecrementTimer(Time.deltaTime);

                if (m_visibledCharWithType.Contains(item.CharacterGameObjectWithType))
                {
                    return;
                }

                if (vt >= m_AIVisibleTime || dir.sqrMagnitude <= m_AIField.ThresoldViewRange * m_AIField.ThresoldViewRange)
                {
                    item.VisibilityTimer = m_AIVisibleTime;
                    m_visibledCharWithType.Add(item.CharacterGameObjectWithType);
                }
            }
            else
            {
                if (item.VisibilityTimer <= 0)
                {
                    item.VisibilityTimer = 0f;
                    return;
                }

                float vt = item.IncrementOrDecrementTimer(-Time.deltaTime);

                if (vt <= 0f)
                {
                    CharacterTypeOfGameObject chType = item.CharacterGameObjectWithType;
                    m_visibledCharWithType.Remove(chType);
                }
            }
        }