예제 #1
0
        public TileManager(Manager manager)
        {
            _manager = manager;
            _spriteBatch = PlayScreen.Spritebatch;
            var mainAtlas = PlayScreen.DecorationAtlas;

            _tileRegions = new TextureRegion[1 + (TileHelper.TypesOfTerrain.Count*24)];

            //for (var i = 0; i < _getIntensity.Length; i++)
            //{
            //    var minusLength = _getIntensity.Length - (float) i;
            //    minusLength /= _getIntensity.Length;
            //    var val = 128 + (int) (minusLength*128);
            //    _getIntensity[i] = new Color(val, val, val);
            //}

            var terrainCounter = 0;
            foreach (KeyValuePair<string, byte> t in TileHelper.TypesOfTerrain)
            {
                for (var i = 0; i < 24; i++)
                {
                    if (t.Value == 0)
                        _tileRegions[terrainCounter++] = mainAtlas.GetRegion(t.Key);
                    else
                    {
                        var newName = String.Format("{0}{1}", t.Key, i);
                        _tileRegions[terrainCounter++] = mainAtlas.GetRegion(newName);
                    }
                }
            }
        }
예제 #2
0
파일: PlayScreen.cs 프로젝트: Choochoo/Ship
        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();
        }