Beispiel #1
0
        public void OnDamage(DamageVO damageVO)
        {
            if (visiable)
            {
                return;
            }

            if (damageVO.fromType != DamageFromType.Solider)
            {
                return;
            }



            if (damageVO.fromType != DamageFromType.Solider)
            {
                return;
            }

            if (damageVO.caster != null && damageVO.caster.unitData.relation == RelationType.Enemy)
            {
                return;
            }

            canvasGroup.DOKill();
            gameObject.SetActive(true);
            canvasGroup.alpha = 1;
            canvasGroup.DOFade(0, damageDuration).SetDelay(damageDelay).OnComplete(() => { if (!visiable)
                                                                                           {
                                                                                               gameObject.SetActive(false);
                                                                                           }
                                                                                   });
        }
Beispiel #2
0
        void OnProjectileComplete(object obj)
        {
            if (obj == null)
            {
                return;
            }
            UnitCtl enemy = (UnitCtl)obj;

            if (enemy == null)
            {
                return;
            }


            DamageVO damageVO = new DamageVO();

            damageVO.caster      = unitCtl;
            damageVO.target      = enemy;
            damageVO.value       = unitData.attackDamage;;
            damageVO.fromType    = DamageFromType.Turret;
            damageVO.damageType  = DamageType.ATTACK;
            damageVO.hitFlyPoint = transform.position;


            damageVO.target.Damage(damageVO);
        }
Beispiel #3
0
        /** 接收士兵伤害 */
        public void DamageBehit(DamageVO damageVO)
        {
            if (unitData.invincible && damageVO.damageType != DamageType.HEAL)
            {
                return;
            }


            if (BeforeDamage != null)
            {
                BeforeDamage(damageVO);
            }


            if (damageVO.damageType == DamageType.HEAL)
            {
                hp += damageVO.value;
                War.textEffect.PlayHP(damageVO.value, this);
            }
            else
            {
                hp -= damageVO.value;
                unitData.beattack = true;

//				Debug.Log(string.Format("hpbug UnitCtl.DamageBehit atk={0}, def={1},  hp={2}, damageVO.value={3}", atk, def,  hp, damageVO.value));

                float consHp = damageVO.value;
                if (hp < 0)
                {
                    consHp = damageVO.value + hp;
                }

                float def2AtkHP = WarFormula.WD_RelativelyHP_Def2Atk(unitData.def, damageVO.caster.unitData.atk, consHp);

                War.textEffect.PlayHP(-consHp, this);

                War.signal.HPConst(unitData.legionId, damageVO.caster.unitData.legionId, consHp);
                War.signal.HPConst(damageVO.caster.unitData.legionId, unitData.legionId, def2AtkHP);


                War.hunManager.Play(damageVO.caster);

                if (consHp != 0)
                {
                    War.hunManager.Play(unitData.colorId, transform.position + new Vector3(Random.Range(-2, 2), 0f, Random.Range(-2, 2)));
                }

                // 添加经验--进攻
                damageVO.caster.legionData.levelData.AddExp_SoliderAtk(consHp, damageVO.caster);
                // 添加经验--防守
                damageVO.target.legionData.levelData.AddExp_SoliderDef(def2AtkHP, damageVO.caster);
            }



            if (OnDamage != null)
            {
                OnDamage(damageVO);
            }
        }
Beispiel #4
0
        /** zdl 接收技能伤害 */

        /*
         * val:改变值,若是伤害为负数
         * isOverMax:是否可以超过最大值
         */
        public void Damage(float val, int isOverMax, UnitCtl caster)
        {
            DamageVO damageVO = new DamageVO();

            damageVO.caster        = caster;
            damageVO.target        = unitCtl;
            damageVO.fromType      = DamageFromType.Skill;
            damageVO.damageType    = val < 0 ? DamageType.ATTACK : DamageType.HEAL;
            damageVO.value         = val < 0 ? -val : val;
            damageVO.enableOverMax = isOverMax == 1;
            Damage(damageVO);
        }
