Esempio n. 1
0
        public override void SetupLevel()
        {
            Program.Level = 1;

            Program.Engine.SetLocation(new Location(new Description2D(0, 0, Program.ScreenWidth, Program.ScreenHeight)));

            Stack <Action> deck = new Stack <Action>();

            deck.Push(() =>
            {
                Program.Referee.AddRule(Rule.Rules["Goal victory"]);
                Program.Engine.AddEntity(DialogBox.Create("Oh, look! I can win by touching the goal."));
            });
            deck.Push(() =>
            {
                Program.Referee.AddRule(Rule.Rules["control Player"]);
                Program.Engine.AddEntity(DialogBox.Create("Aha! I can move now! But what to do?"));
            });
            deck.Push(() => Program.Engine.AddEntity(DialogBox.Create("What is this? I can't move...")));
            deck.Push(() => Program.Referee.AddRule(Rule.Rules["top-down"]));


            SinWaveSound sound = new SinWaveSound(true,
                                                  100, 44100 / Program.TPS * 10,
                                                  0, 44100 / Program.TPS * 90);

            sound.SetWaveFormat(44100, 2);

            Entity deckFlipper = new Entity(new Description2D(0, 0, 0, 0));
            int    timer       = 0;

            deckFlipper.TickAction = (loc, ent) =>
            {
                if (Program.Engine.Location.GetEntities <DialogBox>().Any() || Program.Engine.Location.GetEntities <Banner>().Any())
                {
                    return;
                }

                if (Program.Referee.IsStarted && deck.Any() && timer++ % (Program.TPS * 2.5) == 0)
                {
                    deck.Pop().Invoke();
                }
            };

            Program.Engine.AddEntity(deckFlipper);

            Program.Engine.AddEntity(Player.Create(64, Program.ScreenHeight / 2));

            Program.Engine.AddEntity(Goal.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2));

            Program.Engine.AddEntity(HeadsUpDisplay.Create());

            Program.Referee.ClearRules();

            Program.Referee.Start();

            Program.WavProvider.AddMixerInput((ISampleProvider)sound);
            Program.WavPlayer.Play();
        }
