Пример #1
0
        /*
         * Routine to set everything up for a new game
         */
        public void NewGame(int gridSize)
        {
            WriteToLog.write("---- Game Start ----");

            // initialize the other classes
            GameBoard.NewGame(gridSize);
            GameMap.NewGame();
            SRS.NewGame();
            LRS.NewGame();
            Warp.NewGame();
            Torpedoes.NewGame();
            Phasers.NewGame();
            Shields.NewGame();
            Impulse.NewGame();
            DamageControl.NewGame();
            StarBases.NewGame();
            Probes.NewGame();

            ComsClear();

            // Register starbases
            for (int i = 0; i < GameBoard.GetSize() * GameBoard.GetSize(); i++)
            {
                if (GameBoard.GetGameBoard(i) > 99)
                {
                    // Register this starbase
                    StarBases.AddStarbase(i);
                    WriteToLog.write("Added starbase to loc " + i.ToString());
                }
            }

            // locate the enterprise and play the game
            GameBoard.RandomEnterpriseLocation();
            WriteToLog.write("Enteprise is in sector " + GameBoard.GetLocation());

            SRS.Execute();
            SetCondition();
        }
Пример #2
0
        /*
         * Button execution was broken out of the button handler so the
         * short cut keys can access it in a straight forward way
         */
        private void ButtonCommand(string btn)
        {
            bool executed = false;

            // prevent button hot keys during timer execution
            if (timerStep == 0)
            {
                Debug(btn + " pressed");

                switch (btn.ToUpper())
                {
                case "IMPL":
                    executed = Impulse.Execute();
                    break;

                case "WARP":
                    executed = Warp.Execute();

                    if (executed)
                    {
                        SRS.Execute();
                    }
                    break;

                case "SHLD":
                    Shields.Execute();
                    timerStep     = 4;
                    timer.Enabled = true;
                    //SetCondition();
                    break;

                case "POWER":
                    Shields.divertPower();
                    timerStep     = 4;
                    timer.Enabled = true;
                    //SetCondition();
                    break;

                case "TORP":
                    executed = Torpedoes.Execute();
                    break;

                case "PHAS":
                    executed = Phasers.Execute();
                    break;

                case "DMG":
                    DamageControl.FixAllDamage();
                    timerStep     = 4;
                    timer.Enabled = true;
                    //SetCondition();
                    break;
                }

                if (executed)
                {
                    // update status before animation starts
                    SetCondition();

                    if (IsUsingAnimation())
                    {
                        timerStep     = 1;
                        timer.Enabled = true;
                    }
                    else
                    {
                        Debug("No Animation Executing");
                        GameObjects.MoveWithNoAnimation();
                        GameObjects.TakingFire();
                        GameObjects.MoveWithNoAnimation();
                    }
                }
            }
        }