コード例 #1
0
ファイル: Level.cs プロジェクト: trigger-death/ZeldaOracle
        public Level(string name, int width, int height, int layerCount, Point2I roomSize, Zone zone)
        {
            this.world			= null;
            this.roomSize		= roomSize;
            this.roomLayerCount = layerCount;
            this.dimensions		= Point2I.Zero;
            //this.zone			= zone;

            properties = new Properties(this);
            properties.BaseProperties = new Properties();

            properties.BaseProperties.Set("id", "")
                .SetDocumentation("ID", "", "", "", "The id used to refer to this level.", false, true);

            properties.BaseProperties.Set("dungeon", "")
                .SetDocumentation("Dungeon", "dungeon", "", "", "The dungeon this level belongs to.");
            properties.BaseProperties.Set("dungeon_floor", 0)
                .SetDocumentation("Dungeon Floor", "", "", "", "The floor in the dungeon this level belongs to.");

            properties.BaseProperties.Set("discovered", false);

            properties.Set("id", name);

            properties.BaseProperties.Set("zone", "")
                .SetDocumentation("Zone", "zone", "", "", "The zone type for this room.", true, false);

            Zone = zone;

            Resize(new Point2I(width, height));
        }
コード例 #2
0
        //-----------------------------------------------------------------------------
        // World Initialization
        //-----------------------------------------------------------------------------
        public bool OnLoadWorld(World world)
        {
            scriptMethods.Clear();

            // Load the assembly.
            byte[] rawAssembly = world.ScriptManager.RawAssembly;
            if (rawAssembly == null || rawAssembly.Length == 0)
                return false;
            compiledAssembly = Assembly.Load(rawAssembly);
            if (compiledAssembly == null)
                return false;

            // Find the type (class) of the custom script method.
            Type type = compiledAssembly.GetType("ZeldaAPI.CustomScripts.CustomScript");
            if (type == null)
                return false;

            // Find the default constructor for the type.
            ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);
            if (constructor == null)
                return false;

            // Construct the script object.
            scriptObject = (ZeldaAPI.CustomScriptBase) constructor.Invoke(null);
            if (scriptObject == null)
                return false;

            // Find the script method infos.
            foreach (string scriptName in world.Scripts.Keys) {
                scriptMethods[scriptName] = type.GetMethod("RunScript_" + scriptName);
            }

            return true;
        }
コード例 #3
0
 public WorldTreeNode(World world)
 {
     this.world = world;
     ImageIndex			= 0;
     SelectedImageIndex	= 0;
     Text				= world.Id;
     Name				= "world";
 }
コード例 #4
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public LevelAddForm(World world)
        {
            InitializeComponent();

            this.world = world;

            comboBoxRoomSize.SelectedIndex = 0;

            comboBoxZone.Items.Clear();

            foreach (KeyValuePair<string, Zone> entry in Resources.GetResourceDictionary<Zone>()) {
                comboBoxZone.Items.Add(entry.Key);
            }
            comboBoxZone.SelectedIndex = 0;
        }
コード例 #5
0
ファイル: Level.cs プロジェクト: dreamsxin/ZeldaOracle
        public Level(int width, int height, Point2I roomSize)
        {
            this.world			= null;
            this.roomSize		= roomSize;
            this.roomLayerCount = GameSettings.DEFAULT_TILE_LAYER_COUNT;
            this.dimensions		= Point2I.Zero;
            this.zone			= Resources.GetResource<Zone>("");
            this.properties		= new Properties();
            this.properties.PropertyObject = this;
            this.properties.BaseProperties = new Properties();

            this.properties.BaseProperties.Set("id", "")
                .SetDocumentation("ID", "", "", "The id used to refer to this level.", true, false);

            Resize(new Point2I(width, height));
        }
コード例 #6
0
ファイル: GameControl.cs プロジェクト: dreamsxin/ZeldaOracle
 //-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public GameControl(GameManager gameManager)
 {
     this.gameManager		= gameManager;
     this.roomStateStack		= null;
     this.roomControl		= null;
     this.world				= null;
     this.player				= null;
     this.hud				= null;
     this.inventory			= null;
     this.rewardManager		= null;
     this.isAdvancedGame		= false;
     this.updateRoom			= true;
     this.animateRoom		= true;
     this.menuWeapons		= null;
     this.menuSecondaryItems	= null;
     this.menuEssences		= null;
 }
