Beispiel #1
0
        public bool gameStarted = false;    //Bool showing if the game has started or ended/hasn't started yet

        public Game()
        {
            playerPicsColors = new Dictionary <int, B[, ]>();
            this.players     = new List <Player>();
            this.map         = new Map(xSize, ySize);
            this.graphics    = new GraphicsRepository <A, B>();
            this.field       = graphics.CreateGraphicsObject(xSize * unitSize, ySize * unitSize);
            this.pictures    = new PictureFlyweight <A, B>();
        }
Beispiel #2
0
 public B[,] GetPictureArray(string type)
 {
     B[,] picToReturn = null;
     if (pictures.ContainsKey(type))
     {
         picToReturn = pictures[type];
     }
     else
     {
         A picObject = GetImage(type);
         //Console.WriteLine(sizex + " " + sizey);
         GraphicsAdapter <A, B> pic = graphics.CreateGraphicsObject(sizex, sizey);
         pic.SetImage(picObject);
         picToReturn = pic.GetColorArray();
         pictures.Add(type, picToReturn);
     }
     return(picToReturn);
 }
Beispiel #3
0
        public void drawBackground()
        {
            //Get map blocks(units) and initialise background picture with it's color
            Unit[,] blocks = map.getUnits();
            background     = graphics.CreateGraphicsObject(xSize * unitSize + 150, ySize * unitSize);
            B backgroundColor = graphics.GetBackgroundColor();

            FormPlayerImages();


            background.LockBits();

            //Draw background
            for (int x = 0; x < background.GetWidth(); x++)
            {
                for (int y = 0; y < background.GetHeight(); y++)
                {
                    background.SetPixel(x, y, backgroundColor);
                }
            }

            //Draw walls
            B[,] wallPicTest = pictures.GetPictureArray("wall");
            for (int i = 0; i < xSize; i++)
            {
                for (int j = 0; j < ySize; j++)
                {
                    if (blocks[i, j] != null && blocks[i, j] is Wall)
                    {
                        for (int x = 0; x < unitSize; x++)
                        {
                            for (int y = 0; y < unitSize; y++)
                            {
                                background.SetPixel(i * unitSize + x, j * unitSize + y, wallPicTest[x, y]);
                            }
                        }
                    }
                }
            }
            background.UnlockBits();
        }