예제 #1
0
        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;
        }
예제 #2
0
 /////////////////
 // Set _ListWalls
 public void Set_ListWalls(ListWalls listWalls)
 {
     _ListWalls = listWalls;
 }
예제 #3
0
파일: Render.cs 프로젝트: Genjo15/Snake
        ////////////////
        // 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); }
        }
예제 #4
0
파일: Game.cs 프로젝트: Genjo15/Snake
        /*
         * 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;
        }
예제 #5
0
파일: Render.cs 프로젝트: Genjo15/Snake
        /////////////////////
        // 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); }
        }