コード例 #1
0
        /// <summary>
        /// Get current entities state
        /// </summary>
        /// <param name="cooldown">Current state cooldown. Range from 0 to 1</param>
        public States GetAIStatus(out float cooldown)
        {
            States result = States.Idle;
            float  attentionCooldown, aggresionCooldown;

            attentionCooldown = aggresionCooldown = cooldown = 0;

            for (int i = 0; i < ais.Count; i++)
            {
                if (ais[i].GetState() is AIStateAttention)
                {
                    result = States.Attention;
                    AIStateAttention attention = (AIStateAttention)ais[i].GetState();
                    if (attention.Cooldown > attentionCooldown)
                    {
                        attentionCooldown = attention.Cooldown;
                    }
                }
                else if (ais[i].GetState() is AIStateAggresion)
                {
                    result = States.Aggresion;
                    AIStateAggresion aggresion = (AIStateAggresion)ais[i].GetState();
                    if (aggresion.Cooldown > aggresionCooldown)
                    {
                        aggresionCooldown = aggresion.Cooldown;
                    }
                }
                else if (ais[i].GetState() is AIStateCover)
                {
                    result            = States.Aggresion;
                    aggresionCooldown = 1;
                }
            }

            AIZone[] zones = AIZone.GetZones();
            for (int i = 0; i < zones.Length; i++)
            {
                if (zones[i].IsAggression())
                {
                    result = States.Aggresion;
                    break;
                }
            }

            if (result == States.Attention)
            {
                cooldown = attentionCooldown;
            }
            else if (result == States.Aggresion)
            {
                cooldown = aggresionCooldown;
            }

            return(result);
        }
コード例 #2
0
 /// </inheritdoc>/>
 public void Warp(Vector3 pos)
 {
     if (RagdollEnabled)
     {
         ragdoll.DisableRagdoll(true);
     }
     navMeshAgent.isStopped = true;
     navMeshAgent.Warp(pos);
     navMeshAgent.isStopped = false;
     assignedZone           = AIZone.GetZoneByPos(pos);
 }
コード例 #3
0
        public static void AddAIZone()
        {
            GameObject go = new GameObject("AIZone");

            go.layer = 12;
            AIZone      zone = go.AddComponent <AIZone>();
            BoxCollider coll = go.AddComponent <BoxCollider>();

            coll.size                  = Vector3.one * 5;
            coll.isTrigger             = true;
            Selection.activeGameObject = go;
        }
コード例 #4
0
        /// <summary>
        /// Register the entity in the AIManager and assign the AIZone for it based on its position.
        /// </summary>
        public void RegisterAI(AIEntity ai)
        {
            ais.Add(ai);

            AIZone zone = AIZone.GetZoneByPos(ai.transform.position);

            if (zone == null)
            {
                zone = AIZone.CreateSceneSizeZone();
            }

            zone.AddAI(ai);

            UpdateAttackOrder();
        }
コード例 #5
0
 ///<inheritdoc/>
 protected override void TriggerAction(Transform other)
 {
     base.TriggerAction(other);
     source.Play();
     AIZone.HearSound(new SoundStimuli(transform, soundProperties));
 }
コード例 #6
0
 private void OnEnable()
 {
     zone = AIZone.GetZoneByPos(transform.position);
 }