Exemple #1
0
 public Damage(float[] originalDamages, float[] realDamages = null, Character source = null, Character target = null, bool isDamaged = false)
 {
     this.source = source;
     this.target = target;
     this.originalDamages = originalDamages;
     if (realDamages == null || realDamages.Length == 0)
     {
         this.realDamages = this.originalDamages;
     }
     else
     {
         this.realDamages = realDamages;
     }
     this.isDamaged = isDamaged;
 }
Exemple #2
0
 /// <summary>
 /// 试着扣除相应Point
 /// </summary>
 /// <param name="p_pointLost">Point扣除量</param>
 /// <returns>扣除成功,返回真,否则返回假</returns>
 public virtual bool TryToLosePoint(Character source, float p_pointLost)
 {
     if (p_pointLost < 0)
     {
         p_pointLost = 0;
     }
     if (point > p_pointLost)
     {
         LosePoint(source, p_pointLost);
         return true;
     }
     return false;
 }
Exemple #3
0
 /// <summary>
 /// 无条件扣除相应Point
 /// </summary>
 /// <param name="p_pointLost">Point扣除量</param>
 public virtual void LosePoint(Character source, float p_pointLost)
 {
     if (p_pointLost < 0)
     {
         p_pointLost = 0;
     }
     point -= p_pointLost;
     if (point <= 0)
     {
         if (onPointLE0 != null)
         {
             onPointLE0(source, p_pointLost, point);
         }
     }
 }
Exemple #4
0
 /// <summary>
 /// 获得Point
 /// </summary>
 /// <param name="p_pointObtained">Point获得量</param>
 /// <returns>实际增加的Point</returns>
 public virtual float AddPoint(Character source, float p_pointObtained)
 {
     if (p_pointObtained < 0)
     {
         p_pointObtained = 0;
     }
     float pointTemp = point;
     point += p_pointObtained;
     if (point > maxPoint)
     {
         point = maxPoint;
     }
     return point - pointTemp;
 }
Exemple #5
0
 /// <summary>
 /// 死亡,virtual
 /// </summary>
 /// <param name="p_killer">杀手</param>
 /// <returns>是否死亡</returns>
 public virtual bool Die(Character p_killer)
 {
     if (p_killer == null)
     {
         p_killer = this;
     }
     if (isDead == false)
     {
         isDead = true;
         if (onDie != null)
         {
             onDie(p_killer);
         }
         p_killer.Kill(this);
     }
     return isDead;
 }
Exemple #6
0
 /// <summary>
 /// 杀死一个人物,virtual
 /// </summary>
 /// <param name="p_dead">被害者</param>
 public virtual void Kill(Character p_dead)
 {
 }
Exemple #7
0
 /// <summary>
 /// 获取伤害数据结果
 /// </summary>
 /// <param name="source">源</param>
 /// <param name="target">目标</param>
 /// <returns></returns>
 public Damage GetAttackDamage(Character source, Character target)
 {
     Damage damage = new Damage(attacks.GetAttacks(), null, source, target);
     return damage;
 }
Exemple #8
0
 /// <summary>
 /// 攻击
 /// </summary>
 /// <param name="source">源</param>
 /// <param name="target">目标</param>
 public virtual void Attack(Character source, Character target)
 {
     Damage damage = GetAttackDamage(source, target);
     if(source is FightCharacter)
     {
         ((FightCharacter)source).TakeDamages(damage);
     }
 }