コード例 #7
0
ファイル: Level.cs プロジェクト: dreamsxin/ZeldaOracle
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public Level(string name, int width, int height, int layerCount, Point2I roomSize, Zone zone)
        {
            this.world			= null;
            this.roomSize		= roomSize;
            this.roomLayerCount = layerCount;
            this.dimensions		= Point2I.Zero;
            this.zone			= zone;
            this.properties		= new Properties();
            this.properties.PropertyObject = this;
            this.properties.BaseProperties = new Properties();

            this.properties.BaseProperties.Set("id", "")
                .SetDocumentation("ID", "", "", "The id used to refer to this level.", true, false);

            this.properties.Set("id", name);

            Resize(new Point2I(width, height));
        }
コード例 #8
0
        public void LoadWorld(World world)
        {
            this.world = world;

            scriptRunner.OnLoadWorld(world);
        }
コード例 #9
0
        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public EditorControl()
        {
            this.propertyGridControl	= null;
            this.worldFilePath	= String.Empty;
            this.worldFileName	= "untitled";
            this.world			= null;
            this.level			= null;
            this.tileset		= null;
            this.zone			= null;
            this.rewardManager	= null;
            this.inventory		= null;
            this.timer			= null;
            this.ticks			= 0;
            this.roomSpacing	= 1;
            this.playAnimations	= false;
            this.isInitialized	= false;
            this.hasMadeChanges	= false;

            this.currentLayer				= 0;
            this.currentToolIndex			= 0;
            this.aboveTileDrawMode			= TileDrawModes.Fade;
            this.belowTileDrawMode			= TileDrawModes.Fade;
            this.showRewards				= true;
            this.showGrid					= false;
            this.showEvents					= false;
            this.highlightMouseTile			= true;
            this.selectedRoom				= -Point2I.One;
            this.selectedTile				= -Point2I.One;
            this.selectedTilesetTile		= Point2I.Zero;
            this.selectedTilesetTileData	= null;
            this.playerPlaceMode			= false;
            this.sampleFromAllLayers		= false;
        }
コード例 #10
0
        // Open a world file with the given filename.
        public void OpenFile(string fileName)
        {
            CloseFile();

            hasMadeChanges = false;
            worldFilePath = fileName;
            worldFileName = Path.GetFileName(fileName);

            // Load the world.
            WorldFile worldFile = new WorldFile();
            world = worldFile.Load(fileName);
            if (world.Levels.Count > 0)
                OpenLevel(0);

            RefreshWorldTreeView();
            editorForm.LevelTreeView.ExpandAll();
        }
コード例 #11
0
 // Close the world file.
 public void CloseFile()
 {
     if (IsWorldOpen) {
         propertyGridControl.CloseProperties();
         world			= null;
         level			= null;
         hasMadeChanges	= false;
         worldFilePath	= "";
         editorForm.LevelTreeView.Nodes.Clear();
     }
 }
コード例 #12
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public DungeonAddForm(World world)
        {
            InitializeComponent();

            this.world = world;
        }
