Exemplo n.º 1
0
        //释放技能时
        private IEnumerator ReleaseSkill(BattleUnitSkillAction action)
        {
            //取消范围显示
            if (action.battleSkill.effectRadius > 0)
            {
                BattleFieldRenderer.Instance.SetCircularRangeRenderStateActive(false, GridRenderType.SkillEffectRange);
            }

            //受到技能影响的单位还原
            for (int i = 0; i < action.skillResult.Length; ++i)
            {
                action.skillResult[i].battleUnit.battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Normal);
            }

            yield return(EGameConstL.WaitForHalfSecond);

            //属性刷新
            RefreshAttribute(action.selfAttribute);

            //展示
            for (int i = 0; i < action.skillResult.Length; ++i)
            {
                //同时开启掉血特效
                StartCoroutine(action.skillResult[i].battleUnit.battleUnitRenderer.OnSkillDamage(action.skillResult[i]));
            }
        }
Exemplo n.º 2
0
        //战斗表现生命周期
        //释放技能前
        private IEnumerator BeforeReleaseSkill(BattleUnitSkillAction action)
        {
            //将自己显示为行动状态~变身!
            UpdateRenderState(BattleUnitRenderState.Action);

            //仅有范围的技能显示范围呢
            if (action.battleSkill.effectRadius > 0)
            {
                GridUnit centerGrid = null;
                switch (action.battleSkill.targetType)
                {
                case BattleSkillTargetType.BattleUnit:
                case BattleSkillTargetType.Self:
                    break;
                    centerGrid = action.targetBattleUnit.mapGrid;
                    break;

                case BattleSkillTargetType.GridUnit:
                    centerGrid = action.targetGrid;
                    break;

                default:
                    break;
                }
                if (centerGrid != null)
                {
                    BattleFieldRenderer.Instance.SetCircularRangeRenderStateActive(
                        true,
                        GridRenderType.SkillEffectRange,
                        centerGrid.row, centerGrid.column,
                        action.battleSkill.effectRadius);
                }
            }
            //受到技能影响的单位高亮(暂时)
            for (int i = 0; i < action.skillResult.Length; ++i)
            {
                action.skillResult[i].battleUnit.battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Selected);
            }

            yield return(EGameConstL.WaitForHalfSecond);
        }
Exemplo n.º 3
0
        //使用技能
        private IEnumerator PlaySkillAction(BattleUnitSkillAction action)
        {
            if (action == null)
            {
                UtilityHelper.LogError("Error BattleHeroSkillAction");
                yield break;
            }


            if (action.skillResult == null)
            {
                UtilityHelper.LogError("Error BattleHeroSkillAction: No skill result.");
                yield break;
            }

            //释放前
            yield return(BeforeReleaseSkill(action));

            //释放
            yield return(ReleaseSkill(action));

            //释放后
            yield return(AfterReleaseSkill(action));
        }
Exemplo n.º 4
0
 //释放技能后
 private IEnumerator AfterReleaseSkill(BattleUnitSkillAction action)
 {
     UpdateRenderState(BattleUnitRenderState.Normal);
     yield return(null);
 }
Exemplo n.º 5
0
        //使用技能
        public void UseSkill(BattleUnitAction battleUnitAction, SO_BattleSkill battleSkill, BattleUnit targetBattleUnit = null, GridUnit targetGridUnit = null)
        {
            if (battleSkill == null)
            {
                UtilityHelper.LogError("Use skill error. Battle skill is none.");
                return;
            }
            BattleSkillEffectAnalysis analysis = BattleCalculator.Instance.AnalyseBattleSkillEffect(battleSkill, this, targetBattleUnit, targetGridUnit);

            if (analysis == null)
            {
                UtilityHelper.LogError("Use skill error. Analysis failed:" + battleSkill.skillName);
                return;
            }

            List <BattleUnitSkillResult> skillResults = new List <BattleUnitSkillResult>();

            //主要影响
            for (int i = 0; i < analysis.mainReceiver.Count; ++i)
            {
                skillResults.Add(BattleCalculator.Instance.CalcSingle(this, analysis.mainReceiver[i], battleSkill, true));
            }
            //次要影响
            for (int i = 0; i < analysis.minorReceiver.Count; ++i)
            {
                skillResults.Add(BattleCalculator.Instance.CalcSingle(this, analysis.minorReceiver[i], battleSkill, false));
            }

            //产生使用技能的动作
            if (battleUnitAction != null)
            {
                battleUnitAction.skillAction                  = BattleUnitSkillAction.Get();
                battleUnitAction.skillAction.battleSkill      = battleSkill;
                battleUnitAction.skillAction.skillResult      = skillResults.ToArray();
                battleUnitAction.skillAction.targetBattleUnit = targetBattleUnit;
                battleUnitAction.skillAction.targetGrid       = targetGridUnit;
                battleUnitAction.skillAction.selfAttribute    = BattleSkillCostEnergy(battleSkill);
            }

            //伤害产生效果,计算仇恨
            for (int i = 0; i < skillResults.Count; ++i)
            {
                //接收伤害,属性变更
                skillResults[i].battleUnit.AcceptSkillResult(skillResults[i].syncAttribute, battleUnitAction);

                //产生仇恨
                if (battleSkill.damageType != BattleSkillDamageType.Heal && !skillResults[i].battleUnit.Equals(this))
                {
                    //新仇记录
                    for (int j = 0; j < enemyTeam.battleUnits.Count; ++j)
                    {
                        if (!enemyTeam.battleUnits[j].CanAction)
                        {
                            continue;
                        }

                        //每个战斗单位都需要知道发生了什么
                        enemyTeam.battleUnits[j].battleBehaviourSystem.RecordSkillResult(this, skillResults[i]);
                    }
                }
            }
        }