Esempio n. 2
0
        public override void SetupLevel()
        {
            Program.Level = 6;

            Program.Engine.SetLocation(new Location(new Description2D(0, 0, Program.ScreenWidth, Program.ScreenHeight)));

            bool           dialogShown = false;
            Stack <Action> deck        = new Stack <Action>();

            deck.Push(() =>
            {
                Program.Engine.AddEntity(Powerup.Create("pop DEATH", 24, Program.ScreenHeight / 2 - 48));
                Entity ent     = Powerup.Create("Enemy hurty", 24, Program.ScreenHeight / 2 - 16);
                ent.TickAction = (loc, e) =>
                {
                    if (!dialogShown && loc.GetEntities <Player>().First().Distance((Description2D)e.Description) < 12)
                    {
                        Program.Engine.AddEntity(DialogBox.Create("I'm lucky those were there."));
                        dialogShown = true;
                    }
                };
                Program.Engine.AddEntity(ent);
            });
            deck.Push(() => Program.Engine.AddEntity(Powerup.Create("shoot Enemy", Program.ScreenWidth / 2, Program.ScreenHeight / 2 + 16)));
            deck.Push(() => { });

            Program.Referee.ClearRules();

            Program.Referee.AddRule(Rule.Rules["Goal victory"]);
            Program.Referee.AddRule(Rule.Rules["Enemy hurty"]);
            Program.Referee.AddRule(Rule.Rules["Powerup hurty"]);
            Program.Referee.AddRule(Rule.Rules["Player pickup Powerup"]);
            Program.Referee.AddRule(Rule.Rules["control Player"]);
            Program.Referee.AddRule(Rule.Rules["vvvvvv-platformer"]);

            SinWaveSound sound = new SinWaveSound(true,
                                                  80, 44100 / Program.TPS * 10, 0, 44100 / Program.TPS * 30,
                                                  80, 44100 / Program.TPS * 5, 0, 44100 / Program.TPS * 5, 120, 44100 / Program.TPS * 10, 0, 44100 / Program.TPS * 60,
                                                  80, 44100 / Program.TPS * 10, 0, 44100 / Program.TPS * 30,
                                                  120, 44100 / Program.TPS * 5, 0, 44100 / Program.TPS * 5, 150, 44100 / Program.TPS * 10, 0, 44100 / Program.TPS * 60);

            sound.SetWaveFormat(44100, 2);

            Entity deckFlipper = new Entity(new Description2D(0, 0, 0, 0));
            int    timer       = 0;

            deckFlipper.TickAction = (loc, ent) =>
            {
                if (Program.Engine.Location.GetEntities <DialogBox>().Any() || Program.Engine.Location.GetEntities <Banner>().Any())
                {
                    return;
                }

                if (Program.Referee.IsStarted && deck.Any() && timer++ % (Program.TPS * 5) == 0)
                {
                    deck.Pop().Invoke();
                }
            };

            Program.Engine.AddEntity(deckFlipper);

            ControlSchemas.Reset();

            Program.Engine.AddEntity(DialogBox.Create("This feels very different. And powerups\nhurt me? How am I supposed to progress?"));

            //top
            Program.Engine.AddEntity(Wall.Create(0, 0, 64, 16));
            Program.Engine.AddEntity(Enemy.Create(64, 0));
            Program.Engine.AddEntity(Enemy.Create(80, 0));
            Program.Engine.AddEntity(Wall.Create(96, 0, 64, 16));
            Program.Engine.AddEntity(Enemy.Create(160, 0));
            Program.Engine.AddEntity(Enemy.Create(176, 0));
            Program.Engine.AddEntity(Enemy.Create(192, 0));
            Program.Engine.AddEntity(Wall.Create(208, 0, 128, 16));

            //bottom
            Program.Engine.AddEntity(Wall.Create(0, Program.ScreenHeight, 64, 16));
            Program.Engine.AddEntity(Enemy.Create(64, Program.ScreenHeight));
            Program.Engine.AddEntity(Enemy.Create(80, Program.ScreenHeight));
            Program.Engine.AddEntity(Wall.Create(96, Program.ScreenHeight, 64, 16));
            Program.Engine.AddEntity(Enemy.Create(160, Program.ScreenHeight));
            Program.Engine.AddEntity(Enemy.Create(176, Program.ScreenHeight));
            Program.Engine.AddEntity(Enemy.Create(192, Program.ScreenHeight));
            Program.Engine.AddEntity(Enemy.Create(208, Program.ScreenHeight));

            //walls and enemies
            Program.Engine.AddEntity(Wall.Create(Program.ScreenWidth, 0, 16, Program.ScreenHeight));
            Program.Engine.AddEntity(Wall.Create(0, 0, 16, Program.ScreenHeight));

            Program.Engine.AddEntity(Powerup.Create("pop SPEED", Program.ScreenWidth - 96, 16));
            Program.Engine.AddEntity(Powerup.Create("pop SPEED", Program.ScreenWidth - 96, 32));
            Program.Engine.AddEntity(Wall.Create(Program.ScreenWidth - 96, 48, 16, Program.ScreenHeight - 32));

            for (int i = 16; i < Program.ScreenHeight; i += 16)
            {
                Program.Engine.AddEntity(Enemy.Create(Program.ScreenWidth - 80, i));
            }

            // box and player
            Program.Engine.AddEntity(Enemy.Create(16, Program.ScreenHeight / 2 - 32));
            Program.Engine.AddEntity(Enemy.Create(32, Program.ScreenHeight / 2 - 32));
            Program.Engine.AddEntity(Wall.Create(48, Program.ScreenHeight / 2 - 32, 64, 16));
            Program.Engine.AddEntity(Player.Create(64, Program.ScreenHeight / 2));
            Program.Engine.AddEntity(Wall.Create(48, Program.ScreenHeight / 2 + 32, 64, 16));
            Program.Engine.AddEntity(Wall.Create(112, Program.ScreenHeight / 2 - 32, 16, 80));


            //horizontal split

            Entity trigger   = Powerup.Create("Enemy hurty", 160, Program.ScreenHeight / 2 - 16);
            Guid   triggerId = trigger.Id;

            trigger.AddTickAction((loc, ent) =>
            {
                if (loc.GetEntities <Player>().First().Distance((Description2D)ent.Description) < 20)
                {
                    Program.Engine.AddEntity(DialogBox.Create("WHAT?! I thought they were supposed\nto hurt? Better keep an eye on things."));
                    Program.Referee.AddRule("pop DEATH");
                    loc.RemoveEntity(triggerId);
                }
            });

            Program.Engine.AddEntity(trigger);

            Program.Engine.AddEntity(Wall.Create(112, Program.ScreenHeight / 2, 112, 16));
            Program.Engine.AddEntity(Powerup.Create("pop SPEED", 128, Program.ScreenHeight / 2 + 32));
            Program.Engine.AddEntity(Powerup.Create("pop SPEED", 144, Program.ScreenHeight / 2 + 32));
            Program.Engine.AddEntity(Powerup.Create("pop SPEED", 160, Program.ScreenHeight / 2 + 32));
            Program.Engine.AddEntity(Powerup.Create("pop SPEED", 176, Program.ScreenHeight / 2 + 32));
            Program.Engine.AddEntity(Powerup.Create("pop SPEED", 192, Program.ScreenHeight / 2 + 32));
            Program.Engine.AddEntity(Powerup.Create("pop SPEED", 208, Program.ScreenHeight / 2 + 32));


            Program.Engine.AddEntity(Goal.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2));

            Program.Engine.AddEntity(HeadsUpDisplay.Create());

            Program.Referee.Start();

            Program.WavProvider.AddMixerInput((ISampleProvider)sound);
            Program.WavPlayer.Play();
        }