コード例 #13
0
ファイル: GameDebug.cs プロジェクト: dreamsxin/ZeldaOracle
        public static World CreateTestWorld()
        {
            // Create the world.
            World world = new World();
            world.StartLevelIndex	= 0;
            world.StartRoomLocation	= new Point2I(2, 1);
            world.StartTileLocation	= new Point2I(3, 2);

            // Load the levels from java level files.
            world.Levels.Add(LoadJavaLevel("Content/Worlds/test_level.zwd"));
            world.Levels.Add(LoadJavaLevel("Content/Worlds/interiors.zwd"));
            world.Levels.Add(LoadJavaLevel("Content/Worlds/big_interiors.zwd"));
            world.Levels[0].Properties.Set("id", "overworld");
            world.Levels[1].Properties.Set("id", "interiors");
            world.Levels[2].Properties.Set("id", "big_interiors");

            TileData tdBlock		= Resources.GetResource<TileData>("movable_block");
            TileData tdDiamond		= Resources.GetResource<TileData>("diamond_rock");
            TileData tdBush			= Resources.GetResource<TileData>("bush");
            TileData tdPot			= Resources.GetResource<TileData>("pot");
            TileData tdRock			= Resources.GetResource<TileData>("rock");
            TileData tdGrass		= Resources.GetResource<TileData>("grass");
            TileData tdOwl			= Resources.GetResource<TileData>("owl");
            TileData tdLantern		= Resources.GetResource<TileData>("lantern");
            TileData tdSign			= Resources.GetResource<TileData>("sign");
            TileData tdChest		= Resources.GetResource<TileData>("chest");
            TileData tdReward		= Resources.GetResource<TileData>("reward");
            EventTileData etdWarp	= Resources.GetResource<EventTileData>("warp");

            Level level;
            Room r;
            TileDataInstance t;
            EventTileDataInstance e;

            // Setup the overworld rooms.
            level = world.Levels[0];
            r = level.GetRoomAt(2, 1);
            t = r.CreateTile(tdOwl, 8, 1, 1);
                t.Properties.Set("text", "Hello, World!");
            t = r.CreateTile(tdChest, 7, 1, 1);
                t.Properties.Set("reward", "heart_piece");
            t = r.CreateTile(tdReward, 6, 3, 1);
                t.Properties.Set("reward", "item_flippers_1");
            t = r.CreateTile(tdSign, 1, 1, 1);
                t.Properties.Set("text", "This will<n> prime your load catchers and boost your desktop wallpaper.");
            t = r.CreateTile(tdReward, 2, 6, 1);
                t.Properties.Set("reward", "heart_piece");
            r.CreateTile(tdBlock, 2, 5, 1);
            r.CreateTile(tdGrass, 2, 2, 1);
            r.CreateTile(tdGrass, 2, 3, 1);
            r.CreateTile(tdGrass, 2, 4, 1);
            r.CreateTile(tdGrass, 3, 4, 1);
            r.CreateTile(tdGrass, 4, 5, 1);
            r.CreateTile(tdGrass, 3, 6, 1);
            r.CreateTile(tdGrass, 4, 6, 1);
            r.CreateTile(tdGrass, 5, 6, 1);
            r.CreateTile(tdGrass, 4, 7, 1);
            r.CreateTile(tdGrass, 5, 7, 1);
            r.CreateTile(tdGrass, 6, 7, 1);
            r.CreateTile(tdGrass, 7, 7, 1);
            r.CreateTile(tdGrass, 7, 2, 1);
            r.CreateTile(tdGrass, 8, 2, 1);
            r.CreateTile(tdGrass, 8, 3, 1);

            r = level.GetRoomAt(2, 2);
            e = r.CreateEventTile(etdWarp, 16, 64);
                e.Properties.Add(Property.CreateString("id", "warp_a"));
                e.Properties.Add(Property.CreateString("warp_type", "tunnel"));
                e.Properties.Add(Property.CreateString("destination_level", "overworld"));
                e.Properties.Add(Property.CreateString("destination_warp_point", "warp_b"));

            r = level.GetRoomAt(1, 1);
            e = r.CreateEventTile(etdWarp, 64, 96);
                e.Properties.Add(Property.CreateString("id", "warp_b"));
                e.Properties.Add(Property.CreateString("warp_type", "stairs"));
                e.Properties.Add(Property.CreateString("destination_level", "overworld"));
                e.Properties.Add(Property.CreateString("destination_warp_point", "warp_a"));

            r = level.GetRoomAt(new Point2I(1, 1));
            r.CreateTile(tdDiamond, 1, 1, 1);
            r.CreateTile(tdDiamond, 2, 2, 1);
            r.CreateTile(tdDiamond, 2, 4, 1);
            r.CreateTile(tdPot, 8, 2, 1);

            r = level.GetRoomAt(new Point2I(3, 0));
            r.CreateTile(tdLantern, 3, 2, 1);

            r = level.GetRoomAt(new Point2I(1, 0));
            r.CreateTile(tdRock, 8, 2, 1);

            r = level.GetRoomAt(new Point2I(2, 0));
            for (int x = 1; x < 8; x++) {
                for (int y = 2; y < 6; y++) {
                    r.CreateTile(tdBush, x, y, 1);
                }
            }

            // Set the rooms to random zones.
            /*Random random = new Random();
            for (int x = 0; x < level.Width; x++) {
                for (int y = 0; y < level.Height; y++) {
                    int index = random.Next(0, 3);
                    Zone zone = GameData.ZONE_SUMMER;
                    if (index == 1)
                        zone = GameData.ZONE_GRAVEYARD;
                    else if (index == 2)
                        zone = GameData.ZONE_FOREST;
                    level.GetRoom(new Point2I(x, y)).Zone = zone;
                }
            }*/

            // Setup the interior rooms.
            level = world.Levels[1];
            r = level.GetRoomAt(2, 1);
            r.Zone = GameData.ZONE_INTERIOR;
            r.CreateTile(tdPot, 1, 2, 1);
            r.CreateTile(tdPot, 1, 3, 1);
            r.CreateTile(tdPot, 5, 1, 1);
            r = level.GetRoomAt(3, 1);
            r.Zone = GameData.ZONE_INTERIOR;
            r.CreateTile(tdChest, 8, 1, 1);
            r.CreateTile(tdPot, 8, 2, 1);
            r.CreateTile(tdPot, 4, 6, 1);
            r.CreateTile(tdPot, 5, 6, 1);
            r.CreateTile(tdPot, 6, 6, 1);
            r.CreateTile(tdPot, 7, 6, 1);
            r.CreateTile(tdPot, 8, 6, 1);

            // Save and load the world.
            {
                WorldFile worldFile = new WorldFile();
                worldFile.Save("Content/Worlds/custom_world.zwd", world);
            }
            {
                WorldFile worldFile = new WorldFile();
                world = worldFile.Load("Content/Worlds/custom_world.zwd");
            }

            return world;
        }
