Example #1
0
    public void Hit(float value)
    {
        if (mbInvinsible)
        {
            return;
        }
        mCurrentHP -= value;
        mHPBar.SetValue(mCurrentHP, mMaxHP);

        if (mCurrentHP <= 0)
        {
            mSoundController.PlayEffectSound((int)eSoundType.ExpPlayer);
            Timer effect = mEffectPool.GetFromPool((int)eEffecttype.Player);
            effect.transform.position = transform.position;

            //
            Item  item = mItemPool.GetFromPool(Random.Range(0, 3));
            float xPos = Random.Range(-2.0f, 2f);
            item.transform.position = transform.position + Vector3.right * xPos;

            item = mItemPool.GetFromPool(Random.Range(0, 3));
            xPos = Random.Range(-2.0f, 2f);
            item.transform.position = transform.position + Vector3.right * xPos;

            gameObject.SetActive(false);
            mHPBar.gameObject.SetActive(false);
        }
    }
Example #2
0
 public void AddScore(int value)
 {
     ItemSpawnCount++;
     Score += value;
     ui.SetScore(Score);
     if (ItemSpawnCount >= 5)
     {
         ItemSpawnCount -= 5;
         GameObject temp = ItemP.GetFromPool(Random.Range(0, 2));
         temp.gameObject.SetActive(true);
         float randPosX = Random.Range(-5f, 5f);
         temp.transform.position = new Vector3(randPosX, temp.transform.position.y, 16.5f);
     }
 }
    private void OnDisable()
    {
        GameController.Instance.AddScore(1);
        GameObject effect = EffectPool.Instance.GetFromPool((int)eTYPE_EFFECT.ROCK_TYPE);

        effect.transform.position = this.transform.position;
        SoundController.Instance.PlayeEffectSound(eEffectClips.ExpRock);

        int getItem = 0;

        getItem = Random.Range(0, 100);
        if (getItem <= 30)
        {
            int          idx     = Random.Range(0, 2);
            ItemMovement newItem = itemPool.GetFromPool(idx);
            newItem.transform.position = this.transform.position;
        }
    }
Example #4
0
    private IEnumerator SpawnHazard()
    {
        WaitForSeconds pointFive = new WaitForSeconds(.5f);
        WaitForSeconds period = new WaitForSeconds(mPeriod);
        int            currentAST, currentEnemy;
        float          AstRate;

        while (true)
        {
            yield return(period);

            currentAST   = mASTSpawnCount + mRoundCount * (mRoundCount + 1) / 2;
            currentEnemy = mEnemySpawnCount + mRoundCount / 2;
            AstRate      = (float)currentAST / (currentAST + currentEnemy);

            while (currentAST > 0 && currentEnemy > 0)
            {
                float rate = Random.Range(0, 1f);

                if (rate < AstRate) //운석 생성
                {
                    Asteroid ast = mAstPool.GetFromPool(Random.Range(0, 3));
                    ast.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16);
                    currentAST--;
                }
                else // 적생성
                {
                    Enemy enemy = mEnemyPool.GetFromPool();
                    enemy.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16);
                    currentEnemy--;
                }
                yield return(pointFive);
            }
            for (int i = 0; i < currentAST; i++)
            {
                Asteroid ast = mAstPool.GetFromPool(Random.Range(0, 3));
                ast.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16);
                yield return(pointFive);
            }
            for (int i = 0; i < currentEnemy; i++)
            {
                Enemy enemy = mEnemyPool.GetFromPool();
                enemy.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16);
                yield return(pointFive);
            }

            mRoundCount++;
            Item item = mItemPool.GetFromPool(Random.Range(2, 3));
            item.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16);

            if (mRoundCount % 5 == 0)
            {
                mBoss.transform.position = new Vector3(0, 0, 20);
                mBoss.gameObject.SetActive(true);
                //StopCoroutine(mHazardRoutine);
                while (mBoss.IsAlive)
                {
                    yield return(pointFive);
                }
            }
        }
    }
