예제 #1
0
        public int TakeDamage(int damageValue, Unit sourceUnit, SpellBase spell)
        {
            if (this.IsDead() || this.IsInvincible())
            {
                return(0);
            }
            if (this.IsCanNotBeTakeDamage())
            {
                return(0);
            }
            if (this.aiComp != null && this.aiComp.IsHasMethod("BeHit"))
            {
                this.aiComp.InvokeMethod("BeHit", false, sourceUnit, damageValue);
            }
            //以后用于计算血条收到伤害效果
            int oldHp = this.GetHp();

            SetHp(Math.Max(0, this.GetHp() - damageValue), true);
            this.OnHpChange(sourceUnit, oldHp, this.GetHp());
            this.Broadcast <Unit, Unit, SpellBase, int>(null, UnitEventNameConst.On_Unit_Hurt, sourceUnit, this, spell, damageValue);

            if (this.GetHp() <= 0)
            {
                this.Broadcast <Unit, Unit, SpellBase, int>(null, UnitEventNameConst.Before_Unit_Dead, sourceUnit, this, spell, damageValue);                //回调监听
                this.OnKilled(sourceUnit, spell);
            }

            return(damageValue);
        }
예제 #2
0
파일: BuffCache.cs 프로젝트: uiopsczc/Test
 public BuffCache(float duration, Unit sourceUnit, SpellBase sourceSpell, Hashtable argDict)
 {
     this.duration       = duration;
     this.remainDuration = this.duration;
     this.sourceUnit     = sourceUnit;
     this.sourceSpell    = sourceSpell;
     this.argDict        = argDict;
 }
예제 #3
0
 public void OnSpellAnimationFinished(SpellBase spell)
 {
     if (spell.sourceUnit.currentAttack == spell)
     {
         if (spell.sourceUnit.isNormalAttacking)
         {
             spell.sourceUnit.NormalAttackFinish();
         }
         spell.sourceUnit.currentAttack = null;
         spell.sourceUnit.UpdateMixedStates();
     }
 }
예제 #4
0
        public Buff CreateBuffCache(float duration, Unit sourceUnit, SpellBase sourceSpell, Hashtable argDict)
        {
            var buffCache = new BuffCache(duration, sourceUnit, sourceSpell, argDict);

            buffCacheList.Add(buffCache);
            if (buffCacheList.Count == 1)             //第一个的时候才添加
            {
                this.AddEffects();
                this.AddPropertyDict();
                this.AddTriggerSpell();
                this.buffManager.AddState(this.cfgBuffData.state);
            }

            return(this);
        }