コード例 #14
0
        // Open a world file with the given filename.
        public void OpenFile(string fileName)
        {
            // Load the world.
            WorldFile worldFile = new WorldFile();
            World loadedWorld = worldFile.Load(fileName);

            // Verify the world was loaded successfully.
            if (loadedWorld != null) {
                CloseFile();

                hasMadeChanges		= false;
                worldFilePath		= fileName;
                worldFileName		= Path.GetFileName(fileName);
                needsRecompiling	= true;

                world = loadedWorld;
                if (world.Levels.Count > 0)
                    OpenLevel(0);

                RefreshWorldTreeView();
                editorForm.worldTreeView.ExpandAll();
            }
            else {
                // Display the error.
                MessageBox.Show(editorForm, "Failed to open world file:\n" +
                    worldFile.ErrorMessage, "Error Opening World",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #15
0
 // Close the world file.
 public void CloseFile()
 {
     if (IsWorldOpen) {
         PropertyGrid.CloseProperties();
         world			= null;
         level			= null;
         hasMadeChanges	= false;
         worldFilePath	= "";
         RefreshWorldTreeView();
     }
 }
コード例 #16
0
ファイル: GameControl.cs プロジェクト: dreamsxin/ZeldaOracle
        //-----------------------------------------------------------------------------
        // Methods
        //-----------------------------------------------------------------------------
        // Start a new game.
        public void StartGame()
        {
            roomTicks = 0;

            roomTicks = 0;

            // Setup the player beforehand so certain classes such as the HUD can reference it
            player = new Player();

            inventory						= new Inventory(this);
            menuWeapons						= new MenuWeapons(gameManager);
            menuSecondaryItems				= new MenuSecondaryItems(gameManager);
            menuEssences					= new MenuEssences(gameManager);
            menuWeapons.PreviousMenu		= menuEssences;
            menuWeapons.NextMenu			= menuSecondaryItems;
            menuSecondaryItems.PreviousMenu	= menuWeapons;
            menuSecondaryItems.NextMenu		= menuEssences;
            menuEssences.PreviousMenu		= menuSecondaryItems;
            menuEssences.NextMenu			= menuWeapons;

            GameData.LoadInventory(inventory, true);

            inventory.ObtainAmmo("ammo_scent_seeds");
            //inventory.ObtainAmmo("ammo_pegasus_seeds");
            //inventory.ObtainAmmo("ammo_gale_seeds");
            inventory.ObtainAmmo("ammo_mystery_seeds");

            hud = new HUD(this);
            hud.DynamicHealth = player.Health;

            rewardManager = new RewardManager(this);

            GameData.LoadRewards(rewardManager);

            // Create the room control.
            roomControl = new RoomControl();
            gameManager.PushGameState(roomControl);

            // Create the test world.

            // Load the world.
            //WorldFile worldFile = new WorldFile();
            //world = worldFile.Load("Content/Worlds/temp_world.zwd");

            // Begin the room state.
            if (gameManager.LaunchParameters.Length > 0) {
                WorldFile worldFile = new WorldFile();
                world = worldFile.Load(gameManager.LaunchParameters[0]);
                if (gameManager.LaunchParameters.Length > 1 && gameManager.LaunchParameters[1] == "-test") {
                    int startLevel = Int32.Parse(gameManager.LaunchParameters[2]);
                    int startRoomX = Int32.Parse(gameManager.LaunchParameters[3]);
                    int startRoomY = Int32.Parse(gameManager.LaunchParameters[4]);
                    int startPlayerX = Int32.Parse(gameManager.LaunchParameters[5]);
                    int startPlayerY = Int32.Parse(gameManager.LaunchParameters[6]);

                    player.Position = new Point2I(startPlayerX, startPlayerY) * GameSettings.TILE_SIZE + new Point2I(8, 16);
                    roomControl.BeginRoom(world.Levels[startLevel].Rooms[startRoomX, startRoomY]);
                }
                else {
                    player.Position = world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 16);
                    roomControl.BeginRoom(world.StartRoom);
                }
            }
            else {
                world = GameDebug.CreateTestWorld();
                player.Position = world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 16);
                roomControl.BeginRoom(world.StartRoom);
            }
            roomStateStack = new RoomStateStack(new RoomStateNormal());
            roomStateStack.Begin(this);

            AudioSystem.MasterVolume = 0.06f;
        }