Example #5
0
    private IEnumerator SpawnHazard()
    {
        WaitForSeconds PiointThree = new WaitForSeconds(0.3f);
        WaitForSeconds spawnRate   = new WaitForSeconds(mSpawnRate);
        int            enemyCount  = 3;
        int            astCount    = 5;
        int            CurrentEnemyCount;
        int            CurrentAstCount;
        int            CurrentItemWaveCount = 0;
        float          ratio = 1f / 3;

        while (true)
        {
            CurrentAstCount   = astCount;
            CurrentEnemyCount = enemyCount;
            while (CurrentAstCount > 0 && CurrentEnemyCount > 0)
            {
                float rand = Random.Range(0, 1f);
                // float rand = Random.value(0, 1f);
                if (rand < ratio)
                {
                    Enemy enemy = mEemyPool.GetFromPool();
                    enemy.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax),
                                                           0,
                                                           mSpawnZ);
                    CurrentEnemyCount--;
                    yield return(PiointThree);
                }
                else
                {
                    AsteroidMovement ast = mAstPool.GetFromPool(Random.Range(0, 3));
                    ast.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax),
                                                         0,
                                                         mSpawnZ);
                    CurrentAstCount--;
                    yield return(PiointThree);
                }
            }
            for (int i = 0; i < CurrentAstCount; i++)
            {
                AsteroidMovement ast = mAstPool.GetFromPool(Random.Range(0, 3));
                ast.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax),
                                                     0,
                                                     mSpawnZ);
                yield return(PiointThree);
            }
            for (int i = 0; i < CurrentEnemyCount; i++)
            {
                Enemy enemy = mEemyPool.GetFromPool();
                enemy.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax),
                                                       0,
                                                       mSpawnZ);
                yield return(PiointThree);
            }
            if (CurrentItemWaveCount >= mItemSpawnWaveCount - 1)
            {
                Item tem = mItemPool.GetFromPool(Random.Range(0, 3));
                tem.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax),
                                                     0,
                                                     mSpawnZ);
                CurrentItemWaveCount = 0;
            }
            else
            {
                CurrentItemWaveCount++;
            }
            yield return(spawnRate);
        }
    }
Example #6
0
    private IEnumerator Hazards()
    {
        WaitForSeconds threeSec    = new WaitForSeconds(3);
        WaitForSeconds pointTwoSec = new WaitForSeconds(.2f);


        while (true)
        {
            yield return(threeSec);

            int asteroidSpawnCount = 10, enemySpawnCount = 3;

            while (true)
            {
                if (asteroidSpawnCount > 0 && enemySpawnCount > 0)
                {
                    int randValue = Random.Range(0, 2);
                    if (randValue == 1)
                    {
                        SpawnAsteroid();
                        asteroidSpawnCount--;
                        yield return(pointTwoSec);
                    }
                    else
                    {
                        SpawnEnemy();
                        enemySpawnCount--;
                        yield return(pointTwoSec);
                    }
                }
                else if (enemySpawnCount > 0)
                {
                    for (int i = 0; i < enemySpawnCount; i++)
                    {
                        SpawnEnemy();
                        yield return(pointTwoSec);
                    }
                    break;
                }
                else if (asteroidSpawnCount > 0)
                {
                    for (int i = 0; i < asteroidSpawnCount; i++)
                    {
                        SpawnAsteroid();
                        yield return(pointTwoSec);
                    }
                    break;
                }
                else
                {
                    break;
                }
            }
            CurrentStageNumber++;
            for (int i = 0; i < 3; i++)
            {
                GameObject item = ItemP.GetFromPool((eItemType)Random.Range(0, 2));
                item.transform.position = new Vector3(Random.Range(-5f, 5f), 0, 16);
                item.gameObject.SetActive(true);
            }


            if (CurrentStageNumber % BossStageGap == 0)
            {
                yield return(threeSec);

                BossController boss = BossP.GetFromPool();
                boss.transform.position = new Vector3(0, 0, 19);
                boss.gameObject.SetActive(true);
                IsBossAlive = true;
                CurrentStageNumber++;
            }
            while (IsBossAlive)
            {
                yield return(threeSec);
            }

            //TODO 보스전 중 죽었을시 동작 pause
            //while (player.CurrentHP <= 0)
            //{
            //    yield return null;
            //    Debug.Log("player dead");

            //    IsBossAlive = false;
            //    hazardRoutine = StartCoroutine(Hazards());
            //}
        }
    }