示例#1
0
        private void ShiftRight()
        {
            var oldVectorSpotX = _topLeft.CurrVectorX;
            var newMapLocX = _bottomRight.MapLocX + 1;
            _topLeft = _land[oldVectorSpotX, _topLeft.CurrVectorY];
            _bottomRight = _land[_bottomRight.RightVectorX, _bottomRight.CurrVectorY];
            for (var i = 0; i < Amount; i++)
            {
                // var fogTemp = _fog[i][_amount - 1];
                var landTemp = _land[oldVectorSpotX, i];
                landTemp.MapLocX = newMapLocX;
                var prop = _landTextureLocations[landTemp.MapLocX][landTemp.MapLocY];
                SetBounds(prop.TextureName, ref landTemp, prop.Vals, false);

                var landFTemp = _landFeature[oldVectorSpotX, i];
                landFTemp.MapLocX = newMapLocX;

                var prop2 = _landFeatureTextureLocations[landFTemp.MapLocX][landFTemp.MapLocY];
                if (prop2.HasFeature)
                {
                    SetBounds(prop2.TextureName, ref landFTemp, prop2.Vals, prop2.IsMountain);
                    landFTemp.Visible = true;
                }
                else
                    landFTemp.Visible = false;
            }
        }
示例#2
0
        public MiniTileManager()
        {
            _wd = WorldData.MyWorldData;
            _mainAtlas = PlayScreen.DecorationAtlas;
            _mainTextures = PlayScreen.DecorationTexture;
            _spriteBatch = PlayScreen.Spritebatch;
            //_mapMakerThread = new Thread(CheckMiniMap);

            _halfAmount = (int) (Math.Floor(Amount/2.0));
            _xOffset = PlayScreen.SpawnX - _halfAmount;
            _yOffset = PlayScreen.SpawnY - _halfAmount;
            _land = new MiniTileCollection[Amount,Amount];
            _landFeature = new MiniTileCollection[Amount,Amount];
            _fog = new MiniFogCollection[Amount,Amount];
            _landTextureLocations = new TextureProperties[MainGame.MapWidth][];
            _landFeatureTextureLocations = new TextureProperties[MainGame.MapWidth][];
            _graphicsDevice = MainGame.GraphicD;

            _miniMapFogTexture = new RenderTarget2D(MainGame.GraphicD, 256, 256, false, SurfaceFormat.Color,
                                                    DepthFormat.Depth24Stencil8,
                                                    0, RenderTargetUsage.DiscardContents);

            _miniMapTerrainTexture = new RenderTarget2D(MainGame.GraphicD, 256, 256, false, SurfaceFormat.Color,
                                                        DepthFormat.Depth24Stencil8,
                                                        0, RenderTargetUsage.DiscardContents);
            _miniMapTerrainTexture2 = new RenderTarget2D(MainGame.GraphicD, 256, 256, false, SurfaceFormat.Color,
                                                         DepthFormat.Depth24Stencil8,
                                                         0, RenderTargetUsage.DiscardContents);

            _miniMapFinalDrawTexture = new RenderTarget2D(MainGame.GraphicD, 256, 256, false, SurfaceFormat.Color,
                                                          DepthFormat.Depth24Stencil8,
                                                          0, RenderTargetUsage.DiscardContents);
            //testing

            _textureMask = CreateCircle(76);

            var m = Matrix.CreateOrthographicOffCenter(0, _miniMapFogTexture.Width, _miniMapFogTexture.Height, 0, 0,1);

            _a = new AlphaTestEffect(_graphicsDevice)
                {
                    Projection = m
                };

            _s1 = new DepthStencilState
                {
                    StencilEnable = true,
                    StencilFunction = CompareFunction.Always,
                    StencilPass = StencilOperation.Replace,
                    ReferenceStencil = 1,
                    DepthBufferEnable = false,
                };

            _s2 = new DepthStencilState
                {
                    StencilEnable = true,
                    StencilFunction = CompareFunction.LessEqual,
                    StencilPass = StencilOperation.Keep,
                    ReferenceStencil = 1,
                    DepthBufferEnable = false,
                };

            for (var x = 0; x < MainGame.MapWidth; x++)
            {
                _landTextureLocations[x] = new TextureProperties[MainGame.MapHeight];
                _landFeatureTextureLocations[x] = new TextureProperties[MainGame.MapHeight];
                for (var y = 0; y < MainGame.MapHeight; y++)
                {
                    var landtext = new TextureProperties();
                    var landfeaturetext = new TextureProperties();
                    FillHeight(ref landtext, x, y);

                    if (!CanFillTrees(ref landfeaturetext, x, y))
                    {
                        if (!CanFillGrass(ref landfeaturetext, x, y))
                        {
                            if (!CanFillMountains(ref landfeaturetext, x, y))
                                landfeaturetext.HasFeature = false;
                        }
                    }

                    _landTextureLocations[x][y] = landtext;
                    _landFeatureTextureLocations[x][y] = landfeaturetext;
                }
            }

            for (var i = 0; i < Amount; i++)
            {
                var left = i - 1 < 0 ? Amount - 1 : i - 1;
                var right = i + 1 >= Amount ? 0 : i + 1;
                for (var j = 0; j < Amount; j++)
                {
                    _fog[i, j] = new MiniFogCollection();

                    var top = j - 1 < 0 ? Amount - 1 : j - 1;
                    var bottom = j + 1 >= Amount ? 0 : j + 1;
                    _land[i, j] = new MiniTileCollection(i + _xOffset, j + _yOffset, i, j, top, bottom, left, right);
                    _landFeature[i, j] = new MiniTileCollection(i + _xOffset, j + _yOffset, i, j, top, bottom, left,
                                                                right);

                    if (i == 0 && j == 0)
                        _topLeft = _land[i, j];
                    else if (i == Amount - 1 && j == Amount - 1)
                        _bottomRight = _land[i, j];

                    var prop = _landTextureLocations[_land[i, j].MapLocX][_land[i, j].MapLocY];
                    SetBounds(prop.TextureName, ref _land[i, j], prop.Vals, false);
                    _land[i, j].Visible = true;

                    var prop2 = _landFeatureTextureLocations[_landFeature[i, j].MapLocX][_landFeature[i, j].MapLocY];
                    if (prop2.HasFeature)
                    {
                        SetBounds(prop2.TextureName, ref _landFeature[i, j], prop2.Vals, prop2.IsMountain);
                        _landFeature[i, j].Visible = true;
                    }
                    else
                        _landFeature[i, j].Visible = false;

                    _fog[i, j].SetSpots(i, j);
                    FillFog(i, j);
                }
            }
            InitialDraw();
        }
