2020-05-31 17:07:22 +00:00
|
|
|
|
using SanAndreasUnity.Behaviours;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2019-07-05 22:55:42 +00:00
|
|
|
|
namespace SanAndreasUnity.Behaviours
|
2020-05-31 17:07:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
2019-07-05 22:55:42 +00:00
|
|
|
|
public class UIVehicleSpawner : MonoBehaviour
|
2020-05-31 17:07:22 +00:00
|
|
|
|
{
|
2019-07-05 22:55:42 +00:00
|
|
|
|
public KeyCode spawnKey = KeyCode.V;
|
2020-05-31 17:07:22 +00:00
|
|
|
|
|
2019-07-05 22:55:42 +00:00
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
2020-04-20 20:31:56 +00:00
|
|
|
|
if (Input.GetKeyDown(spawnKey) && GameManager.CanPlayerReadInput())
|
2019-07-05 22:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
if (Utilities.NetUtils.IsServer)
|
|
|
|
|
SpawnVehicle();
|
|
|
|
|
else if (Net.PlayerRequests.Local != null)
|
2019-07-08 21:43:13 +00:00
|
|
|
|
Net.PlayerRequests.Local.RequestVehicleSpawn(-1);
|
2019-07-05 22:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-31 17:07:22 +00:00
|
|
|
|
|
2019-07-08 21:43:13 +00:00
|
|
|
|
private void SpawnVehicle()
|
2019-07-05 22:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
var ped = Ped.Instance;
|
2020-05-31 17:07:22 +00:00
|
|
|
|
|
2019-07-05 22:55:42 +00:00
|
|
|
|
if (null == ped)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-07-08 21:43:13 +00:00
|
|
|
|
Vehicles.Vehicle.CreateRandomInFrontOf(ped.transform);
|
2019-07-05 22:55:42 +00:00
|
|
|
|
|
|
|
|
|
}
|
2019-07-05 21:46:59 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-05 22:55:42 +00:00
|
|
|
|
}
|