Пример #1
0
        //点击了技能,在单体目标技能情况下
        private void OnBattleUnitAndGridTouched_StateSkill_SingleBattleUnitTarget(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //没有点中战斗单位
            if (battleUnitTouched == null)
            {
                return;
            }

            //点中了可以被使用技能的单位
            if (usedManualReleaseAnalysisor.suitableUnits.Contains(battleUnitTouched))
            {
                ManualSkill(battleUnitTouched);
            }

            //点中了超出距离的
            else if (usedManualReleaseAnalysisor.distanceLimit.Contains(battleUnitTouched))
            {
                UtilityHelper.Log("目标超出攻击范围");
            }

            //同一个队伍
            else if (usedManualReleaseAnalysisor.teamLimit.Contains(battleUnitTouched))
            {
                UtilityHelper.Log("不能对同一个队伍的单位使用这个技能");
            }

            else
            {
                UtilityHelper.Log("无效的目标单位");
            }
        }
        public int comboJudge(int skillType)
        {
            skillCombo.Enqueue(skillType);

            if (skillCombo.Count == EGameConstL.ComboCount)
            {
                int id = Check.checkCombo(skillCombo);
                //UpdatePrecombo(id);
                if (id >= 0)
                {
                    return(id);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                int id = Check.checkComboEarly(skillCombo);
                if (id >= 0)
                {
                    //UpdatePrecombo(id);
                    UtilityHelper.LogFormat("Wait for {0} more skills to fill combo", EGameConstL.ComboCount - skillCombo.Count);
                }
                else
                {
                    ClearPrecombo();
                    skillCombo.Clear();
                    UtilityHelper.Log("Combo error, start from first skill again");
                }

                return(-1);
            }
        }
Пример #3
0
        //点击了地块、战斗单位
        public void OnBattleUnitAndGridTouched(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //对应当前地图的操作状态
            switch (manualOperationState)
            {
            case ManualOperationState.Waiting:
                //当前为等待中
                UtilityHelper.Log("当前为等待中...");
                break;

            case ManualOperationState.Select:
                //当前为允许操作待选择
                OnBattleUnitAndGridTouched_StateSelect(gridTouched, battleUnitTouched);
                break;

            case ManualOperationState.Move:
                //当前为选择移动目标
                OnBattleUnitAndGridTouched_StateMove(gridTouched, battleUnitTouched);
                break;

            case ManualOperationState.Skill:
                //当前为技能使用判断
                OnBattleUnitAndGridTouched_StateSkill(gridTouched, battleUnitTouched);
                break;

            default:
                break;
            }
        }
Пример #4
0
        //根据combo类型释放效果

        /*300  力-力-力  攻击力提升
         * 030  速-速-速  bp+3
         * 003  技-技-技  命中+闪避+暴击
         *
         * 201  2力 + 1技 攻击力小幅提升2回合 + 触发第三下特殊伤害:推拉、流血等等
         * 210  2力 + 1速 攻击力小幅提升2回合 + 触发第三下特殊伤害:眩晕、禁足、减速等等
         * 102  2技 + 1力 命中/闪避/暴击小幅提升 + 触发第三次技能改变为暴击伤害
         * 012  2技 + 1速 命中/闪避/暴击小幅提升 + 触发第三次技能改变为强制优势伤害
         * 120  2速 + 1力 bp+1 + 二次攻击
         * 021  2速 + 1技 bp+1 + 二次移动
         * 111  1力 + 1速 + 1技 伤害免疫盾
         */
        private int ComboEffect(int comboID, SO_BattleUnitAttribute unitAttribute)
        {
            int comboResultSkill = 0;

            switch (comboID)
            {
            case 300:
                //battleUnitAttribute.UpdateAtk(EGameConstL.AtkIncrease);
                battleUnitAttribute.AddComboBuffEffect(comboID);
                UtilityHelper.Log("Combo Attack Power * 3 successful!");
                break;

            case 30:
                battleUnitAttribute.UpdateBP(EGameConstL.BPIncrease);
                battleUnitAttribute.AddComboBuffEffect(comboID);
                UtilityHelper.Log("Combo Attack Move * 3 successful!");
                break;

            case 3:
                battleUnitAttribute.IncreaseAbility();
                battleUnitAttribute.AddComboBuffEffect(comboID);
                UtilityHelper.Log("Combo Attack Skill * 3 successful!");
                break;

            case 201:
                ChangeGridEffectWork(5, unitAttribute);
                battleUnitAttribute.AddComboBuffEffect(comboID);
                UtilityHelper.Log("Combo Attack 2 Power 1 Skill successful!");
                break;

            case 210:
                battleUnitAttribute.AddComboBuffEffect(comboID);
                UtilityHelper.Log("Combo Attack 2 Power 1 Move successful!");
                break;

            case 102:
                UtilityHelper.Log("Combo Attack 1 Power 2 Skill successful!");
                break;

            case 12:
                UtilityHelper.Log("Combo Attack 1 Move 2 Skill successful!");
                break;

            case 120:
                UtilityHelper.Log("Combo Attack 1 Power 2 Move successful!");
                break;

            case 21:
                UtilityHelper.Log("Combo Attack 2 Move 1 Skill successful!");
                break;

            case 111:
                UtilityHelper.Log("Combo Attack Power + Move + Skill successful!");
                break;
            }
            battleUnitAttribute.skillComboActiveCheck();
            return(comboResultSkill);
        }
Пример #5
0
        public void Test_RemoteRange(GridUnit gridUnit)
        {
            if (releaserGrid == null)
            {
                releaserGrid = gridUnit;
                releaserGrid.gridUnitRenderer.AppendGridRenderType(GridRenderType.Start);

                battleField.battleMap.GetCircularGrids(releaserGrid.row, releaserGrid.column,
                                                       motionRadius, 0, true, releaseRange);

                foreach (var item in releaseRange)
                {
                    item.gridUnitRenderer.AppendGridRenderType(GridRenderType.SkillReleaseRange);
                }
            }
            else if (targetGrid == null)
            {
                UtilityHelper.TimerStart();

                targetGrid = gridUnit;
                targetGrid.gridUnitRenderer.AppendGridRenderType(GridRenderType.End);

                for (int i = 0; i < 1000; ++i)
                {
                    battleField.battleMap.GetCircularGrids(releaserGrid.row, releaserGrid.column,
                                                           motionRadius, 0, true, skillRange, delegate(GridUnit _gridUnit)
                    {
                        return(_gridUnit.Distance(targetGrid) <= effectRadius);
                    });
                }

                foreach (var item in skillRange)
                {
                    item.gridUnitRenderer.AppendGridRenderType(GridRenderType.SkillEffectRange);
                }

                UtilityHelper.Log("Test_RemoteRange cost:" + UtilityHelper.TimerEnd());
            }
            else
            {
                releaserGrid.gridUnitRenderer.ResetGridRenderType();
                targetGrid.gridUnitRenderer.ResetGridRenderType();
                foreach (var item in releaseRange)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
                foreach (var item in skillRange)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
                releaserGrid = null;
                targetGrid   = null;
                releaseRange.Clear();
                skillRange.Clear();
            }
        }
Пример #6
0
        //点击了技能,在单体带环绕的技能情况下
        private void OnBattleUnitAndGridTouched_StateSkill_SurroundBattleUnit(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //没有点中战斗单位
            if (battleUnitTouched == null)
            {
                return;
            }

            //是否是有效单位
            if (usedManualReleaseAnalysisor.suitableUnits.Contains(battleUnitTouched))
            {
                //重复点击同一个有效的战斗单位,则释放技能
                if (battleUnitTouched.battleUnitRenderer.Equals(selectedBattleUnitRenderer))
                {
                    ManualSkill(battleUnitTouched);
                    return;
                }
                else if (selectedBattleUnitRenderer != null)
                {
                    //取消选中
                    selectedBattleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Normal);
                }
                //显示新的范围
                selectedBattleUnitRenderer = battleUnitTouched.battleUnitRenderer;
                //范围内战斗单位设置为选中
                for (int i = 0; i < usedManualReleaseAnalysisor.suitableUnits.Count; ++i)
                {
                    if (usedManualReleaseAnalysisor.suitableUnits[i].mapGrid.Distance(gridTouched) <= usedManualReleaseAnalysisor.battleSkill.effectRadius)
                    {
                        usedManualReleaseAnalysisor.suitableUnits[i].battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Selected);
                    }
                }
                SetCircularRangeRenderStateActive(
                    true,
                    GridRenderType.SkillEffectRange,
                    gridTouched.row,
                    gridTouched.column,
                    usedManualReleaseAnalysisor.battleSkill.effectRadius);
            }
            //不是有效单位
            else if (usedManualReleaseAnalysisor.distanceLimit.Contains(battleUnitTouched))
            {
                UtilityHelper.Log("目标超出攻击范围");
            }

            //队伍不符合
            else if (usedManualReleaseAnalysisor.teamLimit.Contains(battleUnitTouched))
            {
                UtilityHelper.Log("不能对同一个队伍的单位使用这个技能");
            }

            else
            {
                UtilityHelper.Log("目标单位无效");
            }
        }
