コード例 #1
0
    IEnumerator EnergyTimer(float interval, int genSpeed, int maxEng, int startEng)
    {
        Vector3 lastObjPos = Vector3.zero;

        while (true)
        {
            if (engObjPool.Count() < maxEng)
            {
                enegPool = GenerateEnergy(enegPool, genSpeed);
                GameObject newEnergy = GenEngeryObj(energy);
                engObjPool.Add(newEnergy);
                if (engObjPool.Count() == 1)
                {
                    newEnergy.transform.position = energyBar.transform.position + new Vector3(engBarSprite.bounds.size.x / 2 - 1.3f, 0);
                    if (currentSec != Section.Eng)
                    {
                        newEnergy.transform.position = newEnergy.transform.position + new Vector3(15, 0);
                    }
                    lastObjPos = newEnergy.transform.position;
                }
                else
                {
                    newEnergy.transform.position = energyBar.transform.position + new Vector3(engBarSprite.bounds.size.x / 2 - 1.3f, 0) - (new Vector3(.5f, 0f) * (engObjPool.Count() - 1));
                    if (currentSec != Section.Eng)
                    {
                        newEnergy.transform.position = newEnergy.transform.position + new Vector3(15, 0);
                    }
                }
            }

            yield return(new WaitForSeconds(interval));
        }
    }
コード例 #2
0
 public void AddEnergy(GameObject engObj)
 {
     engPool.Add(engObj);
     if (engPool.Count() == 1)
     {
         engObj.transform.position = transform.position + new Vector3(sprite.bounds.size.x / 2 - 1.3f, 0);
     }
     else
     {
         engObj.transform.position = transform.position + new Vector3(sprite.bounds.size.x / 2 - 1.3f, 0) - new Vector3(.5f, 0f) * (engPool.Count() - 1f);
     }
 }
コード例 #3
0
    public IEnumerator CheckForDamage(float maxTime, float minTime, EngPool pool)
    {
        while (!gameOver && pool.Count() == 0)
        {
            float newRadTime = Random.Range(minTime, maxTime);
            yield return(new WaitForSeconds(newRadTime));



            if (pool.Count() == 0 && !gameOver)
            {
                TakeDamage();
                sndCon.PlayExplosion();
            }
        }
    }