Beispiel #5
0
        /** 被士兵攻打 */
        public void BehitForUnit(UnitData enemy)
        {
            if (!War.isGameing)
            {
                return;
            }
            if (invincible)
            {
                return;
            }

//			Debug.Log(string.Format("hpbug BehitForUnit atk={0}, def={1},  hp={2}, enemy.atk={3}, enemy.hp={3}", atk, def,  hp, enemy.atk, enemy.hp));

//			Debug.Log(string.Format("<color=lightblue>BehitForUnit enemy={0}  enemy.props={1}</color>", enemy, enemy.props.ToStrProp()));
            DamageVO damageVO = new DamageVO();

            damageVO.caster     = enemy.unit;
            damageVO.target     = this.unit;
            damageVO.value      = WarFormula.WD_Solider2Casern_Damage(def, enemy.atk, enemy.hp);
            damageVO.fromType   = DamageFromType.Solider;
            damageVO.damageType = DamageType.ATTACK;

            try
            {
                damageVO.target.DamageBehit(damageVO);
            }
            catch (Exception e)
            {
                if (Application.isEditor)
                {
                    Debug.LogError(e);
                }
                else
                {
                    Debug.LogFormat("<color=red>" + e + "</color>");
                }
            }

//			Debug.Log(string.Format("hpbug BehitForUnit atk={0}, def={1}, hitVO.damageVO.value={2}, hp={3}", atk, def, damageVO.value, hp));
            if (hp >= 0)
            {
                behit = true;
                War.signal.OnBehit(uid, enemy.legionId);
            }
            else
            {
                hp    = WarFormula.WD_RelativelyHP_Def2Atk(def, enemy.atk, -hp);
                behit = false;
                ChangeLegion(enemy.legionId);
            }
        }
        IEnumerator buildHurt(UnitCtl unit, EffectParameter effectInfo)
        {
            yield return(new WaitForSeconds(0.8f));

            if (effectInfo.effect.animPathEnd != "temp")
            {
                GameObject effectPrefab = WarRes.GetPrefab(effectInfo.effect.animPathEnd);
                GameObject effectAnim   = GameObject.Instantiate <GameObject>(effectPrefab);
                effectAnim.transform.position = unit.transform.position;
            }
            DamageVO damageVo = War.skillWarManager.GetDamageParameter(effectInfo.value, false, DamageType.ATTACK, unit, effectInfo.caster);

            unit.Damage(damageVo);
        }
Beispiel #7
0
        public DamageVO Clone()
        {
            DamageVO vo = new DamageVO();

            vo.caster            = caster;
            vo.target            = target;
            vo.damageType        = damageType;
            vo.value             = value;
            vo.enableOverMax     = enableOverMax;
            vo.hitFlyPoint       = hitFlyPoint;
            vo.hitFlyPower       = hitFlyPower;
            vo.hitFlyPowerRadius = hitFlyPowerRadius;
            vo.hitFlyPowerUp     = hitFlyPowerUp;
            return(vo);
        }
