2020-05-31 17:07:22 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using SanAndreasUnity.Behaviours;
|
|
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.UI {
|
|
|
|
|
|
|
|
|
|
public class UtilitiesWindow : PauseMenuWindow {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UtilitiesWindow() {
|
|
|
|
|
|
|
|
|
|
// set default parameters
|
|
|
|
|
|
|
|
|
|
this.windowName = "Utilities";
|
|
|
|
|
this.useScrollView = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start () {
|
|
|
|
|
|
|
|
|
|
this.RegisterButtonInPauseMenu ();
|
|
|
|
|
|
|
|
|
|
// adjust rect
|
2019-07-26 23:34:55 +00:00
|
|
|
|
float width = 240;
|
2019-07-28 22:58:50 +00:00
|
|
|
|
float height = 210;
|
2019-07-28 20:38:10 +00:00
|
|
|
|
if (Utilities.F.ScreenHasHighDensity)
|
|
|
|
|
{
|
2019-07-28 22:58:50 +00:00
|
|
|
|
width = Screen.width * 0.375f;
|
|
|
|
|
height = Screen.height * 0.4f;
|
2019-07-28 20:38:10 +00:00
|
|
|
|
}
|
|
|
|
|
this.windowRect = new Rect(Screen.width / 2 - width / 2, 10, width, height);
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnWindowGUI ()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (Ped.Instance) {
|
|
|
|
|
// display player position
|
|
|
|
|
// Vector2 pos = new Vector2 (_player.transform.position.x + 3000, 6000 - (_player.transform.position.z + 3000));
|
|
|
|
|
GUILayout.Label ("Pos: " + Ped.InstancePos);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-05 19:01:29 +00:00
|
|
|
|
if (Utilities.NetUtils.IsServer)
|
|
|
|
|
DisplayServerGui();
|
2019-07-05 22:39:47 +00:00
|
|
|
|
else if (Net.PlayerRequests.Local != null)
|
|
|
|
|
DisplayClientOnlyGui();
|
2019-07-05 19:01:29 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DisplayServerGui()
|
|
|
|
|
{
|
2019-07-08 19:32:03 +00:00
|
|
|
|
Transform nearbyTransform = Ped.Instance != null ? Ped.Instance.transform : null;
|
2019-07-05 19:01:29 +00:00
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
if (GUILayout.Button ("Spawn random vehicle")) {
|
2019-07-08 21:43:13 +00:00
|
|
|
|
if (Ped.Instance != null)
|
|
|
|
|
Behaviours.Vehicles.Vehicle.CreateRandomInFrontOf(Ped.Instance.transform);
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Change player model"))
|
|
|
|
|
{
|
|
|
|
|
CharacterModelChanger.ChangePedestrianModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Spawn 5 peds"))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
2019-07-08 19:32:03 +00:00
|
|
|
|
Ped.SpawnPed (Ped.RandomPedId, nearbyTransform);
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Spawn 5 stalker peds"))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
2019-07-08 20:11:26 +00:00
|
|
|
|
Ped.SpawnPedStalker (Ped.RandomPedId, nearbyTransform, Ped.Instance);
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Destroy all vehicles"))
|
|
|
|
|
{
|
|
|
|
|
var vehicles = FindObjectsOfType<Behaviours.Vehicles.Vehicle> ();
|
2019-06-23 22:31:53 +00:00
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
foreach (var v in vehicles) {
|
2019-06-23 22:31:53 +00:00
|
|
|
|
Destroy (v.gameObject);
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-05 22:39:47 +00:00
|
|
|
|
void DisplayClientOnlyGui()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var pr = Net.PlayerRequests.Local;
|
|
|
|
|
|
2019-07-08 19:48:06 +00:00
|
|
|
|
if (GUILayout.Button("Request vehicle"))
|
2019-07-05 22:39:47 +00:00
|
|
|
|
{
|
2019-07-08 21:43:13 +00:00
|
|
|
|
pr.RequestVehicleSpawn(-1);
|
2019-07-05 22:39:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 19:48:06 +00:00
|
|
|
|
if (GUILayout.Button("Request ped model change"))
|
2019-07-05 22:39:47 +00:00
|
|
|
|
{
|
|
|
|
|
pr.RequestPedModelChange();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Request suicide"))
|
|
|
|
|
{
|
|
|
|
|
pr.RequestSuicide();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 19:48:06 +00:00
|
|
|
|
if (GUILayout.Button("Request ped stalker"))
|
2019-07-08 19:45:33 +00:00
|
|
|
|
{
|
|
|
|
|
pr.SpawnPedStalker();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 22:16:10 +00:00
|
|
|
|
if (GUILayout.Button("Request to destroy my vehicles"))
|
2019-07-05 22:39:47 +00:00
|
|
|
|
{
|
2019-07-08 22:16:10 +00:00
|
|
|
|
pr.RequestToDestroyMyVehicles();
|
2019-07-05 22:39:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|