示例#1
0
        public void Update()
        {
            //updates player location
            Player.Move();
            //checks if food was found
            if (Representation[Player.LocationY, Player.LocationX] == Food.Icon)
            {
                Player.AddPointsToScore();
                Player.Grow();
                Representation[Player.LocationY, Player.LocationX] = Player.Body[0].Icon;
                SetFoodLocation();
            }
            else if (!(Representation[Player.LocationY, Player.LocationX] == ' ' || Representation[Player.LocationY, Player.LocationX] == Player.Icon))
            {
                Player.StatusValue = Player.Status.Dead;
                Console.Title      = "Died to: " + Representation[Player.LocationY, Player.LocationX].ToString();
            }

            //updates blank board
            for (int i = 0; i < Height; i++)
            {
                for (int j = 0; j < Width; j++)
                {
                    if (i == 0 || i == Height - 1)
                    {
                        Representation[i, j] = '=';
                    }
                    else
                    {
                        Representation[i, j] = j == 0 || j == (Width - 2) ? '|' : ' ';
                    }
                }
            }
            //draws members to board
            UpdateMembers();
        }