Esempio n. 3
0
        public override void SetupLevel()
        {
            bool   wobbleDialog = false;
            Entity movingEnemy  = null;

            Program.Level = 5;

            Program.Engine.SetLocation(new Location(new Description2D(0, 0, Program.ScreenWidth, Program.ScreenHeight)));

            Stack <Action> deck = new Stack <Action>();

            Action spawnPowerups = () =>
            {
                Program.Engine.AddEntity(Powerup.Create("platformer", 224 - 8, Program.ScreenHeight / 2 + 80));
                Program.Engine.AddEntity(Powerup.Create("top-down", 256 - 8, Program.ScreenHeight / 2 + 80));
                Program.Engine.AddEntity(Powerup.Create("platformer", 288 - 8, Program.ScreenHeight / 2 + 80));
                Entity ent = Powerup.Create("top-down", 314 - 8, Program.ScreenHeight / 2 + 80);
                ent.TickAction = (loc, e) =>
                {
                    if (!wobbleDialog && ((Description2D)movingEnemy.Description).Distance((Description2D)e.Description) < 12)
                    {
                        Program.Engine.AddEntity(DialogBox.Create("It'll be hard to keep my orientation.\nBetter keep an eye on it."));
                        wobbleDialog = true;
                    }
                };
                Program.Engine.AddEntity(ent);
            };

            deck.Push(spawnPowerups);
            deck.Push(spawnPowerups);
            deck.Push(spawnPowerups);
            deck.Push(spawnPowerups);
            deck.Push(spawnPowerups);
            deck.Push(spawnPowerups);

            Program.Referee.ClearRules();

            Program.Referee.AddRule(Rule.Rules["Goal victory"]);
            Program.Referee.AddRule(Rule.Rules["Enemy hurty"]);
            Program.Referee.AddRule(Rule.Rules["Any pickup Powerup"]);
            Program.Referee.AddRule(Rule.Rules["control Player"]);
            Program.Referee.AddRule(Rule.Rules["platformer"]);

            Program.Engine.AddEntity(DialogBox.Create("Something seems different."));

            SinWaveSound sound = new SinWaveSound(true,
                                                  80, 44100 / Program.TPS * 30, 0, 44100 / Program.TPS * 5, 100, 44100 / Program.TPS * 5, 70, 44100 / Program.TPS * 5,
                                                  150, 44100 / Program.TPS * 30, 0, 44100 / Program.TPS * 5, 120, 44100 / Program.TPS * 5,
                                                  100, 44100 / Program.TPS * 30, 0, 44100 / Program.TPS * 5, 80, 44100 / Program.TPS * 5, 100, 44100 / Program.TPS * 5, 60, 44100 / Program.TPS * 5,
                                                  120, 44100 / Program.TPS * 30, 0, 44100 / Program.TPS * 5, 90, 44100 / Program.TPS * 5, 150, 44100 / Program.TPS * 5);

            sound.SetWaveFormat(44100, 2);

            Entity deckFlipper = new Entity(new Description2D(0, 0, 0, 0));
            int    timer       = 0;

            deckFlipper.TickAction = (loc, ent) =>
            {
                if (Program.Engine.Location.GetEntities <DialogBox>().Any() || Program.Engine.Location.GetEntities <Banner>().Any())
                {
                    return;
                }

                if (Program.Referee.IsStarted && deck.Any() && timer++ % (Program.TPS * 3.3) == 0)
                {
                    deck.Pop().Invoke();
                }
            };

            Program.Engine.AddEntity(deckFlipper);

            Program.Engine.AddEntity(Player.Create(Program.ScreenWidth / 2 - 32, Program.ScreenHeight - 24));

            Program.Engine.AddEntity(Goal.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2));

            Program.Engine.AddEntity(Enemy.Create(Program.ScreenWidth - 64 - 16, Program.ScreenHeight / 2));
            Program.Engine.AddEntity(Enemy.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2 - 16));
            Program.Engine.AddEntity(Enemy.Create(Program.ScreenWidth - 64 + 16, Program.ScreenHeight / 2));
            Program.Engine.AddEntity(Enemy.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2 + 16));

            //border
            Program.Engine.AddEntity(Wall.Create(0, 0, 16, Program.ScreenHeight));
            Program.Engine.AddEntity(Wall.Create(Program.ScreenWidth, 0, 16, Program.ScreenHeight));
            Program.Engine.AddEntity(Wall.Create(0, 0, Program.ScreenWidth, 16));
            Program.Engine.AddEntity(Wall.Create(0, Program.ScreenHeight, Program.ScreenWidth + 16, 16));

            //others
            Program.Engine.AddEntity(Wall.Create(0, Program.ScreenHeight / 2 + 32, 80, 16));

            Program.Engine.AddEntity(Wall.Create(80, Program.ScreenHeight / 2 + 80, 112, 16));

            Program.Engine.AddEntity(Wall.Create(112, Program.ScreenHeight / 2 + 32, 64, 16));
            Program.Engine.AddEntity(Wall.Create(176, Program.ScreenHeight / 2 - 80, 16, 208));

            Entity ent         = Powerup.Create("clicky attack", 32, 32);
            bool   dialogShown = false;

            ent.TickAction = (loc, e) =>
            {
                if (!dialogShown && loc.GetEntities <Player>().First().Distance((Description2D)e.Description) < 12)
                {
                    Program.Engine.AddEntity(DialogBox.Create("I bet I can use this to clear a path."));
                    dialogShown = true;
                }
            };
            Program.Engine.AddEntity(ent);

            Program.Engine.AddEntity(Powerup.Create("Enemy pickup Powerup", 176, 24));

            movingEnemy = Enemy.Create(224, Program.ScreenHeight / 2 + 80);
            double deltaX = 0.5f;

            movingEnemy.TickAction += (loc, ent) =>
            {
                if (Program.Engine.Location.GetEntities <DialogBox>().Any())
                {
                    return;
                }

                Description2D d2d = movingEnemy.Description as Description2D;
                if (d2d.X == Program.ScreenWidth - 16 || d2d.X == 208)
                {
                    deltaX = -deltaX;
                }

                d2d.ChangeCoordsDelta(deltaX, 0);
            };

            Program.Engine.AddEntity(movingEnemy);

            Program.Engine.AddEntity(HeadsUpDisplay.Create());

            Program.Referee.Start();

            Program.WavProvider.AddMixerInput((ISampleProvider)sound);
            Program.WavPlayer.Play();
        }
