예제 #1
0
 // Use this for initialization
 void Start()
 {
     range     = GetComponent <EnemiesInRange>();
     list      = range.triggerList;
     time      = Time.time;
     playState = gameObject.transform.parent.GetComponent <PlayerValuesScript>();
     audio     = GameObject.Find("Music").GetComponent <AudioSource>();
 }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        //UpdateEnemies();
        if (Target != null || (Target == null && time < 1 / buildingData.AttackSpeed))
        {
            time += Time.deltaTime;
        }

        if (time > 1 / buildingData.AttackSpeed && !IsPlacement)
        {
            foreach (Transform enemy in EnemiesInRange.ToArray())
            {
                if (!enemy)
                {
                    EnemiesInRange.Remove(enemy);
                }
            }
            Attack();
        }
    }