Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the ScrollingCombatText class, based upon the given parameters.
        /// </summary>
        /// <param name="p">The Point location of the ScrollingCombatText</param>
        /// <param name="txt">The string text of the ScrollingCombatText</param>
        /// <param name="type">The SctType type of the ScrollingCombatText</param>
        public ScrollingCombatText(Point p, string txt, SctType type)
        {
            this.myType    = type;
            this.startFade = DateTime.Now.AddSeconds(1);
            this.coords.X  = p.X - 10;
            this.coords.Y  = p.Y - 45;
            this.text      = txt;

            switch (this.myType)
            {
            case SctType.Normal:
                this.textColor = Color.White;
                break;

            case SctType.Critical:
                this.textColor = Color.Yellow;
                this.textSize  = 30;
                this.coords.X -= 5;
                this.startFade.AddSeconds(1);
                break;

            case SctType.Block:
                this.coords.X -= 15;
                this.textColor = Color.Red;
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculates and applies the damage of an attack(Based on this' damage, block and crit values).
        /// </summary>
        /// <param name="victim">The DynamicGameObject which health is going to be reduced.</param>
        /// <param name="rnd">An already instansiated, random-number generator.</param>
        /// <returns>A new instance of the ScrollingCombatText class, based upon calculated attack.</returns>
        public ScrollingCombatText CalcAndApplyDamage(DynamicGameObject victim, Random rnd)
        {
            int dmg = this is Player?rnd.Next(this.damage / 3, this.damage) : rnd.Next(1, this.damage);

            string  combatText = dmg.ToString();
            SctType textType   = SctType.Normal;

            if (rnd.Next(0, 101) <= victim.block)
            {
                combatText = "Block";
                textType   = SctType.Block;
            }
            else if (rnd.Next(0, 101) <= this.crit)
            {
                dmg          *= 3;
                combatText    = dmg.ToString();
                victim.health = (victim.health - dmg) <= 0 ? 0 : victim.health - dmg;
                textType      = SctType.Critical;
            }
            else
            {
                victim.health = (victim.health - dmg) <= 0 ? 0 : victim.health - dmg;
            }

            return(new ScrollingCombatText(victim.coords, combatText, textType));
        }