private IEnumerator doApproach(NTGBattleSkillController skill) { while (alive && Moveable && GetStatus(UnitStatus.Approach) == true && targetUnit != null && targetUnit.Lockable(group) && (transform.position - targetUnit.transform.position).sqrMagnitude > skill.sqrRange) { //navAgent.acceleration = 1000.0f; manualRotation = false; navAgent.destination = targetUnit.transform.position; yield return(new WaitForSeconds(0.1f)); } if (alive && navAgent.enabled) { navAgent.ResetPath(); } if (alive && Shootable && GetStatus(UnitStatus.Approach) == true && targetUnit != null && targetUnit.Lockable(group) && skill.ShootCheck(targetUnit)) { if (targetUnit != null && skill.facingType == NTGBattleSkillFacingType.Target) { transform.LookAt(new Vector3(targetUnit.transform.position.x, transform.position.y, targetUnit.transform.position.z)); } if (mp >= skill.mpCost) { mp -= skill.mpCost; skill.Shoot(targetUnit); } } SetStatus(UnitStatus.Approach, false); }
public virtual void Init(NTGBattleUnitController owner, NTGBattleUnitController shooter = null, NTGBattleSkillController skillController = null, NTGBattleMemberSkillBehaviour behav = null, float[] p = null, string[] sp = null) { this.owner = owner; this.shooter = shooter; this.skillController = skillController; if (behav != null) { Load(behav); } this.p = p; this.sp = sp; FXReset(); if (audioController != null) { audioController.Init(); } foreach (var ls in GetComponents <NTGLuaScript>()) { if (ls.luaScript.Substring(0, ls.luaScript.LastIndexOf(".")) == "Logic.Battle.Skill") { //ls.LuaCall("Init", fxAnchor, owner, p, sp); } } }
private void Approach(NTGBattleSkillController skill) { if (_doApproach != null) { StopCoroutine(_doApproach); } SetStatus(UnitStatus.Approach, true); _doApproach = StartCoroutine(doApproach(skill)); }
public void HintShow(NTGBattleSkillController skill) { this.skill = skill; hintType = skill.skill.HintType; hintSize = skill.skill.HintSize; hint = null; rangeHint.localScale = new Vector3(skill.range * 2, 1, skill.range * 2); if (hintType == 0) { hint = circleHint; hint.parent = owner.mainController.dynamics; hint.localScale = new Vector3(hintSize * 2, 1, hintSize * 2); } else if (hintType == 1 || hintType == 2) { if (hintType == 1) { hint = fan60Hint; } else if (hintType == 2) { hint = fan90Hint; } hint.parent = transform; hint.localScale = new Vector3(skill.range, 1, skill.range); } else if (hintType == 3) { hint = directionHint; hint.parent = transform; hint.localScale = new Vector3(hintSize * 2, 1, skill.range); } if (hint == null) { return; } hintRenderer = hint.gameObject.GetComponent <Renderer>(); hintRenderer.material.SetColor("_Color", normalColor); rangeHintRenderer.material.SetColor("_Color", normalColor); hintShow = true; rangeHint.gameObject.SetActive(true); }
static int SmartTarget(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); NTGBattlePlayerController obj = (NTGBattlePlayerController)ToLua.CheckObject(L, 1, typeof(NTGBattlePlayerController)); NTGBattleSkillController arg0 = (NTGBattleSkillController)ToLua.CheckUnityObject(L, 2, typeof(NTGBattleSkillController)); NTGBattleUnitController o = obj.SmartTarget(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public NTGBattleUnitController SmartTarget(NTGBattleSkillController skill) { NTGBattleUnitController target = null; var units = viewController.unitsInView; float topScore = -1; NTGBattleUnitController lowPlayer = null; NTGBattleUnitController lowBuilding = null; NTGBattleUnitController lowMob = null; float lowPlayerHpPer = 1.0f; float lowBuildingHpPer = 1.0f; float lowMobHpPer = 1.0f; float lowPlayerScore = NTGBattleDataController.GetConfig("skill_player_hp"); float lowBuildingScore = NTGBattleDataController.GetConfig("skill_building_hp"); float lowMobScore = NTGBattleDataController.GetConfig("skill_mob_hp"); if (skill.type != NTGBattleSkillType.Attack) { lowPlayerScore = NTGBattleDataController.GetConfig("atk_player_hp"); lowBuildingScore = NTGBattleDataController.GetConfig("atk_building_hp"); lowMobScore = NTGBattleDataController.GetConfig("atk_mob_hp"); } for (int i = 0; i < units.Count; i++) { var unit = (NTGBattleUnitController)units[i]; if (!unit.Lockable(group)) { continue; } if ((skill.mask & unit.mask) == 0) { continue; } if (unit.group == group) { continue; } var sqrDist = (unit.transform.position - transform.position).sqrMagnitude; if (skill.reqTarget != 2 && sqrDist > skill.sqrRange) { continue; } float hpPercent = unit.hp / unit.hpMax; if (unit is NTGBattlePlayerController) { if (hpPercent < lowPlayerHpPer) { lowPlayer = unit; lowPlayerHpPer = hpPercent; } } else if (unit is NTGBattleMobController && (unit as NTGBattleMobController).type == 3) { if (hpPercent < lowBuildingHpPer) { lowBuilding = unit; lowBuildingHpPer = hpPercent; } } else { if (hpPercent < lowMobHpPer) { lowMob = unit; lowMobHpPer = hpPercent; } } } float sqrTopDist = float.MaxValue; for (int i = 0; i < units.Count; i++) { var unit = (NTGBattleUnitController)units[i]; if (!unit.Lockable(group)) { continue; } if ((skill.mask & unit.mask) == 0) { continue; } if (unit.group == group) { continue; } var sqrDist = (unit.transform.position - transform.position).sqrMagnitude; if (skill.reqTarget != 2 && sqrDist > skill.sqrRange) { continue; } float score = 0; if (skill.type == NTGBattleSkillType.Attack) { if (unit is NTGBattlePlayerController) { score = NTGBattleDataController.GetConfig("atk_player"); } else if (unit is NTGBattleMobController && (unit as NTGBattleMobController).type == 3) { score = NTGBattleDataController.GetConfig("atk_building"); } else { score = NTGBattleDataController.GetConfig("atk_mob"); } } else { if (unit is NTGBattlePlayerController) { score = NTGBattleDataController.GetConfig("skill_player"); } else if (unit is NTGBattleMobController && (unit as NTGBattleMobController).type == 3) { score = NTGBattleDataController.GetConfig("skill_building"); } else { score = NTGBattleDataController.GetConfig("skill_mob"); } } if (sqrDist > skill.sqrRange) { if (skill.type == NTGBattleSkillType.Attack) { score -= NTGBattleDataController.GetConfig("atk_move") * ((float)Math.Sqrt(sqrDist) - skill.range); } else { score -= NTGBattleDataController.GetConfig("skill_move") * ((float)Math.Sqrt(sqrDist) - skill.range); } } if (unit == lowPlayer) { score += lowPlayerScore; } else if (unit == lowBuilding) { score += lowBuildingScore; } else if (unit == lowMob) { score += lowMobScore; } if (score > topScore || (score == topScore && sqrDist < sqrTopDist)) { target = unit; topScore = score; sqrTopDist = sqrDist; } } return(target); }
public virtual void Init(NTGBattleEquipController equipController, NTGBattleSkillController skillController, float[] p) { this.equipController = equipController; this.skillController = skillController; }
protected void Awake() { mobController = GetComponentInParent<NTGBattleMobController>(); skillController = GetComponent<NTGBattleSkillController>(); }