Exemplo n.º 1
0
    IEnumerator SupportRoutine()
    {
        buff.buffID = unit.GetUnitID();
        LayerMask maskCreep = 1 << LayerManager.LayerCreep() | 1 << LayerManager.LayerCreepF();

        while (true)
        {
            if (!unit.IsStunned() && !unit.IsDead())
            {
                Collider[] cols = Physics.OverlapSphere(unit.thisT.position, range, maskCreep);

                List <Collider> tempList = new List <Collider>();
                foreach (Collider col in cols)
                {
                    tempList.Add(col);
                }

                for (int i = 0; i < colList.Count; i++)
                {
                    if (!tempList.Contains(colList[i]))
                    {
                        colList[i].gameObject.GetComponent <UnitCreep>().UnBuff(buff.buffID);
                        colList.RemoveAt(i);
                        i--;
                    }
                }

                for (int i = 0; i < tempList.Count; i++)
                {
                    if (!colList.Contains(tempList[i]))
                    {
                        tempList[i].gameObject.GetComponent <UnitCreep>().Buff(buff);
                    }
                }

                yield return(new WaitForSeconds(0.2f));
            }
            else
            {
                yield return(null);
            }
        }
    }