private DrawingInstruction[] layerTails; // The tails of the drawing instruction queues for each layer.

        #endregion Fields

        #region Constructors

        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public RoomGraphics(RoomControl roomControl)
        {
            this.roomControl	= roomControl;
            this.layerHeads		= new DrawingInstruction[(int) DepthLayer.Count];
            this.layerTails		= new DrawingInstruction[(int) DepthLayer.Count];
            this.layerCounts	= new int[(int) DepthLayer.Count];
        }
Beispiel #2
0
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public EventTile()
 {
     roomControl		= null;
     eventData		= null;
     position		= Vector2F.Zero;
     size			= Point2I.One;
     properties		= new Properties();
     collisionBox	= new Rectangle2I(0, 0, 16, 16);
 }
Beispiel #3
0
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public Entity()
 {
     roomControl		= null;
     isAlive			= false;
     isInRoom		= false;
     isInitialized	= false;
     position		= Vector2F.Zero;
     zPosition		= 0.0f;
     physics			= new PhysicsComponent(this);
     graphics		= new GraphicsComponent(this);
     originOffset	= Point2I.Zero;
     centerOffset	= Point2I.Zero;
     actionAlignDistance = 5;
 }
Beispiel #4
0
 //-----------------------------------------------------------------------------
 // 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;
 }
Beispiel #5
0
        private Entity transformedEntity; // The entity this entity has transformed into (bomb -> explosion)

        #endregion Fields

        #region Constructors

        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public Entity()
        {
            entityIndex			= -1;
            roomControl			= null;
            isAlive				= false;
            isInRoom			= false;
            isInitialized		= false;
            transformedEntity	= null;
            soundBounce			= null;
            position			= Vector2F.Zero;
            zPosition			= 0.0f;
            previousPosition	= Vector2F.Zero;
            previousZPosition	= 0.0f;
            physics				= new PhysicsComponent(this);
            graphics			= new GraphicsComponent(this);
            centerOffset		= Point2I.Zero;
            actionAlignDistance	= 5;
        }
Beispiel #6
0
        //-----------------------------------------------------------------------------
        // 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.dropManager        = null;
            this.isAdvancedGame     = false;
            this.updateRoom         = true;
            this.animateRoom        = true;
            this.menuWeapons        = null;
            this.menuSecondaryItems = null;
            this.menuEssences       = null;
            this.scriptRunner       = null;
        }
Beispiel #7
0
 //-----------------------------------------------------------------------------
 // Initialization
 //-----------------------------------------------------------------------------
 public void Initialize(RoomControl control)
 {
     this.roomControl = control;
     Initialize();
 }
Beispiel #8
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------

        public UnitSystem(RoomControl roomControl)
        {
            this.roomControl = roomControl;
        }
 //-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public UnitSystem(RoomControl roomControl)
 {
     this.roomControl = roomControl;
 }
 //-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public TileManager(RoomControl roomControl)
 {
     this.roomControl		= roomControl;
     this.tileGridCellSize	= new Point2I(GameSettings.TILE_SIZE, GameSettings.TILE_SIZE);
 }
Beispiel #11
0
        //-----------------------------------------------------------------------------
        // Management
        //-----------------------------------------------------------------------------
        // Initializes the entity and sets up containment variables.
        public void Initialize(RoomControl control)
        {
            this.roomControl	= control;
            this.isAlive		= true;
            this.isInRoom		= true;

            if (!isInitialized) {
                isInitialized = true;
                Initialize();
                previousPosition  = position;
                previousZPosition = zPosition;
            }
        }
Beispiel #12
0
        public void TransitionToRoom(Room nextRoom, RoomTransition transition)
        {
            // Create the new room control.
            RoomControl newControl = new RoomControl();
            newControl.gameManager	= gameManager;
            newControl.level		= level;
            newControl.room			= nextRoom;
            newControl.roomLocation	= nextRoom.Location;

            // Play the transition.
            transition.OldRoomControl = this;
            transition.NewRoomControl = newControl;
            gameManager.PopGameState();
            gameManager.PushGameState(transition);
            GameControl.RoomControl = newControl;
        }
 //-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public RoomPhysics(RoomControl roomControl)
 {
     this.roomControl = roomControl;
 }
