public IEnumerator IEStartSkill(BattleRoleData source, BattleRoleData target, int dmgVal) { source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_cast, false); SLEffectManager.Instance.playCommonEffectCast(source.transform.position); yield return(new WaitForSeconds(castLastTime)); source.playBulletCastAnimation(bullet, source.unit_model.position, target.unit_model.position); yield return(new WaitForSeconds(bulletLastTime)); #region 计算技能状态 source.SkillCheck(this, target); IsCausedCritDmg = source.CritHappen; IsCausedMiss = !source.AccurHappen; IsCausedFault = source.FaultHappen; float criD = 1; if (IsCausedCritDmg) { criD = AllRandomSetClass.SimplePercentToDecimal (source.ThisBasicRoleProperty().CRIDmg + 100); } int NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); #endregion dmgVal = (int)(dmgVal * criD); dmgVal += NowExpect; Debug.Log(source.name + "shoot cause" + dmgVal + " damage to " + target.name); //source.unit_character_model.CurrentCharacterModel.ChangeModelAnim(SDConstants.AnimName_IDLE, true); #region 输技能状态 target.HpController.isCriDmg = IsCausedCritDmg; target.HpController.isEvoHappen = IsCausedMiss; target.HpController.isFault = IsCausedFault; #endregion dmgVal = (int)(dmgVal * AllRandomSetClass.SimplePercentToDecimal(100 + target.PhysModify)); target.HpController.getDamage(dmgVal, _skillKind); yield return(new WaitForSeconds(skillLastTime)); StartCoroutine(IEWaitForEnd(source)); }
public IEnumerator IEStartSkill(BattleRoleData source, BattleRoleData target) { source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_cast, false); SLEffectManager.Instance.playCommonEffectCast(source.transform.position); yield return(new WaitForSeconds(castLastTime)); List <BattleRoleData> list = DealWithAOEAction(source, target, AOEType); for (int i = 0; i < list.Count; i++) { stateWork(source, list[i]); if (_standardState.Success) { Debug.Log("成功为 " + target.name + " 添加状态 " + _standardState.NAME); } } yield return(new WaitForSeconds(skillLastTime)); StartCoroutine(IEWaitForEnd(source)); }
public void stateWork(BattleRoleData source, BattleRoleData target) { if (UseState && !stateCantWork) { if (_standardState != null) { SDConstants.AOEType aoe = _standardState.StateAOE; if (_standardState.AimAtSelf) { target = source; stateCantWork = true; List <BattleRoleData> list = DealWithAOEAction(source, target , _standardState.StateAOE); _standardState.StartState(this, source, target); } else { if (aoe == SDConstants.AOEType.None || aoe == SDConstants.AOEType.Continuous2 || aoe == SDConstants.AOEType.Continuous3) { _standardState.StartState(this, source, target); } else { stateCantWork = true; List <BattleRoleData> list = DealWithAOEAction(source, target , _standardState.StateAOE); foreach (BattleRoleData unit in list) { _standardState.StartState(this, source, unit); } } } } } }
/// <summary> /// 敌人释放技能时判定目标 /// </summary> public void chooseRandomHeroToAttack() { //Debug.Log("敌方:" + _currentBattleUnit.name + " 自动选择目标"); _currentSkill = _currentActionPanel.CurrentSkill; if (_currentSkill.ThisSkillAim == SkillAim.Other) { _currentTargetUnit = Remaining_SRL[TauntFunction()]; _currentTUType = SDConstants.CharacterType.Hero; } else { if (_currentSkill.ThisSkillAim == SkillAim.Self || _currentSkill.ThisSkillAim == SkillAim.All) { _currentTargetUnit = _currentBattleUnit; } else { int _rand = UnityEngine.Random.Range(0, Remaining_ORL.Count); _currentTargetUnit = Remaining_ORL[_rand]; _currentTUType = SDConstants.CharacterType.Enemy; } } }
public void BattleInit() { SDGameManager.Instance.isGaming = true; IsWaitingPlayerAction = false; All_Array = new List <BattleRoleData>(); AllSRL_Array = new List <BattleRoleData>(); AllORL_Array = new List <BattleRoleData>(); Remaining_SRL = new List <BattleRoleData>(); Remaining_ORL = new List <BattleRoleData>(); GameObject[] heros = GameObject.FindGameObjectsWithTag(SDConstants.HERO_TAG); GameObject[] enemies = GameObject.FindGameObjectsWithTag(SDConstants.ENEMY_TAG); foreach (GameObject obj in heros) { BattleRoleData unit = obj.GetComponentInParent <BattleRoleData>(); unit.BM = this; AllSRL_Array.Add(unit); if (!unit.IsDead) { Remaining_SRL.Add(unit); } All_Array.Add(unit); } foreach (GameObject obj in enemies) { BattleRoleData unit = obj.GetComponentInParent <BattleRoleData>(); unit.BM = this; AllORL_Array.Add(unit); if (!unit.IsDead) { Remaining_ORL.Add(unit); } All_Array.Add(unit); } ListUnitActionOrder(); ABM.initAction(All_Array); GC.checkHeroesStatus(); }
/// <summary> /// 技能消耗 /// </summary> /// <param name="source"></param> /// <param name="target"></param> public virtual void CalculateBeforeFunction(BattleRoleData source, BattleRoleData target) { int BC = BCCostPerTime; BC += BCCostPerLevel * source.ThisBasicRoleProperty().LEVEL; BC += BCCostPerSkillGrade * skillgrade; BC += (int)(BCCostUsingPercent * source.MpController.maxMp * 0.01f); // if (IsOmega) { BC = source.MpController.maxMp; } // source.MpController.consumeMp(BC); // if (GetComponent <HSkilInfo>()) { UseSkillAddMpTp(source, GetComponent <HSkilInfo>().AfterwardsAddType); } else { UseSkillAddMpTp(source, SDConstants.AddMpTpType.PreferMp); } }
public void addEnemy(string enemyId, int index, int rareWeight, bool isBoss = false) { Transform s; if (isBoss) { s = Instantiate(bossPrefab) as Transform; } else { s = Instantiate(enemyPrefab) as Transform; } s.localScale = Vector3.zero; s.SetParent(enemyParent); s.position = getPosByIndex(index, true); s.name = SDConstants.ENEMY_TAG + enemyId + "POS" + index; BattleRoleData unit = s.GetComponent <BattleRoleData>(); unit.posIndex = index + SDConstants.MaxSelfNum; //unit.sidePosId = index; unit.rareWeight = rareWeight; unit.initEnemyController(enemyId); StartCoroutine(IEShowEnemyBornAnim(s)); }
public bool CheckIfCanConsume(BattleRoleData source) { if (IsOmega) { if (source.MpController.currentMp < source.MpController.maxMp) { Debug.Log("无法消耗足量法力"); return(false); } } else { int bc = BCCostPerTime + BCCostPerLevel * source.ThisBasicRoleProperty().LEVEL + BCCostPerSkillGrade * skillgrade + (int)(BCCostUsingPercent * source.MpController.maxMp * 0.01f); if (source.MpController.currentMp < bc && bc > 0) { Debug.Log("无法消耗足量法力"); return(false); } } Debug.Log("技能消耗符合条件"); return(true); }
public List <BattleRoleData> DealWithAOEAction (bool targetIsHero, SDConstants.AOEType AOE, bool isRevive = false) { if (!BM) { BM = FindObjectOfType <BattleManager>(); } List <BattleRoleData> results = new List <BattleRoleData>(); List <BattleRoleData> All; BattleRoleData target; if (isRevive) { All = targetIsHero ? BM.AllSRL_Array : BM.AllORL_Array; List <BattleRoleData> _all = All.FindAll(x => x.IsDead); All = _all; target = All[UnityEngine.Random.Range(0, All.Count)]; } else { All = targetIsHero ? BM.Remaining_SRL : BM.Remaining_ORL; target = All[UnityEngine.Random.Range(0, All.Count)]; } if (AOE == SDConstants.AOEType.None) { //this.StartSkill(source, target); results.Add(target); } else if (AOE == SDConstants.AOEType.Horizontal) { string _N = target.gameObject.name; if (_N.Contains("POS8")) { results.Add(target); } else { Transform _parent = target.transform.parent; for (int i = 0; i < _parent.childCount; i++) { if (_N.Contains("POS0") || _N.Contains("POS2") || _N.Contains("POS6") || _N.Contains("POS4") || _N.Contains("POS5")) { string N = _parent.GetChild(i).name; if (N.Contains("POS0") || N.Contains("POS2") || N.Contains("POS6") || N.Contains("POS4") || N.Contains("POS5") || N.Contains("POS8")) { BattleRoleData unit0 = _parent.GetChild(i).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } } } else if (_N.Contains("POS1") || _N.Contains("POS3") || _N.Contains("POS7") || _N.Contains("POS4") || _N.Contains("POS5")) { string N = _parent.GetChild(i).name; if (N.Contains("POS1") || N.Contains("POS3") || N.Contains("POS7") || N.Contains("POS4") || N.Contains("POS5") || N.Contains("POS8")) { BattleRoleData unit0 = _parent.GetChild(i).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } } } } } } else if (AOE == SDConstants.AOEType.Horizontal1) { Transform _parent = target.transform.parent; for (int i = 0; i < _parent.childCount; i++) { string N = _parent.GetChild(i).name; if (N.Contains("POS0") || N.Contains("POS2") || N.Contains("POS6") || N.Contains("POS4") || N.Contains("POS5") || N.Contains("POS8")) { BattleRoleData unit0 = _parent.GetChild(i).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } } } } else if (AOE == SDConstants.AOEType.Horizontal2) { Transform _parent = target.transform.parent; for (int i = 0; i < _parent.childCount; i++) { string N = _parent.GetChild(i).name; if (N.Contains("POS1") || N.Contains("POS3") || N.Contains("POS7") || N.Contains("POS4") || N.Contains("POS5") || N.Contains("POS8")) { BattleRoleData unit0 = _parent.GetChild(i).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } } } } else if (AOE == SDConstants.AOEType.Vertical) { string _N = target.gameObject.name; if (_N.Contains("POS8")) { results.Add(target); } else { Transform _parent = target.transform.parent; for (int i = 0; i < _parent.childCount; i++) { //bool exit = false; if (_N.Contains("POS2") || _N.Contains("POS3") || _N.Contains("POS5") || _N.Contains("POS6") || _N.Contains("POS7")) { string N = _parent.GetChild(i).name; if (N.Contains("POS2") || N.Contains("POS3") || N.Contains("POS5") || N.Contains("POS6") || N.Contains("POS7") || N.Contains("POS8")) { BattleRoleData unit0 = _parent.GetChild(i).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } } } else if (_N.Contains("POS0") || _N.Contains("POS1") || _N.Contains("POS4") || _N.Contains("POS6") || _N.Contains("POS7")) { string N = _parent.GetChild(i).name; if (N.Contains("POS0") || N.Contains("POS1") || N.Contains("POS4") || N.Contains("POS6") || N.Contains("POS7") || N.Contains("POS8")) { BattleRoleData unit0 = _parent.GetChild(i).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } } } } } } else if (AOE == SDConstants.AOEType.Vertical1) { Transform _parent = target.transform.parent; for (int i = 0; i < _parent.childCount; i++) { string N = _parent.GetChild(i).name; if (N.Contains("POS2") || N.Contains("POS3") || N.Contains("POS5") || N.Contains("POS6") || N.Contains("POS7") || N.Contains("POS8")) { BattleRoleData unit0 = _parent.GetChild(i).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } } } } else if (AOE == SDConstants.AOEType.Vertical2) { Transform _parent = target.transform.parent; for (int i = 0; i < _parent.childCount; i++) { string N = _parent.GetChild(i).name; if (N.Contains("POS0") || N.Contains("POS1") || N.Contains("POS4") || N.Contains("POS6") || N.Contains("POS7") || N.Contains("POS8")) { BattleRoleData unit0 = _parent.GetChild(i).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } } } } else if (AOE == SDConstants.AOEType.All) { BattleRoleData[] list = target.transform.parent .GetComponentsInChildren <BattleRoleData>(); for (int i = 0; i < list.Length; i++) { bool flag = false; if (list[i].IsDead && isRevive) { flag = true; } else if (!list[i].IsDead) { flag = true; } if (flag) { //this.StartSkill(source, list[i]); results.Add(list[i]); } } } else if (AOE == SDConstants.AOEType.Random1)//随机选择一个 { List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } List <int> _results = RandomIntger.NumListReturn(1, list.Count); for (int i = 0; i < _results.Count; i++) { //this.StartSkill(source, BM.All_Array[list[_results[i]]]); results.Add(BM.All_Array[list[_results[i]]]); } } else if (AOE == SDConstants.AOEType.Random2) { List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } List <int> _results = RandomIntger.NumListReturn(2, list.Count); for (int i = 0; i < _results.Count; i++) { results.Add(BM.All_Array[list[_results[i]]]); //this.StartSkill(source, BM.All_Array[list[_results[i]]]); } } else if (AOE == SDConstants.AOEType.Random3) { List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } List <int> _results = RandomIntger.NumListReturn(3, list.Count); for (int i = 0; i < _results.Count; i++) { results.Add(BM.All_Array[list[_results[i]]]); //this.StartSkill(source, BM.All_Array[list[_results[i]]]); } } else if (AOE == SDConstants.AOEType.Continuous2) { results.Add(target); List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } int index = UnityEngine.Random.Range(0, list.Count); results.Add(BM.All_Array[list[index]]); } else if (AOE == SDConstants.AOEType.Continuous3) { results.Add(target); List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } int index = UnityEngine.Random.Range(0, list.Count); results.Add(BM.All_Array[list[index]]); index = UnityEngine.Random.Range(0, list.Count); results.Add(BM.All_Array[list[index]]); } else { results.Add(target); //this.StartSkill(source, target); } return(results); }
//关卡开始时初始化所有行动单元,赋予速度 public void initAction(List <BattleRoleData> allUnits) { stopAction(); foreach (Transform t in actionUnitParent) { Destroy(t.gameObject); } // standardSpeedArray = new int[allUnits.Count]; allActionUnits = new List <ActionRoleData>(); for (int i = 0; i < allUnits.Count; i++) { BattleRoleData BUnit = allUnits[i]; Transform actionUnit = Instantiate(actionUnitPrefab) as Transform; actionUnit.SetParent(actionUnitParent); actionUnit.GetComponent <ActionRoleData>().nameText.text = BUnit.name; ActionRoleData unit = actionUnit.GetComponent <ActionRoleData>(); // int speed = BUnit.ThisBasicRoleProperty()._role.ReadCurrentRoleRA(AttributeData.Speed); standardSpeedArray[i] = speed; unit.speed = speed; // //actionUnit.GetComponent<Canvas>().sortingOrder = i; if (BUnit._Tag == SDConstants.CharacterType.Enemy) { actionUnit.position = startEnemyPos.position; unit.isEnemy = true; if (BUnit.IsBoss) { unit.headImage.initCharacterModelById (BUnit.UnitId, SDConstants.CharacterAnimType.Enemy, 0.15f, true); } else { unit.headImage.initCharacterModelById (BUnit.UnitId, SDConstants.CharacterAnimType.Enemy, 0.3f, true); } } else { actionUnit.position = startHeroPos.position; unit.isEnemy = false; int hashcode = BUnit.unitHashcode; string heroId = SDDataManager.Instance.getHeroIdByHashcode(hashcode); SDConstants.CharacterAnimType type = (SDConstants.CharacterAnimType) (SDDataManager.Instance.getHeroCareerById(heroId)); //unit.headImage.initCharacterModel(hashcode, type, 3f); } actionUnit.localScale = Vector3.one; if (BUnit.ReadThisStateEnable(StateTag.Dizzy)) { unit.stateBgImage.sprite = unit.stateSprites[1]; } else { unit.stateBgImage.sprite = unit.stateSprites[0]; } unit.battleUnit = BUnit; unit.isActed = false; allActionUnits.Add(unit); if (BUnit.IsDead) { actionUnit.gameObject.SetActive(false); } } BuildABMoveSpeed(allActionUnits); //BM.NextActionUnit(); startAction(); }
public override int dmgCaused(BattleRoleData source, BattleRoleData target) { return(base.dmgCaused(source, target)); }
// Start is called before the first frame update void Start() { _unit = GetComponentInParent <BattleRoleData>(); _characterType = _unit._Tag; refreshState(); }
public RoleBarChart valCaused(BattleRoleData source, BattleRoleData target) { return(BasicVal); }
public IEnumerator IEStartSkill(BattleRoleData source, BattleRoleData target , int physicalVal, int elementalVal, int arcaneVal) { source.playMoveTowardAnimation(target.unit_model.position); yield return(new WaitForSeconds(moveTowardAndBackTime)); source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_attack, false); SLEffectManager.Instance.playCommonEffectSlash(target.transform.position); yield return(new WaitForSeconds(SDConstants.AnimTime_ATTACK - hitTime)); int d0 = physicalVal; int d1 = elementalVal; int d2 = arcaneVal; #region 计算技能状态 source.SkillCheck(this, target); IsCausedCritDmg = source.CritHappen; IsCausedMiss = !source.AccurHappen; IsCausedFault = source.FaultHappen; if (IsCausedCritDmg) { float criD = AllRandomSetClass.SimplePercentToDecimal (source.ThisBasicRoleProperty().CRIDmg + 100); d0 = (int)(d0 * criD); d1 = (int)(d1 * criD); d2 = (int)(d2 * criD); } #endregion #region Expect int NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); d0 += NowExpect; NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); d1 += NowExpect; NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); d2 += NowExpect; #endregion #region 输技能状态 target.HpController.isCriDmg = IsCausedCritDmg; target.HpController.isEvoHappen = IsCausedMiss; target.HpController.isFault = IsCausedFault; #endregion float DECIMAL = AllRandomSetClass.SimplePercentToDecimal(100 + target.PhysModify); d0 = (int)(d0 * DECIMAL); d1 = (int)(d1 * DECIMAL); d2 = (int)(d2 * DECIMAL); Debug.Log(source.name + " slash cause " + d0 + " physical damage " + d1 + " elemental damage " + d2 + " arcane damage" + " to " + target.name); target.HpController.getDamage(d0, SkillKind.Physical); target.HpController.getDamage(d1, SkillKind.Elemental); target.HpController.getDamage(d2, SkillKind.Arcane); yield return(new WaitForSeconds(hitTime)); //yield return new WaitForSeconds(skillLastTime); source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_idle, true); source.playMoveBackAnimation(); yield return(new WaitForSeconds(moveTowardAndBackTime)); StartCoroutine(IEWaitForEnd(source)); }
public void ConfirmSkillAndTarget() { ActionConfirm = false; if (_currentActionPanel == null || _currentActionPanel.CurrentSkill == null) { return; } _currentSkill = _currentActionPanel.CurrentSkill; int touchId = SelectController.WhenPointDownIndex(); if (_currentSkill.ThisSkillAim == SkillAim.Self || _currentSkill.RandomTarget) { if (confirmSkillStep == 0) { confirmSkillStep = 1; } else if (confirmSkillStep == 1) { ActionConfirm = true; _currentTargetUnit = All_Array[touchId]; _currentTUType = _currentTargetUnit._Tag; // if (_currentSkill.ThisSkillAim != SkillAim.Self) { SelectController.ConfirmTarget(touchId); } else { currentTouchId = 0; } } } else { if (All_Array[touchId].IsOptionTarget) { if (currentTouchId < 0) { currentTouchId = touchId; } if (touchId != currentTouchId) { currentTouchId = touchId; confirmSkillStep = 0; } else { if (confirmSkillStep == 1) { ActionConfirm = true; } else if (confirmSkillStep == 0) { confirmSkillStep = 1; _currentTargetUnit = All_Array[currentTouchId]; _currentTUType = _currentTargetUnit._Tag; SelectController.ConfirmTarget(touchId); } } } else { RolePlayJumpAnim(All_Array[touchId]); Debug.Log("无效目标"); } } }
public virtual int dmgCaused(BattleRoleData source, BattleRoleData target) { return(0); }
public int sourceValCaused(BattleRoleData source, BattleRoleData target) { return(Mathf.Min((int)(FigureToSource * (1 - 0.25f * SkillGrade)), 0)); }
public override RoleBarChart bcCaused(BattleRoleData source, BattleRoleData target) { return(base.bcCaused(source, target)); }
public void CalCurAtkDamage(BattleRoleData curAtkData, BattleRoleData hurtData) { hurtData.TempDecHpByHurt = curAtkData.Atk; }
//获取当前受击者数据 public BattleRoleData GetCurHurtRoleData(BattleRoleData atkRoleData) { bool isSelf = atkRoleData.IsPlayer; List <BattleRoleData> rivalList = new List <BattleRoleData>(); for (int i = 0; i < this.BattleRoleList.Count; i++) { if (this.BattleRoleList[i].IsPlayer == !isSelf && this.BattleRoleList[i].CurHp > 0) { rivalList.Add(this.BattleRoleList[i]); } } //与最近的敌人之间的距离 Dictionary <int, List <int> > nearStepDict = SearchPath.GetStepDict(atkRoleData.Pos); List <int> step = new List <int>(nearStepDict.Keys); step.Sort(delegate(int step1, int step2) { return(step1.CompareTo(step2)); }); int shortestStep = 0; for (int i = 0; i < step.Count; i++) { List <int> curStepPosList = nearStepDict[step[i]]; for (int j = 0; j < rivalList.Count; j++) { for (int m = 0; m < curStepPosList.Count; m++) { if (rivalList[j].Pos == curStepPosList[m]) { shortestStep = step[i]; break; } } if (shortestStep != 0) { break; } } if (shortestStep != 0) { break; } } //Debug.LogError("shortestStep:" + shortestStep); if (shortestStep != 0) { //根据最短距离搜索敌人列表 List <BattleRoleData> shortestRoleList = new List <BattleRoleData>(); for (int i = 0; i < rivalList.Count; i++) { for (int j = 0; j < nearStepDict[shortestStep].Count; j++) { if (rivalList[i].Pos == nearStepDict[shortestStep][j]) { shortestRoleList.Add(rivalList[i]); break; } } } //有多个相同距离的敌人时,选择血量最少的 List <BattleRoleData> hpRoleList = new List <BattleRoleData>(); shortestRoleList.Sort(delegate(BattleRoleData data1, BattleRoleData data2) { return(data1.CurHp.CompareTo(data2.CurHp)); }); for (int i = 0; i < shortestRoleList.Count; i++) { if (shortestRoleList[i].CurHp == shortestRoleList[0].CurHp) { hpRoleList.Add(shortestRoleList[i]); } } //血量相同时,随机抽取一个 int index = Random.Range(0, hpRoleList.Count - 1); return(hpRoleList[index]); } else { return(null); } }
void FixedUpdate() { //IsWaitingPlayerAction = ABM.IsWaitingAction; if (CountDownTime > 0) { CountDownTime -= Time.deltaTime; return; } if (IsWaitingPlayerAction) { if (SDDataManager.Instance.SettingData.isAutoBattle && _currentActionPanel != null) { IsWaitingPlayerAction = false; _currentActionPanel.hideActionPanel(); //UsingPropBtn.interactable = false; CancelBtn.interactable = false; _currentActionPanel.chooseASkillFromSkillGroup(); //chooseAutoBattleTarget(); if (_currentBattleUnit.IsEnemy) { chooseRandomHeroToAttack(); } else { chooseAutoBattleTarget(); } CountDownTime = 1.5f; handleAction(); } else { if (SDGameManager.Instance.isUsingProp)//正在使用道具 { if (_PropTarget == SDConstants.AUTO_TARGET_TAG) { if (Input.GetMouseButtonDown(0)) { ActionConfirm = true; } } else { //SelectController.GetComponent<Image>().raycastTarget = true; //使用QuicklySelectSkillTarget来选择和判断角色 if (Input.GetMouseButtonDown(0)) { int touchId = SelectController.WhenPointDownIndex(); if (All_Array[touchId].IsOptionTarget) { ActionConfirm = true; PropTargetUnit = All_Array[touchId]; SelectController.ConfirmTarget(touchId); } else { RolePlayJumpAnim(All_Array[touchId]); Debug.Log("无效目标"); } } } if (ActionConfirm) { ActionConfirm = false; CountDownTime = 0.5f; startUseProp(); CancelBtn.interactable = false; hideOptionTarget(); SelectController.ResetTarget(); //handleAction(); } } else { if (!SDGameManager.Instance.isGamePaused && confirmSkillStep != 2) { if (ActionConfirm && confirmSkillStep == 1) { ActionConfirm = false; confirmSkillStep = 2; CountDownTime = 0.75f; // Debug.Log("目标为:" + _currentTUType + " name:" + _currentTargetUnit.name); RolePlayJumpAnim(_currentTargetUnit); handleAction(); } } } } } }
public int AllResult(BattleRoleData source, BattleRoleData target, AttributeData tag, int SkillGrade) { int LEVEL = source.ThisBasicRoleProperty().LEVEL; return(UsingRAShow(source, tag, LEVEL, SkillGrade)); }
public int AllResult(BattleRoleData source, BattleRoleData target, SkillKind tag, int SkillGrade) { AttributeData t = tag == SkillKind.Physical ? AttributeData.AT : AttributeData.MT; return(AllResult(source, target, t, SkillGrade)); }
public void NextActionUnit() { if (Remaining_ORL.Count == 0) { return; } if (Remaining_SRL.Count == 0) { return; } if (_currentBattleUnit != null) { _currentBattleUnit.actionSign.gameObject.SetActive(false); } _currentBattleUnit = All_Array[0]; All_Array.Remove(_currentBattleUnit); All_Array.Add(_currentBattleUnit); if (_currentBattleUnit.IsDead) { NextActionUnit(); return; } if (_currentBattleUnit.ReadThisStateEnable(StateTag.Dizzy)) { _currentBattleUnit.CheckStates(); if (SDGameManager.Instance.isFastModeEnabled) { NextActionUnit(); } return; } _currentBattleUnit.actionSign.gameObject.SetActive(true); _currentActionPanel = _currentBattleUnit.APC; checkCurrentUnitTag(); // _currentBattleUnit.CheckStates();//计算角色状态对其影响 if (_currentBattleUnit.IsDead) { NextActionUnit(); return;//重新进行死亡判断 } if (_currentBUType != SDConstants.CharacterType.Enemy) { if (SDDataManager.Instance.SettingData.isAutoBattle) { _currentActionPanel.chooseRandomSkillFromGroup(); chooseAutoBattleTarget(); handleAction(); } else { SDGameManager.Instance.isUsingProp = false; // IsWaitingPlayerAction = true; //显示全部可用交互 _currentActionPanel.showActionPanel(); //UsingPropBtn.interactable = true; CancelBtn.interactable = true; } } else { _currentActionPanel.showActionPanel(); _currentActionPanel.chooseASkillFromSkillGroup(); chooseRandomHeroToAttack(); handleAction(); } currentTouchId = -1; confirmSkillStep = 0; }
public int targetValCaused(BattleRoleData source, BattleRoleData target) { return(Mathf.Min((int)(FigureToTarget * (1 + 0.25f * SkillGrade)), 85)); }
void UsePropWithoutState(string FN, SDConstants.AOEType AOE , BattleRoleData currentActionUnit, BattleRoleData propTargetUnit) { string[] fns = FN.Split(':'); string[] fnElements = fns[0].Split('_'); string[] paramstrs = fns[1].Split(','); int p0 = 0; int p1 = 0; p0 = SDDataManager.Instance.getInteger(paramstrs[0]); if (paramstrs.Length > 1) { p1 = SDDataManager.Instance.getInteger(paramstrs[1]); } NumberData param0 = new NumberData(p0); NumberData param1 = new NumberData(p1); string functionName = fns[0]; if (functionName.Contains("addHP")) { addHp(currentActionUnit, propTargetUnit, param0 , AOE); } else if (functionName.Contains("addMP")) { addMp(currentActionUnit, propTargetUnit, param0 , AOE); } else if (functionName.Contains("addTP")) { addTp(currentActionUnit, propTargetUnit, param0 , AOE); } else if (functionName.Contains("revive")) { bool flag = false; if (propTargetUnit.IsDead) { flag = true; } else { List <BattleRoleData> lit = DealWithAOEAction(currentActionUnit , propTargetUnit, AOE); foreach (BattleRoleData unit in lit) { if (unit.IsDead) { flag = true; propTargetUnit = unit; break; } } } if (flag) { revive(currentActionUnit, propTargetUnit, param0, param1 , AOE); } } else if (functionName.Contains("catch")) { if (!propTargetUnit.IsDead && propTargetUnit.HpController.CurrentHp * 1f / propTargetUnit.HpController.MaxHp <= 0.2f) { catchSlave(currentActionUnit, propTargetUnit, param0); } } else if (functionName.Contains("remove")) { List <BattleRoleData> list = DealWithAOEAction (currentActionUnit, propTargetUnit, AOE); if (fnElements[1].ToLower() != "all") { StateTag tag = ROHelp.STATE_TAG(fnElements[1]); if (fnElements[1].ToLower() == "random") { tag = (StateTag)(UnityEngine.Random.Range(0, (int)StateTag.End)); } for (int i = 0; i < list.Count; i++) { list[i].clearPerTagStates(tag); } } else { for (int i = 0; i < list.Count; i++) { list[i].clearAllStates(); } } } else if (functionName.Contains("damage")) { damage(currentActionUnit, propTargetUnit, param0, AOE); } }
public void SimpleStartState(BattleRoleData source, BattleRoleData target) { StateFunctionWork(source, target, ralCaused(source, target) , bcCaused(source, target) , dmgCaused(source, target), StateLastTime); }
public List <BattleRoleData> DealWithAOEAction (BattleRoleData currentActionUnit, BattleRoleData propTargetUnit , SDConstants.AOEType AOE, bool isRevive = false) { BattleManager BM = FindObjectOfType <BattleManager>(); List <BattleRoleData> results = new List <BattleRoleData>(); if (AOE == SDConstants.AOEType.None) { results.Add(propTargetUnit); } else if (AOE == SDConstants.AOEType.Horizontal) { int childId = propTargetUnit.transform.GetSiblingIndex(); int nextId = (childId + 2) % SDConstants.MaxSelfNum; results.Add(propTargetUnit); BattleRoleData next = propTargetUnit.transform.parent.GetChild(nextId) .GetComponent <BattleRoleData>(); bool flag = false; if (next.IsDead && isRevive) { flag = true; } else if (!next.IsDead) { flag = true; } if (flag) { results.Add(next); } } else if (AOE == SDConstants.AOEType.Horizontal1) { BattleRoleData unit0 = propTargetUnit.transform.parent.GetChild(0).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } BattleRoleData unit1 = propTargetUnit.transform.parent.GetChild(2).GetComponent <BattleRoleData>(); bool flag1 = false; if (unit1.IsDead && isRevive) { flag1 = true; } else if (!unit1.IsDead) { flag1 = true; } if (flag1) { results.Add(unit1); } } else if (AOE == SDConstants.AOEType.Horizontal2) { BattleRoleData unit0 = propTargetUnit.transform.parent.GetChild(1).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } BattleRoleData unit1 = propTargetUnit.transform.parent.GetChild(3).GetComponent <BattleRoleData>(); bool flag1 = false; if (unit1.IsDead && isRevive) { flag1 = true; } else if (!unit1.IsDead) { flag1 = true; } if (flag1) { results.Add(unit1); } } else if (AOE == SDConstants.AOEType.Vertical) { int childId = propTargetUnit.transform.GetSiblingIndex(); int nextId; if (childId > 1) { nextId = 5 - childId; } else { nextId = 1 - childId; } //this.StartSkill(source, target); results.Add(propTargetUnit); BattleRoleData next = propTargetUnit.transform.parent.GetChild(nextId) .GetComponent <BattleRoleData>(); bool flag = false; if (next.IsDead && isRevive) { flag = true; } else if (!next.IsDead) { flag = true; } if (flag) { results.Add(next); } //this.StartSkill(source, next); } else if (AOE == SDConstants.AOEType.Vertical1) { BattleRoleData unit0 = propTargetUnit.transform.parent.GetChild(2).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } BattleRoleData unit1 = propTargetUnit.transform.parent.GetChild(3).GetComponent <BattleRoleData>(); bool flag1 = false; if (unit1.IsDead && isRevive) { flag1 = true; } else if (!unit1.IsDead) { flag1 = true; } if (flag1) { results.Add(unit1); } } else if (AOE == SDConstants.AOEType.Vertical2) { BattleRoleData unit0 = propTargetUnit.transform.parent.GetChild(0).GetComponent <BattleRoleData>(); bool flag0 = false; if (unit0.IsDead && isRevive) { flag0 = true; } else if (!unit0.IsDead) { flag0 = true; } if (flag0) { results.Add(unit0); } BattleRoleData unit1 = propTargetUnit.transform.parent.GetChild(1).GetComponent <BattleRoleData>(); bool flag1 = false; if (unit1.IsDead && isRevive) { flag1 = true; } else if (!unit1.IsDead) { flag1 = true; } if (flag1) { results.Add(unit1); } } else if (AOE == SDConstants.AOEType.All) { BattleRoleData[] list = propTargetUnit.transform.parent .GetComponentsInChildren <BattleRoleData>(); for (int i = 0; i < list.Length; i++) { bool flag = false; if (list[i].IsDead && isRevive) { flag = true; } else if (!list[i].IsDead) { flag = true; } if (flag) { //this.StartSkill(source, list[i]); results.Add(list[i]); } } } else if (AOE == SDConstants.AOEType.Random1)//随机选择一个 { List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } List <int> _results = RandomIntger.NumListReturn(1, list.Count); for (int i = 0; i < _results.Count; i++) { //this.StartSkill(source, BM.All_Array[list[_results[i]]]); results.Add(BM.All_Array[list[_results[i]]]); } } else if (AOE == SDConstants.AOEType.Random2) { List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } List <int> _results = RandomIntger.NumListReturn(2, list.Count); for (int i = 0; i < _results.Count; i++) { results.Add(BM.All_Array[list[_results[i]]]); //this.StartSkill(source, BM.All_Array[list[_results[i]]]); } } else if (AOE == SDConstants.AOEType.Random3) { List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } List <int> _results = RandomIntger.NumListReturn(3, list.Count); for (int i = 0; i < _results.Count; i++) { results.Add(BM.All_Array[list[_results[i]]]); //this.StartSkill(source, BM.All_Array[list[_results[i]]]); } } else if (AOE == SDConstants.AOEType.Continuous2) { results.Add(propTargetUnit); List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } int index = UnityEngine.Random.Range(0, list.Count); results.Add(BM.All_Array[list[index]]); } else if (AOE == SDConstants.AOEType.Continuous3) { results.Add(propTargetUnit); List <int> list = new List <int>(); for (int i = 0; i < BM.All_Array.Count; i++) { if (BM.All_Array[i].IsDead && isRevive) { list.Add(i); } else if (!BM.All_Array[i].IsDead) { list.Add(i); } } int index = UnityEngine.Random.Range(0, list.Count); results.Add(BM.All_Array[list[index]]); index = UnityEngine.Random.Range(0, list.Count); results.Add(BM.All_Array[list[index]]); } else { results.Add(propTargetUnit); } return(results); }
public virtual RoleAttributeList ralCaused(BattleRoleData source, BattleRoleData target) { return(RoleAttributeList.zero); }
public IEnumerator IEStartSkill(BattleRoleData source, BattleRoleData target, NumberData val, bool AsSkill = true) { source.playMoveTowardAnimation(target.unit_model.position); yield return(new WaitForSeconds(moveTowardAndBackTime)); if (source.unit_character_model.CurrentCharacterModel != null) { source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_attack, false); } SLEffectManager.Instance.playCommonEffectNormalAttack(target.transform.position); yield return(new WaitForSeconds(SDConstants.AnimTime_ATTACK - hitTime)); int damage = val.DATA; if (val.dataTag == NumberData.DataType.percent) { damage = (int)(target.HpController.MaxHp * val.DECIMAL); } if (AsSkill) { #region 计算技能状态 source.SkillCheck(this, target); IsCausedCritDmg = source.CritHappen; IsCausedMiss = !source.AccurHappen; IsCausedFault = source.FaultHappen; float criD = 1; if (IsCausedCritDmg) { criD = AllRandomSetClass.SimplePercentToDecimal (source.ThisBasicRoleProperty().CRIDmg + 100); } int NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); #endregion damage = (int)(damage * criD); damage += NowExpect; #region 输技能状态 target.HpController.isCriDmg = IsCausedCritDmg; target.HpController.isEvoHappen = IsCausedMiss; target.HpController.isFault = IsCausedFault; #endregion damage = (int)(damage * AllRandomSetClass.SimplePercentToDecimal(100 + target.PhysModify)); Debug.Log(source.name + " attack cause " + damage + " damage to " + target.name); target.HpController.getDamage(damage, SkillKind.Physical); } else { Debug.Log(source.name + " casue " + damage + " damage to " + target.name); target.HpController.getDamage(damage, SkillKind.End); } yield return(new WaitForSeconds(hitTime)); //yield return new WaitForSeconds(skillLastTime); if (source.unit_character_model.CurrentCharacterModel != null) { source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_idle, true); } source.playMoveBackAnimation(); yield return(new WaitForSeconds(moveTowardAndBackTime)); StartCoroutine(IEWaitForEnd(source)); }