Beispiel #1
0
        public Playfield(int Height, int Width, ContentManager Content)
        {
            this._height = Height;
            this._width = Width;
            this._playfield = new Hexfield[_height, _width];
            this._content = Content;
            this._texMan = new TextureManager(Content);
            this._textures = _texMan.TexturesTerrain;
            this._texturesMasks = _texMan.TexturesTerrainMasks;

            int counter = 0;
            Random rnd = new Random();

            for (int y = 0; y <= _playfield.GetUpperBound(0); y++)
            {
                for (int x = 0; x <= _playfield.GetUpperBound(1); x++, counter++)
                {
                    int rnTexElement = rnd.Next(0, _textures.Count);
                    int tnMaskElement = rnd.Next(0, _texturesMasks.Count);
                    int prioTemp = _texMan.PriorityTerrain[_textures.ElementAt(rnTexElement).Key];
                    if ((x % 2) == 0) // gerade
                    {
                        _playfield[y, x] = new Hexfield(new Point((int)((Help.Helpers.HexFieldWidth) * (3.0/4.0)) * x,
                                                                 (Help.Helpers.HexFieldHeight) * y),
                                                                  counter,
                                                                  _textures.ElementAt(rnTexElement).Value,
                                                                  _texturesMasks.ElementAt(tnMaskElement).Value,
                                                                  x,y, prioTemp);
                    }
                    else
                    {
                        _playfield[y, x] = new Hexfield(new Point((int)((Help.Helpers.HexFieldWidth) * (3.0/4.0)) * x,
                                                                 (Help.Helpers.HexFieldHeight * y + Help.Helpers.HexFieldHeight / 2)),
                                                                  counter,
                                                                  _textures.ElementAt(rnTexElement).Value,
                                                                  _texturesMasks.ElementAt(tnMaskElement).Value,
                                                                  x,y, prioTemp);
                    }
                }
            }
            setHexEdgeTextures();
            //blendNeighbors();
        }
Beispiel #2
0
 public void setNeighbor(int NeighborIndex, Hexfield Neighbor)
 {
     if (NeighborIndex > 5)
     {
         throw (new IndexOutOfRangeException("NeighborIndex kann nur 0..5 sein!"));
     }
     else
     {
         _neigbors[NeighborIndex] = Neighbor;
     }
 }