Пример #7
0
 //某个战斗单位点击了BP
 public void BattleUnitBP(BattleUnit battleUnit)
 {
     if (battleUnit.battleUnitAttribute.BPCanUse())
     {
         battleUnit.battleUnitAttribute.BPUsing();
     }
     else
     {
         UtilityHelper.Log("BP cannot used");
     }
 }
Пример #8
0
        private void Start()
        {
            //先自保
            DontDestroyOnLoad(this);

            UtilityHelper.Log("Main start.");

            UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks);

            //准备管理器
            PrepareBaseManager();
        }
Пример #9
0
        //点击了地块、战斗单位
        private void Test_Nav(GridUnit gridTouched)
        {
            if (start == null)
            {
                start = gridTouched;
                start.gridUnitRenderer.AppendGridRenderType(GridRenderType.Start);
            }
            else if (end == null)
            {
                end = gridTouched;
                end.gridUnitRenderer.AppendGridRenderType(GridRenderType.End);

                //Nav

                UtilityHelper.TimerStart();
                for (int i = 0; i < 1000; i++)
                {
                    //SetCircularRangeRenderStateActive(true, GridRenderType.SkillEffectRange, start.row, start.column, 3);
                    MapNavigator.Instance.Navigate(battleField.battleMap,
                                                   start,
                                                   end,
                                                   lastPath, null, -1, 2);
                }

                UtilityHelper.Log("TimeCost:" + UtilityHelper.TimerEnd());
                //foreach (var item in lastSearched)
                //{
                //    item.gridUnitRenderer.AppendGridRenderType(GridRenderType.Searched);
                //}
                foreach (var item in lastPath)
                {
                    item.gridUnitRenderer.AppendGridRenderType(GridRenderType.Path);
                }
            }
            else
            {
                start.gridUnitRenderer.ResetGridRenderType();
                end.gridUnitRenderer.ResetGridRenderType();
                foreach (var item in lastPath)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
                foreach (var item in lastSearched)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
                start = null;
                end   = null;
                SetCircularRangeRenderStateActive(false, GridRenderType.SkillEffectRange);
            }
        }
