174 lines
3.6 KiB
C#
174 lines
3.6 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class EquipmentPreviewManager : MonoBehaviour
|
|
{
|
|
public int currentSkybox;
|
|
|
|
public List<Material> skyboxes = new List<Material>();
|
|
|
|
[HideInInspector]
|
|
public ReflectionProbe reflectionProbe;
|
|
|
|
public Light mainLight;
|
|
|
|
public float lightIntensityChange = 0.1f;
|
|
|
|
public GameObject equipmentGui;
|
|
|
|
public List<EquipmentPreview> previews = new List<EquipmentPreview>();
|
|
|
|
public List<EquipmentPreview> previewsDLC = new List<EquipmentPreview>();
|
|
|
|
[HideInInspector]
|
|
public List<EquipmentPreview> currentPreviews;
|
|
|
|
[HideInInspector]
|
|
public int currentPreview;
|
|
|
|
public Camera camera;
|
|
|
|
public static bool wasInEquipmentTest;
|
|
|
|
private void Start()
|
|
{
|
|
reflectionProbe = Object.FindObjectOfType<ReflectionProbe>();
|
|
reflectionProbe.RenderProbe();
|
|
currentPreviews = previews;
|
|
HideAll();
|
|
currentPreviews[0].gameObject.SetActive(true);
|
|
ChangePreview();
|
|
ChangeSkybox();
|
|
wasInEquipmentTest = true;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.C))
|
|
{
|
|
ChangeSkybox(false);
|
|
}
|
|
else if (Input.GetKeyDown(KeyCode.V))
|
|
{
|
|
ChangeSkybox(true);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.G))
|
|
{
|
|
ToggleGUI();
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Z))
|
|
{
|
|
if (mainLight.intensity > 0.5f)
|
|
{
|
|
mainLight.intensity -= lightIntensityChange;
|
|
reflectionProbe.RenderProbe();
|
|
}
|
|
}
|
|
else if (Input.GetKeyDown(KeyCode.X) && mainLight.intensity < 1.5f)
|
|
{
|
|
mainLight.intensity += lightIntensityChange;
|
|
reflectionProbe.RenderProbe();
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.R))
|
|
{
|
|
iTween[] array = Object.FindObjectsOfType<iTween>();
|
|
iTween[] array2 = array;
|
|
foreach (iTween iTween2 in array2)
|
|
{
|
|
iTween2.isRunning = !iTween2.isRunning;
|
|
}
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
{
|
|
if (currentPreviews == previews)
|
|
{
|
|
currentPreviews = previewsDLC;
|
|
}
|
|
else if (currentPreviews == previewsDLC)
|
|
{
|
|
currentPreviews = previews;
|
|
}
|
|
currentPreview = 0;
|
|
HideAll();
|
|
currentPreviews[0].gameObject.SetActive(true);
|
|
ChangePreview();
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.LeftArrow))
|
|
{
|
|
ChangePreview(false);
|
|
}
|
|
else if (Input.GetKeyDown(KeyCode.RightArrow))
|
|
{
|
|
ChangePreview(true);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
LoadingManager.LoadScene("MainMenu");
|
|
}
|
|
}
|
|
|
|
public void ChangeSkybox(bool next)
|
|
{
|
|
currentSkybox += (next ? 1 : (-1));
|
|
if (currentSkybox < 0)
|
|
{
|
|
currentSkybox = skyboxes.Count - 1;
|
|
}
|
|
if (currentSkybox >= skyboxes.Count)
|
|
{
|
|
currentSkybox = 0;
|
|
}
|
|
ChangeSkybox();
|
|
}
|
|
|
|
public void ChangeSkybox()
|
|
{
|
|
RenderSettings.skybox = skyboxes[currentSkybox];
|
|
reflectionProbe.RenderProbe();
|
|
}
|
|
|
|
public void ChangePreview(bool next)
|
|
{
|
|
currentPreview += (next ? 1 : (-1));
|
|
if (currentPreview < 0)
|
|
{
|
|
currentPreview = currentPreviews.Count - 1;
|
|
}
|
|
if (currentPreview >= currentPreviews.Count)
|
|
{
|
|
currentPreview = 0;
|
|
}
|
|
for (int i = 0; i < currentPreviews.Count; i++)
|
|
{
|
|
currentPreviews[i].gameObject.SetActive(i == currentPreview);
|
|
}
|
|
ChangePreview();
|
|
}
|
|
|
|
public void ChangePreview()
|
|
{
|
|
if ((bool)currentPreviews[currentPreview].cameraPosition)
|
|
{
|
|
camera.transform.position = currentPreviews[currentPreview].cameraPosition.position;
|
|
camera.transform.rotation = currentPreviews[currentPreview].cameraPosition.rotation;
|
|
}
|
|
}
|
|
|
|
public void HideAll()
|
|
{
|
|
for (int i = 0; i < previews.Count; i++)
|
|
{
|
|
previews[i].gameObject.SetActive(false);
|
|
}
|
|
for (int j = 0; j < previewsDLC.Count; j++)
|
|
{
|
|
previewsDLC[j].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void ToggleGUI()
|
|
{
|
|
equipmentGui.SetActive(!equipmentGui.activeSelf);
|
|
}
|
|
}
|