コード例 #1
0
        public void Load()
        {
            _pools = new Dictionary <string, ObjectPool>();
            _pools.Add("Bullet_PLR", new BulletPool(EntityType.BULLET_PLR, 500, 0.01f, Vector2.zero, "Bullet_0", string.Empty, CreateNewDefaultBullet));

            _pools.Add("Bullet_NMY", new BulletPool(EntityType.BULLET_NMY, 800, 0.05f, Vector2.zero, "Bullet_0", string.Empty, CreateNewDefaultBullet));
            _pools.Add("Bullet_Small", new BulletPool(EntityType.BULLET_NMY, 800, 0.05f, Vector2.zero, "Bullet_Small", string.Empty, CreateNewDefaultBullet));
            _pools.Add("Bullet_Medium", new BulletPool(EntityType.BULLET_NMY, 512, 1.5f, Vector2.zero, "Bullet_Medium", string.Empty, CreateNewDefaultBullet));
            _pools.Add("Bullet_Big", new BulletPool(EntityType.BULLET_NMY, 512, 4, Vector2.zero, string.Empty, "Bullet_Big", CreateNewDefaultBullet));

            _pools.Add("Boss_1_E", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.BOSS_1, Difficulty.EASY), 1));
            _pools.Add("Boss_1_M", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.BOSS_1, Difficulty.EASY), 1));
            _pools.Add("Boss_1_H", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.BOSS_1, Difficulty.EASY), 1));
            _pools.Add("Boss_1_DED", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.BOSS_1, Difficulty.EASY), 1));

            _pools.Add("Enemy_1_1_Up", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.ENEMY, Difficulty.EASY, 0), 1));
            _pools.Add("Enemy_1_1_Down", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.ENEMY, Difficulty.EASY, 1), 1));

            _pools.Add("Enemy_1_Sine_Up", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.ENEMY, Difficulty.EASY, 2), 1));
            _pools.Add("Enemy_1_Sine_Down", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.ENEMY, Difficulty.EASY, 3), 1));

            _pools.Add("Enemy_1_Final_Up", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.ENEMY, Difficulty.EASY, 998), 1));
            _pools.Add("Enemy_1_Final_Down", new StateMachinePool(StateMachinePool.GetEntityStateMachine(EntityID.ENEMY, Difficulty.EASY, 999), 1));


            _pools.Add("Player_Life", new EffectPool(500, "Player_Life", 4));
            _pools.Add("Player_Death", new EffectPool(500, "Player_Death", 4));
            _pools.Add("Player_Respawn", new EffectPool(500, "Player_Respawn", 4));

            _pools.Add("Enemy_1", new EnemyPool(1, 5, 400, "Enemy_1", "", "Player_Death", Vector2.zero, new ColliderBase[] { new CircleCollider(Vector2.zero, 5.5f) }, 16));
        }
