Example #1
0
        //-----------------------------------------------------------------------------
        // Implementations
        //-----------------------------------------------------------------------------
        public Entity CreateDropEntity(GameControl gameControl)
        {
            if (drops.Count == 0)
                return null;
            int roll;

            // Roll to see if we drop anything at all.
            if (oddsNumerator < oddsDenominator) {
                roll = GRandom.NextInt(oddsDenominator);
                if (roll >= oddsNumerator)
                    return null;
            }

            // Sum up the odds of all the available drops in the list.
            int dropsOddsSum = 0;
            for (int i = 0; i < drops.Count; i++) {
                if (drops[i].Drop.IsAvailable(gameControl))
                    dropsOddsSum += drops[i].Odds;
            }

            // Roll to see which drop to create.
            roll = GRandom.NextInt(dropsOddsSum);

            // Determine which drop should be created.
            int x = 0;
            for (int i = 0; i < drops.Count; i++) {
                if (drops[i].Drop.IsAvailable(gameControl)) {
                    x += drops[i].Odds;
                    if (roll < x)
                        return drops[i].Drop.CreateDropEntity(gameControl);
                }
            }

            return null;
        }
Example #2
0
        //-----------------------------------------------------------------------------
        // Virtual methods
        //-----------------------------------------------------------------------------
        public override void OnCollect(GameControl gameControl)
        {
            //AudioSystem.PlaySound("Pickups/get_ammo");

            gameControl.Inventory.ObtainItem(gameControl.Inventory.GetItem(itemID));
            gameControl.Inventory.GetItem(itemID).Level = level;
        }
        //-----------------------------------------------------------------------------
        // Virtual methods
        //-----------------------------------------------------------------------------
        public override void OnCollect(GameControl gameControl)
        {
            if (gameControl.HUD.DynamicHealth >= gameControl.Player.MaxHealth)
                AudioSystem.PlaySound(GameData.SOUND_GET_HEART);

            gameControl.Player.Health += amount * 4;
        }
Example #4
0
        //-----------------------------------------------------------------------------
        // Virtual methods
        //-----------------------------------------------------------------------------
        public override void OnCollect(GameControl gameControl)
        {
            if (gameControl.HUD.DynamicRupees >= gameControl.Inventory.GetAmmo("rupees").MaxAmount)
                AudioSystem.PlaySound(GameData.SOUND_GET_RUPEE);

            gameControl.Inventory.GetAmmo("rupees").Amount += amount;
        }
        //-----------------------------------------------------------------------------
        // Virtual methods
        //-----------------------------------------------------------------------------
        public override void OnCollect(GameControl gameControl)
        {
            if (gameControl.HUD.DynamicHealth >= gameControl.Player.MaxHealth)
                AudioSystem.PlaySound("Pickups/get_heart");

            gameControl.Player.Health += amount * 4;
        }
Example #6
0
        //-----------------------------------------------------------------------------
        // Virtual methods
        //-----------------------------------------------------------------------------
        public override void OnCollect(GameControl gameControl)
        {
            if (gameControl.HUD.DynamicRupees >= gameControl.Inventory.GetAmmo("rupees").MaxAmount)
                AudioSystem.PlaySound("Pickups/get_rupee");

            gameControl.Inventory.GetAmmo("rupees").Amount += amount;
        }
Example #7
0
 //-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public HUD(GameControl gameControl)
 {
     this.gameControl	= gameControl;
     this.dynamicRupees	= 0;
     this.dynamicHealth	= 3 * 4;
     this.healthTimer	= 0;
 }
Example #8
0
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public Inventory(GameControl gameControl)
        {
            this.gameControl		= gameControl;
            this.items				= new List<Item>();
            this.ammo				= new List<Ammo>();
            this.equippedWeapons	= new ItemWeapon[NumEquipSlots];

            this.piecesOfHeart		= 0;
        }
 //-----------------------------------------------------------------------------
 // Virtual methods
 //-----------------------------------------------------------------------------
 public override void OnCollect(GameControl gameControl)
 {
     gameControl.Inventory.PiecesOfHeart++;
     if (gameControl.Inventory.PiecesOfHeart == 4) {
         gameControl.Inventory.PiecesOfHeart = 0;
         gameControl.Player.MaxHealth += 4;
         gameControl.Player.Health += 4;
     }
 }
