/// <summary>
        /// Attempts to create a Poison Zone at the passed in point.
        /// This will only occur if the Ability is off cooldown.
        /// </summary>
        /// <param name="pt">Point.</param>
        public void CastPoisonZone(Point2D pt)
        {
            CPlayer player = World.GetComponent <CPlayer>(PLAYER_ENTITY_ID);

            if (AbilityIsReady(player.TimeOfLastPoisonZone, POISON_ZONE_COOLDOWN))
            {
                EntityFactory.CreatePoisonZone(pt.X, pt.Y);
                player.TimeOfLastPoisonZone = World.GameTime;
            }
        }
예제 #2
0
        /// <summary>
        /// Renders everything related to the Player, including UI elements.
        /// </summary>
        public override void Process()
        {
            CRenderable renderable = World.GetComponent <CRenderable>(PlayerSystem.PLAYER_ENTITY_ID);
            CHealth     health     = World.GetComponent <CHealth>(PlayerSystem.PLAYER_ENTITY_ID);
            CPlayer     player     = World.GetComponent <CPlayer>(PlayerSystem.PLAYER_ENTITY_ID);

            RenderCooldowns(player);
            RenderShop(player);
            RenderHealthBar(health);
        }
        /// <summary>
        /// Purchases an Explosion Man for the Player if they have enough gold. Lowers the Player's gold
        /// and spawns an Explosion Man at the centre of the most populated Hash cell on the field.
        /// </summary>
        public void BuyExplosionMan()
        {
            CPlayer player = World.GetComponent <CPlayer>(PLAYER_ENTITY_ID);

            if (player.Gold >= EXPLOSION_MAN_COST)
            {
                EntityFactory.CreateExplosionMan();
                player.Gold -= EXPLOSION_MAN_COST;
            }
        }
        /// <summary>
        /// Purchases an Archer for the Player if they have enough gold. Lowers the Player's gold, increments the
        /// Archer count and spawns an Archer at a random y coordinate inside the Castle.
        /// </summary>
        public void BuyArcher()
        {
            CPlayer player = World.GetComponent <CPlayer>(PLAYER_ENTITY_ID);

            if (player.Gold >= ARCHER_COST)
            {
                EntityFactory.CreatePlayerArcher(_spawnAtX, _spawnAtY.Next(20, 550));
                player.Gold -= ARCHER_COST;
                ARCHER_COUNT++;
            }
        }
        /// <summary>
        /// Attemps to create a Freezing Bullet heading towards the passed in point.
        /// This will only occur if the Ability is off cooldown.
        /// </summary>
        /// <param name="pt">The point the Freezing Bullet will head towards.</param>
        public void CastFreezingBullet(Point2D pt)
        {
            CPlayer player = World.GetComponent <CPlayer>(PLAYER_ENTITY_ID);

            if (AbilityIsReady(player.TimeOfLastFreezingBullet, FREEZING_BULLET_COOLDOWN))
            {
                CPosition playerPos = World.GetComponent <CPosition>(PLAYER_ENTITY_ID);
                EntityFactory.CreateFreezingBullet(playerPos.Centre.X, playerPos.Centre.Y, pt.X, pt.Y);
                player.TimeOfLastFreezingBullet = World.GameTime;
            }
        }
예제 #6
0
        /// <summary>
        /// Renders all text related to the Player's purchase options.
        /// </summary>
        /// <param name="player">The Player.</param>
        private void RenderShop(CPlayer player)
        {
            SwinGame.DrawBitmap(_goldText, 120, 35);
            SwinGame.DrawText(player.Gold.ToString(), Color.Black, SwinGame.FontNamed("GameFont"), 165, 35);

            SwinGame.DrawBitmap(_archersText, 220, 35);
            SwinGame.DrawText(PlayerSystem.ARCHER_COUNT.ToString(), Color.Black, SwinGame.FontNamed("GameFont"), 290, 35);

            SwinGame.DrawBitmap(_buyArcherText, 505, 10);
            SwinGame.DrawBitmap(_tenGoldText, 535, 30);

            SwinGame.DrawBitmap(_buyExplosionManText, 635, 10);
            SwinGame.DrawBitmap(_fiftyGoldText, 665, 30);
        }
예제 #7
0
        /// <summary>
        /// Renders details for each cooldown the Player has. This includes progress bars and text.
        /// </summary>
        /// <param name="player">Player.</param>
        private void RenderCooldowns(CPlayer player)
        {
            #region FREEZING BULLET

            SwinGame.DrawBitmap(_freezingBulletText, 800, 10);
            SwinGame.FillRectangle(Color.DarkGray, 920, 5, COOLDOWN_BAR_WIDTH, 20);

            if (PlayerSystem.AbilityIsReady(player.TimeOfLastFreezingBullet, PlayerSystem.FREEZING_BULLET_COOLDOWN))
            {
                SwinGame.FillRectangle(Color.DarkBlue, 920, 5, COOLDOWN_BAR_WIDTH, 20);
                SwinGame.DrawBitmap(_readyText, 1010, 10);
            }
            else
            {
                float freezeBarWidth = COOLDOWN_BAR_WIDTH * CooldownPercentage(player.TimeOfLastFreezingBullet, PlayerSystem.FREEZING_BULLET_COOLDOWN);
                SwinGame.FillRectangle(Color.DarkBlue, 920, 5, freezeBarWidth, 20);
            }

            #endregion FREEZING BULLET

            #region POISON ZONE

            SwinGame.DrawBitmap(_poisonZoneText, 800, 50);
            SwinGame.FillRectangle(Color.DarkGray, 920, 45, COOLDOWN_BAR_WIDTH, 20);

            if (PlayerSystem.AbilityIsReady(player.TimeOfLastPoisonZone, PlayerSystem.POISON_ZONE_COOLDOWN))
            {
                SwinGame.FillRectangle(Color.Purple, 920, 45, COOLDOWN_BAR_WIDTH, 20);
                SwinGame.DrawBitmap(_readyText, 1010, 50);
            }
            else
            {
                float poisonBarWidth = COOLDOWN_BAR_WIDTH * CooldownPercentage(player.TimeOfLastPoisonZone, PlayerSystem.POISON_ZONE_COOLDOWN);
                SwinGame.FillRectangle(Color.Purple, 920, 45, poisonBarWidth, 20);
            }

            #endregion POISON ZONE
        }
        /// <summary>
        /// Takes a Loot Component; extracts its contents and gives it to the Player
        /// </summary>
        /// <param name="loot">The Loot to be given to the Player.</param>
        public void GiveLoot(CLoot loot)
        {
            CPlayer player = World.GetComponent <CPlayer>(PLAYER_ENTITY_ID);

            player.Gold += loot.Value;
        }