예제 #1
0
 protected Food(BorderWall wall, char foodSymbol, int points)
     : base(wall.LeftX, wall.TopY)
 {
     this.wall       = wall;
     this.FoodPoints = points;
     this.foodSymbol = foodSymbol;
     this.random     = new Random();
 }
예제 #2
0
        public Engine(BorderWall wall, InfoWall infoWall, Snake snake)
        {
            this.snake        = snake;
            this.wall         = wall;
            this.infoWall     = infoWall;
            pointsOfDirection = new Point[4];

            snakeDirection = defaultSnakeDirection;
        }
예제 #3
0
        public static void Main()
        {
            ConsoleWindow.CustomizeConsole();

            BorderWall wall     = new BorderWall(GameConstraits.GameCols, GameConstraits.GameRows);
            InfoWall   infoWall = new InfoWall(GameConstraits.InfoCols, GameConstraits.InfoRows);

            Snake snake = new Snake(wall);

            Engine engine = new Engine(wall, infoWall, snake);

            engine.Run();
        }
예제 #4
0
        public Snake(BorderWall wall)
        {
            this.wall = wall;

            this.SnakeElements = new Queue <Point>();
            this.foods         = new Food[3];

            this.foodIndex = RandomFoodNumber;

            this.GetFoods();
            this.CreateSnake();
            Score = 0;

            foods[foodIndex].SetRandomPosition(SnakeElements);
        }
예제 #5
0
        // Helper functions to set tiles in the level to walls
        private void setWallIntoLevel(BorderWall wallType, int wallIndexX, int wallIndexY)
        {
            int tileX = 0, tileY = 0;

            switch (wallType)
            {
            case BorderWall.Single:
                tileX = wallIndexX * (BORDER_WALL_LENGTH + 1);
                tileY = wallIndexY * (BORDER_WALL_LENGTH + 1);
                borderCornerColors[wallIndexX, wallIndexY] = Color.Lerp(Color.White, getTileColor(tileX, tileY), COLOR_TINT_FACTOR);
                grid[tileX, tileY] = LevelContent.LevelTile.Wall;
                pathfinding.costGrid[tileX, tileY] = Pathfinding.COST_WALL;
                break;

            case BorderWall.Horiz:
                tileX = wallIndexX * (BORDER_WALL_LENGTH + 1) + 1;
                tileY = wallIndexY * (BORDER_WALL_LENGTH + 1);
                borderHorizColors[wallIndexX, wallIndexY] = Color.Lerp(Color.White, getTileColor(tileX, tileY), COLOR_TINT_FACTOR);
                for (int i = 0; i < BORDER_WALL_LENGTH; i++)
                {
                    grid[tileX + i, tileY] = LevelContent.LevelTile.Wall;
                    pathfinding.costGrid[tileX + i, tileY] = Pathfinding.COST_WALL;
                }
                break;

            case BorderWall.Vert:
                tileX = wallIndexX * (BORDER_WALL_LENGTH + 1);
                tileY = wallIndexY * (BORDER_WALL_LENGTH + 1) + 1;
                borderVertColors[wallIndexX, wallIndexY] = Color.Lerp(Color.White, getTileColor(tileX, tileY), COLOR_TINT_FACTOR);
                for (int j = 0; j < BORDER_WALL_LENGTH; j++)
                {
                    grid[tileX, tileY + j] = LevelContent.LevelTile.Wall;
                    pathfinding.costGrid[tileX, tileY + j] = Pathfinding.COST_WALL;
                }
                break;
            }
        }
예제 #6
0
 // Helper functions to set tiles in the level to walls
 private void setWallIntoLevel(BorderWall wallType, int wallIndexX, int wallIndexY)
 {
     int tileX = 0, tileY = 0;
     switch (wallType)
     {
         case BorderWall.Single:
             tileX = wallIndexX * (BORDER_WALL_LENGTH + 1);
             tileY = wallIndexY * (BORDER_WALL_LENGTH + 1);
             borderCornerColors[wallIndexX, wallIndexY] = Color.Lerp(Color.White, getTileColor(tileX, tileY), COLOR_TINT_FACTOR);
             grid[tileX, tileY] = LevelContent.LevelTile.Wall;
             pathfinding.costGrid[tileX, tileY] = Pathfinding.COST_WALL;
             break;
         case BorderWall.Horiz:
             tileX = wallIndexX * (BORDER_WALL_LENGTH + 1) + 1;
             tileY = wallIndexY * (BORDER_WALL_LENGTH + 1);
             borderHorizColors[wallIndexX, wallIndexY] = Color.Lerp(Color.White, getTileColor(tileX, tileY), COLOR_TINT_FACTOR);
             for (int i = 0; i < BORDER_WALL_LENGTH; i++)
             {
                 grid[tileX + i, tileY] = LevelContent.LevelTile.Wall;
                 pathfinding.costGrid[tileX + i, tileY] = Pathfinding.COST_WALL;
             }
             break;
         case BorderWall.Vert:
             tileX = wallIndexX * (BORDER_WALL_LENGTH + 1);
             tileY = wallIndexY * (BORDER_WALL_LENGTH + 1) + 1;
             borderVertColors[wallIndexX, wallIndexY] = Color.Lerp(Color.White, getTileColor(tileX, tileY), COLOR_TINT_FACTOR);
             for (int j = 0; j < BORDER_WALL_LENGTH; j++)
             {
                 grid[tileX, tileY + j] = LevelContent.LevelTile.Wall;
                 pathfinding.costGrid[tileX, tileY + j] = Pathfinding.COST_WALL;
             }
             break;
     }
 }
예제 #7
0
 public FoodHash(BorderWall wall)
     : base(wall, foodSymbol, foodPoints)
 {
 }
예제 #8
0
 public FoodDollar(BorderWall wall)
     : base(wall, foodSymbol, foodPoints)
 {
 }
예제 #9
0
 public FoodPercent(BorderWall wall)
     : base(wall, foodSymbol, foodPoints)
 {
 }