Example #10
0
 //-----------------------------------------------------------------------------
 // Virtual methods
 //-----------------------------------------------------------------------------
 public override void OnCollect(GameControl gameControl)
 {
     gameControl.Inventory.PiecesOfHeart++;
     if (gameControl.Inventory.PiecesOfHeart == 4) {
         gameControl.Inventory.PiecesOfHeart = 0;
         gameControl.Player.MaxHealth += 4;
         gameControl.Player.Health += 4;
         gameControl.DisplayMessage(new Message("You got four<n><red>Pieces of Heart<red>!<n>That makes one<n><red>Heart Container<red>!"));
     }
 }
Example #11
0
 //-----------------------------------------------------------------------------
 // Implementations
 //-----------------------------------------------------------------------------
 public Entity CreateDropEntity(GameControl gameControl)
 {
     if (reward != null) {
         return new CollectibleReward(reward, true);
     }
     else if (entityType != null) {
         // Spawn a new entity.
         Entity entity = (Entity) entityType.GetConstructor(Type.EmptyTypes).Invoke(null);
         return entity;
     }
     return null;
 }
        //-----------------------------------------------------------------------------
        // Virtual methods
        //-----------------------------------------------------------------------------
        public override void OnCollect(GameControl gameControl)
        {
            // TEMP: hard coded dungeon reward possibilities.
            Dungeon dungeon = gameControl.RoomControl.Dungeon;

            if (dungeon != null) {
                if (id == "small_key") {
                    dungeon.NumSmallKeys++;
                    AudioSystem.PlaySound(GameData.SOUND_GET_ITEM);
                }
                else if (id == "boss_key") {
                    dungeon.HasBossKey = true;
                    AudioSystem.PlaySound(GameData.SOUND_GET_ITEM);
                }
                else if (id == "map") {
                    dungeon.HasMap = true;
                }
                else if (id == "compass") {
                    dungeon.HasCompass = true;
                }
            }
        }
Example #13
0
 //-----------------------------------------------------------------------------
 // Overridden Methods
 //-----------------------------------------------------------------------------
 public override void OnCollect(GameControl gameControl)
 {
     gameControl.Inventory.GetAmmo(ammoID).Amount += amount;
     AudioSystem.PlaySound(GameData.SOUND_GET_ITEM);
 }
Example #14
0
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public RewardManager(GameControl gameControl)
 {
     this.gameControl	= gameControl;
     this.rewards		= new Dictionary<string, Reward>();
 }
Example #15
0
 public override void Draw(Graphics2D g)
 {
     DrawRoom(g, new Vector2F(0, 16));                   // Draw the room.
     GameControl.HUD.Draw(g, false);                     // Draw the HUD.
     GameControl.DrawRoomState(g);                       // Draw the current room state.
 }
Example #16
0
 //-----------------------------------------------------------------------------
 // Accessors
 //-----------------------------------------------------------------------------
 public void Begin(GameControl gameControl)
 {
     if (!isActive) {
         this.gameControl = gameControl;
         isActive = true;
         gameControl.UpdateRoom = updateRoom;
         gameControl.AnimateRoom = animateRoom;
         OnBegin();
     }
 }
