예제 #1
0
 private ObjectData(Rectangle bounds, ObjectType type, DungeonData target, string text)
 {
     Bounds = bounds;
     Type   = type;
     Target = target;
     Text   = text;
 }
예제 #2
0
        public GameScene(GameManager game, DungeonData dungeonData)
        {
            this.game = game;
            Data      = dungeonData;

            var dungeonMap = new DungeonMap(dungeonData);

            Add(dungeonMap);

            var uiCamera = Engine.CreateCamera();

            SetCamera(Global.LayerUi, uiCamera);

            //Add(new TimeWidget(this, Engine.HalfWidth, 0));
            Add(new ComboWidget(game.Player, Engine.HalfWidth, 1));

            Add(new CoinWidget(game.Player, Engine.Width - 2, 1));
            Add(new HpWidget(game.Player, 2, 2));

            //Add(new RoomWidget(this, Engine.Width - 2, 1));
            Add(new InventoryWidget(game.Player, 202, 2));

            Add(new Shaker());

            //Engine.Track(this, "state");
        }
예제 #3
0
        protected override void OnLoadContent()
        {
            Input.Define("left", Keys.A, Keys.Left);
            Input.Define("left", Buttons.DPadLeft);

            Input.Define("right", Keys.D, Keys.Right);
            Input.Define("right", Buttons.DPadRight);

            Input.Define("up", Keys.W, Keys.Up);
            Input.Define("up", Buttons.DPadUp);

            Input.Define("down", Keys.S, Keys.Down);
            Input.Define("down", Buttons.DPadDown);

            Input.Define("a", Keys.Z, Keys.N);
            Input.Define("a", Buttons.A);

            Input.Define("b", Keys.X, Keys.M);
            Input.Define("b", Buttons.B);

            Input.Define("start", Keys.Enter, Keys.Space);
            Input.Define("start", Buttons.Start);

            Input.Define("back", Keys.Escape);
            Input.Define("back", Buttons.Back);

//#if DEBUG
            Input.Define("reset", Keys.R);
            Input.Define("debug_1", Keys.D1);
            Input.Define("debug_2", Keys.D2);
            Input.Define("debug_3", Keys.D3);
            Input.Define("debug_4", Keys.D4);
            Input.Define("debug_5", Keys.D5);
            Input.Define("debug_6", Keys.D6);
            Input.Define("debug_7", Keys.D7);
            Input.Define("debug_8", Keys.D8);
            Input.Define("debug_9", Keys.D9);
            Input.Define("debug_10", Keys.D0);
//#endif

            Asset.AddPixelMask("circle_small", "mask/circle_small");
            Asset.AddPixelMask("circle_big", "mask/circle_big");

            EntityData.Init();
            DungeonData.Init();

            CrtEffect = Asset.LoadEffect("effects/CRT-easymode");
            CrtEffect.Parameters["InputSize"].SetValue(new Vector2(Width, Height));
            if (Global.CrtEnabled)
            {
                PostProcessor = CrtEffect;
            }
        }
예제 #4
0
        public static void Init()
        {
            Log.Debug("Loading maps...");
            var maps = Asset.LoadAll <TiledMap>("map");

            foreach (var map in maps.Values)
            {
                if (map.Properties.GetString("type") == "dungeon")
                {
                    var name = Path.GetFileName(map.Name);
                    if (dungeons.ContainsKey(name))
                    {
                        throw new Exception("Dungeon '" + name + "' already exists.");
                    }
                    dungeons[name] = new DungeonData(map, name);
                }
            }

            Log.Debug("Initializing objects...");
            foreach (var room in dungeons.Values)
            {
                room.InitObjects();
            }
        }
예제 #5
0
 public void GotoDungeon(DungeonData dungeon)
 {
     // TODO transition
     game.LoadScene(dungeon.Name);
     Asset.LoadSoundEffect("sfx/room_switch").Play();
 }
예제 #6
0
 public void AddScene(string name)
 {
     scenes[name] = new GameScene(this, DungeonData.Get(name));
 }
예제 #7
0
 public static ObjectData CreateLink(Rectangle bounds, DungeonData target)
 {
     return(new ObjectData(bounds, ObjectType.Link, target, null));
 }
예제 #8
0
        public DungeonMap(DungeonData data)
        {
            Data = data;

            Type   = Global.TypeMap;
            Width  = data.WidthTiles * Global.TileSize;
            Height = data.HeightTiles * Global.TileSize;

            var solidGrid = new GridCollider(data.WidthTiles, data.HeightTiles, Global.TileSize, Global.TileSize, "tileset");

            Collider = solidGrid;

            var groundMap = new Tilemap(data.Tileset, data.WidthTiles, data.HeightTiles);

            groundMap.Layer = Global.LayerMapGround;
            Add(groundMap);

            var backMap = new Tilemap(data.Tileset, data.WidthTiles, data.HeightTiles);

            backMap.Layer = Global.LayerMapWall;
            Add(backMap);

            var frontMap = new Tilemap(data.Tileset, data.WidthTiles, data.HeightTiles);

            frontMap.Layer = Global.LayerMapRoof;
            Add(frontMap);

            Data.IterateTiles((tile) =>
            {
                if (tile.Trigger == null)
                {
                    if (tile.SolidType == TileSolidType.PixelMask)
                    {
                        solidGrid.SetPixelMaskAt(tile.X, tile.Y, tile.DisplayTid, tile.Properties);
                    }
                    else
                    {
                        solidGrid.SetTileAt(tile.X, tile.Y, tile.SolidType, tile.Properties);
                    }
                }

                switch (tile.Type)
                {
                case DungeonTileType.Ground:
                    RenderFlatTile(groundMap, tile, TileGround);
                    break;

                case DungeonTileType.Wall:
                    RenderWallTile(solidGrid, backMap, tile, TileWall);
                    break;

                case DungeonTileType.Roof:
                    RenderFlatTile(frontMap, tile, TileRoof);
                    break;
                }

                if (tile.Trigger != null)
                {
                    backMap.SetTileAt(tile.X, tile.Y, tile.DisplayTid);
                }
            });

            tireLayer       = new DrawLayer(data.WidthTiles * Global.TileSize, data.HeightTiles * Global.TileSize);
            tireLayer.Layer = Global.LayerTireEffect;
            Add(tireLayer);
        }