Beispiel #14
0
        //-----------------------------------------------------------------------------
        // Management
        //-----------------------------------------------------------------------------
        // Initializes the entity and sets up containment variables.
        public void Initialize(RoomControl control)
        {
            this.roomControl	= control;
            this.isAlive		= true;
            this.isInRoom		= true;

            if (!isInitialized) {
                isInitialized = true;
                Initialize();
            }
        }
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public RoomTransition()
 {
     roomOld = null;
     roomNew = null;
     eventSetupNewRoom = null;
 }
Beispiel #16
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------

        public TileManager(RoomControl roomControl)
        {
            this.roomControl      = roomControl;
            this.tileGridCellSize = new Point2I(GameSettings.TILE_SIZE, GameSettings.TILE_SIZE);
        }
Beispiel #17
0
 public static void DrawRoomTiles(Graphics2D g, RoomControl roomControl)
 {
     // Draw debug info for tiles.
     foreach (Tile tile in roomControl.GetTiles())
         DrawTile(g, tile);
 }
Beispiel #18
0
 public static void DrawRoom(Graphics2D g, RoomControl roomControl)
 {
     // Draw debug info for entities.
     for (int i = roomControl.Entities.Count - 1; i >= 0; i--)
         DrawEntity(g, roomControl.Entities[i]);
 }
Beispiel #19
0
        //-----------------------------------------------------------------------------
        // 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;
        }
        // Start a new game.
        public void StartGame()
        {
            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;

            mapDungeon = new ScreenDungeonMap(gameManager);

            GameData.LoadInventory(inventory, true);

            inventory.ObtainAmmo("ammo_ember_seeds");
            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);
            dropManager = new DropManager(this);
            GameData.LoadDrops(dropManager, rewardManager);

            // Create the script runner.
            scriptRunner = new ScriptRunner(this);

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

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

            // Begin the room state.
            if (gameManager.LaunchParameters.Length > 0) {
                LoadWorld(gameManager.LaunchParameters[0]);

                if (gameManager.LaunchParameters.Length > 1 && gameManager.LaunchParameters[1] == "-test") {
                    // Launch parameters can define player's start position.
                    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.SetPositionByCenter(new Point2I(startPlayerX, startPlayerY) * GameSettings.TILE_SIZE + new Point2I(8, 8));
                    player.MarkRespawn();
                    roomControl.BeginRoom(world.Levels[startLevel].Rooms[startRoomX, startRoomY]);
                }
                else {
                    player.SetPositionByCenter(world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 8));
                    player.MarkRespawn();
                    roomControl.BeginRoom(world.StartRoom);
                }
            }
            else {
                //WorldFile worldFile = new WorldFile();
                //world = worldFile.Load("temp_world.zwd");
                LoadWorld(GameDebug.CreateTestWorld());
                player.SetPositionByCenter(world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 8));
                player.MarkRespawn();
                roomControl.BeginRoom(world.StartRoom);
            }
            roomStateStack = new RoomStateStack(new RoomStateNormal());
            roomStateStack.Begin(this);

            if (!roomControl.Room.IsHiddenFromMap)
                lastRoomOnMap = roomControl.Room;

            AudioSystem.MasterVolume = 0.04f; // The way David likes it.
        }
