Ejemplo n.º 1
0
 void Start()
 {
     memory = (memory == null) ? GetComponent <AIMemory>() : memory;
     if (sounds.weaponSource == null)
     {
         SetWeaponSoundSource();
     }
 }
Ejemplo n.º 2
0
        public void Attack(GameObject overrideTarget = null)
        {
            if (number_of_allowed_attacks < 1)
            {
                return;
            }
            number_of_allowed_attacks -= 1;
            if (isDebugging == true)
            {
                Debug.Log(name + " attacked");
            }
            AIMemory   memory = GetComponent <AIMemory>();
            GameObject target = null;

            if (overrideTarget == null)
            {
                target = memory.GetTarget();
            }
            else
            {
                target = overrideTarget;
            }
            if (target == null)
            {
                return;
            }
            GameObject returnTarget = AIHelpers.InaccurateRaycast(
                target.transform,
                memory.GetEyes().transform,
                memory.GetIgnoreLayers(),
                memory.GetOffsetRange(),
                memory.GetInaccuracy(),
                memory.GetFireRange(),
                isDebugging
                );

            PlayMuzzleFlash();
            PlayWeaponSound();
            if (returnTarget != null)
            {
                if (isDebugging == true)
                {
                    Debug.Log(name + " sending damage to " + returnTarget.transform.root.name);
                }
                if (returnTarget.transform.root.GetComponent <Health>())
                {
                    returnTarget.transform.root.GetComponent <Health>().ApplyDamage(memory.GetRangeDamageAmount(), gameObject);
                }
            }
        }
Ejemplo n.º 3
0
        public void BroadCastTargetPosition()
        {
            AIMemory memory   = GetComponent <AIMemory>();
            Vector3  position = memory.GetLastTargetPosition();
            float    distance = memory.GetShoutDistance();

            string[]     friendTags = memory.GetFriendTags();
            GameObject[] friends    = AIHelpers.GetAllGameObjectsInRange(friendTags, distance);
            foreach (GameObject friend in friends)
            {
                friend.GetComponent <AIMemory>().SetLastTargetPosition(position);
                friend.GetComponent <AIMemory>().SetIncreasedLevel();
            }
        }