Пример #10
0
        private void OnItemClicked(PackageItem item)
        {
            if (item == null)
            {
                return;
            }

            if (battleUnitPackage != null &&
                battleUnitPackage.Owner != null &&
                BattleUnitPackage.Owner.CheckManualState(ManualActionState.SkillOrItem))
            {
                UtilityHelper.Log(string.Format("{0}使用了道具{1}", battleUnitPackage.Owner.battleUnitAttribute.name, item.item.itemName));
                battleUnitPackage.Owner.UseItem(item.item.itemID, 1);
            }
        }
Пример #11
0
        //点击了BP
        private void OnClickedBP()
        {
            if (battleUnit == null)
            {
                Close();
                return;
            }

            UtilityHelper.Log("choose to use BP now");

            if (BattleFieldRenderer.Instance)
            {
                BattleFieldRenderer.Instance.BattleUnitBP(battleUnit);
            }

            UpdateBPBtnState();
        }
        public void RemoveBuff(int buffID)
        {
            switch (buffID)
            {
            case 300:
                UpdateAtk(EGameConstL.AtkDecrease);
                UtilityHelper.Log("Combo Attack Power * 3 Remove!");
                break;

            case 30:
                UpdateBP(EGameConstL.BPDecrease);
                UtilityHelper.Log("Combo Attack Move * 3 Remove!");
                break;

            case 3:
                DecreaseAbility();
                UtilityHelper.Log("Combo Attack Skill * 3 Remove!");
                break;

            case 201:

                UtilityHelper.Log("Combo Attack 2 Power 1 Skill Remove!");
                break;

            case 210:
                UtilityHelper.Log("Combo Attack 2 Power 1 Move Remove!");
                break;

            case 102:
                UtilityHelper.Log("Combo Attack 1 Power 2 Skill Remove!");
                break;

            case 12:
                UtilityHelper.Log("Combo Attack 1 Move 2 Skill Remove!");
                break;

            case 120:
                UtilityHelper.Log("Combo Attack 1 Power 2 Move Remove!");
                break;

            case 21:
                UtilityHelper.Log("Combo Attack 2 Move 1 Skill Remove!");
                break;
            }
            return;
        }
Пример #13
0
        private void PrepareBattle()
        {
            UtilityHelper.Log("Prepare Battle");

            //界面
            UIViewManager.Instance.InitManager();

            //战斗相关
            BattleManager.Instance.InitManager();       //主
            BattleSkillManager.Instance.InitManager();  //战斗技能

            //特效管理器
            EffectManager.Instance.InitManager();

            //道具
            PackageItemManager.Instance.InitManager();
        }
Пример #14
0
 private void MouseOperation()
 {
     //如果点击了鼠标左键
     if (Input.GetMouseButtonDown(0))
     {
         if (EventSystem.current.IsPointerOverGameObject())
         {
             //点中了UI
             UtilityHelper.Log("点中了UI ->" + UnityEngine.EventSystems.EventSystem.current.gameObject.name);
             return;
         }
         ClickedBattleField(Input.mousePosition);
     }
     else if (Input.GetMouseButtonDown(1))
     {
         //右键点击为取消
         manualOperationHelper.ClickedCancel();
     }
 }
