//in-game actions public virtual GameObject auto_attack(GameObject target) { if ((target == null) || (!autoAtkTimer.is_over()) || (!within_range(target)) || !can_attack() || (!Utility.LayerTargetable(target))) { return(null); } //transform.LookAt (new Vector3(target.transform.position.x, transform.position.y, transform.position.z)); GameObject projectile = new GameObject(); if (autoAtkTimer.is_over()) { change_incombat_state(true); Unit tgt = target.GetComponent <Unit> (); if (flags.ranged) { projectile = Instantiate(autoAtk_prefab, transform.position, transform.rotation) as GameObject; Projectile proj_script = Utility.get_projectile_script(projectile); proj_script.init(this, prepare_dmg(), runtime_u_stats.projectile_spd, true, target); } else //melee //setup damage and on-hit stuff { if (tgt.receive_damage(this, true, prepare_dmg())) //TODO should have a null check here //OnKillingTarget (tgt); called by the target { cur_target_obj = null; } } autoAtkTimer.restart(); } return(projectile); }
//Updates public virtual void update_timers() { autoAtkTimer.update_timer(); if (flags.in_combat) { inCombat_timer.update_timer(); if (inCombat_timer.is_over()) { change_incombat_state(false); } } //update and possibily, clear status List <Status> trashbin = new List <Status>(); foreach (Status sts in status) { sts.update_status(); if (sts.is_over()) { trashbin.Add(sts); } } foreach (Status trash in trashbin) { flags.set_flag_from_string(trash.flags, false); status.Remove(trash); } trashbin.Clear(); }
// Update is called once per frame void Update() { timer_wave.update_timer(); if (timer_wave.is_over()) { wave_active = true; minion_sent = 0; timer_wave.restart(); } if (wave_active) { timer_micro.update_timer(); if (timer_micro.is_over()) { int minion_num = NormalWave.Count; List <Minion.Minion_Type> list = NormalWave; if (type == WaveType.ENHANCED) { minion_num = CannonWave.Count; list = CannonWave; } else if (type == WaveType.SUPER) { minion_num = SuperWave.Count; list = SuperWave; } spawn_minion_check_flag(list, minion_num); } } }
// 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(); } } }
// Update is called once per frame public virtual void Update() { //..and not a server-controlled object if (!unit.netID.isServer) { return; } if (!unit.flags.is_dead) { ThinkTimer.update_timer(); if (ThinkTimer.is_over()) { clean_up_all_lists(); think(); ThinkTimer.restart(); } //if we're aiming at a target, move until within range, and attack if (unit.cur_target_obj != null) { if (Utility.LayerTargetable(unit.cur_target_obj)) { if (unit.within_range(unit.cur_target_obj)) { unit.stop_moving(); unit.auto_attack(unit.cur_target_obj); } else //we have to move close to the target { unit.resume_moving(); unit.attackto(unit.cur_target_obj); } } else { unit.cur_target_obj = null; } } else //continue with the objective { unit.resume_moving(); unit.return_to_objective(); } } }
public bool is_over() { return(timer.is_over()); }
// Update is called once per frame void Update() { if (dur_timer.get_time_remaining() <= 3f * 100f - (maxDmgTime - dmgTimeRemaining) * timeStep) { dmgTimeRemaining -= 1; float dmg_modifier = 1f; if (targets.Count == 1) { if (targets [0] != null) { if (targets [0].gameObject.tag == GameSceneConsts.MINION_TAG) { dmg_modifier *= (1.33f * 0.75f); } else { dmg_modifier *= 1.33f; } if (Utility.is_crit(host.runtime_u_stats.crit_chance)) { dmg_modifier *= 2f; } actual_dmg = dmg_modifier * dmg; if (targets [0] != null) { targets [0].receive_damage(host, false, actual_dmg); } } } else { foreach (Unit tgt in targets) { if (tgt != null) { dmg_modifier = 1f; if (Utility.is_crit(host.runtime_u_stats.crit_chance)) { dmg_modifier *= 2f; } if (tgt.gameObject.tag == GameSceneConsts.MINION_TAG) { dmg_modifier *= 0.75f; actual_dmg = dmg_modifier * dmg; if (tgt != null) { tgt.receive_damage(host, false, actual_dmg); } } else { if (tgt != null) { tgt.receive_damage(host, false, dmg); } } } } } } if (dur_timer.is_over() || (dmgTimeRemaining <= 0)) { self_destroy(); } }
GameObject E_obj; //runtime e object public override void update_timers() { if (!netID.isLocalPlayer) { return; } autoAtkTimer.update_timer(); Q_timer.update_timer(); W_timer.update_timer(); E_timer.update_timer(); R_timer.update_timer(); Passive_timer.update_timer(); death_timer.update_timer(); if (!flags.is_dead) { regen_timer.update_timer(); if (regen_timer.is_over()) { regen_timer.reset_timer(); change_health(runtime_u_stats.hp_reg); //TODO mana regen here } } //Q skills Q_dur_timer.update_timer(); if (Q_dur_timer.is_over()) { Q_dur_timer.reset_timer(); Q_flag = false; } Q_move_dur_timer.update_timer(); if (Q_move_dur_timer.is_over()) { Q_move_dur_timer.reset_timer(); bonus_u_stats_mult.move_speed -= Q_move_bonus; update_movement_speed(); } W_dur_timer.update_timer(); if (W_dur_timer.is_over()) { W_dur_timer.reset_timer(); W_flag = false; W_dmg_rdc_runtime = 0f; update_dmg_reduction(); } E_dur_timer.update_timer(); if (E_dur_timer.is_over()) { if (E_obj == null) { E_dur_timer.reset_timer(); } E_flag = false; } //update and possibily, clear status List <Status> trashbin = new List <Status>(); foreach (Status sts in status) { sts.update_status(); if (sts.is_over()) { trashbin.Add(sts); } } foreach (Status trash in trashbin) { flags.set_flag_from_string(trash.flags, false); status.Remove(trash); } trashbin.Clear(); if (isPlayer) { refresh_player_panel(); } }
//low-level stuff /* * public GameObject cur_collision_obj; * * void OnTriggerEnter(Collider col){ * if(col.transform.parent != transform.parent) * cur_collision_obj = col.gameObject; * } * * void OnTriggerExit(Collider col){ * if(col.transform.parent != transform.parent) * cur_collision_obj = null; * } */ public override void update_unique() { if (!netID.isLocalPlayer) { return; } //this one seems to work fine for a champion, but we'll see if (!flags.is_dead) { //ai takeover if (reached(navagent.destination)) { ai_takeover = true; rotation_override = false; } else { ai_takeover = false; rotation_override = true; } //if (reached (navagent.destination)) // rotation_override = false; Vector3 lookatdir = navagent.steeringTarget - transform.position; Vector3 cur_forward = transform.forward; lookatdir.y = 0f; cur_forward.y = 0f; transform.position = navagent.transform.position; //Vector3.Lerp(transform.position, navagent.transform.position, Time.deltaTime); if (navagent.desiredVelocity.magnitude >= 0.1f * runtime_u_stats.move_speed * GameSceneConsts.dist_multiplier) { navagent.velocity = navagent.desiredVelocity.normalized * runtime_u_stats.move_speed * GameSceneConsts.dist_multiplier; } else { navagent.velocity = Vector3.zero; } //print (navagent.velocity.magnitude); if (!stunned()) { //if (Mathf.Abs (Vector3.Angle (lookatdir, cur_forward)) >= 10f) {//10 is a magic number TODO rewrite this if (cur_target_obj != null) { if (within_range(cur_target_obj)) { //no override means it should autoattack, so stop moving stop_moving(); auto_attack(cur_target_obj); } if (ai_takeover && (cur_target_obj != null)) { transform.LookAt(new Vector3(cur_target_obj.transform.position.x, transform.position.y, cur_target_obj.transform.position.z)); } else { transform.LookAt(new Vector3(navagent.steeringTarget.x, transform.position.y, navagent.steeringTarget.z)); resume_moving(); } } else { transform.LookAt(new Vector3(navagent.steeringTarget.x, transform.position.y, navagent.steeringTarget.z)); resume_moving(); } } } else //special update during death { if (death_timer.is_over()) //time to respawn { death_timer.reset_timer(); respawn(); } } }