protected override void OnMouseDown(UIMouseEventParameter p) { base.OnMouseDown(p); EventBusManager.Instance().Publish("closeVehiclePanel", null); VehicleHolder.getInstance().setVehicleInfo(vehicleInfo); }
protected override void OnToolUpdate() { if (m_toolController != null && !m_toolController.IsInsideUI && Cursor.visible) { RaycastOutput raycastOutput; if (RaycastRoad(out raycastOutput)) { ushort netSegmentId = raycastOutput.m_netSegment; if (netSegmentId != 0) { NetManager netManager = Singleton <NetManager> .instance; NetSegment netSegment = netManager.m_segments.m_buffer[(int)netSegmentId]; if (netSegment.m_flags.IsFlagSet(NetSegment.Flags.Created)) { if (Event.current.type == EventType.MouseDown /*&& Event.current.button == (int)UIMouseButton.Left*/) { Vector3 pos1; Vector3 pos2; Vector3 rot1; Vector3 rot2; bool smooth1; bool smooth2; netSegment.CalculateCorner(netSegmentId, true, true, true, out pos1, out rot1, out smooth1); netSegment.CalculateCorner(netSegmentId, true, false, true, out pos2, out rot2, out smooth2); LoggerUtils.Log(string.Format("pos:{0},rot:{1}", pos1, rot1)); LoggerUtils.Log(string.Format("pos:{0},rot:{1}", pos2, rot2)); Vector3 diff = pos2 - pos1; float angle = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg; LoggerUtils.Log(string.Format("angle:{0}", angle)); ShowToolInfo(false, null, new Vector3()); VehicleInfo info = VehicleHolder.getInstance().getVehicleInfo(); VehicleHolder.getInstance().setActive(netSegment.m_middlePosition, Vector3.zero); //unset self as tool ToolsModifierControl.toolController.CurrentTool = ToolsModifierControl.GetTool <DefaultTool>(); ToolsModifierControl.SetTool <DefaultTool>(); UnityEngine.Object.Destroy(this); } else { ShowToolInfo(true, "Spawn Vehicle", netSegment.m_bounds.center); } } } } } else { ShowToolInfo(false, null, new Vector3()); } }
public override void OnLevelLoaded(LoadMode mode) { if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame || mode == LoadMode.NewMap || mode == LoadMode.LoadMap) { UIView view = UIView.GetAView(); vehicleHolder = VehicleHolder.getInstance(); UI = ToolsModifierControl.toolController.gameObject.AddComponent <UIMainPanel>(); panelExtender = ToolsModifierControl.toolController.gameObject.AddComponent <GamePanelExtender>(); } }
public override void OnLevelUnloading() { VehicleHolder.getInstance().setInactive(); EventBusManager.Instance().Clear(); }
void Update() { if (!initialized) { privateVehicleInfoPanel = GameObject.Find("(Library) CitizenVehicleWorldInfoPanel").GetComponent <CitizenVehicleWorldInfoPanel>(); privateVehicleInfoPanel.Find <UITextField>("VehicleName").width = 150; drivePrivateVehicleBtn = CreateCameraButton ( privateVehicleInfoPanel.component, (component, param) => { Vector3 position; Vector3 rotation; VehicleInfo vehicleInfo; InstanceID instance = ReflectionUtils.ReadPrivate <CitizenVehicleWorldInfoPanel, InstanceID>(privateVehicleInfoPanel, "m_InstanceID"); vehicleInfo = instance.Vehicle != 0 ? manager.m_vehicles.m_buffer[instance.Vehicle].Info : manager.m_parkedVehicles.m_buffer[instance.ParkedVehicle].Info; position = instance.Vehicle != 0 ? manager.m_vehicles.m_buffer[instance.Vehicle].GetLastFrameData().m_position : manager.m_parkedVehicles.m_buffer[instance.ParkedVehicle].m_position; rotation = instance.Vehicle != 0 ? manager.m_vehicles.m_buffer[instance.Vehicle].GetLastFrameData().m_rotation.eulerAngles : manager.m_parkedVehicles.m_buffer[instance.ParkedVehicle].m_rotation.eulerAngles; VehicleHolder.getInstance().setVehicleInfo(vehicleInfo); VehicleHolder.getInstance().setActive(position, rotation); privateVehicleInfoPanel.Hide(); } ); serviceVehicleInfoPanel = GameObject.Find("(Library) CityServiceVehicleWorldInfoPanel").GetComponent <CityServiceVehicleWorldInfoPanel>(); serviceVehicleInfoPanel.Find <UITextField>("VehicleName").width = 150; driveServiceVehicleBtn = CreateCameraButton ( serviceVehicleInfoPanel.component, (component, param) => { Vector3 position; Vector3 rotation; VehicleInfo vehicleInfo; InstanceID instance = ReflectionUtils.ReadPrivate <CityServiceVehicleWorldInfoPanel, InstanceID>(serviceVehicleInfoPanel, "m_InstanceID"); vehicleInfo = instance.Vehicle != 0 ? manager.m_vehicles.m_buffer[instance.Vehicle].Info : manager.m_parkedVehicles.m_buffer[instance.ParkedVehicle].Info; position = instance.Vehicle != 0 ? manager.m_vehicles.m_buffer[instance.Vehicle].GetLastFrameData().m_position : manager.m_parkedVehicles.m_buffer[instance.ParkedVehicle].m_position; rotation = instance.Vehicle != 0 ? manager.m_vehicles.m_buffer[instance.Vehicle].GetLastFrameData().m_rotation.eulerAngles : manager.m_parkedVehicles.m_buffer[instance.ParkedVehicle].m_rotation.eulerAngles; VehicleHolder.getInstance().setVehicleInfo(vehicleInfo); VehicleHolder.getInstance().setActive(position, rotation); serviceVehicleInfoPanel.Hide(); } ); publicVehicleInfoPanel = GameObject.Find("(Library) PublicTransportVehicleWorldInfoPanel").GetComponent <PublicTransportVehicleWorldInfoPanel>(); publicVehicleInfoPanel.Find <UITextField>("VehicleName").width = 150; publicVehicleBtn = CreateCameraButton ( publicVehicleInfoPanel.component, (component, param) => { Vector3 position; Vector3 rotation; VehicleInfo vehicleInfo; InstanceID instance = ReflectionUtils.ReadPrivate <PublicTransportVehicleWorldInfoPanel, InstanceID>(publicVehicleInfoPanel, "m_InstanceID"); vehicleInfo = instance.Vehicle != 0 ? manager.m_vehicles.m_buffer[instance.Vehicle].Info : manager.m_parkedVehicles.m_buffer[instance.ParkedVehicle].Info; position = instance.Vehicle != 0 ? manager.m_vehicles.m_buffer[instance.Vehicle].GetLastFrameData().m_position : manager.m_parkedVehicles.m_buffer[instance.ParkedVehicle].m_position; rotation = instance.Vehicle != 0 ? manager.m_vehicles.m_buffer[instance.Vehicle].GetLastFrameData().m_rotation.eulerAngles : manager.m_parkedVehicles.m_buffer[instance.ParkedVehicle].m_rotation.eulerAngles; VehicleHolder.getInstance().setVehicleInfo(vehicleInfo); VehicleHolder.getInstance().setActive(position, rotation); publicVehicleInfoPanel.Hide(); } ); initialized = true; } }