Beispiel #8
0
        //伤害单个
        IEnumerator autoHurtBuildAllHurtSingle(SkillParameter skillParameter, EffectParameter effectInfo, UnitCtl unit, bool needDealSkill2)
        {
            yield return(new WaitForSeconds(0));

            int lengion = War.skillWarManager.getLegionByHeroUid(skillParameter.curHeroUid);

            if (lengion == unit.unitData.legionId)
            {
                yield break;
            }
            float hurtValue = effectInfo.value;

            if (effectInfo.effect.type == (int)eSKillWarEffectType.eEffectHurtBuidingMax)
            {
                hurtValue = unit.unitData.maxHp * effectInfo.value / 100;
            }
            else if (effectInfo.effect.type == (int)eSKillWarEffectType.eEffectHurtRate)
            {
                Debug.LogFormat("=================hp:{0} value:{1}", unit.unitData.hp, effectInfo.value);
                hurtValue = unit.unitData.hp * effectInfo.value / 100;
            }
            DamageVO damageVo = War.skillWarManager.GetDamageParameter(hurtValue, false, DamageType.ATTACK, unit, effectInfo.caster);

            unit.Damage(damageVo, 0f, 0.2f, effectInfo.effect.hurtCount);
            //War.skillWarManager.soldierDieSHow(unit);

            //处理技能2
            if (needDealSkill2 == true && skillParameter.curDealSkillIdx == 1)
            {
                Debug.LogFormat("=====needDealSkill2 true=====");
                War.skillWarManager.dealSkill2Effect(skillParameter);
            }

            if (effectInfo.effect.time > 0)
            {
                //War.skillWarManager.StartCoroutine(autoHurtBuildAllTimer(skillParameter, unit));
                BuildSkillDots skillDots = unit.GetComponent <BuildSkillDots>();
                if (skillDots != null)
                {
                    skillDots.GetSkillHurt(effectInfo);
                }
            }
            Debug.Log(string.Format("<color=yellow> autoHurtBuildAllHurtSingle all=skill id:{0}, lvl:{1} v:{2}  effecttime:{3}</color>",
                                    skillParameter.skillId, skillParameter.skillLvl, effectInfo.value, effectInfo.effect.time));
        }
        //定时伤害
        IEnumerator autoHurtBuildAllTimer(EffectParameter effectInfo)
        {
            UnitCtl unit = gameObject.GetComponent <UnitCtl>();

            effectInfo.waitTime = effectInfo.effect.time;
            DelayDestory destoryTimer = effectInfo.effectAnim.GetComponent <DelayDestory>();

            if (destoryTimer != null)
            {
                destoryTimer.DelayTime = effectInfo.waitTime;
            }
            int timerCount = 0;

            //SkillWarConf skillWarConf = War.model.GetSkillWarConf(skillParameter.skillId);
            while (true)
            {
                yield return(new WaitForSeconds(1.0f));

                try
                {
                    DamageVO damageVo = War.skillWarManager.GetDamageParameter(effectInfo.value, false, DamageType.ATTACK, unit, effectInfo.caster);
                    unit.Damage(damageVo);

                    Debug.Log(string.Format("<color=yellow> autoHurtBuildAllTimer all= effectid:{0}  </color>",
                                            effectInfo.effect.id));
                    timerCount++;
                    if (timerCount >= effectInfo.waitTime)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    if (Application.isEditor)
                    {
                        Debug.LogError(e);
                    }
                    break;
                }
            }

            effectInfo.waitTime = 0;
            CleanList();
            Debug.Log(string.Format("<color=white> autoHurtBuildAllTimer done=</color>"));
        }
 public void OnBeforeDamage(DamageVO damageVO)
 {
     if (damageVO.damageType == DamageType.HEAL)
     {
         return;
     }
     Debug.Log("=====OnBeforeDamage=====" + damageVO.target.unitData.shield + "====: " + damageVO.value);
     if (damageVO.target.unitData.shield < damageVO.value)
     {
         damageVO.target.unitData.shield = 0.0f;
         damageVO.value -= damageVO.target.unitData.shield;
     }
     else
     {
         damageVO.target.unitData.shield -= damageVO.value;
         damageVO.value = 0.0f;
     }
 }
Beispiel #11
0
        IEnumerator AverageDamage(DamageVO damageVO, float delay, float gapTime, int count)
        {
            yield return(new WaitForSeconds(delay));

            if (count <= 0)
            {
                count = 1;
            }
            float totalVal = damageVO.value;

            if (Mathf.Abs(totalVal) < count)
            {
                count = Mathf.CeilToInt(Mathf.Abs(totalVal));
            }
            float averageVal = totalVal / count;

            for (int i = 0; i < count; i++)
            {
                try
                {
                    DamageVO vo = damageVO.Clone();
                    vo.value = averageVal;
                    Damage(vo);
                }
                catch (System.Exception e)
                {
                    if (Application.isEditor)
                    {
                        Debug.Log(e);
                    }

                    break;
                }
                yield return(new WaitForSeconds(gapTime));
            }
        }
Beispiel #12
0
        IEnumerator manualHurtRangEnd(SkillParameter skillParameter, EffectParameter effectInfo)
        {
            yield return(new WaitForSeconds(0.2f));

            //UnitCtl curUnit = War.scene.GetBuild(skillParameter.curHeroBuildId);

            foreach (UnitCtl unit in effectInfo.unitCtlList)
            {
                try
                {
                    if (unit == null || unit.unitData == null)
                    {
                        continue;
                    }
                    if (unit.unitData.hp <= 0)
                    {
                        continue;
                    }

                    if (unit.unitData.unitType == UnitType.Build)
                    {
                        int lengion = War.skillWarManager.getLegionByHeroUid(skillParameter.curHeroUid);
                        if (lengion == unit.unitData.legionId)
                        {
                            yield break;
                        }

                        float hurt = effectInfo.value - (effectInfo.unitCtlList.Count - 1);
                        if (hurt >= 1)
                        {
                            DamageVO damageVo = War.skillWarManager.GetDamageParameter(hurt, false, DamageType.ATTACK, unit, effectInfo.caster);
                            unit.Damage(damageVo, 0f, 0.2f, effectInfo.effect.hurtCount);
                        }
                    }
                    else
                    {
                        TrackParamClass param = new TrackParamClass();
                        param.caster     = effectInfo.caster;
                        param.high       = 4.0f;
                        param.range      = 5.0f;
                        param.speedTrack = 20.0f;
                        param.unitCtlCur = unit;
                        unit.GetComponent <SkillTrackController>().addForceParabola(effectInfo.receivePos, 6.0f, param);
                    }
                }
                catch (System.Exception e)
                {
                    if (Application.isEditor)
                    {
                        Debug.Log(e);
                    }

                    break;
                }
            }

            SkillWarConf skillWarConf = War.model.GetSkillWarConf(skillParameter.skillId);

            Debug.Log(string.Format("<color=yellow> manualHurtRang=id:{0} {1} leftcount{2}</color>",
                                    skillParameter.skillId, effectInfo.value, effectInfo.unitCtlList.Count));
            if (skillParameter.curDealSkillIdx == 1)
            {
                War.skillWarManager.dealSkill2Effect(skillParameter);
            }
        }