Пример #15
0
        private void Test_Range(GridUnit gridTouched)
        {
            if (lastUnits.Count > 0)
            {
                foreach (var item in lastUnits)
                {
                    item.gridUnitRenderer.ResetGridRenderType();
                }
            }

            UtilityHelper.TimerStart();
            for (int i = 0; i < 100; i++)
            {
                battleField.battleMap.GetCircularGrids(gridTouched.row, gridTouched.column, 3, 0, false, lastUnits);
            }

            UtilityHelper.Log("TimeCost:" + UtilityHelper.TimerEnd());
            foreach (var item in lastUnits)
            {
                item.gridUnitRenderer.AppendGridRenderType(GridRenderType.MoveRange);
            }
        }
Пример #16
0
        public static int checkComboEarly(Queue <int> skillCombo)
        {
            if (skillCombo.Count == 2)
            {
                /*
                 * int skill1 = skillCombo.Dequeue();
                 * int skill2 = skillCombo.Dequeue();
                 * for (int i = 0; i < ConfigReader.comboInfoDic.Count; i++)
                 * {
                 *  if (ConfigReader.comboInfoDic[i].skill1 == skill1 && ConfigReader.comboInfoDic[i].skill2 == skill2)
                 *  {
                 *
                 *      skillCombo.Enqueue(skill1);
                 *      skillCombo.Enqueue(skill2);
                 *      return i;
                 *  }
                 * }
                 */
                UtilityHelper.Log("We are in combo stage 2");
            }
            else if (skillCombo.Count == 1)
            {
                /*
                 * int skill1 = skillCombo.Dequeue();
                 * for (int i = 0; i < ConfigReader.comboInfoDic.Count; i++)
                 * {
                 *  if (ConfigReader.comboInfoDic[i].skill1 == skill1)
                 *  {
                 *
                 *      skillCombo.Enqueue(skill1);
                 *      return i;
                 *  }
                 * }
                 */
                UtilityHelper.LogFormat("We are in combo stage 1");
            }

            return(1);
        }
Пример #17
0
        //战斗结束
        private void BattleEnd()
        {
            if (battleState == BattleState.Exception)
            {
                UtilityHelper.LogError(string.Format("{0} battle error:", this.ToString()));
            }

            if (battleFieldRenderer != null)
            {
                battleFieldRenderer.BattleEnd();
            }

            UtilityHelper.Log(string.Format("<color=#ff0000> {0} battle end, step {1}.</color>\n{2}", this.ToString(), battleFieldEvents.Count, Desc()));

            //输出到csv
            if (!string.IsNullOrEmpty(BattleManager.Instance.brPath))
            {
                OutputBattleReport(BattleManager.Instance.brPath);
            }

            //生成战斗结果
            GenerateBattleResult();
        }
Пример #18
0
        //点击了技能按钮,则选中该技能
        private void OnClickedSkillItem()
        {
            //获取当前点击对象
            string btnName  = EventSystem.current.currentSelectedGameObject.name;
            int    skillIdx = -1;

            if (int.TryParse(btnName.Replace(EGameConstL.STR_SkillBtn, string.Empty), out skillIdx))
            {
                SkillConfigInfo skill = ConfigReader.skillInfoDic[skillIdx];
                if (chosedSkill.ContainsKey(skill.id))
                {
                    UtilityHelper.Log("Already choose that skill");
                }
                else
                {
                    chosedSkill.Add(skill.id, skill);
                    ShowChosedSkillPanle();
                }
            }
            else
            {
                UtilityHelper.LogError("Skill item name error ->" + btnName);
            }
        }
Пример #19
0
 public void Start()
 {
     UtilityHelper.Log("go into lobby awake");
     InitUIObjects();
 }
Пример #20
0
 private void showUI(BaseEventData data)
 {
     UtilityHelper.Log("We are enter in battle unit and wait for operation");
 }