Esempio n. 4
0
        public override void SetupLevel()
        {
            Program.Level = 3;
            int delay = Program.TPS * 1;

            Program.Engine.SetLocation(new Location(new Description2D(0, 0, Program.ScreenWidth, Program.ScreenHeight)));

            bool           dialogShown = false;
            Stack <Action> deck        = new Stack <Action>();

            deck.Push(() =>
            {
                Program.Referee.AddRule(Rule.Rules["Player pickup Powerup"]);
                Program.Engine.AddEntity(DialogBox.Create("I bet I can collect it now."));
                dialogShown = false;
            });

            deck.Push(() =>
            {
                Entity ent     = Powerup.Create("pop DEATH", Program.ScreenWidth - 32, Program.ScreenHeight / 2);
                delay          = Program.TPS * 5;
                ent.TickAction = (loc, e) =>
                {
                    if (!dialogShown && loc.GetEntities <Player>().First().Distance((Description2D)e.Description) < 12)
                    {
                        if (!Program.Referee.Piles[Rule.RuleType.POWERUP].Any())
                        {
                            Program.Engine.AddEntity(DialogBox.Create("I guess nothing happens?"));
                        }
                        else
                        {
                            Program.Engine.AddEntity(DialogBox.Create("Time to reach the goal."));
                        }
                        dialogShown = true;
                    }
                };
                Program.Engine.AddEntity(ent);
                Program.Engine.AddEntity(DialogBox.Create("What's that? Better go check it out."));
            });
            deck.Push(() => Program.Referee.AddRule(Rule.Rules["Goal hurty"]));
            deck.Push(() => Program.Referee.AddRule(Rule.Rules["Goal victory"]));
            deck.Push(() =>
            {
                Program.Engine.AddEntity(DialogBox.Create("I better watch out for any tricks."));
            });

            Program.Referee.ClearRules();

            Program.Referee.AddRule(Rule.Rules["control Player"]);
            Program.Referee.AddRule(Rule.Rules["top-down"]);

            SinWaveSound sound = new SinWaveSound(true,
                                                  100, 44100 / Program.TPS * 20, 150, 44100 / Program.TPS * 15, 200, 44100 / Program.TPS * 10, 300, 44100 / Program.TPS * 5, 0, 44100 / Program.TPS * 5,
                                                  120, 44100 / Program.TPS * 5, 150, 44100 / Program.TPS * 2, 200, 44100 / Program.TPS * 2, 0, 44100 / Program.TPS * 10, 100, 44100 / Program.TPS * 30, 80, 44100 / Program.TPS * 30, 60, 44100 / Program.TPS * 30
                                                  );

            sound.SetWaveFormat(44100, 2);

            Entity deckFlipper = new Entity(new Description2D(0, 0, 0, 0));
            int    timer       = 0;

            deckFlipper.TickAction = (loc, ent) =>
            {
                if (Program.Engine.Location.GetEntities <DialogBox>().Any() || Program.Engine.Location.GetEntities <Banner>().Any())
                {
                    return;
                }

                if (Program.Referee.IsStarted && deck.Any() && timer++ % delay == 0)
                {
                    deck.Pop().Invoke();
                }
            };

            Program.Engine.AddEntity(deckFlipper);

            Program.Engine.AddEntity(Player.Create(64, Program.ScreenHeight / 2));

            Program.Engine.AddEntity(Goal.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2));

            Program.Engine.AddEntity(HeadsUpDisplay.Create());

            Program.Referee.Start();

            Program.WavProvider.AddMixerInput((ISampleProvider)sound);
            Program.WavPlayer.Play();
        }