Beispiel #13
0
        /** 接收技能伤害 */
        public void Damage(DamageVO damageVO)
        {
            if (unitData == null || (unitData.invincible && damageVO.damageType != DamageType.HEAL))
            {
                return;
            }

            if (BeforeDamage != null)
            {
                BeforeDamage(damageVO);
            }


            if (damageVO.value == 0)
            {
                return;
            }

//			Debug.Log(string.Format("damageVO.damageType={0}, damageVO.value={1}", damageVO.damageType, damageVO.value));
            if (damageVO.damageType == DamageType.HEAL)
            {
                float legionHP = 0;
                if (War.vsmode == VSMode.PVE_Expedition)
                {
                    legionHP = War.scene.GetLegionHP(legionData.legionId);

                    if (legionHP + damageVO.value > legionData.expeditionTotalMaxHP)
                    {
                        damageVO.value = legionData.expeditionTotalMaxHP - legionHP;
                    }
                }


                float addHP = damageVO.value;

                if (damageVO.enableOverMax)
                {
                    hp += addHP;
                }
                else
                {
                    bool isPerOver = hp > hpMax;
                    if (isPerOver == false)
                    {
                        float addHPTmp = hpMax - hp;
                        addHP = addHPTmp > addHP ? addHP : addHPTmp;
                        hp   += addHP;
                    }
                    else
                    {
                        addHP = 0;
                        return;
                    }
                }


                War.textEffect.PlayHP(addHP, this, 60);
                War.signal.HPAdd(unitData.legionId, damageVO.caster.unitData.legionId, addHP);

                if (War.vsmode == VSMode.PVE_Expedition)
                {
                    if (legionData.expeditionTotalHP >= legionData.expeditionTotalMaxHP)
                    {
                        legionData.expeditionLeftHP = legionData.expeditionTotalMaxHP - legionHP - addHP;
                    }
                }
            }
            else
            {
                unitData.behit = true;
                hp            -= damageVO.value;

                float consHp = damageVO.value;
                if (hp < 0)
                {
                    consHp = damageVO.value + hp;
                }

                if (unitData.unitType != UnitType.Solider)
                {
                    War.textEffect.PlayHP(-consHp, this, 60);
                }

                War.signal.HPConst(unitData.legionId, damageVO.caster.unitData.legionId, consHp);

                if (damageVO.fromType == DamageFromType.Turret)
                {
                    damageVO.caster.legionData.levelData.AddExp_SoliderTurret(consHp, this);
                }
                else
                {
                    damageVO.caster.legionData.levelData.AddExp_SoliderSkill(consHp, this);
                }
            }


            if (hp <= 0)
            {
                hp = 0;

                if (unitData.unitType == UnitType.Solider)
                {
                    War.hunManager.Play(this);
//					unitData.isHitFly = true;
//					unitData.hitFlyPoint = damageVO.hitFlyPoint;
//					if(damageVO.hitFlyPower > 0)unitData.hitFlyPower                = damageVO.hitFlyPower;
//					if(damageVO.hitFlyPowerRadius > 0)unitData.hitFlyPowerRadius	= damageVO.hitFlyPowerRadius;
//					if(damageVO.hitFlyPowerUp > 0)unitData.hitFlyPowerUp            = damageVO.hitFlyPowerUp;
                }
            }

            if (OnDamage != null)
            {
                OnDamage(damageVO);
            }
        }
Beispiel #14
0
 /// <summary>
 /// 总伤害分X次数,平均化
 /// </summary>
 /// <param name="damageVO">总伤害数据</param>
 /// <param name="delay">第一次延迟多长时间.</param>
 /// <param name="gapTime">连续的间隔时间 time.</param>
 /// <param name="count">次数.</param>
 public void Damage(DamageVO damageVO, float delay, float gapTime, int count)
 {
     StartCoroutine(AverageDamage(damageVO, delay, gapTime, count));
 }