Beispiel #21
0
        // Start a new game.
        public void StartGame()
        {
            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;

            mapDungeon = new ScreenDungeonMap(gameManager);

            GameData.LoadInventory(inventory, true);

            inventory.ObtainAmmo("ammo_ember_seeds");
            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);
            dropManager = new DropManager(this);
            GameData.LoadDrops(dropManager, rewardManager);

            // Create the script runner.
            scriptRunner = new ScriptRunner(this);

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

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

            // Begin the room state.
            if (gameManager.LaunchParameters.Length > 0)
            {
                LoadWorld(gameManager.LaunchParameters[0]);

                if (gameManager.LaunchParameters.Length > 1 && gameManager.LaunchParameters[1] == "-test")
                {
                    // Launch parameters can define player's start position.
                    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.SetPositionByCenter(new Point2I(startPlayerX, startPlayerY) * GameSettings.TILE_SIZE + new Point2I(8, 8));
                    player.MarkRespawn();
                    roomControl.BeginRoom(world.Levels[startLevel].Rooms[startRoomX, startRoomY]);
                }
                else
                {
                    player.SetPositionByCenter(world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 8));
                    player.MarkRespawn();
                    roomControl.BeginRoom(world.StartRoom);
                }
            }
            else
            {
                //WorldFile worldFile = new WorldFile();
                //world = worldFile.Load("temp_world.zwd");
                LoadWorld(GameDebug.CreateTestWorld());
                player.SetPositionByCenter(world.StartTileLocation * GameSettings.TILE_SIZE + new Point2I(8, 8));
                player.MarkRespawn();
                roomControl.BeginRoom(world.StartRoom);
            }
            roomStateStack = new RoomStateStack(new RoomStateNormal());
            roomStateStack.Begin(this);

            if (!roomControl.Room.IsHiddenFromMap)
            {
                lastRoomOnMap = roomControl.Room;
            }

            AudioSystem.MasterVolume = 0.04f;             // The way David likes it.
        }
Beispiel #22
0
        public void TransitionToRoom(Room nextRoom, RoomTransition transition, GameState exitState, GameState enterState, EventTileDataInstance warpTile)
        {
            // Create the new room control.
            RoomControl newControl = new RoomControl();

            newControl.gameManager  = gameManager;
            newControl.room         = nextRoom;
            newControl.roomLocation = nextRoom.Location;

            //               [Exit]                       [Enter]
            // [RoomOld] -> [RoomOld] -> [Transition] -> [RoomNew] -> [RoomNew]

            // Create the sequence of game states for the transition.
            GameState postTransitionState = new GameStateAction(delegate(GameStateAction actionState) {
                gameManager.PopGameState();                 // Pop the queue state.
                gameManager.PushGameState(newControl);      // Push the new room control state.

                // Find the warp event were warping to and grab its enter-state.
                if (warpTile != null)
                {
                    WarpEvent eventTile = newControl.FindEventTile(warpTile) as WarpEvent;
                    if (eventTile != null)
                    {
                        enterState = eventTile.CreateEnterState();
                    }
                }
                if (enterState != null)
                {
                    gameManager.PushGameState(enterState);                     // Push the enter state.
                }
            });
            GameState preTransitionState = new GameStateAction(delegate(GameStateAction actionState) {
                GameControl.RoomControl = newControl;
                gameManager.PopGameState();                 // Pop the queue state.
                gameManager.PopGameState();                 // Pop the room control state.
                gameManager.PushGameState(new GameStateQueue(transition, postTransitionState));
                newControl.FindEventTile(warpTile);
            });

            if (warpTile != null)
            {
                transition.NewRoomSetup += delegate(RoomControl roomControl) {
                    // Find the warp event were warping to.
                    WarpEvent eventTile = newControl.FindEventTile(warpTile) as WarpEvent;
                    if (eventTile != null)
                    {
                        eventTile.SetupPlayerInRoom();
                    }
                };
            }

            // Create the game state for the transition sequence.
            GameState state = preTransitionState;

            if (exitState != null)
            {
                state = new GameStateQueue(exitState, preTransitionState);
            }

            // Begin the transition.
            transition.OldRoomControl = this;
            transition.NewRoomControl = newControl;
            gameManager.PushGameState(state);
        }
