public void SetTextTests()
        {
            // Test invalid input
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetActorText(null));
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetActorText(""));
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetTargetText(null));
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetTargetText(""));
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetHitsText(null));
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetHitsText(""));
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetDamageText(null));
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetDamageText(""));
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetResultsText(null));
            Assert.ThrowsException <ArgumentException>(() => TextManager.SetResultsText(""));

            // Test valid input
            // Just give it a valid string since nothing is returned or checkable...
            TextManager.SetActorText("Actor");
            TextManager.SetTargetText("Target");
            TextManager.SetHitsText("Hits");
            TextManager.SetDamageText("Damage");
            TextManager.SetResultsText("Results");

            // Static cleanup
            TextManager.Clear();
        }
示例#2
0
        /// <summary>
        /// This method will keep looping until a bug is found, or if the player closes the program.
        /// </summary>
        private static void Update()
        {
            #region Game-Diff-Selection
            // Write instructions + information to Console.
            TextManager.WriteLine("Select a game: ");
            foreach (var index in IndexToGameMode)
            {
                TextManager.WriteLine($"{index.Key}. {index.Value}");
            }
            TextManager.WriteLine();
            TextManager.WriteLine("Enter a number to select game: \n", ConsoleColor.Green);

            // Get gamemode from user input
            var gameIndex = GetIndexFromUserInput(IndexToGameMode.Count);
            var gameName  = IndexToGameMode[gameIndex];

            // Write instrutions + information to Console.
            TextManager.Clear();
            TextManager.WriteLine($"Game Selected: {gameName}");
            foreach (var index in IndexToDifficulty)
            {
                TextManager.WriteLine($"{index.Key}. {index.Value}");
            }
            TextManager.WriteLine();
            TextManager.WriteLine("Enter a number to select difficulty: \n", ConsoleColor.Green);

            // Get game difficulty from user input
            var difficultyIndex = GetIndexFromUserInput(IndexToDifficulty.Count);
            var difficulty      = IndexToDifficulty[difficultyIndex];

            // Write instructions + information to Console.
            TextManager.Clear();
            TextManager.WriteLine($"Game Selected: {gameName}");
            TextManager.WriteLine($"Difficulty Selected: {difficulty}");
            TextManager.WriteLineBreak();
            TextManager.WriteLine();
            #endregion

            // Start game depending on what the user had input.
            switch (gameIndex)
            {
            case 1:
                CurrentGame = new MineSweeper(difficulty);
                break;

            case 2:
                CurrentGame = new PuyoPuyo(difficulty);
                break;

            default:
                throw new Exception("Invalid game mode has been declared.");
            }

            // Start the game once the user has selected a game and difficulty.
            CurrentGame.StartGame();
        }
示例#3
0
 /// <summary>
 /// Write instructions whenever the player starts this game.
 /// </summary>
 internal override void WriteInstructions()
 {
     TextManager.WriteLine("Objective: Your goal is to reveal every area in the mine field without triggering a mine");
     TextManager.WriteLine("How to play: Enter a coordinate to review an area.");
     TextManager.WriteLine($"Pick a letter from A -> {Char.ToUpper(CharToRowIndex.Keys.ElementAt(TotalRows - 1))}, followed by a number between 1 -> {TotalColumns}", ConsoleColor.Yellow);
     TextManager.WriteLine("Examples: B2, F12", ConsoleColor.Gray);
     WaitForInput();
     TextManager.Clear();
     DrawMineField();
 }
