public override void init() { init_pre(); ui = Utility.get_UI(transform.parent.gameObject); ui_champ = Utility.get_UI(transform.parent.gameObject) as UI_Champion; rb = GetComponent <Rigidbody> (); if (!netID.isLocalPlayer && isPlayer) { return; } death_timer = new Utility.Timer(0f); death_timer.change_max_timer(2f); //TODO should not be a fixed value; death_timer.reset_timer(); //if (transform.parent.FindChild ("NavUnit") != null) { // navagent = transform.parent.FindChild ("NavUnit").gameObject.GetComponent<NavMeshAgent> (); // if (navagent != null) // navagent.transform.SetParent (null); //} //navagent.updateRotation = false; //navagent.updatePosition = false; //init stats flags.init(); c_flags.init(); base_u_stats.init(); bonus_u_stats.init(); u_stats_growth.init(); base_c_stats.init(); runtime_c_stats.init(); status = new List <Status> (); load_garen_base_stats(); init_garen_skills(); init_post(); /* * //init runtime stats * runtime_u_stats = base_u_stats; * update_attack_speed (); * update_movement_speed (); * * //set suto attack timers * autoAtkTimer = new Utility.Timer(runtime_u_stats.attack_speed); * autoAtkTimer.start_timer (); * //rb.detectCollisions = true; * //init appearances * //load special FX * * //Unity stuff * self_col = GetComponent<Collider> (); * init_AtkTarget (); * * init_resources (); */ //navagent.updatePosition = false; }
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(); } } }