Exemplo n.º 1
0
 public TestBox()
 {
     _mainAtlas = PlayScreen.DecorationAtlas;
     _mainTextures = PlayScreen.DecorationTexture;
     _rect = new Rectangle(0, 0, PlayScreen.SectorTileSize, PlayScreen.SectorTileSize);
     TerrainTesting();
 }
Exemplo n.º 2
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            texture = Content.Load<Texture2D>("texture");
            textureAtlas = Content.Load<TextureAtlas>("atlasJSON");
            textureRegion = textureAtlas.GetRegion("Enemy Bug");
        }
Exemplo n.º 3
0
        public PlayScreen(GameScreenManager gameScreenManager, Texture2D interfaceTexture, TextureAtlas interfaceAtlas)
            : base(gameScreenManager)
        {
            SpawnX = 214;
            SpawnY = 250;
            _cam = new Camera2D(MainGame.GraphicD.Viewport);
            Seeds.CreateNewSeeds();
            Spritebatch = new SpriteBatch(MainGame.GraphicD);

            DecorationTexture = MainGame.ContentLoader.Load<Texture2D>("Screens/Play/Sheets/decorations");
            DecorationAtlas = MainGame.ContentLoader.Load<TextureAtlas>("Screens/Play/Sheets/decorationsJSON");

            CharacterTexture = MainGame.ContentLoader.Load<Texture2D>("Screens/Play/Sheets/characters");
            CharacterAtlas = MainGame.ContentLoader.Load<TextureAtlas>("Screens/Play/Sheets/charactersJSON");

            InterfaceTexture = interfaceTexture;
            InterfaceAtlas = interfaceAtlas;

            var worlditems = new TextureRegion[WorldItemKey.AllItems.Count];
            for (var i = 0; i < WorldItemKey.AllItems.Count; i++)
                worlditems[i] = DecorationAtlas.GetRegion(WorldItemKey.AllItems[i]);
            WorldItemKey.ItemRegions = worlditems;

            #if DEBUG
            if (ShowMap)
            {
                WorldData.MyWorldData = new WorldData();
                _cw = new CreateWorld(true, false);
                //_tb = new TestBox();
            }
            else
            {
                var az = Enumerable.Range(0, 64*64).Select(i => Color.Red).ToArray();
                ErrorBox = new Texture2D(MainGame.GraphicD, 64, 64, false, SurfaceFormat.Color);
                ErrorBox.SetData(az);
            #endif
                // Create a new SpriteBatch, which can be used to draw textures.

                // showMap = new CreateWorld(GraphicsDevice);
                if (WorldData.MyWorldData == null)
                {
                    //look for file
                    //Utility.RemoveSave();
                    WorldData.MyWorldData = Utility.LoadGameData();
                    if (WorldData.MyWorldData == null)
                    {
                        WorldData.MyWorldData = new WorldData();
                        _cw = new CreateWorld(false, true);
                    }
                }
                _managers = new Manager();
                _myInputs = new Inputs();
            #if DEBUG
            }
            #endif

            GC.Collect();
        }
Exemplo n.º 4
0
        public Sprite(Beatup game, string atlas_name, string sheet_name, string sprite_name)
        {
            atlas = game.Content.Load<TextureAtlas>(atlas_name);
            region = atlas.GetRegion(sprite_name);

            sheet = game.Content.Load<Texture2D>(sheet_name);

            this.position.X = 0;
            this.position.Y = 0;

            flippedX = false;
            rotation = 0;

            scale_x = 4.0f;
            scale_y = 4.0f;
        }
Exemplo n.º 5
0
        public WelcomeScreen(GameScreenManager gameScreenManager, Texture2D interfaceTexture,
                             TextureAtlas interfaceAtlas)
            : base(gameScreenManager)
        {
            _interfaceTexture = interfaceTexture;
            _interfaceAtlas = interfaceAtlas;
            _buttonExitPosition.Width =
                _buttonLoadGamePosition.Width =
                _buttonNewGamePosition.Width =
                _buttonSettingsPosition.Width = _interfaceAtlas.GetRegion("NewGame").Bounds.Width;

            _buttonExitPosition.Height =
                _buttonLoadGamePosition.Height =
                _buttonNewGamePosition.Height =
                _buttonSettingsPosition.Height = _interfaceAtlas.GetRegion("NewGame").Bounds.Height;
            _inputs = new MainInput();
            _spriteBatch = new SpriteBatch(MainGame.GraphicD);
        }
Exemplo n.º 6
0
        public CharacterAnim(TextureAtlas atlas, string prefix, string action, int defaultFrame,
                             Vector2[] myFramesOffsets, byte speed = SpeedNormal)
        {
            _myAtlas = atlas;
            //_spriteBatch = PlayScreen.Spritebatch;
            // var mainAtlas = PlayScreen.DecorationAtlas;
            AnimationPrefix = prefix;
            AnimationAction = action;
            AnimationLength = myFramesOffsets.Length;
            AnimationSpeed = speed;
            _defaultFrame = defaultFrame;
            _currentFrame = _defaultFrame;
            _myFramesOffsets = myFramesOffsets;

            _myFrames = new TextureRegion[AnimationLength];

            for (var i = 0; i < AnimationLength; i++)
                _myFrames[i] = atlas.GetRegion(string.Format("{0}-{1}{2}", prefix, action, i));
        }
Exemplo n.º 7
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();
        }