コード例 #1
0
    public TitleConsole(int width, int height) : base(width, height)
    {
        DefaultBackground = Color.Black;

        landGrid = new bool[Width, Height];
        var start = new Button(10, 1)
        {
            Position = new Point(5, 5),
            Text     = "START",
        };

        start.Click += (btn, args) => {
            StartGame();
        };
        this.Controls.Add(start);

        var quit = new Button(10, 1)
        {
            Position = new Point(5, 6),
            Text     = "QUIT",
        };

        quit.Click += (btn, args) => {
            ExitGame();
        };
        this.Controls.Add(quit);

        titleLines = 0;
        waterLevel = Height - 10;

        timers = new List <ITimer> {
            new TimerLimited(0.25, () => {
                titleLines++;
            }, 25),
            new TimerLimited(5, () => {
                timers = new List <ITimer> {
                    new Timer(waterLineInterval, () => {
                        waterLines.Add(new XY(0, waterLevel + Random.Next(waterHeight)));
                    }),
                    new Timer(waterTrailInterval, () => {
                        waterLines.ForEach(line => waterTrails.Add(new WaterTrail(line.x, line.y, waterTrailLifespan)));
                    }),
                    new Timer(planeInterval, () => {
                        planes.Add(new XY(0, planeLevel + Random.Next(10)));
                    }),
                    new Timer(playerInterval, () => {
                        planes.ForEach(plane => {
                            if (Main.InRange(plane.x + PLANE.LineLength(), Width / 2, 30) && Random.Next(2) < 1)
                            {
                                players.Add(plane.clone + new XY(8, 1));
                            }
                        });
                    }),
                    new TimerLimited(0.05, () => {
                        for (int i = 0; i < 25; i++)
                        {
                            land.Add(new XY(Width / 2 + Random.Amplitude(15) + Random.Amplitude(15) + Random.Amplitude(15), planeLevel));
                        }
                    }, (int)(landSpawnTime / 0.05))
                };
            }),
        };
    }