示例#1
0
 private void LateUpdate()
 {
     foreach (KeyValuePair <FieldEffect, float> pair in m_enemyFieldEffect)
     {
         //current time < start time + duration
         if (pair.Key.effect == FieldEffect.EffectType.Damage && m_time < (pair.Value + pair.Key.duration))
         {
             List <EnemyUnit> enemies = EnemyPool.GetPool();
             for (int i = 0; i < enemies.Count; i++)
             {
                 if (enemies[i].isActiveAndEnabled)
                 {
                     enemies[i].currentHp -= pair.Key.effectPower;
                 }
             }
         }
     }
     foreach (KeyValuePair <FieldEffect, float> pair in m_slimeFieldEffect)
     {
         //current time < start time + duration
         if (pair.Key.effect == FieldEffect.EffectType.Damage && m_time < (pair.Value + pair.Key.duration))
         {
             List <Unit> slimes = SlimePool.GetPool();
             for (int i = 0; i < slimes.Count; i++)
             {
                 if (slimes[i].isActiveAndEnabled)
                 {
                     slimes[i].currentHp -= pair.Key.effectPower;
                 }
             }
         }
     }
 }
示例#2
0
 public static void InitPool(int size)
 {
     poolSize = size;
     while (slimePool.Count < poolSize)
     {
         GameObject go = GameObject.Instantiate(GameDatabase.Instance.SlimeDatabase.baseSlimePrefab);
         go.SetActive(false);
         SlimePool.GetPool().Add(go.GetComponent <Unit>());
     }
 }
示例#3
0
    public Unit GetClosestSameElementSlime()
    {
        if (this.element == Element.Normal)
        {
            return(null);
        }
        Unit[] sameElemUnits = SlimePool.GetPool().FindAll(unit => unit.element == this.element).ToArray();
        Unit   cloestUnit    = null;

        for (int i = 0; i < sameElemUnits.Length; i++)
        {
            Vector3 direction = (sameElemUnits[i].transform.position - this.transform.position);
            if (direction.x > 0 && direction.y == 0 && sameElemUnits[i].transform.position.x <= this.transform.position.x + 2.5f)
            {
                cloestUnit = sameElemUnits[i];
                return(cloestUnit);
            }
        }
        return(cloestUnit);
    }