Example #17
0
        public void BeginRoom(Room room)
        {
            this.room            = room;
            this.roomLocation    = room.Location;
            this.dungeon         = room.Dungeon;
            this.isSideScrolling = room.Zone.IsSideScrolling;

            // Discover the room.
            room.IsDiscovered       = true;
            room.Level.IsDiscovered = true;

            // Clear event tiles.
            eventTiles.Clear();

            // Clear all entities from the old room (except for the player).
            entities.Clear();
            if (Player != null)
            {
                Player.Initialize(this);
                Player.EntityIndex = 0;
                entities.Add(Player);
            }

            // Create the tile grid.
            tileManager.Initialize(room);
            for (int x = 0; x < room.Width; x++)
            {
                for (int y = 0; y < room.Height; y++)
                {
                    for (int i = 0; i < room.LayerCount; i++)
                    {
                        TileDataInstance data = room.TileData[x, y, i];

                        if (data != null && data.IsAtLocation(x, y) &&
                            data.ModifiedProperties.GetBoolean("enabled", true))
                        {
                            // Place the tile.
                            Tile tile = Tile.CreateTile(data);
                            PlaceTile(tile, x, y, i, false);
                        }
                    }
                }
            }

            // Create the event tiles.
            eventTiles.Capacity = room.EventData.Count;
            for (int i = 0; i < room.EventData.Count; i++)
            {
                EventTileDataInstance data = room.EventData[i];
                if (data.Properties.GetBoolean("enabled", true))
                {
                    EventTile eventTile = EventTile.CreateEvent(data);
                    eventTiles.Add(eventTile);
                }
            }

            // Initialize the tiles.
            tileManager.InitializeTiles();

            // Initialize the event tiles.
            for (int i = 0; i < eventTiles.Count; i++)
            {
                eventTiles[i].Initialize(this);
            }

            tileManager.PostInitializeTiles();

            entityCount = entities.Count;

            viewControl.Bounds   = RoomBounds;
            viewControl.ViewSize = GameSettings.VIEW_SIZE;

            // Fire the RoomStart event.
            GameControl.FireEvent(room, "event_room_start");

            allMonstersDead = false;
        }
Example #18
0
        private void UpdateObjects()
        {
            requestedTransitionDirection = -1;

            // Update entities.
            entityCount = entities.Count;
            for (int i = 0; i < entities.Count; i++)
            {
                if (entities[i].IsAlive && entities[i].IsInRoom && i < entityCount)
                {
                    if (GameControl.UpdateRoom)
                    {
                        entities[i].Update();
                    }
                    if (GameControl.AnimateRoom)
                    {
                        entities[i].UpdateGraphics();
                    }

                    if (requestedTransitionDirection >= 0)
                    {
                        break;
                    }
                }
            }

            // Remove destroyed entities.
            for (int i = 0; i < entities.Count; i++)
            {
                if (!entities[i].IsAlive || !entities[i].IsInRoom)
                {
                    entities.RemoveAt(i--);
                }
            }

            //if (requestedTransitionDirection >= 0)
            //	return;

            // Update tiles.
            tileManager.UpdateTiles();

            // Update the event tiles.
            for (int i = 0; i < eventTiles.Count; i++)
            {
                eventTiles[i].Update();
            }

            // Process Physics.
            if (GameControl.UpdateRoom)
            {
                roomPhysics.ProcessPhysics();
                Player.CheckRoomTransitions();
            }

            bool nextAllMonstersDead = AllMonstersDead();

            if (nextAllMonstersDead && !allMonstersDead)
            {
                GameControl.FireEvent(room, "event_all_monsters_dead");
            }
            allMonstersDead = nextAllMonstersDead;
        }
Example #19
0
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public DropManager(GameControl gameControl)
 {
     this.gameControl	= gameControl;
     this.dropLists		= new Dictionary<string, DropList>();
 }
Example #20
0
        //-----------------------------------------------------------------------------
        // Virtual methods
        //-----------------------------------------------------------------------------
        public override void OnCollect(GameControl gameControl)
        {
            //AudioSystem.PlaySound("Pickups/get_ammo");

            gameControl.Inventory.GetAmmo(ammoID).Amount += amount;
        }
Example #21
0
 public override bool IsAvailable(GameControl gameControl)
 {
     return gameControl.Inventory.IsAmmoAvailable(ammoID);
 }
Example #22
0
 public bool IsAvailable(GameControl gameControl)
 {
     if (reward != null)
         return reward.IsAvailable(gameControl);
     return true;
 }
Example #23
0
        // Initializes the game manager.
        public void Initialize(GameBase gameBase)
        {
            this.gameBase = gameBase;

            elapsedTicks = 0;

            FormatCodes.Initialize();
            Controls.Initialize();
            ScreenResized();

            AudioSystem.MasterVolume = 0.1f;

            // Begin the game state stack with a RoomControl.
            gameStateStack	= new GameStateStack(new StateDummy());
            gameStateStack.Begin(this);
            gameControl		= new GameControl(this);
            gameControl.StartGame();
        }
Example #24
0
 //-----------------------------------------------------------------------------
 // Virtual methods
 //-----------------------------------------------------------------------------
 public virtual void OnCollect(GameControl gameControl)
 {
 }
Example #25
0
 public bool IsAvailable(GameControl gameControl)
 {
     return true;
 }