private void ShipStatsUpdate() { // Writes information in the bottem_left corner float relative_vel = SceneGlobals.ReferenceSystem.RelativeVelocity(PlayerShip.Velocity).magnitude; texts["velocity_indicator"].text = (Mathf.Round(relative_vel * 100f) / 100f).ToString() + " m/s"; texts["angular_momentum_indicator"].text = (Mathf.Round(PlayerShip.AngularVelocity.magnitude * Mathf.Deg2Rad * 100f) / 100f).ToString() + " rad/s"; // Points to one turret if (turret_selected) { HighlightingPosition = MainCam.WorldToScreenPoint(selected_turret.Position); } if (HighlightingPosition == Vector3.zero) { pointers ["turret_position"].transform.position = new Vector3(-200, -200, 0); } else { Vector3 screen_pos = HighlightingPosition; screen_pos.z = 0f; pointers ["turret_position"].transform.position = HighlightingPosition; pointers ["turret_position"].transform.Rotate(0, 0, Time.deltaTime * 90); } // Updates stuff SliderUpdate(); TurretSliderUpdate(); if (Input.mouseScrollDelta.y > 0 && (selected_turret != null || selected_group != null)) { // up scroll_bar.value -= .05f; } if (Input.mouseScrollDelta.y < 0 && (selected_turret != null || selected_group != null)) { // down scroll_bar.value += .05f; } mouse_on_menu = !GroupSwitch?turret_menu.rectTransform.rect.Contains(Input.mousePosition - turret_menu.rectTransform.position) : group_menu.rectTransform.rect.Contains(Input.mousePosition - group_menu.rectTransform.position); if (!mouse_on_menu && !turret_selected) { turret_menu.rectTransform.position = new Vector3(-200, -200, 0); selected_turret = null; } if (!mouse_on_menu && !group_selected) { group_menu.rectTransform.position = new Vector3(-100, -200, 0); selected_group = null; } }
///<summary> This should be called from the third frame on </summary> private void BattleSymbolsUpdate() { // Defines Target Target target = player_script.target; ReferenceSystem ref_sys = SceneGlobals.ReferenceSystem; // Projects the player's "absolute" velocity (relative to the origin of the scene) if (PlayerShip != null && ref_sys.RelativeVelocity(PlayerShip.Velocity) != Vector3.zero) { Image prog = pointers["prograde_marker"]; ProjectVecOnScreen(ref_sys.RelativeVelocity(PlayerShip.Velocity), camera_transform, ref prog); } // Projects the players relative velocity to his selected target if (target.Exists) { if (!target.virt_ship) { if (PlayerShip.Velocity - target.Ship.Velocity != Vector3.zero) { Image tgt_vel = pointers["target_velocity_marker"]; ProjectVecOnScreen(PlayerShip.Velocity - target.Ship.Velocity, camera_transform, ref tgt_vel); } } } // Weapon indicators foreach (Weapon w in PlayerShip.Parts.GetAll <Weapon>()) { Image img = weapon_states[w]; Vector3 new_pos = MainCam.WorldToScreenPoint(player_transform.position + (player_transform.forward * 100000)); new_pos.z = 0; img.rectTransform.position = new_pos; if (w.ooo_time > 0) { float ratio = 1 - (w.ooo_time / w.init_ooo_time) * .75f; img.color = new Color(ratio, ratio, ratio); } else { img.color = new Color(1f, 1 - w.heat, 1 - w.heat); } } // Turret Indicators foreach (Turret t in PlayerShip.Parts.GetAll <Turret>()) { Image img = turret_states[t]; Vector3 new_pos = MainCam.WorldToScreenPoint(transform.position + (t.BarrelRot * Vector3.forward * 100000f)); new_pos.z = 0; img.rectTransform.position = new_pos; if (t.ooo_time > 0) { float ratio = 1 - (t.ooo_time / t.init_ooo_time) * .75f; img.color = new Color(ratio, ratio, ratio); } else { img.color = new Color(1f, 1 - t.heat, 1 - t.heat); } } // Draws the "direction pointer" (the velocity direction) Vector3 direction_projection = direction == Vector3.zero ? new Vector3(-200, -200) : MainCam.WorldToScreenPoint(direction + transform.position); direction_projection.z = 0; pointers ["direction_pointer"].transform.position = direction_projection; Vector3 velocity_dir = PlayerShip.Velocity == Vector3.zero ? new Vector3(-200, -200) : MainCam.WorldToScreenPoint(PlayerShip.Position + PlayerShip.Velocity.normalized * 1e9f); velocity_dir.z = 0; pointers ["prograde"].transform.position = velocity_dir; pointers ["prograde"].color = Vector3.Angle(PlayerShip.Velocity, camera_transform.forward) < 90f ? Color.green : Color.red; if (player_script.target != null) { if (player_script.target.Exists) { tgting_point = player_script.target.Position; } } if (group_follows_cursor) { if (current_group != null) { current_group.SetTgtDir(CursorWorldDirection); } } }