// Update is called once per frame void Update() { damage_final = damage; if (targets.Count == 1) { damage_final = (1f + single_target_bonus) * damage; } if (is_continuous) { if (!sharing_dmg) { dmg_timer.update_timer(); } if (dmg_timer.is_over()) { foreach (GameObject obj in targets) { Unit unit = obj.GetComponent <Unit> (); if (unit != null) { //unit.receive_damage (damage_final); if (!unit.has_status(enter_status.name)) { unit.receive_status(enter_status); } } } dmg_timer.restart(); done_damage_times += 1; } if (!sharing_dur) { dur_timer.update_timer(); } if (dur_timer.is_over()) { if (done_damage_times < max_damage_times) { foreach (GameObject obj in targets) { Unit unit = obj.GetComponent <Champion> (); if (unit != null) { //unit.receive_damage ((float)(max_damage_times - done_damage_times) * damage_final); if (!unit.has_status(enter_status.name)) { unit.receive_status(end_status); } } } } skill_prefab_destroy_sequence(); } } }
public virtual Types.damage_combo prepare_dmg() { Types.damage_combo dmg = new Types.damage_combo(); dmg.init(); dmg.physical_dmg = runtime_u_stats.damage; dmg = Onhit_pre(dmg); return(dmg); }
void init_garen_skills() { Q_skill = new skill(); Q_skill.need_indicate_target = false; W_skill = new skill(); W_skill.need_indicate_target = false; W_skill.cd = 24f; E_skill = new skill(); E_skill.need_indicate_target = false; R_skill = new skill(); R_skill.need_indicate_target = true; Passive_skill = new skill(); Q_timer = new Utility.Timer(Q_cd); Q_timer.finish(); W_timer = new Utility.Timer(W_skill.cd); W_timer.finish(); E_timer = new Utility.Timer(E_cd); E_timer.finish(); R_timer = new Utility.Timer(R_skill.cd); R_timer.finish(); Passive_timer = new Utility.Timer(Passive_skill.cd); Q_flag = false; W_flag = false; E_flag = false; Passive_flag = false; //Q : Decisive Strike Q_skill.cd = 8f; Q_skill.dmg = 30f; Q_skill.ad_ratio = 1.4f; Q_skill.timer.change_max_timer(Q_skill.cd); Q_dur_timer = new Utility.Timer(4.5f); //its fixed Q_move_dur_timer = new Utility.Timer(Q_move_time); Q_silence_time = 1.5f; //TODO test only Q_skill.level = 4; upgrade_skill("Q"); //W : W_dur_timer = new Utility.Timer(W_dur); //E : Judgement E_dur_timer = new Utility.Timer(E_dur); E_aoe_prefab = Resources.Load("Prefabs/Champions/Garen/Garen_E_prefab") as GameObject; E_damage = new Types.damage_combo(); //TODO test only E_skill.level = 0; upgrade_skill("E"); W_skill.level = 0; upgrade_skill("W"); //TODO test only R_skill.level = 2; upgrade_skill("R"); }
public virtual Types.damage_combo Onhit_pre(Types.damage_combo combo) //magic damage, etc { combo = combo + Onhit_pre_item(combo); combo = combo + Onhit_dmg; if (Utility.is_crit(runtime_u_stats.crit_chance)) { combo.physical_dmg *= 2; } return(combo); }
public void init(Collider slf, float radius, bool continuous, Types.damage_combo dmg, Types.damage_combo start_dmg, Types.damage_combo end_dmg, float dur = 0, int times_of_dmg = 0, //paras for continuous damage bool crit = false, float single_tgt_bonus = 0, //if only one target in there, any additional damage? bool champ = true, bool minion = true, bool neturals = true, Utility.Timer share_dur = null, Utility.Timer share_dmg = null, Status enter_sts = default(Status), Status end_sts = default(Status)) { self = slf; duration = dur; damage = dmg; start_damage = start_dmg; end_damage = end_dmg; max_damage_times = times_of_dmg; done_damage_times = 0; can_crit = crit; single_target_bonus = single_tgt_bonus; enter_status = enter_sts; end_status = end_sts; affect_champions = champ; affect_minions = minion; affect_neturals = neturals; is_continuous = continuous; if (is_continuous) { if (share_dur == null) { sharing_dur = false; dur_timer = new Utility.Timer(dur); dur_timer.start_timer(); } else { sharing_dur = true; dur_timer = share_dur; } if (share_dmg == null) { sharing_dmg = false; dmg_timer = new Utility.Timer((float)(duration / max_damage_times)); dmg_timer.start_timer(); } else { sharing_dmg = true; dmg_timer = share_dmg; } } clder = GetComponent <CapsuleCollider> (); clder.radius = radius * GameSceneConsts.dist_multiplier; }
// Use this for initialization public void init(Garen _host, Utility.Timer E_timer, int damageTime, Types.damage_combo _dmg) { targets = new List <Unit> (); host = _host; self_col = GetComponent <CapsuleCollider> (); self_col.radius = 325f * GameSceneConsts.dist_multiplier; dur_timer = E_timer; dmg = _dmg; //how many times E deals damage dmgTimeRemaining = damageTime; maxDmgTime = damageTime; //it become damage per time dmg.physical_dmg /= (float)damageTime; timeStep = 3f * 100f / (float)damageTime; }
public void init(Unit _host, Types.damage_combo _dmg, float _speed, bool _guided = false, GameObject _tgt = null) { col = GetComponent <BoxCollider>(); host = _host; parent_obj = transform.parent.gameObject; guided = _guided; invalid = false; target = _tgt; targetPos = _tgt.transform.position; dmg = _dmg; speed = _speed * GameSceneConsts.dist_multiplier; transform.LookAt(target.transform.position); }
public override bool act_E() { if ((E_skill.level > 0) && (E_timer.is_over()) && (!E_flag) && can_cast()) { E_flag = true; //how many times E deals damage int dmg_times = 5 + (int)((runtime_c_stats.level - 1 - ((runtime_c_stats.level - 1) % 3)) / 3); //the total damage of E update_E_damage(); E_dur_timer.restart(); E_timer.restart(); E_obj = Instantiate(E_aoe_prefab, transform.position, transform.rotation) as GameObject; Types.damage_combo zero = new Types.damage_combo(); zero.init(); E_obj.GetComponent <Garen_E> ().init(this, E_dur_timer, dmg_times, E_damage); E_obj.name = "Garen_E_prefab"; E_obj.transform.SetParent(transform.parent); return(true); } return(false); }
//call this before actual init(); public void init_pre() { netID = transform.parent.gameObject.GetComponent <NetworkIdentity> (); self_col = GetComponent <Collider> (); cur_target_obj = null; status = new List <Status> (); flags = new unit_flags(); flags.init(); if ((!netID.isLocalPlayer) && (isPlayer)) { return; } //stats base_u_stats = new unit_stats(); base_u_stats.init(); base_u_stats_mult = new unit_stats(); base_u_stats_mult.init_to_1(); u_stats_growth = new unit_stats(); u_stats_growth.init(); bonus_u_stats = new unit_stats(); bonus_u_stats.init(); bonus_u_stats_mult = new unit_stats(); bonus_u_stats_mult.init_to_1(); inCombat_timer = new Utility.Timer(GameSceneConsts.in_combat_time); regen_timer = new Utility.Timer(GameSceneConsts.regen_interval); regen_timer.start_timer(); items = new Item[GameSceneConsts.max_item + GameSceneConsts.max_supp_item]; for (int i = 0; i < items.Length; ++i) { items [i] = null; } Onhit_dmg = new Types.damage_combo(); Onhit_dmg.init(); recent_dmg_receive = new Types.damage_combo(); recent_dmg_receive.init(); }
//all on-hit item effect need to be processed after hitting target (e.g. lifesteal) public virtual void Onhit_post_item(Types.damage_combo dmg) { }
public virtual void Onhit_post(Types.damage_combo dmg) //life steal, etc { Onhit_post_item(dmg); //life steal change_health(dmg.physical_dmg * runtime_u_stats.life_steal); }
//all on-hit item effect need to be processed before hitting target public virtual Types.damage_combo Onhit_pre_item(Types.damage_combo combo) { combo.init(); return(combo); }
//this funtion can be called only once during for one skill/autoattack public virtual bool receive_damage(Unit source, bool applyOnhit, Types.damage_combo dmg) //return true if killed someone { recent_dmg_receive.init(); bool result = false; float calc_pd = Utility.get_damage(dmg.physical_dmg, runtime_u_stats.armor * (1f - dmg.armor_pen_percent) - dmg.armor_pen, runtime_u_stats.dmg_reduction); float calc_md = Utility.get_magic_damage(dmg.magic_dmg, runtime_u_stats.magic_resist * (1f - dmg.magic_pen_percent) - dmg.magic_pen, runtime_u_stats.dmg_reduction); float temp; temp = change_health(-calc_pd); if (temp < 0) { recent_dmg_receive.physical_dmg += (-temp); result = true; } else { recent_dmg_receive.physical_dmg += temp; } temp = change_health(-calc_md); if (temp < 0) { recent_dmg_receive.magic_dmg += (-temp); result = true; } else { recent_dmg_receive.magic_dmg += temp; } temp = change_health(-dmg.true_dmg * (1f - runtime_u_stats.dmg_reduction)); if (temp < 0) { recent_dmg_receive.true_dmg += (-temp); result = true; } else { recent_dmg_receive.true_dmg += temp; } temp = change_health(-dmg.pure_dmg); if (temp < 0) { recent_dmg_receive.pure_dmg += (-temp); result = true; } else { recent_dmg_receive.pure_dmg += temp; } Utility.generate_dmg_txt(gameObject, (int)calc_pd, Color.red); Utility.generate_dmg_txt(gameObject, (int)calc_md, Color.cyan); //aftermath change_incombat_state(true); if (applyOnhit && Utility.LifeStealable(gameObject)) { source.Onhit_post(recent_dmg_receive); } if ((!flags.is_dead) && result) { source.OnKillingTarget(this); process_death(); } return(result); }