//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); }
// 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); } } }
public void change_incombat_state(bool _state) { flags.in_combat = _state; if (_state) { inCombat_timer.restart(); } else { inCombat_timer.finish(); } }
//skills public override bool act_Q() { if ((Q_skill.level > 0) && (Q_timer.is_over()) && (!Q_flag) && can_cast()) { Q_flag = true; Q_dur_timer.restart(); Q_timer.restart(); Q_move_dur_timer.restart(); bonus_u_stats_mult.move_speed += Q_move_bonus; update_movement_speed(); return(true); } return(false); }
// 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(); } } }