示例#4
0
        /// <summary>
        /// Will display a message once the game is over.
        /// </summary>
        /// <param name="failed"></param>
        private void DisplayOver(bool failed)
        {
            TextManager.WriteLineBreak();
            TextManager.WriteLine();

            // Display appropriate message when the game ends.
            if (failed)
            {
                TextManager.WriteLine("Game Over.", ConsoleColor.Red);
            }
            else
            {
                TextManager.WriteLine("You win!", ConsoleColor.Green);
            }

            // Read user input
            WaitForInput();
            TextManager.Clear();
        }
        public void TearDownResultTest()
        {
            // Build up a couple of texts
            TextManager.SetActorText("Actor");
            TextManager.SetTargetText("Target");
            TextManager.SetHitsText("Hits");
            TextManager.SetDamageText("Damage");
            TextManager.SetResultsText("Results");

            // Teardown results, then ensure the rest of the teardowns work as expected
            TextManager.TearDownResults();
            Assert.IsTrue(TextManager.TearDownText());
            Assert.IsTrue(TextManager.TearDownText());
            Assert.IsTrue(TextManager.TearDownText());
            Assert.IsTrue(TextManager.TearDownText());
            Assert.IsFalse(TextManager.TearDownText());

            // Static cleanup
            TextManager.Clear();
        }
        public void TearDownTest()
        {
            // Build up a couple of texts and then tear them down
            TextManager.SetActorText("Actor");
            TextManager.SetTargetText("Target");
            TextManager.SetHitsText("Hits");
            TextManager.SetDamageText("Damage");
            TextManager.SetResultsText("Results");

            // Should be true 5 times before there's no text to tear down
            Assert.IsTrue(TextManager.TearDownText());
            Assert.IsTrue(TextManager.TearDownText());
            Assert.IsTrue(TextManager.TearDownText());
            Assert.IsTrue(TextManager.TearDownText());
            Assert.IsTrue(TextManager.TearDownText());
            Assert.IsFalse(TextManager.TearDownText());

            // Static cleanup
            TextManager.Clear();
        }
 public void Clear()
 {
     for (int i = 0; i < CandidatesNum; ++i)
     {
         //btn[i].GetComponentInChildren<Text>().text = "";
         if (cands[i] != null)
         {
             cands[i].word = "";
         }
     }
     for (int i = 0; i < RadialNum; ++i)
     {
         radialText[i].text = "";
     }
     for (int i = 0; i < CandidatesNum; ++i)
     {
         listText[i].text = "";
     }
     SetRadialMenuDisplay(false);
     gesture.chooseCandidate = false;
     history.Clear();
     textManager.Clear();
 }
示例#8
0
        /// <summary>
        /// Main Game Loop.
        /// </summary>
        /// <returns></returns>
        internal override bool Update()
        {
            // Write instructions
            TextManager.WriteLine("Enter a Coordinate: \n", ConsoleColor.Green);

            // Get Coordinate
            var coordinate = ParseInput(TextManager.WaitAndReadInput());

            TextManager.Clear();

            // Validate Coordinate
            if (coordinate == null)
            {
                if (MineFieldInitialized)
                {
                    DrawMineField(false);
                }
                else
                {
                    DrawMineField();
                }

                TextManager.WriteLine("Invalid input.", ConsoleColor.Red);
                TextManager.WriteLine();
                return(true);
            }

            // Generate MineField if it hasn't been generated yet
            if (!MineFieldInitialized)
            {
                GenerateMineFieldArea(coordinate);
            }

            // If coordinate is already solved, remind user.
            var area = MineFieldArea[coordinate.Row, coordinate.Column];

            if (area == MineArea.Revealed || area == MineArea.Safe)
            {
                DrawMineField(false);
                TextManager.WriteLine("Coordinate is already revealed.", ConsoleColor.Red);
                TextManager.WriteLine();
                return(true);
            }

            // Select MineField area and draw the mine field
            var failed    = PlayMineArea(coordinate);
            var totalLeft = CountTotalUnknownAreas();

            DrawMineField(failed);

            // Write information
            TextManager.WriteLine($"Total Area Remaining: {totalLeft}");
            TextManager.WriteLine();

            if (totalLeft == 0)
            {
                EndGame();
            }

            return(!failed);
        }
示例#9
0
        /// <summary>
        ///
        /// </summary>
        private void DrawPlayfield()
        {
            TextManager.Clear();
            var partnerpos = GetCurrentPartnerPosition();


            for (var i = 0; i < TotalRows; i++)
            {
                for (var j = 0; j < TotalColumns; j++)
                {
                    if (CurrentPosition.Row == i && CurrentPosition.Column == j)
                    {
                        DrawPuyo(CurrentPair.PuyoCenter, true);
                    }
                    else if (partnerpos.Row == i && partnerpos.Column == j)
                    {
                        DrawPuyo(CurrentPair.PuyoPartner, true);
                    }

                    else
                    {
                        DrawPuyo(Playfield[i, j]);
                    }

                    if (j == TotalColumns - 1)
                    {
                        TextManager.Write("_.", ConsoleColor.Black);

                        switch (i)
                        {
                        case 0:
                            TextManager.Write("Score:");
                            break;

                        case 1:
                            TextManager.Write(CurrentScore.ToString(), ConsoleColor.Red);
                            break;

                        case 3:
                            TextManager.Write("Next:");
                            break;

                        case 4:
                            DrawPuyo(NextPairs[0].PuyoCenter);
                            break;

                        case 5:
                            DrawPuyo(NextPairs[0].PuyoPartner);
                            break;

                        case 7:
                            DrawPuyo(NextPairs[1].PuyoPartner);
                            break;

                        case 8:
                            DrawPuyo(NextPairs[1].PuyoPartner);
                            break;
                        }
                    }
                }
                TextManager.WriteLine();
            }
        }