Esempio n. 5
0
        public override void SetupLevel()
        {
            Program.Level = 2;

            Program.Engine.SetLocation(new Location(new Description2D(0, 0, Program.ScreenWidth, Program.ScreenHeight)));

            Action good = () =>
            {
                Program.Referee.AddRule(Rule.Rules["Goal victory"]);
                Program.Referee.Piles[Rule.RuleType.DEATH].Pop();
            };

            Action bad = () =>
            {
                Program.Referee.Piles[Rule.RuleType.VICTORY].Pop();
                Program.Referee.AddRule("Goal hurty");
            };

            Stack <Action> deck = new Stack <Action>();

            for (int i = 0; i < 3; i++)
            {
                deck.Push(bad);
                deck.Push(good);
            }

            deck.Push(bad);
            deck.Push(() =>
            {
                good();
                Program.Engine.Location.AddEntity(DialogBox.Create("And now it's back! Better time this right."));
            });
            deck.Push(() =>
            {
                bad();
                Program.Engine.Location.AddEntity(DialogBox.Create("Wait... the victory condition is removed?\nAnd the goal will hurt me?!"));
            });
            deck.Push(() => Program.Engine.Location.AddEntity(DialogBox.Create("Let's make it to the goal again.")));

            Program.Referee.ClearRules();

            Program.Referee.AddRule(Rule.Rules["Goal victory"]);
            Program.Referee.AddRule(Rule.Rules["control Player"]);
            Program.Referee.AddRule(Rule.Rules["top-down"]);

            Entity deckFlipper = new Entity(new Description2D(0, 0, 0, 0));
            int    timer       = 0;

            SinWaveSound sound = new SinWaveSound(true,
                                                  100, 44100 / Program.TPS * 20, 250, 44100 / Program.TPS * 15, 200f, 44100 / Program.TPS * 10, 0, 44100 / Program.TPS * 15,
                                                  100, 44100 / Program.TPS * 20, 150, 44100 / Program.TPS * 15, 200f, 44100 / Program.TPS * 10, 300f, 44100 / Program.TPS * 5, 0, 44100 / Program.TPS * 20
                                                  );

            sound.SetWaveFormat(44100, 2);

            deckFlipper.TickAction = (loc, ent) =>
            {
                if (Program.Engine.Location.GetEntities <DialogBox>().Any() || Program.Engine.Location.GetEntities <Banner>().Any())
                {
                    sound.Quiet = true;
                    return;
                }

                sound.Quiet = false;

                if (deck.Any() && timer++ % (Program.TPS * 1) == 0)
                {
                    deck.Pop().Invoke();
                }
            };

            Program.Engine.AddEntity(deckFlipper);

            Program.Engine.AddEntity(Player.Create(64, Program.ScreenHeight / 2));

            Program.Engine.AddEntity(Goal.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2));

            Program.Engine.AddEntity(HeadsUpDisplay.Create());

            Program.Referee.Start();

            Program.WavProvider.AddMixerInput((ISampleProvider)sound);
            Program.WavPlayer.Play();
        }