Пример #21
0
        public static Dictionary <int, ComboConfigInfo> ReadSkillComboConfigFromXml(string xmlFilePath)
        {
            //UtilityHelper.Log("begin reading combo xml file");
            //TextAsset xmlfile = Resources.Load(xmlFilePath) as TextAsset;

            XmlDocument xmlDoc = null;
            Dictionary <int, ComboConfigInfo> comboInfoDic = new Dictionary <int, ComboConfigInfo>();
            Object       asset       = Resources.Load(xmlFilePath);
            ResourceUnit xmlfileUnit = new ResourceUnit(null, 0, asset, null, ResourceType.ASSET);
            TextAsset    xmlfile     = xmlfileUnit.Asset as TextAsset;

            if (!xmlfile)
            {
                return(comboInfoDic);
            }
            UtilityHelper.Log("read combo xml successful");
            xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xmlfile.text);
            XmlNodeList infoNodeList = xmlDoc.SelectSingleNode("ComboSkill").ChildNodes;

            for (int i = 0; i < infoNodeList.Count; i++)
            {//(XmlNode xNode in infoNodeList)
                if ((infoNodeList[i] as XmlElement).GetAttributeNode("un32ID") == null)
                {
                    continue;
                }

                string typeName = (infoNodeList[i] as XmlElement).GetAttributeNode("un32ID").InnerText;
                //Debug.LogError(typeName);
                ComboConfigInfo comboInfo = new ComboConfigInfo();
                comboInfo.id = (int)Convert.ToUInt32(typeName);
                foreach (XmlElement xEle in infoNodeList[i].ChildNodes)
                {
                    #region 搜索
                    switch (xEle.Name)
                    {
                    case "Name":
                    {
                        comboInfo.name = Convert.ToString(xEle.InnerText);
                    }
                    break;

                    case "skill1":
                    {
                        comboInfo.skill1 = Convert.ToInt32(xEle.InnerText);
                    }
                    break;

                    case "skill2":
                    {
                        comboInfo.skill2 = Convert.ToInt32(xEle.InnerText);
                    }
                    break;

                    case "skill3":
                    {
                        comboInfo.skill3 = Convert.ToInt32(xEle.InnerText);
                    }
                    break;

                    case "effect":
                    {
                        comboInfo.effect = Convert.ToInt32(xEle.InnerText);
                    }
                    break;
                    }

                    #endregion
                }
                comboInfoDic.Add(i, comboInfo);
                //UtilityHelper.LogFormat("add {0} with skill1 = {1}, skill2 = {2}, skill3 = {3}", comboInfo.id, comboInfo.skill1,
                //comboInfo.skill2, comboInfo.skill3);
            }

            return(comboInfoDic);
        }
Пример #22
0
        public static Dictionary <int, SkillConfigInfo> ReadSkillConfigFromXml(string xmlFilePath)
        {
            Dictionary <int, SkillConfigInfo> skillInfoDic = new Dictionary <int, SkillConfigInfo>();
            XmlDocument xmlDoc = null;
            //TextAsset xmlfile = Resources.Load(xmlFilePath) as TextAsset;

            //UtilityHelper.LogFormat("begin reading skill xml file from {0}", xmlFilePath);
            Object       asset       = Resources.Load(xmlFilePath);
            ResourceUnit xmlfileUnit = new ResourceUnit(null, 0, asset, null, ResourceType.ASSET);
            TextAsset    xmlfile     = xmlfileUnit.Asset as TextAsset;

            if (!xmlfile)
            {
                return(skillInfoDic);
            }
            UtilityHelper.Log("read skill xml successful");

            xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xmlfile.text);
            XmlNodeList infoNodeList = xmlDoc.SelectSingleNode("SkillCfg").ChildNodes;

            for (int i = 0; i < infoNodeList.Count; i++)
            {//(XmlNode xNode in infoNodeList)
                if ((infoNodeList[i] as XmlElement).GetAttributeNode("un32ID") == null)
                {
                    continue;
                }

                string typeName = (infoNodeList[i] as XmlElement).GetAttributeNode("un32ID").InnerText;
                //Debug.LogError(typeName);
                SkillConfigInfo skillInfo = new SkillConfigInfo();
                skillInfo.id = (int)Convert.ToUInt32(typeName);
                foreach (XmlElement xEle in infoNodeList[i].ChildNodes)
                {
                    #region 搜索
                    switch (xEle.Name)
                    {
                    case "Name":
                    {
                        skillInfo.name = Convert.ToString(xEle.InnerText);
                    }
                    break;

                    case "SkillIcon":
                    {
                        skillInfo.icon = Convert.ToString(xEle.InnerText);
                    }
                    break;

                    case "ReleaseRadius":
                    {
                        skillInfo.releaseRadius = Convert.ToInt32(xEle.InnerText);
                    }
                    break;

                    case "EffectRadius":
                    {
                        skillInfo.effectRadius = Convert.ToInt32(xEle.InnerText);
                    }
                    break;

                    case "DamageType":
                    {
                        skillInfo.damageType = Convert.ToInt32(xEle.InnerText);
                    }
                    break;

                    case "TargetType":
                    {
                        skillInfo.targetType = Convert.ToInt32(xEle.InnerText);
                    }
                    break;

                    case "mainValue":
                    {
                        skillInfo.mainValue = Convert.ToInt32(xEle.InnerText);
                    }
                    break;

                    case "ReleaseAction":
                    {
                        skillInfo.action = Convert.ToString(xEle.InnerText);
                    }
                    break;

                    case "ReleaseSound":
                    {
                        skillInfo.sound = Convert.ToString(xEle.InnerText);
                    }
                    break;

                    case "info":
                        skillInfo.info = Convert.ToString(xEle.InnerText);
                        break;
                    }

                    #endregion
                }
                skillInfoDic.Add(skillInfo.id, skillInfo);
                //Debug.LogError("add buff" + buffInfo.BuffID);
            }

            return(skillInfoDic);
        }
