示例#1
0
 public static Grille Parse(Texture2D toParse)
 {
     Grille toReturn = new Grille(toParse.Width, toParse.Height);
     Color[] colorData = new Color[toParse.Width * toParse.Height];
     toParse.GetData(colorData);
     for (int j = 0; j < toParse.Width; j++)
     {
         for (int i = 0; i < toParse.Height; i++)
         {
             var buf = colorData[j + i * toParse.Width];
             if (buf == Color.White)
             {
                 toReturn.cellules[j, i] = new Cell(j, i);
                 toReturn.cellules[j, i].chiffre = 1;
                 toReturn.cellules[j, i].couleur = buf;
                 toReturn.cellules[j, i].kind = Cell.Kind.Creep;
             }
             else if (buf == Color.Lime)
             {
                 toReturn.cellules[j, i] = new Cell(j, i);
                 toReturn.cellules[j, i].chiffre = 2;
                 toReturn.cellules[j, i].couleur = Color.Green;
                 toReturn.cellules[j, i].kind = Cell.Kind.Turret;
             }
             else if (buf == Color.Red)
             {
                 toReturn.cellules[j, i] = new Cell(j, i);
                 toReturn.cellules[j, i].chiffre = 0;
                 toReturn.cellules[j, i].couleur = buf;
                 toReturn.cellules[j, i].kind = Cell.Kind.Rock;
             }
         }
     }
     return toReturn;
 }
示例#2
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     texture     = Content.Load <Texture2D>("Cell");
     spriteBatch = new SpriteBatch(GraphicsDevice);
     grid        = Grille.Parse(Content.Load <Texture2D>("map1"));
     cam         = new Camera(grid);
     mouse       = new MouseHandler();
     changed     = new List <Cell>();
     // TODO: use this.Content to load your game content here
 }
示例#3
0
        public static Grille Parse(Texture2D toParse)
        {
            Grille toReturn = new Grille(toParse.Width, toParse.Height);

            Color[] colorData = new Color[toParse.Width * toParse.Height];
            toParse.GetData(colorData);
            for (int j = 0; j < toParse.Width; j++)
            {
                for (int i = 0; i < toParse.Height; i++)
                {
                    var buf = colorData[j + i * toParse.Width];
                    if (buf == Color.White)
                    {
                        toReturn.cellules[j, i]         = new Cell(j, i);
                        toReturn.cellules[j, i].chiffre = 1;
                        toReturn.cellules[j, i].couleur = buf;
                        toReturn.cellules[j, i].kind    = Cell.Kind.Creep;
                    }
                    else if (buf == Color.Lime)
                    {
                        toReturn.cellules[j, i]         = new Cell(j, i);
                        toReturn.cellules[j, i].chiffre = 2;
                        toReturn.cellules[j, i].couleur = Color.Green;
                        toReturn.cellules[j, i].kind    = Cell.Kind.Turret;
                    }
                    else if (buf == Color.Red)
                    {
                        toReturn.cellules[j, i]         = new Cell(j, i);
                        toReturn.cellules[j, i].chiffre = 0;
                        toReturn.cellules[j, i].couleur = buf;
                        toReturn.cellules[j, i].kind    = Cell.Kind.Rock;
                    }
                }
            }
            return(toReturn);
        }
示例#4
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     texture = Content.Load<Texture2D>("Cell");
     spriteBatch = new SpriteBatch(GraphicsDevice);
     grid = Grille.Parse(Content.Load<Texture2D>("map1"));
     cam = new Camera(grid);
     mouse = new MouseHandler();
     changed = new List<Cell>();
     // TODO: use this.Content to load your game content here
 }
示例#5
0
 public Camera(Grille grid)
 {
     mapWidth  = grid.cellules.GetLength(0) * Cell.grosseur;
     mapHeight = grid.cellules.GetLength(1) * Cell.grosseur;
 }
示例#6
0
 public Camera(Grille grid)
 {
     mapWidth = grid.cellules.GetLength(0) * Cell.grosseur;
     mapHeight = grid.cellules.GetLength(1) * Cell.grosseur;
 }