Example #1
0
        /// <summary>
        /// Rewards the NPC with XP based on the level of the Mob killed.
        /// </summary>
        /// <param name="mobLevel">The level of the mob that is awarding XP.</param>
        public void RewardXP(Entity sender, int mobLevel, GameTime gameTime, TeeEngine engine)
        {
            int xpGiven;
            if (mobLevel == Level)
            {
                xpGiven = (Level * 5) + 45;
            }
            else if (mobLevel < Level)
            {
                xpGiven = ((Level * 5) + 45) * (1 - (Level - mobLevel) / 5);
            }
            else // mobLevel > Level
            {
                xpGiven = ((Level * 5) + 45) * (int)(1 + 0.05 * (mobLevel - Level));
            }

            XP += xpGiven;

            // Check for lvl up condition
            if (XP >= XPToNextLevel)
            {
                LevelUp();
            }

            StatusText text = new StatusText(String.Format("+{0} XP", xpGiven), Color.Yellow, new Vector2(Pos.X, Pos.Y - CurrentBoundingBox.Height), Direction.Up);

            engine.AddEntity(text);
        }
Example #2
0
        /// <summary>
        /// Method called when the NPC has been hit by some Entity residing within the
        /// game engine. Override this method in order to perform custom functionality
        /// during a Hit event.
        /// </summary>
        public virtual void OnHit(Entity sender, int damage, GameTime gameTime, TeeEngine engine)
        {
            if (HP <= 0)
                return;

            HP -= damage;

            StatusText text;
            if(sender is Hero)
                text = new StatusText(String.Format("-{0}", damage), Color.OrangeRed, new Vector2(Pos.X, Pos.Y - CurrentBoundingBox.Height), Direction.Up);
            else
                text = new StatusText(String.Format("-{0}", damage), Color.Maroon, new Vector2(Pos.X, Pos.Y + 15), Direction.Down);

            engine.AddEntity(text);
        }