Пример #23
0
        //使用技能
        public void UseSkill(SO_BattleSkill battleSkill, BattleUnit targetBattleUnit = null, GridUnit targetGridUnit = null)
        {
            if (battleSkill == null)
            {
                UtilityHelper.LogError("Use skill error. Battle skill is none.");
                return;
            }

            GridUnit temp = targetGridUnit;

            if (temp == null && targetBattleUnit != null)
            {
                temp = targetBattleUnit.mapGrid;
            }
            if (temp != null && mapGrid.Distance(temp) > battleSkill.GetReleaseRadius(mapGrid))
            {
                return;
            }

            BattleSkillEffectAnalysis analysis = BattleCalculator.Instance.AnalyseBattleSkillEffect(battleSkill, this, targetBattleUnit, targetGridUnit);

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

            skillResults.Clear();

            //主要影响
            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));
            }

            //连招combo统计
            if (battleUnitAttribute.manualOperation)
            {
                UtilityHelper.Log("Check combo now");

                //返回真表示连招成立,则调用连招效果
                int comboID = battleUnitAttribute.comboJudge((int)battleSkill.damageType);
                if (comboID != -1)
                {
                    //对于即时生效的技能需要直接改变skillResult
                    ComboEffect(comboID, battleUnitAttribute);
                }
            }

            //产生使用技能的动作
            BattleUnitSkillAction skillAction = BattleUnitActionEvent.CreateEvent <BattleUnitSkillAction>(BattleUnitActionType.UseSkill, this);

            skillAction.battleSkill      = battleSkill;
            skillAction.skillResult      = skillResults.ToArray();
            skillAction.targetBattleUnit = targetBattleUnit;
            skillAction.targetGrid       = targetGridUnit;
            skillAction.selfAttribute    = BattleSkillCostEnergy(battleSkill);
            battleField.AppendBattleAction(skillAction);

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

                //产生仇恨
                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;
                        }

                        //每个战斗单位都需要知道发生了什么
                        if (!enemyTeam.battleUnits[j].battleUnitAttribute.manualOperation)
                        {
                            enemyTeam.battleUnits[j].battleBehaviourSystem.RecordSkillResult(this, skillResults[i]);
                        }
                    }
                }
            }
        }
Пример #24
0
        //点击了地块、战斗单位 -- 在当前是选择移动目标的情况下
        private void OnBattleUnitAndGridTouched_StateMove(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //点中了战斗单位
            if (battleUnitTouched != null)
            {
                //显示战斗单位的详情
                UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
            }
            //点中了地图
            else
            {
                //障碍物不能作为移动目标(暂时)
                if (gridTouched.GridType == GridType.Obstacle)
                {
                    UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
                }
                else
                {
                    //点击是否超出了范围
                    GridUnit fromGrid = manualOperatingBattleUnitRenderer.battleUnit.mapGrid;
                    if (fromGrid.Distance(gridTouched) > manualOperatingBattleUnitRenderer.battleUnit.battleUnitAttribute.mobility)
                    {
                        UtilityHelper.Log("超出了移动半径!");
                        UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
                    }
                    else
                    {
                        MapNavigator.Instance.NewNavigate(
                            manualOperatingBattleUnitRenderer.battleUnit,
                            fieldRenderer.battleField.battleMap,
                            fromGrid,
                            gridTouched,
                            UtilityObjs.gridUnits);
                        //判断移动是否可以到达
                        //bool result = MapNavigator.Instance.Navigate(
                        //    fieldRenderer.battleField.battleMap,
                        //    fromGrid,
                        //    gridTouched,
                        //    UtilityObjs.gridUnits,
                        //    null,
                        //    manualOperatingBattleUnitRenderer.battleUnit.battleUnitAttribute.mobility
                        //    );

                        bool result = MapNavigator.Instance.NewNavigate(
                            manualOperatingBattleUnitRenderer.battleUnit,
                            fieldRenderer.battleField.battleMap,
                            fromGrid,
                            gridTouched,
                            UtilityObjs.gridUnits);

                        //判断是否可以到达(导航成功且可以可以到达)
                        if (result && UtilityObjs.gridUnits[UtilityObjs.gridUnits.Count - 1].Equals(gridTouched))
                        {
                            //可以到达
                            ManualMoveTo(gridTouched, UtilityObjs.gridUnits.ToArray());
                            UtilityObjs.gridUnits.Clear();
                        }
                        else
                        {
                            //不可以到达
                            UtilityHelper.Log("点击位置不可到达!");
                            UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
                        }
                    }
                }
            }
        }
