Exemple #1
0
    // Use this for initialization
    public void Start()
    {
        List <EnemyUnit> exploded = new List <EnemyUnit>();
        List <Unit>      list     = SlimePool.GetActiveSlimeList();

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].element == Element.Fire)
            {
                Collider[] col = Physics.OverlapBox(list[i].transform.position, new Vector3(range / 2, 1, 1));
                for (int enemyIndex = 0; enemyIndex < col.Length; enemyIndex++)
                {
                    EnemyUnit e = col[enemyIndex].GetComponent <EnemyUnit>();
                    if (e != null)
                    {
                        if (allowMultihit)
                        {
                            exploded.Add(e);
                        }
                        else
                        {
                            if (!exploded.Contains(e))
                            {
                                exploded.Add(e);
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #2
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;
                 }
             }
         }
     }
 }
Exemple #3
0
 ///change Input getbutton=>touch
 // Use this for initialization
 void Awake()
 {
     Instances = this;
     SlimePool.InitPool(m_poolSize);
     StageController.Instance.onGamePaused   += _OnPaused;
     StageController.Instance.onGameUnpaused += _OnUnpaused;
 }
Exemple #4
0
    public void CreateSlime(Element elem, int level, Vector3 position)
    {
        Unit newUnit = SlimePool.PoolRequest();

        GameDatabase.Instance.SlimeDatabase.GetSlimeData(elem, 1).CreateInstance(newUnit);
        StartCoroutine(Throwing(newUnit.gameObject, elem, position));
    }
Exemple #5
0
    public void Heal(float totalHeal)
    {
        List <Unit> list = SlimePool.GetActiveSlimeList();

        for (int i = 0; i < list.Count; i++)
        {
            list[i].currentHp = (list[i].currentHp + totalHeal > list[i].maxHp)? list[i].maxHp : list[i].currentHp + totalHeal;
        }
    }
Exemple #6
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>());
     }
 }
    public void DestroyAllslimeelement()
    {
        List <Unit> list = SlimePool.GetActiveSlimeList();

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].element == slimeElementtodestroy)
            {
                list[i]._Die();
            }
        }
        Heal();
    }
Exemple #8
0
    private void Awake()
    {
        m_thisInstance = this;
        m_arrSkillPool = new SkillAttackPool[(int)PlayerAttack.E_SKILL_TYPE.E_MAX];

        SlimePool.Create("Prefab/Slime", "SlimePool", 50);
        DamageTextPool.Create("Prefab/DamageText", "DamageTextPool", 50);

        m_arrSkillPool[0] = SkillAttackPool.Create("Prefab/SkillAttack1", "SkillAttack1Pool", 50);
        m_arrSkillPool[1] = SkillAttackPool.Create("Prefab/SkillAttack2", "SkillAttack2Pool", 50);

        m_arrSkillPool[0].gameObject.layer = 2;
        m_arrSkillPool[1].gameObject.layer = 1;
    }
Exemple #9
0
    public void Start()
    {
        List <Unit>      sList = SlimePool.GetActiveSlimeList();
        List <EnemyUnit> eList = EnemyPool.GetActiveEnemyList();

        for (int i = 0; i < sList.Count; i++)
        {
            if (Random.Range(0, 2) < 1)
            {
                sList[i].TakeDamage(sList[i].currentHp + 1);
            }
        }
        for (int j = 0; j < eList.Count; j++)
        {
            if (Random.Range(0, 2) < 1)
            {
                eList[j].TakeDamage(eList[j].currentHp + 1);
            }
        }
    }
Exemple #10
0
    public static SlimePool Create
    (
        string strPrefabName, // "해당 'Pool'에서 관리 할 프리팹의 이름"
        string strObjectName, // "'PoolObject'의 이름"
        int nPoolItemMaxCount // "'Pool'에서 관리 할 오브젝트의 최고 개수"
    )
    {
        GameObject objContainer = null;

        objContainer  = new GameObject();
        m_refInstance = objContainer.AddComponent(typeof(SlimePool)) as SlimePool;

        m_refInstance.m_strPrefabName   = strPrefabName;
        m_refInstance.m_nObjectMaxCount = nPoolItemMaxCount;
        m_refInstance.gameObject.name   = strObjectName;

        m_refInstance.PreloadObject();

        return(m_refInstance);
    }
Exemple #11
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);
    }
Exemple #12
0
    private void Spawn()
    {
        if (!SlimePool.GetInstance())
        {
            return;
        }

        int        nSpawnPoolIndex = 0;
        GameObject objEnemy        = null;

        objEnemy = SlimePool.GetInstance().EnableObject();

        if (!objEnemy)
        {
            return;
        }

        nSpawnPoolIndex = Random.Range(0, m_arraySpawnPool.Length);

        objEnemy.transform.position = m_arraySpawnPool[nSpawnPoolIndex].position;
        objEnemy.transform.rotation = m_arraySpawnPool[nSpawnPoolIndex].rotation;

        SlimePool.GetInstance().Setup(objEnemy);
    }
Exemple #13
0
 void Awake()
 {
     instance = this;
 }
Exemple #14
0
 void Start()
 {
     Instance = this; // Lazy Singleton
 }
Exemple #15
0
 void Start()
 {
     Instance = this;         // Lazy Singleton
 }
Exemple #16
0
    private IEnumerator StartRelease(float fTime)
    {
        yield return(new WaitForSeconds(fTime));

        SlimePool.GetInstance().ReleaseObject(gameObject);
    }