Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Forms;
  8.  
  9. namespace Digger
  10. {
  11.     public class Game
  12.     {
  13.         private int mapWidth;
  14.         public int MapWidth
  15.         {
  16.             get { return mapWidth; }
  17.             set
  18.             {
  19.                 if (value < 0) throw new ArgumentException();
  20.                 mapWidth = value;
  21.             }
  22.         }
  23.            
  24.         private int mapHeight;
  25.         public int MapHeight
  26.         {
  27.             get { return mapHeight; }
  28.             set
  29.             {
  30.                 if (value < 0) throw new ArgumentException();
  31.                 mapHeight = value;
  32.             }
  33.         }
  34.  
  35.         public int Scores { get; set; }
  36.         public bool IsOver { get; set; }
  37.         public Keys KeyPressed { get; set; }
  38.         public ICreature[,] Map { get; set; }
  39.  
  40.         public Game(int mapWidth, int mapHeight)
  41.         {
  42.             MapWidth = mapWidth;
  43.             MapHeight = mapHeight;
  44.             Map = new ICreature[MapWidth,MapHeight];
  45.            
  46.             var rand = new Random();
  47.             for(var  i = 0; i < MapWidth;i++)
  48.                 for (var j = 0; j < MapHeight; j++)
  49.                 {
  50.                     if (i <= 3 || i == 10 || j == 10 || j == 17 || i == 17)
  51.                         continue;                
  52.                     Map[i, j] = new Terrain();
  53.                 }
  54.            
  55.             Map[10, 15] = new Monster();
  56.             Map[1, 1] = new Player();
  57.             for (var a = 0; a < 15; a++)
  58.             {
  59.                 Map[rand.Next(0, MapWidth - 1), rand.Next(0, MapHeight - 3)] = new Sack();
  60.                 Map[rand.Next(0, MapWidth - 1), rand.Next(0, MapHeight - 1)] = new Gold();
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement