public Knight(int x, int y, Enums.Color color) { this.X = x; this.Y = y; this.Color = color; ChessBoard = new int[8, 8]; }
public event PacmanDiedEventHandler PacmanDiedEvent; //event encapsulating pacman died event /// <summary> /// The Ghost constructor will take as input a GameState object /// in order to get information about the pacman object, the maze /// and the pen of the ghosts. The constructor will also initialize /// the position fo the ghost, its target relative to Pacman's position, /// a ghoststate enum and a color of the ghost with the input with /// the input values passed to the method. An exception will be thrown /// if the gamestate object passed is null or if the target's x or y /// values are negative /// </summary> /// <param name="g">A GameState object</param> /// <param name="x">the int x coordinates of the ghost position</param> /// <param name="y">the int y coordinates of the ghost position</param> /// <param name="target">the vector target of the ghost</param> /// <param name="start">the ghoststate enum of the ghost</param> /// <param name="c">the color of the ghost</param> public Ghost(GameState g, int x, int y, Vector2 target, GhostState start, Enums.Color c) { if (Object.ReferenceEquals(null, g)) { throw new ArgumentException("The input GameState object passed to the Ghost constructor must not be null"); } if (x < 0 || y < 0) { throw new ArgumentException("The Ghost's x and y position must be negative"); } this.pacman = g.Pacman; this.maze = g.Maze; this.pen = g.Pen; this.target = target; this.colour = c; this.position = new Vector2(x, y); if (start == GhostState.Scared) { this.currentState = new Scared(this, this.maze); } if (start == GhostState.Chasing) { this.currentState = new Chase(this, this.maze, this.target, this.pacman); } if (start == GhostState.Penned) { this.currentState = new Penned(); } this.points = 200; //default points set to 200 }
private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { if (serialPort.BytesToRead > 0) { char cmd = (char)serialPort.ReadChar(); if (cmd.Equals('C')) { while (serialPort.BytesToRead < 3) { ; } int r = serialPort.ReadByte(); int g = serialPort.ReadByte(); int b = serialPort.ReadByte(); Enums.Color detectedColor = Utils.Classify(r, g, b); PlayIf(detectedColor); lastColor = detectedColor; Dispatcher.BeginInvoke(new Action(delegate { Update(r, g, b); })); } } }
private string m_pName; //name of Bunny public Bunny(int m_pSex, int m_pColor, int m_pAge) //constructor of bunny { this.m_pSex = (Enums.Sex)m_pSex; this.m_pColor = (Enums.Color)m_pColor; this.m_pAge = m_pAge; return; }
public Pawn(int x, int y, Enums.Color color) { haveMoved = false; this.X = x; this.Y = y; this.Color = color; ChessBoard = new int[8, 8]; }
public string getValues() { Enums.Sex m_pSex = this.m_pSex; Enums.Color m_pColor = this.m_pColor; int m_pAge = this.m_pAge; string m_pName = this.m_pName; return("Bunny " + m_pName + " was burn. Features:\nGender: " + m_pSex + " Color: " + m_pColor + " Age: " + m_pAge); }
internal static void Color(this Run run, Enums.Color color) { RunProperties runProperties = run.GetOrCreate <RunProperties>(true); runProperties.Color = new Color() { Val = Convert.ToWordprocessingColor(color) }; }
// let's suppose we don't want ad-hoc queries on products public IEnumerable <Product> FilterByColor(IEnumerable <Product> products, Enums.Color color) { foreach (var p in products) { if (p.Color == color) { yield return(p); } } }
public Product(string name, Enums.Color color, Enums.Size size) { if (name == null) { throw new ArgumentNullException(paramName: nameof(name)); } Name = name; Color = color; Size = size; }
private void PlayIf(Enums.Color color) { if (lastColor != color) { if (@event.PlaybackState == PlaybackState.Playing) { @event.Stop(); sine.Frequency = (double)color; @event.Init(sine); } @event.Play(); } }
public Card(int cardNum) { this.cardNum = cardNum; Thread.Sleep(20); Random random = new Random((int)DateTime.Now.Ticks); Array allColors = Enum.GetValues(typeof(Enums.Color)); Array allShadings = Enum.GetValues(typeof(Enums.Shading)); Array allShapes = Enum.GetValues(typeof(Enums.Shape)); Array allNumbers = Enum.GetValues(typeof(Enums.Number)); this.color = (Enums.Color)allColors.GetValue(random.Next(allColors.Length)); this.shading = (Enums.Shading)allShadings.GetValue(random.Next(allShadings.Length)); this.shape = (Enums.Shape)allShapes.GetValue(random.Next(allShapes.Length)); this.number = (Enums.Number)allNumbers.GetValue(random.Next(allNumbers.Length)); }
public Product(string name, Enums.Color color, Enums.Size size) { Name = name; Color = color; Size = size; }
public ColorSpecification(Enums.Color color) { this.color = color; }
public static IEnumerable <Product> FilterBySizeAndColor(IEnumerable <Product> products, Enums.Size size, Enums.Color color) { foreach (var p in products) { if (p.Size == size && p.Color == color) { yield return(p); } } } // state space explosion
static public void MoveFocus(ChessBoard chessBoard, int x, int y) { Enums.Color previousColor = Enums.Color.Black; IPiece piece = null; int xBoard = 0, yBoard = 0; while (true) { Console.BackgroundColor = ConsoleColor.DarkGreen; switch (Console.ReadKey(true).Key) { case ConsoleKey.UpArrow: if (yBoard - 1 < 0) { break; } Console.SetCursorPosition(x, y - 3); y -= 3; yBoard--; break; case ConsoleKey.DownArrow: if (yBoard + 1 > 7) { break; } Console.SetCursorPosition(x, y + 3); y += 3; yBoard++; break; case ConsoleKey.LeftArrow: if (xBoard - 1 < 0) { break; } Console.SetCursorPosition(x - 8, y); x -= 8; xBoard--; break; case ConsoleKey.RightArrow: if (xBoard + 1 > 7) { break; } Console.SetCursorPosition(x + 8, y); x += 8; xBoard++; break; case ConsoleKey.Enter: int cursorLeft = Console.CursorLeft; int cursorTop = Console.CursorTop; Console.SetCursorPosition(3, 10); Console.Write(" "); Console.SetCursorPosition(cursorLeft, cursorTop); if (piece == null) { if (chessBoard.Board[xBoard, yBoard] != null) { piece = chessBoard.Board[xBoard, yBoard]; if (piece.Color == previousColor) { Console.SetCursorPosition(3, 10); Console.Write("Its not your piece!"); piece = null; } } } else { cursorLeft = Console.CursorLeft; cursorTop = Console.CursorTop; if (chessBoard.Move(xBoard, yBoard, piece) == false) { Console.SetCursorPosition(3, 10); Console.Write("Cant move there!"); } else { chessBoard.Move(xBoard, yBoard, piece); previousColor = piece.Color; } piece = null; DrawChessBoard(); SetPieces(chessBoard, cursorLeft, cursorTop); } break; default: break; } } }
public Rectangle(Point leftTop, Point rightBottom, Enums.Color color) : base(color) { LeftTop = leftTop; RightBottom = rightBottom; }
/// <summary>Constructor for CheerBadge</summary> public CheerBadge(int cheerAmount) { CheerAmount = cheerAmount; Color = getColor(cheerAmount); }