Пример #25
0
        //开始战斗
        private void Fight()
        {
            battleState = BattleState.Fighting;

            BattleUnit actionUnit = null;

            do
            {
                //连接渲染器,则一步一更新
                //没有连接渲染器,则一直计算直到结束
                actionUnit = actionQueue.Peek();
                if (firstFight)
                {
                    firstFight = false;
                }
                else
                {
                    if (actionUnit.BPStage)
                    {
                        UtilityHelper.Log("We are in BP stage, continue to fight");
                        actionUnit.battleUnitAttribute.BPUsed();
                    }
                    else
                    {
                        UtilityHelper.Log("change queue order");
                        if (actionUnit.battleUnitAttribute.BPUsingStage())
                        {
                            actionUnit.battleUnitAttribute.OutOfBPAction();
                        }
                        actionQueue.Dequeue();
                        CalculateNextAction(actionUnit);
                        actionUnit = actionQueue.Peek();
                    }
                }

                //增加BP值
                if (actionUnit.battleUnitAttribute.manualOperation &&
                    actionUnit.battleUnitAttribute.BPUsingStage() == false)
                {
                    if (actionUnit.battleUnitAttribute.BP < EGameConstL.BPMax)
                    {
                        actionUnit.battleUnitAttribute.BP++;
                    }
                }

                if (actionUnit == null)
                {
                    battleState = BattleState.End;
                    break;
                }

                if (actionUnit.CanAction)
                {
                    HeroActionState state = actionUnit.BattleAction();

                    switch (state)
                    {
                    case HeroActionState.Normal:
                        battleState = BattleState.Fighting;
                        break;

                    case HeroActionState.WaitForPlayerChoose:
                        battleState = BattleState.WaitForPlayer;
                        break;

                    case HeroActionState.Error:
                        battleState = BattleState.Exception;
                        break;

                    case HeroActionState.Warn:
                        battleState = BattleState.Exception;
                        UtilityHelper.LogWarning(string.Format("Warning: battle action state warning -> {0}", actionUnit.ToString()));
                        break;

                    default:
                        break;
                    }
                }

                if (battleFieldEvents.Count > EGameConstL.BattleFieldMaxActions)
                {
                    UtilityHelper.LogError("Battle actions overflow max limit.");
                    battleState = BattleState.Exception;
                }
                else
                {
                    //只在这种情况下做战斗结束的判断
                    if (!actionUnit.CanAction ||
                        actionUnit.targetBattleUnit == null ||
                        !actionUnit.targetBattleUnit.CanAction)
                    {
                        CheckBattleEnd();
                    }
                }
            } while (battleFieldRenderer == null &&
                     battleState != BattleState.End &&
                     battleState != BattleState.Exception);

            //连接了渲染器,一步一表现
            if (battleFieldRenderer != null)
            {
                if (battleState == BattleState.WaitForPlayer)
                {
                    battleFieldRenderer.PlayBattle(null);
                }

                else
                {
                    battleFieldRenderer.PlayBattle(Run);
                }
            }
            else
            {
                Run();
            }
        }