Esempio n. 6
0
        public override void SetupLevel()
        {
            Program.Level = 4;

            Program.Engine.SetLocation(new Location(new Description2D(0, 0, Program.ScreenWidth, Program.ScreenHeight)));

            Stack <Action> deck = new Stack <Action>();

            deck.Push(() =>
            {
                bool dialogShown = false;
                Entity ent       = Powerup.Create("pop DEATH", 32, Program.ScreenHeight / 2);
                ent.TickAction   = (loc, e) =>
                {
                    if (!dialogShown && loc.GetEntities <Player>().First().Distance((Description2D)e.Description) < 12)
                    {
                        Program.Engine.AddEntity(DialogBox.Create("Now I can sneak by them!"));
                        dialogShown = true;
                    }
                };
                Program.Engine.AddEntity(ent);
            });

            deck.Push(() =>
            {
                bool dialogShown = false;
                Entity ent       = Powerup.Create("pop CONTROL", Program.ScreenWidth - 32, Program.ScreenHeight / 2);
                ent.TickAction   = (loc, e) =>
                {
                    if (!dialogShown && loc.GetEntities <Player>().First().Distance((Description2D)e.Description) < 12)
                    {
                        Program.Engine.AddEntity(DialogBox.Create("Oh no, I can't move. Better restart.\n(Press R)"));
                        dialogShown = true;
                    }
                };
                Program.Engine.AddEntity(ent);
            });
            deck.Push(() => Program.Engine.AddEntity(Powerup.Create("pop VICTORY", Program.ScreenWidth / 2, Program.ScreenHeight / 2)));

            Program.Referee.ClearRules();

            Program.Referee.AddRule(Rule.Rules["Goal victory"]);
            Program.Referee.AddRule(Rule.Rules["Enemy hurty"]);
            Program.Referee.AddRule(Rule.Rules["Player pickup Powerup"]);
            Program.Referee.AddRule(Rule.Rules["control Player"]);
            Program.Referee.AddRule(Rule.Rules["top-down"]);

            SinWaveSound sound = new SinWaveSound(true,
                                                  80, 44100 / Program.TPS * 30, 0, 44100 / Program.TPS * 5,
                                                  150, 44100 / Program.TPS * 30, 0, 44100 / Program.TPS * 5,
                                                  100, 44100 / Program.TPS * 30, 0, 44100 / Program.TPS * 5,
                                                  120, 44100 / Program.TPS * 30, 0, 44100 / Program.TPS * 5);

            sound.SetWaveFormat(44100, 2);

            Entity deckFlipper = new Entity(new Description2D(0, 0, 0, 0));
            int    timer       = 0;

            deckFlipper.TickAction = (loc, ent) =>
            {
                if (Program.Engine.Location.GetEntities <DialogBox>().Any() || Program.Engine.Location.GetEntities <Banner>().Any())
                {
                    return;
                }

                if (Program.Referee.IsStarted && deck.Any() && timer++ % (Program.TPS * 5) == 0)
                {
                    deck.Pop().Invoke();
                }
            };

            Program.Engine.AddEntity(DialogBox.Create("What are those? They don't look\ntoo friendly."));

            Program.Engine.AddEntity(deckFlipper);

            Program.Engine.AddEntity(Player.Create(64, Program.ScreenHeight / 2));

            bool   dialogShown = false;
            Entity entity      = Goal.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2);

            entity.TickAction = (loc, e) =>
            {
                if (!dialogShown && !Program.Referee.Piles[Rule.RuleType.VICTORY].Any() && loc.GetEntities <Player>().First().Distance((Description2D)e.Description) < 12)
                {
                    Program.Engine.AddEntity(DialogBox.Create("Hmm? Didn't I start with a victory\ncondition? Better try this again.\n(Press R)"));
                    dialogShown = true;
                }
            };
            Program.Engine.AddEntity(entity);

            Program.Engine.AddEntity(Enemy.Create(Program.ScreenWidth - 64 - 16, Program.ScreenHeight / 2));
            Program.Engine.AddEntity(Enemy.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2 - 16));
            Program.Engine.AddEntity(Enemy.Create(Program.ScreenWidth - 64 + 16, Program.ScreenHeight / 2));
            Program.Engine.AddEntity(Enemy.Create(Program.ScreenWidth - 64, Program.ScreenHeight / 2 + 16));

            Program.Engine.AddEntity(HeadsUpDisplay.Create());

            Program.Referee.Start();

            Program.WavProvider.AddMixerInput((ISampleProvider)sound);
            Program.WavPlayer.Play();
        }