Beispiel #23
0
        public static void UpdateRoomDebugKeys(RoomControl roomControl)
        {
            GameControl gameControl = roomControl.GameControl;

            if (Keyboard.IsKeyPressed(Keys.G)) {
                gameControl.DisplayMessage("I was a <red>hero<red> to broken robots 'cause I was one of them, but how can I sing about being damaged if I'm not?<p> That's like <green>Christina Aguilera<green> singing Spanish. Ooh, wait! That's it! I'll fake it!");
            }
            if (Keyboard.IsKeyPressed(Keys.Insert)) {
                gameControl.Inventory.FillAllAmmo();
            }
            if (Keyboard.IsKeyPressed(Keys.Delete)) {
                gameControl.Inventory.EmptyAllAmmo();
            }
            if (Keyboard.IsKeyPressed(Keys.Home)) {
                gameControl.Player.MaxHealth = 4 * 14;
                gameControl.Player.Health = gameControl.Player.MaxHealth;
            }
            if (Keyboard.IsKeyPressed(Keys.End)) {
                gameControl.Player.Health = 4 * 3;
            }

            if (Keyboard.IsKeyPressed(Keys.T)) {
                switch (gameControl.Player.Tunic) {
                case PlayerTunics.GreenTunic:	gameControl.Player.Tunic = PlayerTunics.RedTunic; break;
                case PlayerTunics.RedTunic:		gameControl.Player.Tunic = PlayerTunics.BlueTunic; break;
                case PlayerTunics.BlueTunic:	gameControl.Player.Tunic = PlayerTunics.GreenTunic; break;
                }
            }
            if (Keyboard.IsKeyPressed(Keys.H)) {
                gameControl.Player.Hurt(0);
            }
            if (Keyboard.IsKeyPressed(Keys.M)) {
                AudioSystem.PlaySong("overworld");
            }
            if (Keyboard.IsKeyPressed(Keys.N)) {
                AudioSystem.MasterVolume = 1.0f;
            }
            if (Keyboard.IsKeyPressed(Keys.Q)) {
                int[] rupees = { 1, 5, 20, 100, 200 };//, 5, 20, 100, 200 };
                int rupee = GRandom.NextInt(rupees.Length);
                Collectible collectible = gameControl.RewardManager.SpawnCollectible("rupees_" + rupees[rupee].ToString());
                collectible.Position = gameControl.Player.Position;
                collectible.ZPosition = 100;
            }
            if (Keyboard.IsKeyPressed(Keys.Y)) {
                GraphicsComponent.DrawCollisionBoxes = !GraphicsComponent.DrawCollisionBoxes;
            }
            if (Keyboard.IsKeyPressed(Keys.K)) {
                Collectible collectible = gameControl.RewardManager.SpawnCollectible("hearts_1");
                collectible.Position = gameControl.Player.Position;
                collectible.ZPosition = 100;
            }
            if (Keyboard.IsKeyPressed(Keys.B)) {
                Collectible collectible = gameControl.RewardManager.SpawnCollectible("ammo_bombs_5");
                collectible.Position = gameControl.Player.Position;
                collectible.ZPosition = 100;
            }
            if (Keyboard.IsKeyPressed(Keys.J)) {
                Collectible collectible = gameControl.RewardManager.SpawnCollectible("ammo_arrows_5");
                collectible.Position = gameControl.Player.Position;
                collectible.ZPosition = 100;
            }
        }
Beispiel #24
0
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public RoomTransition()
 {
     roomOld = null;
     roomNew = null;
 }
Beispiel #25
0
        //-----------------------------------------------------------------------------
        // Initialization
        //-----------------------------------------------------------------------------
        public void Initialize(RoomControl control)
        {
            this.roomControl	= control;
            this.isAlive		= true;

            if (!isInitialized) {
                isInitialized	= true;
                hasMoved		= false;
                velocity		= Vector2F.Zero;

                graphics.ImageVariant = roomControl.Room.Zone.ImageVariantID;

                // Begin a path if there is one.
                string pathString = properties.GetString("path", "");
                TilePath p = TilePath.Parse(pathString);
                BeginPath(p);

                // Set the solid state.
                isSolid = (SolidType != TileSolidType.NotSolid);

                // Setup default drop list.
                if (IsDigable && !IsSolid)
                    dropList = RoomControl.GameControl.DropManager.GetDropList("dig");
                else
                    dropList = RoomControl.GameControl.DropManager.GetDropList("default");

                // Call the virtual initialization method.
                OnInitialize();
            }
        }