Exemplo n.º 6
0
        //输出分析战报
        private void OutputBattleReport(string path)
        {
            StringBuilder strBuilder = new StringBuilder();

            if (!File.Exists(path))
            {
                strBuilder.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}\n", "BattleID", "State", "SN", "AtkTeam", "FirstAction", "Attacker", "SufferTeam", "Sufferer", "SkillName", "SkillType", "Damage/HP");
            }

            foreach (var item in battleFieldEvents)
            {
                switch (item.actionType)
                {
                case BattleFieldEventType.BattleUnitAction:
                    BattleUnitSkillAction skillAction = item as BattleUnitSkillAction;
                    if (skillAction != null)
                    {
                        foreach (var skillResult in skillAction.skillResult)
                        {
                            BattleTeam firstActionTeam = ((resetTimes & 1) == 0) ? teams[1] : teams[0];
                            strBuilder.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}\n",
                                                    resetTimes,
                                                    "Action",
                                                    item.SN,
                                                    skillAction.actionUnit.battleTeam,
                                                    firstActionTeam.Equals(skillAction.actionUnit.battleTeam) ? 1 : 0,
                                                    skillAction.actionUnit.battleUnitAttribute.battleUnitName,
                                                    skillResult.battleUnit.battleTeam,
                                                    skillResult.battleUnit.battleUnitAttribute.battleUnitName,
                                                    skillAction.battleSkill.skillName,
                                                    skillAction.battleSkill.damageType.ToString(),
                                                    skillResult.syncAttribute.hpChanged);

                            //统计击杀
                            if (skillResult.syncAttribute.currentHP <= 0)
                            {
                                strBuilder.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}\n",
                                                        resetTimes,
                                                        "Kill",
                                                        item.SN,
                                                        skillAction.actionUnit.battleTeam,
                                                        firstActionTeam.Equals(skillAction.actionUnit.battleTeam) ? 1 : 0,
                                                        skillAction.actionUnit.battleUnitAttribute.battleUnitName,
                                                        skillResult.battleUnit.battleTeam,
                                                        skillResult.battleUnit.battleUnitAttribute.battleUnitName,
                                                        skillAction.battleSkill.skillName,
                                                        skillAction.battleSkill.damageType.ToString(),
                                                        skillResult.syncAttribute.hpChanged);
                            }
                        }
                    }
                    break;

                case BattleFieldEventType.BattleStart:
                    break;

                case BattleFieldEventType.BattleEnd:
                    break;

                default:
                    break;
                }
            }
            foreach (var team in teams)
            {
                foreach (var bu in team.battleUnits)
                {
                    BattleTeam firstActionTeam = ((resetTimes & 1) == 0) ? teams[1] : teams[0];
                    strBuilder.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}\n",
                                            resetTimes,
                                            "End",
                                            string.Empty,
                                            bu.battleTeam,
                                            firstActionTeam.Equals(bu.battleTeam) ? 1 : 0,
                                            bu.battleUnitAttribute.battleUnitName,
                                            string.Empty,
                                            string.Empty,
                                            string.Empty,
                                            string.Empty,
                                            bu.battleUnitAttribute.hp);
                }
            }
            File.AppendAllText(path, strBuilder.ToString());
        }