예제 #1
0
 public virtual void initialize()
 {
     gm             = GameManager.getInstance();
     minionMovement = (MinionMovement)GetComponent <MinionMovement>();
     buffs          = new List <Buff>();
     attrs          = new List <Attribute>();
     attrs.Add(health);
     attrs.Add(damage);
     attrs.Add(armor);
     attrs.Add(attackRadius);
     attrs.Add(damageModifier);
     attrs.Add(minionMovement.detectionRadius);
     attrs.Add(minionMovement.speed);
     attrs.ForEach(attr => attr.init());
     hpCanvas = GameObject.Find(hpCanvasName);
     hpBar    = (GameObject)Instantiate(hpBarPrefab);
     hpBar.transform.SetParent(hpCanvas.transform, false);
     hpBarImage = hpBar.GetComponent <Image>();
     minionMovement.setMinionType(minionType);
     minionMovement.setKiteRange(attackRadius.get() * .9f);
     minionMovement.setLivesValue(livesValue);
     if (hpBarImage == null)
     {
         Debug.LogWarning("Minion Health Bar does not have an Image component");
     }
     if (minionType == MinionType.Range)
     {
         rangeLastFire = Time.time;
     }
 }
예제 #2
0
        void updateTarget()
        {
            GameObject[] targets       = GameObject.FindGameObjectsWithTag(targetTag);
            float        minDist       = Mathf.Infinity;
            GameObject   nearestTarget = null;

            foreach (GameObject target in targets)
            {
                float dist = Vector3.Distance(transform.position, target.transform.position);
                if (dist < minDist)
                {
                    minDist       = dist;
                    nearestTarget = target;
                }
            }
            if (nearestTarget != null && minDist <= range.get())
            {
                target         = nearestTarget.transform;
                targetMinion   = target.GetComponent <Minion>();
                targetMovement = target.GetComponent <MinionMovement>();
            }
            else
            {
                target = null;
            }
        }