public void applyMagicAtk(GameLife hit, SkillState skill, string damageEffect = "damaged01") { TowerSkill sinfo = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId); int lv = skill.skillLevel; int damage = 0; switch (skill.skillId) { case "1004": damage = sinfo.x [lv - 1]; //damageEffect = ""; break; case "1005": damage = sinfo.x[lv - 1]; break; case "1006": damage = sinfo.x[lv - 1]; break; default: break; } hit.DoDamage(damage); EffectManager.inst.EmitFollowingEffect(damageEffect, 500, hit); }
public override void setSkillCD(int readySkill) { SkillState s = skills [readySkill]; TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(s.skillId); skillCoolDown[readySkill] = ts.cooldown[s.skillLevel - 1]; }
// public bool checkOverlap(){ // Collider2D[] cols = Physics2D.OverlapCircleAll (transform.position,r,1<<LayerMask.NameToLayer("enemy")); // if (cols.Length == 0) { // Debug.Log ("可建造"); // } // return false; // } public void applyNormalAtk(GameLife hit, string damageEffect = "damaged01") { //hit.knock (atkTarget.transform.position - this.transform.position, 0.2f, 6f); List <Buff> attackEffect = new List <Buff> (); foreach (SkillState skill in skillComponent.skills) { if (skill == null || skill.skillId == null) { continue; } TowerSkill sinfo = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId); if (sinfo.tsType == eTowerSkillType.PASSIVE && sinfo.checkPoint == ePassiveCheckPoint.ATK) { attackEffect.Add(new Buff(sinfo.x[skill.skillLevel - 1], 50, 1000)); } } List <AtkInfo> atk = new List <AtkInfo> (); atk.Add(mainAtk); atk.AddRange(extraAtk); hit.DoDamage(atk, mingzhong, property, attackEffect); EffectManager.inst.EmitFollowingEffect(damageEffect, 500, hit); }
void checkCastBehaviour(int dTime) { // if (atkTarget != null && atkBhvTimer < atkPreTime) { // return; // } //攻击前摇时 不进行施法 if (atkStage == eAtkStage.PRE_YAO) { return; } //效果结算 if (castStage == eAtkStage.READY) { return; } castBhvTimer += dTime; bool isSkillEffect = false; if (castStage == eAtkStage.PRE_YAO && castBhvTimer > castPreTime) { castStage = eAtkStage.POST_YAO; isSkillEffect = true; } else if (castStage == eAtkStage.POST_YAO && castBhvTimer > castPreTime + castPostTime) { castStage = eAtkStage.READY; castBhvTimer = 0; } if (isSkillEffect) { SkillState skill = skillComponent.skills [castIdx]; TowerSkill s = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId); if (s.tsType == eTowerSkillType.SELF_TARGET) { gainBuff(); } else if (s.tsType == eTowerSkillType.ACTIVE) { if (s.targetType == eAtkType.RANGED_HOMING) { genBullet(s.bulletStyle.bulletName, castTarget, skill, true, false); castTarget = null; } else if (s.targetType == eAtkType.RANGED_INSTANT) { applyNormalAtk(castTarget, s.bulletStyle.bulletName); castTarget = null; } } else { } } }
protected override void calcuAuraSkill(SkillState skillState) { TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(skillState.skillId); int level = skillState.skillLevel; int range = ts.x[level - 1]; if (level - 1 < ts.y.Count) { } int y = ts.y [level - 1]; int z = ts.z [level - 1]; if (ts.debuff) { List <GameLife> enemyCopy = BattleManager.getInstance().getTmpEnemyList(); Vector2 a = new Vector2(owner.posXInt, owner.posYInt); foreach (GameLife e in enemyCopy) { Vector2 b = new Vector2(e.posXInt, e.posYInt); if ((a - b).magnitude < range) { switch (ts.skillId) { case "1003": EffectManager.inst.EmitFollowingEffect("burning", 300, e); e.DoDamage(y); break; default: break; } } } } else { if (!localTimers.ContainsKey(ts.skillId)) { localTimers [ts.skillId] = 0; } int timer = localTimers[ts.skillId]; switch (ts.skillId) { case "1009": if (timer > 5000) { localTimers[ts.skillId] = 0; BattleManager.getInstance().player.gl.DoDamage(-5000); } break; default: break; } } }
public void setInfo(SkillState skill) { this.skill = skill; TowerSkill sinfo = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId); _desp.text = sinfo.skillDesp; _lv_num.text = skill.skillLevel + ""; _icon.url = GameConstant.TOWER_SKILL_ICON_PATH + skill.skillId; }
public TowerSkill getTowerSkillInfo(string skillId) { TowerSkill data = null; if (!towerSkills.TryGetValue(skillId, out data)) { data = towerSkills ["1001"]; } return(data); }
protected override bool isPermanentSkill(string skillId) { TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(skillId); if (ts.tsType == eTowerSkillType.AURA) { return(true); } return(false); }
protected override bool isPassiveSkill(string skillId) { TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(skillId); if (ts.tsType == eTowerSkillType.PASSIVE) { return(true); } return(false); }
void loadTowerSkillInfo() { //TextAsset ta = Resources.Load ("json/tower_skill/100") as TextAsset; //towerSkills = JsonConvert.DeserializeObject<Dictionary<string,TowerSkill>> (ta.text); Object[] content = Resources.LoadAll("ScriptableObj/TowerSkill"); foreach (Object o in content) { TowerSkill ts = (TowerSkill)o; towerSkills.Add(ts.skillId, ts); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); obj.Update(); // EditorGUILayout.PropertyField(skillId); // EditorGUILayout.PropertyField(skillName); // EditorGUILayout.PropertyField(skillDesp); // EditorGUILayout.PropertyField(maxLv); // // // EditorGUILayout.PropertyField(cooldown,true); // EditorGUILayout.PropertyField(x,true); // EditorGUILayout.PropertyField(y,true); // EditorGUILayout.PropertyField(z,true); towerSkill = (TowerSkill)target; towerSkill.tsType = (eTowerSkillType)EditorGUILayout.EnumPopup("Type-", towerSkill.tsType); if (towerSkill.tsType == eTowerSkillType.ACTIVE) { EditorGUILayout.PropertyField(targetType); EditorGUILayout.PropertyField(bulletStyle.FindPropertyRelative("bulletName")); } else if (towerSkill.tsType == eTowerSkillType.PASSIVE) { EditorGUILayout.PropertyField(checkPoint); } else if (towerSkill.tsType == eTowerSkillType.AURA) { EditorGUILayout.PropertyField(debuff); } obj.ApplyModifiedProperties(); }
public static TowerBattleProperty genTowerBattleProperty(TowerTemplate tt) { TowerBase tb = tt.tbase; List <TowerComponent> components = new List <TowerComponent>(); foreach (TowerComponent tc in tt.components) { if (tc == null || tc.cid == null) { continue; } components.Add(tc); } int atkRange = tb.towerModel.atkRange; int atkSpeed = tb.atkSpd; List <AtkInfo> extraAtk = new List <AtkInfo> (); AtkInfo mainAtk = new AtkInfo(tb.mainAtk); for (int i = 0; i < tb.extraAtk.Count; i++) { extraAtk.Add(new AtkInfo(tb.extraAtk[i])); } List <SkillState> skills = new List <SkillState> (); skills.AddRange(tb.skills); //List<SkillState> extraSkills = new List<SkillState> (); foreach (TowerComponent tc in components) { foreach (TowerComponentEffect effect in tc.effects) { switch (effect.type) { case eTowerComponentEffectType.ATK_CHANGE: mainAtk.damage += effect.x; break; case eTowerComponentEffectType.EXTRA_ABILITY: // string skillId = effect.extra; int skillLevel = effect.x; TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(skillId); { bool found = false; for (int i = 0; i < skills.Count; i++) { if (skills [i].skillId == skillId) { found = true; skills [i].skillLevel += skillLevel; if (skills [i].skillLevel > ts.maxLv) { skills [i].skillLevel = ts.maxLv; } break; } } if (!found) { SkillState skill = new SkillState(); skill.skillId = skillId; skill.skillLevel = skillLevel; skills.Add(skill); } } break; case eTowerComponentEffectType.ATK_SPD_CHANGE: atkSpeed += effect.x; break; case eTowerComponentEffectType.ATK_RANGE_CHANGE: atkRange += effect.x; break; case eTowerComponentEffectType.EXTRA_ATK: if (mainAtk.property == (eProperty)effect.x) { mainAtk.damage += effect.y; } else { bool found = false; for (int i = 0; i < extraAtk.Count; i++) { if (extraAtk [i].property == (eProperty)effect.x) { found = true; extraAtk [i].damage += effect.y; break; } } if (!found) { extraAtk.Add(new AtkInfo(effect.x, effect.y)); } } break; default: break; } } } TowerBattleProperty res = new TowerBattleProperty(); res.atkRange = atkRange; res.atkSpd = atkSpeed; res.mainAtk = mainAtk; res.extraAtk = extraAtk; res.originSkills = skills; return(res); }
void changeDetailView() { _changes.RemoveChildrenToPool(); string p = ""; p += ""; Dictionary <string, int[]> diff = new Dictionary <string, int[]> (); _c_before.text = "无"; _c_after.text = "无"; //diff ["name"] = new string[2]{"无 "," 无"}; if (nowComponent != null) { _c_before.text = nowComponent.cname.PadLeft(6, ' '); //diff ["name"][0] = nowComponent.cname.PadLeft(6,' '); foreach (TowerComponentEffect effect in nowComponent.effects) { if (effect.type == eTowerComponentEffectType.ATK_CHANGE) { diff ["atk"] = new int[2] { effect.x, 0 }; } else if (effect.type == eTowerComponentEffectType.ATK_RANGE_CHANGE) { diff ["atk_range"] = new int[2] { effect.x, 0 }; } else if (effect.type == eTowerComponentEffectType.ATK_SPD_CHANGE) { diff ["atk_spd"] = new int[2] { effect.x, 0 }; } else if (effect.type == eTowerComponentEffectType.EXTRA_ATK) { diff ["atk_p_" + effect.x] = new int[2] { effect.y, 0 }; } else if (effect.type == eTowerComponentEffectType.EXTRA_ABILITY) { diff ["extra_" + effect.extra] = new int[2] { effect.x, 0 }; } } } if (choose != -1) { TowerComponent tc = PlayerData.getInstance().bagComponents [choose]; _c_after.text = tc.cname.PadLeft(6, ' '); //diff ["name"][1] = tc.cname.PadLeft(6,' '); foreach (TowerComponentEffect effect in tc.effects) { if (effect.type == eTowerComponentEffectType.ATK_CHANGE) { if (diff.ContainsKey("atk")) { diff ["atk"] [1] = effect.x; } else { diff ["atk"] = new int[2] { 0, effect.x }; } } else if (effect.type == eTowerComponentEffectType.ATK_RANGE_CHANGE) { if (diff.ContainsKey("atk_range")) { diff ["atk_range"] [1] = effect.x; } else { diff ["atk_range"] = new int[2] { 0, effect.x }; } } else if (effect.type == eTowerComponentEffectType.ATK_SPD_CHANGE) { if (diff.ContainsKey("atk_spd")) { diff ["atk_spd"] [1] = effect.x; } else { diff ["atk_spd"] = new int[2] { 0, effect.x }; } } else if (effect.type == eTowerComponentEffectType.EXTRA_ATK) { if (diff.ContainsKey("atk_" + effect.x)) { diff ["atk_p_" + effect.x] [1] = effect.y; } else { diff ["atk_p_" + effect.x] = new int[2] { 0, effect.y }; } } else if (effect.type == eTowerComponentEffectType.EXTRA_ABILITY) { if (diff.ContainsKey("extra" + effect.extra)) { diff ["extra_" + effect.extra] [1] = effect.x; } else { diff ["extra_" + effect.extra] = new int[2] { 0, effect.x }; } } } } p += '\n'; foreach (var kv in diff) { if (kv.Key == "name") { continue; } if (kv.Key.StartsWith("extra")) { PropertyCompareLine pline = (PropertyCompareLine)_changes.AddItemFromPool(); string sid = kv.Key.Substring(6); TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(sid); pline.setAsProperty(ts.skillName, "lv" + kv.Value [1], (kv.Value [1] - kv.Value [0]) + ""); } else if (kv.Key.StartsWith("atk_p")) { PropertyCompareLine pline = (PropertyCompareLine)_changes.AddItemFromPool(); string prop = kv.Key.Substring(6); eProperty pp = (eProperty)int.Parse(prop); string sv = string.Format("{0:f1}", kv.Value [1] * 0.001f); string schange = string.Format("{0:f1}", (kv.Value [1] - kv.Value [0]) * 0.001f); pline.setAsAtkProperty(pp, sv, schange); } else { PropertyCompareLine pline = (PropertyCompareLine)_changes.AddItemFromPool(); string trueKey = kv.Key.Replace("_", "\n"); pline.setAsProperty(trueKey, kv.Value [1] + "", (kv.Value [1] - kv.Value [0]) + ""); } p += kv.Key + " "; p += kv.Value [0]; p += " << "; p += kv.Value [1]; p += '\n'; } _txt_now.text = p; }
void checkAutoSkill(int dTime) { if (checkSkillTimer > 0) { checkSkillTimer -= dTime; } if (checkSkillTimer > 0) { return; } if (castStage != eAtkStage.READY) { return; } checkSkillTimer = CHECK_SKILL_INTERVAL; List <int> readySkills = skillComponent.getReadySkill(); GameLife closestOne = MapManager.getInstance().getClosestEnemy(this); List <int> readyUsableSkill = new List <int> (); if (readySkills.Count == 0) { return; } if (closestOne == null || !closestOne.IsAlive) { return; } for (int i = 0; i < readySkills.Count; i++) { SkillState skill = skillComponent.skills [readySkills [i]]; int diss = (posXInt - closestOne.posXInt) * (posXInt - closestOne.posXInt) + (posYInt - closestOne.posYInt) * (posYInt - closestOne.posYInt); int dis = (int)Mathf.Sqrt(diss); //Vector2 diff = closestOne.transform.position - transform.position; TowerSkill s = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId); if (s.tsType == eTowerSkillType.SELF_TARGET) { readyUsableSkill.Add(readySkills[i]); } else { if (dis <= s.x[skill.skillLevel - 1]) { readyUsableSkill.Insert(0, readySkills[i]); } } } if (readyUsableSkill.Count == 0) { return; } SkillState toUse = skillComponent.skills[readyUsableSkill [0]]; TowerSkill ss = GameStaticData.getInstance().getTowerSkillInfo(toUse.skillId); if (ss.tsType == eTowerSkillType.SELF_TARGET) { anim.SetTrigger("buff"); } else if (ss.tsType == eTowerSkillType.ACTIVE) { castTarget = closestOne; anim.SetTrigger("skill"); anim.SetFloat("skill_style", Random.Range(0, 2) * 1.0f); } else { } skillComponent.setSkillCD(readyUsableSkill [0]); castBhvTimer = 0; castStage = eAtkStage.PRE_YAO; castIdx = readyUsableSkill [0]; }