示例#3
0
 private void SetBounds(string textureName, ref MiniTileCollection updateMe, int[] vals, bool isElevated)
 {
     if (textureName.Length == 0)
         System.Diagnostics.Debug.WriteLine("Bad news, check mini tile manager");
     else
     {
         if (isElevated)
         {
             var bounds = _mainAtlas.GetRegion(textureName).Bounds;
             updateMe.UpdateTexture(bounds, bounds, bounds, bounds, true);
         }
         else
         {
             var bounds1String = string.Format("{0}{1}", textureName, vals[0]);
             var bounds2String = string.Format("{0}{1}", textureName, vals[1]);
             var bounds3String = string.Format("{0}{1}", textureName, vals[2]);
             var bounds4String = string.Format("{0}{1}", textureName, vals[3]);
             var bounds1 = _mainAtlas.GetRegion(bounds1String).Bounds;
             var bounds2 = _mainAtlas.GetRegion(bounds2String).Bounds;
             var bounds3 = _mainAtlas.GetRegion(bounds3String).Bounds;
             var bounds4 = _mainAtlas.GetRegion(bounds4String).Bounds;
             updateMe.UpdateTexture(bounds1, bounds2, bounds3, bounds4, false);
         }
     }
 }
示例#4
0
        private void ShiftUp()
        {
            var oldVectorSpotY = _bottomRight.CurrVectorY;
            var newMapLocY = _topLeft.MapLocY - 1;
            _topLeft = _land[_topLeft.CurrVectorX, oldVectorSpotY];
            _bottomRight = _land[_bottomRight.CurrVectorX, _bottomRight.TopVectorY];
            for (var i = 0; i < Amount; i++)
            {
                var landTemp = _land[i, oldVectorSpotY];
                landTemp.MapLocY = newMapLocY;
                var prop = _landTextureLocations[landTemp.MapLocX][landTemp.MapLocY];
                SetBounds(prop.TextureName, ref landTemp, prop.Vals, false);

                var landFTemp = _landFeature[i, oldVectorSpotY];
                landFTemp.MapLocY = newMapLocY;

                var prop2 = _landFeatureTextureLocations[landFTemp.MapLocX][landFTemp.MapLocY];
                if (prop2.HasFeature)
                {
                    SetBounds(prop2.TextureName, ref landFTemp, prop2.Vals, prop2.IsMountain);
                    landFTemp.Visible = true;
                }
                else
                    landFTemp.Visible = false;
            }
        }