/// <summary> /// A method that creates baloons depending on the colors passed to the method. /// </summary> /// <param name="colorOfBalloon">The enum value that the method is called upon.</param> /// <returns>A new baloon.</returns> public Balloon MakeBalloon(BaloonColor colorOfBalloon) { Balloon newBalloon; this.balloonsCreated++; switch (colorOfBalloon) { case BaloonColor.Blue: newBalloon = new Balloon("blue"); break; case BaloonColor.Green: newBalloon = new Balloon("green"); break; case BaloonColor.Red: newBalloon = new Balloon("red"); break; case BaloonColor.Yellow: newBalloon = new Balloon("yellow"); break; default: throw new ArgumentException(); } if (this.balloonsCreated % BonusBalloonProbailityInPercent == 0) { return newBalloon; } return newBalloon; }
public override void RenderGameFieldState(byte[,] fieldClone) { // the console is cleared only once - at first print of the field if (!this.isBackgroundChanged) { Console.BackgroundColor = ConsoleColor.White; Console.Clear(); this.isBackgroundChanged = true; } // sets the buffer size to maximum possible, because when printing many lines the cursor gets out of the console and throws an exception Console.BufferHeight = short.MaxValue - 1; Console.ForegroundColor = ConsoleColor.Black; var fieldAsString = FieldToString.DrawEmptyFrame(fieldClone); var topCursorPosition = Console.CursorTop; Console.WriteLine(fieldAsString); var defaultConsoleForegroundColor = Console.ForegroundColor; for (int row = 0; row < fieldClone.GetLength(0); row++) { Console.SetCursorPosition(InitialLeftCursorPosition, topCursorPosition + InitialTopCursorPosition + row); for (int col = 0; col < fieldClone.GetLength(1); col++) { if (fieldClone[row, col] == 0) { Console.Write(" "); continue; } BaloonColor color = (BaloonColor)fieldClone[row, col]; Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), color.ToString()); Console.Write("♥ "); } } Console.SetCursorPosition(0, topCursorPosition + InitialTopCursorPosition + 2 + fieldClone.GetLength(0)); Console.ForegroundColor = defaultConsoleForegroundColor; }
public override void Initialize(Animation Texture, Vector2 Position, float Speed, object specialParameter) { base.Initialize(Texture, Position, Speed, specialParameter); this.color = (BaloonColor)specialParameter; }