コード例 #2
0
        private IEnumerator EasyDifficulty()
        {
            EnemyPool _enemyNorm = Program.PoolManager.GetPool <EnemyPool>("Enemy_1");

            StateMachinePool poolNmy1Up   = Program.PoolManager.GetPool <StateMachinePool>("Enemy_1_1_Up");
            StateMachinePool poolNmy1Down = Program.PoolManager.GetPool <StateMachinePool>("Enemy_1_1_Down");


            StateMachinePool poolNmy2Up   = Program.PoolManager.GetPool <StateMachinePool>("Enemy_1_Sine_Up");
            StateMachinePool poolNmy2Down = Program.PoolManager.GetPool <StateMachinePool>("Enemy_1_Sine_Down");


            StateMachinePool poolNmyFinalUp   = Program.PoolManager.GetPool <StateMachinePool>("Enemy_1_Final_Up");
            StateMachinePool poolNmyFinalDown = Program.PoolManager.GetPool <StateMachinePool>("Enemy_1_Final_Down");

            yield return(Program.UpdateTime.WaitForSeconds(2.0f));

            float time          = 0;
            float spawnInterval = 0.15f;

            Enemy nmy;

            int squareX = 4;
            int squareY = 2;

            List <Enemy>   enemies   = new List <Enemy>();
            List <Vector2> positions = new List <Vector2>();

            for (int y = 0; y < squareY; y++)
            {
                for (int x = 0; x < squareX; x++)
                {
                    Vector2 pos = new Vector2(80 + x * 24.0f, (y + 0.65f) * 8.0f);

                    nmy = _enemyNorm.Get() as Enemy;
                    nmy.Setup(poolNmy1Up.Get() as StateMachine, 40, 1);
                    nmy.renderingOffset = 200 + (y + x);
                    enemies.Add(nmy);
                    positions.Add(pos);

                    pos.y = -pos.y;
                    nmy   = _enemyNorm.Get() as Enemy;
                    nmy.Setup(poolNmy1Down.Get() as StateMachine, 40, 1);
                    nmy.renderingOffset = 200 - (y + x);
                    enemies.Add(nmy);
                    positions.Add(pos);
                }
            }

            for (int i = 0; i < enemies.Count; i += 2)
            {
                enemies[i].Spawn(positions[i], Vector2.zero);
                enemies[i + 1].Spawn(positions[i + 1], Vector2.zero);
                yield return(Program.UpdateTime.WaitForSeconds(spawnInterval));
            }

            while (true)
            {
                bool breakThis = true;
                for (int i = enemies.Count - 1; i >= 0; i--)
                {
                    if (enemies[i].IsAlive)
                    {
                        breakThis = false; break;
                    }
                }

                if (breakThis)
                {
                    break;
                }
                yield return(null);
            }

            enemies.Clear();
            positions.Clear();

            yield return(Program.UpdateTime.WaitForSeconds(1.0f));

            spawnInterval = 0.25f;

            squareY *= 2;
            squareX *= 2;

            for (int y = 0; y < squareY; y++)
            {
                for (int x = 0; x < squareX; x++)
                {
                    Vector2 pos = new Vector2(80 + x * 8.0f, (y + 0.65f) * 4.0f);

                    nmy = _enemyNorm.Get() as Enemy;
                    nmy.Setup(poolNmy2Up.Get() as StateMachine, 40, 1);
                    nmy.renderingOffset = 200 + (y + x);
                    enemies.Add(nmy);
                    positions.Add(pos);

                    pos.y = -pos.y;
                    nmy   = _enemyNorm.Get() as Enemy;
                    nmy.Setup(poolNmy2Down.Get() as StateMachine, 40, 1);
                    nmy.renderingOffset = 200 - (y + x);
                    enemies.Add(nmy);
                    positions.Add(pos);
                }
            }

            for (int i = 0; i < enemies.Count; i += 2)
            {
                enemies[i].Spawn(positions[i], Vector2.zero);
                enemies[i + 1].Spawn(positions[i + 1], Vector2.zero);
                yield return(Program.UpdateTime.WaitForSeconds(spawnInterval));
            }

            while (true)
            {
                bool breakThis = true;
                for (int i = enemies.Count - 1; i >= 0; i--)
                {
                    if (enemies[i].IsAlive)
                    {
                        breakThis = false; break;
                    }
                }

                if (breakThis)
                {
                    break;
                }
                yield return(null);
            }

            enemies.Clear();
            positions.Clear();

            yield return(Program.UpdateTime.WaitForSeconds(1.0f));


            //Final Wave
            time = 0;
            float attackInterval   = 0.05f;
            float attackFrequency  = 2.0f;
            float attackAmplitudeY = 8;
            float attackAmplitudeX = 24f;
            int   enemyCount       = 16;
            int   countS           = 0;

            while (countS <= enemyCount)
            {
                if (time < attackInterval)
                {
                    time += Program.UpdateTime.DeltaTime;
                    yield return(null);

                    continue;
                }

                float nn = (countS / (float)enemyCount) * attackFrequency * Maths.PI;
                float x  = Maths.Cos(nn * 0.5f) * attackAmplitudeX * 2;
                float y  = Maths.Sin(nn) * attackAmplitudeY;

                Vector2 pos = new Vector2(100 + x, y);

                nmy = _enemyNorm.Get() as Enemy;
                nmy.Setup((pos.y < 0 ? poolNmyFinalDown.Get() : poolNmyFinalUp.Get()) as StateMachine, 20, 1);
                nmy.renderingOffset = 200 + (int)y;
                nmy.Spawn(pos, Vector2.zero);
                enemies.Add(nmy);

                pos = new Vector2(100 + x, -y);

                nmy = _enemyNorm.Get() as Enemy;
                nmy.Setup((pos.y < 0 ? poolNmyFinalDown.Get() : poolNmyFinalUp.Get()) as StateMachine, 20, 1);
                nmy.renderingOffset = 200 + (int)y;
                nmy.Spawn(pos, Vector2.zero);
                enemies.Add(nmy);

                countS++;
                time = 0;
                yield return(null);
            }

            while (true)
            {
                bool breakThis = true;
                for (int i = enemies.Count - 1; i >= 0; i--)
                {
                    if (enemies[i].IsAlive)
                    {
                        breakThis = false; break;
                    }
                }

                if (breakThis)
                {
                    break;
                }
                yield return(null);
            }

            enemies.Clear();

            yield return(Program.UpdateTime.WaitForSeconds(1.0f));

            _boss.Spawn(new Vector2(100, 0), Vector2.zero);
            yield return(Program.UpdateTime.WaitForSeconds(13.0f));

            _background.StartScrollSpeedFade(0.35f, 3.0f, FadingType.FADE_IN);

            while (true)
            {
                if (!_boss.IsAlive)
                {
                    break;
                }
                yield return(null);
            }
        }