private FullSnake _Snake; // Temporary snake. #endregion Fields #region Constructors /* * Constructor of NetworkCOntainer * - Initialize variables. * */ public NetworkContainer() { _Msg = "000"; _Snake = new FullSnake(); _Fruit = new Fruit(); _Insect = new Insect(); _ListWalls = new ListWalls(); _Nickname = ""; _Score = 0; _HasBeenModified = false; }
///////////////// // Set _ListWalls public void Set_ListWalls(ListWalls listWalls) { _ListWalls = listWalls; }
//////////////// // Render Walls public void RenderWalls(ListWalls listWalls) { if(listWalls.Get_ListWallsSize() >= 1) /*for (int i = 0; i < listWalls.Get_ListWallsSize(); i++) { _MyGraphics.DrawRectangle(_Pen, element.Get_X(), element.Get_Y(), element.Get_Side(), element.Get_Side()); // Draw a rectangle for each element of the list of walls. }*/ _MyGraphics.DrawRectangle(_Pen, listWalls.Get_ListWalls()[listWalls.Get_ListWallsSize() - 1].Get_X(), listWalls.Get_ListWalls()[listWalls.Get_ListWallsSize() - 1].Get_Y(), listWalls.Get_ListWalls()[listWalls.Get_ListWallsSize() - 1].Get_Side(), listWalls.Get_ListWalls()[listWalls.Get_ListWallsSize() - 1].Get_Side()); //} //catch (Exception e) { Console.WriteLine(e); } }
/* * Method for initializing the Game: * - Initialize object for playing. * - Initialize timers (one for the game progress, one for the insect). * - initialize the thread for graphical rendering. * */ public void InitializeGame() { _FullSnake = new FullSnake(this.gameBoardPictureBox.Width); _Fruit = new Fruit(this.gameBoardPictureBox.Width, this.gameBoardPictureBox.Height); _Insect = new Insect(this.gameBoardPictureBox.Width, this.gameBoardPictureBox.Height, -666, -666); if (_Multiplayer) _ListWalls = new ListWalls(); _Score = 0; _TimerInterval = 70; _Direction = 1; _GameOver = false; _InsectIsPresent = false; _InGame = true; _Timer = new Timer(); _Timer.Interval = _TimerInterval; _Timer.Tick += new EventHandler(TimerTick); _InsectTimer = new Timer(); _InsectTimer.Interval = 1000; _InsectTimer.Tick += new EventHandler(InsectTimerTick); _RenderThread = new System.Threading.Thread(new System.Threading.ThreadStart(Render)); _RenderThread.Name = "RenderThread"; _RenderThread.IsBackground = true; }
///////////////////// // Render mini Walls public void RenderMiniWalls(ListWalls listWalls) { if (listWalls.Get_ListWallsSize() >= 1) //try //{ _MyMiniGraphics.DrawRectangle(_Pen, listWalls.Get_ListWalls()[listWalls.Get_ListWallsSize() - 1].Get_X()/2, listWalls.Get_ListWalls()[listWalls.Get_ListWallsSize() - 1].Get_Y()/2, listWalls.Get_ListWalls()[listWalls.Get_ListWallsSize() - 1].Get_Side()/2, listWalls.Get_ListWalls()[listWalls.Get_ListWallsSize() - 1].Get_Side()/2); //} // catch (Exception e) { Console.WriteLine(e); } }