Exemplo n.º 1
0
        //进入战场
        public void EnterBattleField(BattleField battleField, GridUnit bornGrid)
        {
            if (battleField != null && bornGrid != null)
            {
                this.battleField = battleField;

                //设置敌方队伍
                enemyTeam = battleField.GetBattleTeam(this, false);

                //重置属性
                battleUnitAttribute.RandomAttributes();
                battleUnitAttribute.Reset();

                //创建背包
                if (package == null)
                {
                    package = BattleUnitPackage.CreateInstance(this, 2);
                }

                package.Clear();

                //进入战场
                BattleUnitEnterBattleFieldAction enterBattleFieldAction = BattleUnitActionEvent.CreateEvent <BattleUnitEnterBattleFieldAction>(BattleUnitActionType.EnterBattleField, this);
                enterBattleFieldAction.battleField             = battleField;
                enterBattleFieldAction.bornGrid                = bornGrid;
                enterBattleFieldAction.attribute               = new BattleUnitSyncAttribute();
                enterBattleFieldAction.attribute.hpChanged     = 0;
                enterBattleFieldAction.attribute.currentHP     = battleUnitAttribute.hp;
                enterBattleFieldAction.attribute.energyChanged = 0;
                enterBattleFieldAction.attribute.currentEnergy = 0;
                battleField.AppendBattleAction(enterBattleFieldAction);

                //进入格子
                EnterGrid(bornGrid);

                //初始化战斗行为系统
                if (battleBehaviourSystem != null)
                {
                    battleBehaviourSystem.Init(this, battleField);
                }

                //重置bbsys
                if (battleBehaviourSystem != null)
                {
                    battleBehaviourSystem.ResetSystem();
                }
            }
        }
        public List <BattleUnit> battleUnitInvalid = new List <BattleUnit>(10); //战斗单位状态异常(无法战斗)

        //分析
        public void Analysis(BattleUnit battleUnit, SO_BattleSkill skill)
        {
            Reset();

            if (battleUnit == null || skill == null)
            {
                return;
            }

            releaser    = battleUnit;
            battleSkill = skill;

            //队伍不符的
            BattleTeam team = battleUnit.battleField.GetBattleTeam(battleUnit, !(skill.damageType == BattleSkillDamageType.Heal));

            teamLimit.AddRange(team.battleUnits);

            //队伍相符的
            team = battleUnit.battleField.GetBattleTeam(battleUnit, skill.damageType == BattleSkillDamageType.Heal);
            for (int i = 0; i < team.battleUnits.Count; ++i)
            {
                //无法行动的
                if (!team.battleUnits[i].CanAction)
                {
                    battleUnitInvalid.Add(team.battleUnits[i]);
                }

                //超出范围的
                else if (team.battleUnits[i].mapGrid.Distance(battleUnit.mapGrid) > skill.GetMaxReleaseRadiusForCalculate(releaser.mapGrid))
                {
                    distanceLimit.Add(team.battleUnits[i]);
                }

                //范围内的
                else
                {
                    suitableUnits.Add(team.battleUnits[i]);
                }
            }
        }
Exemplo n.º 3
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());
        }
Exemplo n.º 4
0
        public BattleSkillEffectAnalysis AnalyseBattleSkillEffect(SO_BattleSkill battleSkill, BattleUnit releaser = null, BattleUnit targetBattleUnit = null, GridUnit targetGridUnit = null)
        {
            battleSkillEffectAnalysis.Reset();

            if (releaser == null)
            {
                UtilityHelper.LogError("Analyse Battle Skill Effect error.Releaser is none.");
                return(null);
            }

            switch (battleSkill.targetType)
            {
            //对战斗单位
            case BattleSkillTargetType.BattleUnit:
                if (targetBattleUnit == null)
                {
                    return(null);
                }
                else
                {
                    battleSkillEffectAnalysis.battleSkill = battleSkill;
                    //记录主要影响
                    battleSkillEffectAnalysis.mainReceiver.Add(targetBattleUnit);
                    if (battleSkill.effectRadius > 0)
                    {
                        //暂时定为次要目标与主要目标同类
                        BattleTeam battleTeam = targetBattleUnit.battleField.GetBattleTeam(targetBattleUnit, true);
                        if (battleTeam != null)
                        {
                            for (int i = 0; i < battleTeam.battleUnits.Count; ++i)
                            {
                                if (!battleTeam.battleUnits[i].CanAction || battleTeam.battleUnits[i].Equals(targetBattleUnit))
                                {
                                    continue;
                                }
                                //有次要影响
                                if (battleTeam.battleUnits[i].mapGrid.Distance(targetBattleUnit.mapGrid) <= battleSkill.effectRadius)
                                {
                                    battleSkillEffectAnalysis.minorReceiver.Add(battleTeam.battleUnits[i]);
                                }
                            }
                        }
                    }
                }
                break;

            //对自己
            case BattleSkillTargetType.Self:
                battleSkillEffectAnalysis.battleSkill = battleSkill;
                //记录主要影响
                battleSkillEffectAnalysis.mainReceiver.Add(releaser);
                if (battleSkill.effectRadius > 0)
                {
                    //暂时定为次要目标与主要目标同类
                    BattleTeam battleTeam = releaser.battleField.GetBattleTeam(releaser, true);
                    if (battleTeam != null)
                    {
                        for (int i = 0; i < battleTeam.battleUnits.Count; ++i)
                        {
                            if (!battleTeam.battleUnits[i].CanAction || battleTeam.battleUnits[i].Equals(releaser))
                            {
                                continue;
                            }
                            //有次要影响
                            if (battleTeam.battleUnits[i].mapGrid.Distance(releaser.mapGrid) <= battleSkill.effectRadius)
                            {
                                battleSkillEffectAnalysis.minorReceiver.Add(battleTeam.battleUnits[i]);
                            }
                        }
                    }
                }
                break;

            //对某个地点
            case BattleSkillTargetType.GridUnit:
                if (targetGridUnit == null)
                {
                    return(null);
                }
                else
                {
                    battleSkillEffectAnalysis.battleSkill = battleSkill;
                    if (battleSkill.effectRadius > 0)
                    {
                        BattleTeam battleTeam = releaser.battleField.GetBattleTeam(releaser, battleSkill.damageType == BattleSkillDamageType.Heal);
                        if (battleTeam != null)
                        {
                            for (int i = 0; i < battleTeam.battleUnits.Count; ++i)
                            {
                                if (!battleTeam.battleUnits[i].CanAction || battleTeam.battleUnits[i].Equals(releaser))
                                {
                                    continue;
                                }
                                //记录主要影响
                                if (battleTeam.battleUnits[i].mapGrid.Distance(targetGridUnit) <= battleSkill.effectRadius)
                                {
                                    battleSkillEffectAnalysis.mainReceiver.Add(battleTeam.battleUnits[i]);
                                }
                            }
                        }
                    }
                }
                break;

            default:
                break;
            }

            return(battleSkillEffectAnalysis);
        }
Exemplo n.º 5
0
 //离开队伍
 public void QuitBattleTeam()
 {
     battleTeam = null;
 }
Exemplo n.º 6
0
 //进入队伍
 public void JoinBattleTeam(BattleTeam team)
 {
     battleTeam = team;
 }