Exemplo n.º 1
0
        public BattleHeroSkillResult CalcSingle(BattleUnit from, BattleUnit to, SO_BattleSkill battleSkill)
        {
            BattleHeroSkillResult result = new BattleHeroSkillResult();

            result.battleUnit    = to;
            result.battleSkill   = battleSkill;
            result.syncAttribute = new BattleHeroSyncAttribute();
            //简单计算生命值
            switch (battleSkill.damageType)
            {
            case BattleSkillDamageType.Physical:
            case BattleSkillDamageType.Magic:
                result.syncAttribute.hpChanged = -battleSkill.mainValue;
                break;

            case BattleSkillDamageType.Heal:
                result.syncAttribute.hpChanged = Mathf.Min(battleSkill.mainValue, to.maxHp - to.hp);
                break;

            default:
                break;
            }
            //hp变化
            to.hp += result.syncAttribute.hpChanged;
            to.hp  = Mathf.Clamp(to.hp, 0, to.maxHp);
            //记录变化
            result.syncAttribute.currentHP = to.hp;
            return(result);
        }
Exemplo n.º 2
0
        public BattleHeroSkillResult CalcSingle(BattleUnit from, BattleUnit to, int skillID)
        {
            BattleHeroSkillResult result = new BattleHeroSkillResult();

            result.battleUnit    = to;
            result.syncAttribute = new BattleHeroSyncAttribute();
            //生命变化量暂定为攻击值
            result.syncAttribute.hpChanged = -from.atk;
            //hp变化
            to.hp += result.syncAttribute.hpChanged;
            to.hp  = Mathf.Clamp(to.hp, 0, to.maxHp);
            //记录变化
            result.syncAttribute.currentHP = to.hp;
            return(result);
        }
Exemplo n.º 3
0
        //受到技能伤害
        private void OnSkillDamage(BattleHeroSkillResult skillResult)
        {
            if (skillResult == null)
            {
                return;
            }

            //播放掉血特效
            EffectDamageLabel damageEffect = EffectManager.Instance.CreateEffectByName <EffectDamageLabel>(EGameConstL.Effect_DamageLabel, EffectPlayType.WorldPosition);

            if (damageEffect != null)
            {
                damageEffect.SortingLayer = EGameConstL.SortingLayer_Battle_Effect;
                damageEffect.gameObject.SetActive(true);
                damageEffect.transform.position = unitRenderer.transform.position;
                damageEffect.SetDamage(skillResult.syncAttribute.hpChanged, skillResult.battleSkill.damageType);
            }
        }
Exemplo n.º 4
0
        //使用技能
        private void UseSkill(List <BattleAction> actions)
        {
            int skillID = 0;

            BattleHeroSkillResult skillResult = BattleCalculator.Instance.CalcSingle(this, targetBattleUnit, skillID);

            if (actions != null)
            {
                BattleHeroSkillAction action = new BattleHeroSkillAction(this, skillID);
                action.skillResult = new BattleHeroSkillResult[1] {
                    skillResult
                };
                actions.Add(action);
            }

            if (skillResult != null)
            {
                skillResult.battleUnit.AcceptSkillResult(skillResult.syncAttribute, actions);
            }
        }
Exemplo n.º 5
0
        //使用技能
        public void UseSkill(List <BattleAction> actions, BattleUnit target, int skillID)
        {
            if (target == null)
            {
                UtilityHelper.LogError("Use skill error, none target");
                return;
            }

            BattleHeroSkillResult skillResult = BattleCalculator.Instance.CalcSingle(this, target, skillID);

            if (actions != null)
            {
                BattleHeroSkillAction action = new BattleHeroSkillAction(this, skillID);
                action.skillResult = new BattleHeroSkillResult[1] {
                    skillResult
                };
                actions.Add(action);
            }

            if (skillResult != null)
            {
                skillResult.battleUnit.AcceptSkillResult(skillResult.syncAttribute, actions);
            }
        }