Esempio n. 1
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            // generate map
            Refs.p = new Player("The Protagonist", Color.Cyan);
            Refs.p.SetXY(32, 12);             // todo fix hardcoded numbers

            Refs.h = new Harem();

            Refs.m = new MazeGenerator().Create(65, 25);

            // draw initial map
            FlowMap.RemakeAllFlows();
            UpdateMap();
            GlowTest();
            HelpPopup();

            Player p = Refs.p;
            Cubi   c = Refs.h.roster[0];

            Announce("Welcome to the underworld. Look out, they're getting away!", p.myAlign, p.myColor);
            Announce("You'll never catch meeee!", c.myAlign, c.myColor);
            Announce("We'll see about that!", p.myAlign, p.myColor);
            Announce("Whee! *giggle*", c.myAlign, c.myColor);

            c = Refs.h.roster[1];
            Announce("Run, Master! *nyhha!*", c.myAlign, c.myColor);

            c = Refs.h.roster[2];
            Announce("Chase me Master! *hehe*", c.myAlign, c.myColor);

            Refs.p.UpdateInventory();
        }
Esempio n. 2
0
        public void PreviewKeyDownHandler(object sender, PreviewKeyDownEventArgs e)
        {
            this.ActiveControl = defaultFocus;

            var sw = new Stopwatch(); sw.Start();

            Console.WriteLine("Key " + e.KeyCode + " Pressed");
            Console.WriteLine("Starting new frame.");
            try
            {
                if (turnTimer.ElapsedMilliseconds < 300)
                {
                    return;
                }
                turnTimer.Start();

                int timePass = Refs.p.HandlePlayerInput(e);

                Refs.m.HealWalls();
                Console.WriteLine("Finished HealWalls at " + sw.ElapsedMilliseconds + "ms in.");

                Console.WriteLine("Finished RunLos at " + sw.ElapsedMilliseconds + "ms in.");

                FlowMap.RemakeAllFlows();
                Console.WriteLine("Finished RemakeAllFlows at " + sw.ElapsedMilliseconds + "ms in.");

                if (timePass == 0)
                {
                    UpdateMap();
                    Console.WriteLine("Finished UpdateMap at " + sw.ElapsedMilliseconds + "ms in.");
                }
                else
                {
                    while (timePass > 0)
                    {
                        // run ai for multiple turns if needed
                        foreach (Cubi c in Refs.h.roster)
                        {
                            c.AiMove();
                        }
                        Console.WriteLine("Finished AiMove at " + sw.ElapsedMilliseconds + "ms in.");

                        Refs.m.SpreadNectar();
                        UpdateMap();
                        Thread.Sleep(75);

                        Console.WriteLine("Finished UpdateMap at " + sw.ElapsedMilliseconds + "ms in.");
                        timePass--;
                        Refs.p.turnCounter++;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Last chance catch of exception " + ex.GetType() +
                                " with message " + ex.Message + " at " + ex.Source +
                                " with trace " + ex.StackTrace);
            }

            Console.WriteLine("Total time this update = " + sw.ElapsedMilliseconds + "ms. or " +
                              1000 / sw.ElapsedMilliseconds + " fps if it mattered.");

            this.ActiveControl = defaultFocus;
        }