Ejemplo n.º 1
0
        /// <summary>
        /// 角色受到伤害
        /// </summary>
        /// <param name="damage"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public bool GetDamage(int damage, int index)
        {
            MyDraw.DrawDamageAnimation(this, index);
            int tempDamage = 0;

            if (Hp >= damage)
            {
                tempDamage = damage;
                Hp        -= damage;
            }
            else
            {
                tempDamage = Hp;
                Hp         = 0;
            }
            string text = string.Format("{0}受到了{1}点伤害", Name, tempDamage);

            MyDraw.DrawCharacterInfo(this, index);
            MyDraw.DrawBattleMessageDelay(text);
            if (!IsAlive())
            {
                if (!IsRevive())
                {
                    MyDraw.DrawBattleMessageDelay(Name + "死亡了");
                    ResetState();
                }
                MyDraw.DrawCharacterInfo(this, index);
            }
            return(IsAlive());
        }