示例#1
0
    // 敵を食べて得点を得る
    void EatEnemy(Collision collision)
    {
        for (int i = 0; i < (int)EnemyColor.max; ++i)
        {
            EnemyColor mEnemyColor = (EnemyColor)i;

            if (collision.gameObject.CompareTag(mEnemyColor.ToString()))
            {
                if (oldEnemyColor == mEnemyColor)
                {
                    ++combo;
                    score.Add(addScore * combo);
                }
                else
                {
                    oldEnemyColor = mEnemyColor;
                    combo         = 1;
                    score.Add(addScore);
                }
                ++totalEatNum;
                GetComponent <AudioSource>().PlayOneShot(GetComponent <Sound>().GetSE(2));
                Debug.Log(mEnemyColor.ToString() + "と接触");
                // Destroy(collision.gameObject);
            }
        }
        Debug.Log(combo + "コンボ");
        Debug.Log("敵を食べた数:" + totalEatNum);
    }
    public void SetRandomEnemy(GameObject newEnemy, int maxLevel)
    {
        int        randomValue = Random.Range(0, maxLevel);
        EnemyColor color       = (EnemyColor)randomValue;
        string     colorStr    = color.ToString() + "_";

        if ((int)color == 0)
        {
            colorStr = "";
        }

        EnemySize size       = (EnemySize)Random.Range(0, 6);
        string    enemySize  = size.ToString();
        string    spriteName = colorStr + enemySize;

        newEnemy.GetComponent <SpriteRenderer>().sprite = findEnemySpriteByName(spriteName.ToLower());
        newEnemy.GetComponent <EnemyController>().SetColor(color);
        newEnemy.GetComponent <EnemyController>().SetSize(size);
    }
示例#3
0
        private void SpawnSpinnerGroup(int size)
        {
            //List<Enemy> group = new List<Enemy>();
            EnemyColor color_    = EnemyColor.NONE;
            int        direction = rand.Next(0, 3); // Generate a number 0 - 3 [0, 1, 2, 3] to determine what side to spawn on.

            for (int i = 0; i < 15; i++)
            {
                Enemy enemy;
                if (size == 0) // small
                {
                    color_ = EnemyColor.PINK;
                    enemy  = new Enemy(EnemyType.SMALL_SPINNER, enemyTextures[EnemyType.SMALL_SPINNER.ToString() + "_" + color_.ToString()], color_);
                }
                else
                {
                    color_ = EnemyColor.BLUE;
                    enemy  = new Enemy(EnemyType.LARGE_SPINNER, enemyTextures[EnemyType.SMALL_SPINNER.ToString() + "_" + color_.ToString()], color_);
                }
                switch (direction)
                {
                case 0:     // Top
                    enemy.Position = new Vector2(rand.Next(50, ActionScreen.background.Width - 50), 50);
                    enemy.VY      += enemy.Speed;
                    break;

                case 1:     // Bottom
                    enemy.Position = new Vector2(rand.Next(50, ActionScreen.background.Width - 50), ActionScreen.background.Height - 50);
                    enemy.VY      -= enemy.Speed;
                    break;

                case 2:     // Left
                    enemy.Position = new Vector2(100, rand.Next(50, ActionScreen.background.Height - 50));
                    enemy.VX      += enemy.Speed;
                    break;

                case 3:     // Right
                    enemy.Position = new Vector2(rand.Next(ActionScreen.background.Width + 50, ActionScreen.background.Width - 50), rand.Next(-50, ActionScreen.background.Height + 50));
                    enemy.VX      -= enemy.Speed;
                    break;
                }
                enemies.Add(enemy);
            }
        }
示例#4
0
        private void SpawnRandomAsteroid(EnemyType eType)
        {
            int        color  = rand.Next(0, 4);
            EnemyColor eColor = EnemyColor.NONE;

            switch (color)
            {
            case 0:
                eColor = EnemyColor.RED;
                break;

            case 1:
                eColor = EnemyColor.BLUE;
                break;

            case 2:
                eColor = EnemyColor.GREEN;
                break;

            case 3:
                eColor = EnemyColor.PURPLE;
                break;

            case 4:
                eColor = EnemyColor.PINK;
                break;
            }
            Enemy enemy     = new Enemy(eType, enemyTextures[eType.ToString() + "_" + eColor.ToString()], eColor);
            int   direction = rand.Next(0, 3); // Generate a number 0 - 3 [0, 1, 2, 3] to determine what side to spawn on.

            switch (direction)
            {
            case 0:     // Top
                enemy.Position = new Vector2(rand.Next(100, ActionScreen.background.Width - 100), 100);
                break;

            case 1:     // Bottom
                enemy.Position = new Vector2(rand.Next(100, ActionScreen.background.Width - 100), ActionScreen.background.Height - 100);
                break;

            case 2:     // Left
                enemy.Position = new Vector2(100, rand.Next(100, ActionScreen.background.Height - 100));
                break;

            case 3:     // Right
                enemy.Position = new Vector2(rand.Next(ActionScreen.background.Width + 50, ActionScreen.background.Width - 50), rand.Next(-50, ActionScreen.background.Height + 50));
                break;
            }
            enemy.Velocity      += new Vector2(rand.Next(-enemy.Speed, enemy.Speed), rand.Next(-enemy.Speed, enemy.Speed));
            enemy.Transformation = Matrix.CreateTranslation(new Vector3(-enemy.Center, 0.0f)) *
                                   // Matrix.CreateScale(block.Scale) *  would go here
                                   Matrix.CreateRotationZ(enemy.Angle) *
                                   Matrix.CreateTranslation(new Vector3(enemy.Position, 0.0f));
            enemies.Add(enemy);
            ParticleManager.particleEffects["WarpIn"].Trigger(enemy.Position);
        }