Пример #26
0
        //点击了技能,在以固定地点为原点的技能情况下
        private void OnBattleUnitAndGridTouched_StateSkill_GridUnitTarget(GridUnit gridTouched, BattleUnit battleUnitTouched)
        {
            //如果当前有点中的格子
            if (selectedGridUnitRenderer != null &&
                (selectedGridUnitRenderer.Equals(gridTouched.gridUnitRenderer) || usedManualReleaseAnalysisor.battleSkill.GetReleaseRadius(usedManualReleaseAnalysisor.releaser.mapGrid) <= 0))
            {
                //如果当前的释放距离为0,表示无需二次点击确认,直接释放
                if (usedManualReleaseAnalysisor.battleSkill.GetReleaseRadius(usedManualReleaseAnalysisor.releaser.mapGrid) <= 0)
                {
                    ManualSkill(manualOperatingBattleUnitRenderer.battleUnit.mapGrid);
                    return;
                }

                //点中了重复的格子,判断是否有目标
                bool hasTarget = false;
                for (int i = 0; i < usedManualReleaseAnalysisor.suitableUnits.Count; ++i)
                {
                    if (usedManualReleaseAnalysisor.suitableUnits[i].mapGrid.Distance(gridTouched) <= usedManualReleaseAnalysisor.battleSkill.effectRadius)
                    {
                        hasTarget = true;
                        break;
                    }
                }
                //有目标,则释放
                if (hasTarget)
                {
                    ManualSkill(gridTouched);
                }
                else
                {
                    UtilityHelper.Log("范围内没有目标");
                }
            }
            else
            {
                //这个格子不在范围内
                if (manualOperatingBattleUnitRenderer.battleUnit.mapGrid.Distance(gridTouched) <= usedManualReleaseAnalysisor.battleSkill.GetReleaseRadius(usedManualReleaseAnalysisor.releaser.mapGrid))
                {
                    if (selectedGridUnitRenderer != null)
                    {
                        //取消上一个范围显示
                        SetCircularRangeRenderStateActive(false, GridRenderType.SkillEffectRange);
                        //取消可被攻击单位的显示
                        for (int i = 0; i < usedManualReleaseAnalysisor.suitableUnits.Count; ++i)
                        {
                            usedManualReleaseAnalysisor.suitableUnits[i].battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Normal);
                        }
                    }
                    //设置新的范围显示
                    selectedGridUnitRenderer = gridTouched.gridUnitRenderer;
                    SetCircularRangeRenderStateActive(
                        true,
                        GridRenderType.SkillEffectRange,
                        gridTouched.row,
                        gridTouched.column,
                        usedManualReleaseAnalysisor.battleSkill.effectRadius
                        );
                    //设置新的可被攻击单位的显示
                    for (int i = 0; i < usedManualReleaseAnalysisor.suitableUnits.Count; ++i)
                    {
                        if (usedManualReleaseAnalysisor.suitableUnits[i].mapGrid.Distance(gridTouched) <= usedManualReleaseAnalysisor.battleSkill.effectRadius)
                        {
                            usedManualReleaseAnalysisor.suitableUnits[i].battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Selected);
                        }
                    }
                }
                else
                {
                    UtilityHelper.Log("超出区域");
                    UIViewManager.Instance.ShowView(UIViewName.BattleFieldUnitInfo, gridTouched, battleUnitTouched);
                }
            }
        }
Пример #27
0
 public virtual void InitManager()
 {
     UtilityHelper.Log(string.Format("--> {0} <-- inited.", MgrName));
 }
Пример #28
0
        public static GridUnit[] ReadScene1LocationFromXml(BattleMap map, string xmlFilePath, int teamKind, int gridCount)
        {
            GridUnit[] bornGrids = new GridUnit[gridCount];
            int        x = 0, y = 0;
            //GridUnit tmpGrid = new GridUnit(map, 0, 0);
            XmlDocument xmlDoc = null;
            //TextAsset xmlfile = Resources.Load(xmlFilePath) as TextAsset;

            //UtilityHelper.LogFormat("begin reading skill xml file from {0}", xmlFilePath);
            Object       asset       = Resources.Load(xmlFilePath);
            ResourceUnit xmlfileUnit = new ResourceUnit(null, 0, asset, null, ResourceType.ASSET);
            TextAsset    xmlfile     = xmlfileUnit.Asset as TextAsset;

            if (!xmlfile)
            {
                return(bornGrids);
            }
            UtilityHelper.Log("read scene 1 location xml successful");

            xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xmlfile.text);
            XmlNodeList infoNodeList = xmlDoc.SelectSingleNode("Locations").ChildNodes;

            for (int i = 0; i < infoNodeList.Count; i++)
            {//(XmlNode xNode in infoNodeList)
                if ((infoNodeList[i] as XmlElement).GetAttributeNode("un32ID") == null)
                {
                    continue;
                }

                string typeName = (infoNodeList[i] as XmlElement).GetAttributeNode("un32ID").InnerText;
                int    id       = (int)Convert.ToUInt32(typeName);

                if (id != teamKind)
                {
                    continue;
                }

                foreach (XmlElement xEle in infoNodeList[i].ChildNodes)
                {
                    switch (xEle.Name)
                    {
                    case "row":
                    {
                        x = Convert.ToInt32(xEle.InnerText);
                    }
                    break;

                    case "column":
                    {
                        y = Convert.ToInt32(xEle.InnerText);
                    }
                    break;
                    }
                }

                //tmpGrid.localPosition = new Vector3((tmpGrid.column + 1)* EGameConstL.Map_GridWidth, -(tmpGrid.row + 1)* EGameConstL.Map_GridOffsetY, 0);
                //Debug.LogFormat("i = {0}, row = {1}, column = {2}, position = {3}", i, tmpGrid.row, tmpGrid.column, tmpGrid.localPosition);
                //Debug.LogFormat("i = {0}, row = {1}, column = {2}, position = {3}", i, x, y, map.mapGrids[y, x].localPosition);
                if (teamKind == 0)
                {
                    bornGrids[i] = map.mapGrids[y, x];
                }
                else if (teamKind == 1)
                {
                    bornGrids[i - 1] = map.mapGrids[y, x];
                }
            }
            return(bornGrids);
        }