Esempio n. 7
0
        public override void SetupLevel()
        {
            Program.Level = 7;

            Program.Engine.SetLocation(new Location(new Description2D(0, 0, Program.ScreenWidth, Program.ScreenHeight)));

            Program.Referee.ClearRules();

            Entity entb = Boss.Create(Program.ScreenHeight - 16, Program.ScreenHeight / 2);

            Program.Engine.AddEntity(entb);

            Stack <Action> deck = new Stack <Action>();

            if (Boss.savedHealth == 100 || Program.Diff != Program.Difficulty.EASY)
            {
                deck.Push(() =>
                {
                    Program.Engine.AddEntity(Powerup.Create("shoot Boss", Program.ScreenWidth - 128, Program.ScreenHeight / 2));
                    Program.Engine.AddEntity(DialogBox.Create("I just need to get close enough..."));
                });
                deck.Push(() => Program.Engine.AddEntity(DialogBox.Create("This isn't good. I have to do something.")));
                deck.Push(() => { });
            }
            else
            {
                Program.Referee.AddRule(Rule.Rules["shoot Boss"]);
            }

            Program.Referee.AddRule(Rule.Rules["Enemy hurty"]);
            Program.Referee.AddRule(Rule.Rules["Player pickup Powerup"]);
            Program.Referee.AddRule(Rule.Rules["control Player"]);
            Program.Referee.AddRule(Rule.Rules["top-down"]);

            SinWaveSound sound = new SinWaveSound(true);

            sound.SetWaveFormat(44100, 2);

            Entity deckFlipper = new Entity(new Description2D(0, 0, 0, 0));
            int    timer       = 0;

            deckFlipper.TickAction = (loc, ent) =>
            {
                if (Program.Engine.Location.GetEntities <DialogBox>().Any() || Program.Engine.Location.GetEntities <Banner>().Any())
                {
                    return;
                }

                if (Program.Referee.IsStarted && deck.Any() && timer++ % (Program.TPS * 10) == 0)
                {
                    deck.Pop().Invoke();
                }
            };

            Program.Engine.AddEntity(deckFlipper);

            string machineName = Environment.MachineName;

            if (!introDialogShown)
            {
                Program.Engine.AddEntity(
                    DialogBox.Create("[???]: What where did you come from?",
                                     DialogBox.Create("Who are you?",
                                                      DialogBox.Create($"[???] I am {machineName}.",
                                                                       DialogBox.Create("That couldn't be true.",
                                                                                        DialogBox.Create($"[{machineName}] It is. And you're not\nsupposed to be here. It's time\nto delete you."))))));
                introDialogShown = true;
            }
            else
            {
                Program.Engine.AddEntity(DialogBox.Create($"[{machineName}] It's time to delete you."));
            }

            Program.Engine.AddEntity(Player.Create(64, Program.ScreenHeight / 2));

            Program.Engine.AddEntity(Wall.Create(0, 0, 16, Program.ScreenHeight));
            Program.Engine.AddEntity(Wall.Create(Program.ScreenWidth, 0, 16, Program.ScreenHeight));
            Program.Engine.AddEntity(Wall.Create(0, 0, Program.ScreenWidth, 16));
            Program.Engine.AddEntity(Wall.Create(0, Program.ScreenHeight, Program.ScreenWidth + 16, 16));

            Program.Engine.AddEntity(HeadsUpDisplay.Create());

            Program.Referee.ResetTimer(Program.TPS * 180);

            Program.Referee.Start();

            Program.WavProvider.AddMixerInput((ISampleProvider)sound);
            Program.WavPlayer.Play();
        }