狗屎Minimax坏我代码
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
using SickscoreGames.ExampleScene;
|
||||
using SickscoreGames.HUDNavigationSystem;
|
||||
using SickscoreGames.ExampleScene;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class ExampleInteractions : MonoBehaviour
|
||||
{
|
||||
@@ -16,6 +11,7 @@ public class ExampleInteractions : MonoBehaviour
|
||||
|
||||
private RaycastHit hit;
|
||||
private Transform pickupText;
|
||||
private Transform openDoorText;
|
||||
private Transform interactionText;
|
||||
private HUDNavigationSystem _HUDNavigationSystem;
|
||||
#endregion
|
||||
@@ -30,9 +26,17 @@ public class ExampleInteractions : MonoBehaviour
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (_HUDNavigationSystem == null)
|
||||
return;
|
||||
|
||||
HandleKeyInput ();
|
||||
HandleItemPickUp ();
|
||||
HandlePrismColorChange ();
|
||||
|
||||
if (_HUDNavigationSystem.isEnabled)
|
||||
{
|
||||
HandleItemPickUp ();
|
||||
HandleDoorOpening();
|
||||
HandlePrismColorChange ();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -41,78 +45,67 @@ public class ExampleInteractions : MonoBehaviour
|
||||
void HandleKeyInput ()
|
||||
{
|
||||
// update radar zoom / indicator border input
|
||||
if (Input.GetKey (KeyCode.X) && _HUDNavigationSystem.radarZoom < 5f)
|
||||
if (ExampleUniversalInput.GetKey (KeyCode.X) && _HUDNavigationSystem.radarZoom < 5f)
|
||||
_HUDNavigationSystem.radarZoom += .0175f;
|
||||
else if (Input.GetKey (KeyCode.C) && _HUDNavigationSystem.radarZoom > .25f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.C) && _HUDNavigationSystem.radarZoom > .25f)
|
||||
_HUDNavigationSystem.radarZoom -= .0175f;
|
||||
else if (Input.GetKey (KeyCode.V) && _HUDNavigationSystem.indicatorOffscreenBorder < .7f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.V) && _HUDNavigationSystem.indicatorOffscreenBorder < .7f)
|
||||
_HUDNavigationSystem.indicatorOffscreenBorder += .01f;
|
||||
else if (Input.GetKey (KeyCode.B) && _HUDNavigationSystem.indicatorOffscreenBorder > .07f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.B) && _HUDNavigationSystem.indicatorOffscreenBorder > .07f)
|
||||
_HUDNavigationSystem.indicatorOffscreenBorder -= .01f;
|
||||
else if (Input.GetKey (KeyCode.N) && _HUDNavigationSystem.minimapScale > .06f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.N) && _HUDNavigationSystem.minimapScale > .06f)
|
||||
_HUDNavigationSystem.minimapScale -= .0075f;
|
||||
else if (Input.GetKey (KeyCode.M) && _HUDNavigationSystem.minimapScale < .35f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.M) && _HUDNavigationSystem.minimapScale < .35f)
|
||||
_HUDNavigationSystem.minimapScale += .0075f;
|
||||
|
||||
// update feature enable / disable input
|
||||
if (Input.GetKeyDown (KeyCode.H))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.H))
|
||||
_HUDNavigationSystem.EnableSystem (!_HUDNavigationSystem.isEnabled);
|
||||
if (Input.GetKeyDown (KeyCode.Alpha1))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha1))
|
||||
_HUDNavigationSystem.EnableRadar (!_HUDNavigationSystem.useRadar);
|
||||
if (Input.GetKeyDown (KeyCode.Alpha2))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha2))
|
||||
_HUDNavigationSystem.EnableCompassBar (!_HUDNavigationSystem.useCompassBar);
|
||||
if (Input.GetKeyDown (KeyCode.Alpha3))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha3))
|
||||
_HUDNavigationSystem.EnableIndicators (!_HUDNavigationSystem.useIndicators);
|
||||
if (Input.GetKeyDown (KeyCode.Alpha4))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha4))
|
||||
_HUDNavigationSystem.EnableMinimap (!_HUDNavigationSystem.useMinimap);
|
||||
|
||||
// toggle radar / minimap mode
|
||||
if (Input.GetKeyDown (KeyCode.Alpha5))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha5))
|
||||
_HUDNavigationSystem.radarMode = (_HUDNavigationSystem.radarMode == RadarModes.RotateRadar) ? RadarModes.RotatePlayer : RadarModes.RotateRadar;
|
||||
if (Input.GetKeyDown (KeyCode.Alpha6))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha6))
|
||||
_HUDNavigationSystem.minimapMode = (_HUDNavigationSystem.minimapMode == MinimapModes.RotateMinimap) ? MinimapModes.RotatePlayer : MinimapModes.RotateMinimap;
|
||||
|
||||
// toggle minimap custom layers
|
||||
if (Input.GetKeyDown (KeyCode.Alpha7) && _HUDNavigationSystem.currentMinimapProfile != null) {
|
||||
GameObject blackWhiteLayer = _HUDNavigationSystem.currentMinimapProfile.GetCustomLayer ("exampleLayer");
|
||||
if (blackWhiteLayer != null)
|
||||
blackWhiteLayer.SetActive (!blackWhiteLayer.activeSelf);
|
||||
}
|
||||
|
||||
// toggle day/night scene
|
||||
if (Input.GetKeyUp (KeyCode.Return)) {
|
||||
if (SceneManager.GetActiveScene ().buildIndex == 0)
|
||||
SceneManager.LoadScene (1);
|
||||
else
|
||||
SceneManager.LoadScene (0);
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha7) && _HUDNavigationSystem.currentMinimapProfile) {
|
||||
GameObject customLayer = _HUDNavigationSystem.currentMinimapProfile.GetCustomLayer ("exampleLayer");
|
||||
if (customLayer)
|
||||
customLayer.SetActive (!customLayer.activeSelf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HandleItemPickUp ()
|
||||
{
|
||||
if (!_HUDNavigationSystem.isEnabled)
|
||||
return;
|
||||
|
||||
// check for pickup items
|
||||
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), out hit, interactionDistance, layerMask) && hit.collider.name.Contains ("PickUp")) {
|
||||
// get HUD navigation element component
|
||||
HUDNavigationElement element = hit.collider.gameObject.GetComponent<HUDNavigationElement> ();
|
||||
if (element != null) {
|
||||
if (element) {
|
||||
// show pickup text
|
||||
if (element.Indicator != null) {
|
||||
if (element.Indicator) {
|
||||
pickupText = element.Indicator.GetCustomTransform ("pickupText");
|
||||
if (pickupText != null)
|
||||
if (pickupText)
|
||||
pickupText.gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
// wait for interaction input and destroy gameobject
|
||||
if (Input.GetKeyDown (KeyCode.E))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.E))
|
||||
Destroy (element.gameObject);
|
||||
}
|
||||
} else {
|
||||
// reset pickup text
|
||||
if (pickupText != null) {
|
||||
if (pickupText) {
|
||||
pickupText.gameObject.SetActive (false);
|
||||
pickupText = null;
|
||||
}
|
||||
@@ -120,25 +113,56 @@ public class ExampleInteractions : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
void HandleDoorOpening ()
|
||||
{
|
||||
// check for door
|
||||
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), out hit, interactionDistance, layerMask) && hit.collider.name.Contains ("Door")) {
|
||||
// get HUD navigation element component
|
||||
HUDNavigationElement element = hit.collider.gameObject.GetComponent<HUDNavigationElement> ();
|
||||
if (element) {
|
||||
// show text
|
||||
if (element.Indicator) {
|
||||
openDoorText = element.Indicator.GetCustomTransform ("openDoorText");
|
||||
if (openDoorText)
|
||||
openDoorText.gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
// wait for input and change scene
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.E))
|
||||
{
|
||||
// toggle SkyIsland / House scene
|
||||
if (SceneManager.GetActiveScene().buildIndex == 0)
|
||||
SceneManager.LoadScene(1);
|
||||
else
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// reset text
|
||||
if (openDoorText) {
|
||||
openDoorText.gameObject.SetActive (false);
|
||||
openDoorText = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HandlePrismColorChange ()
|
||||
{
|
||||
if (!_HUDNavigationSystem.isEnabled)
|
||||
return;
|
||||
|
||||
// check for colored prisms
|
||||
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), out hit, interactionDistance, layerMask) && hit.collider.name.Contains ("Prism")) {
|
||||
// get HUD navigation element component
|
||||
HUDNavigationElement element = hit.collider.gameObject.GetComponentInChildren<HUDNavigationElement> ();
|
||||
if (element != null) {
|
||||
if (element) {
|
||||
// show interaction text
|
||||
if (element.Indicator != null) {
|
||||
if (element.Indicator) {
|
||||
interactionText = element.Indicator.GetCustomTransform ("interactionText");
|
||||
if (interactionText != null)
|
||||
if (interactionText)
|
||||
interactionText.gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
// wait for interaction input and change prism color
|
||||
if (Input.GetKeyDown (KeyCode.E)) {
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.E)) {
|
||||
// generate random color
|
||||
Color randomColor = Random.ColorHSV (0f, 1f, 1f, 1f, .5f, 1f);
|
||||
|
||||
@@ -148,7 +172,7 @@ public class ExampleInteractions : MonoBehaviour
|
||||
}
|
||||
} else {
|
||||
// reset interaction text
|
||||
if (interactionText != null) {
|
||||
if (interactionText) {
|
||||
interactionText.gameObject.SetActive (false);
|
||||
interactionText = null;
|
||||
}
|
||||
@@ -160,7 +184,7 @@ public class ExampleInteractions : MonoBehaviour
|
||||
{
|
||||
// get renderer from prism
|
||||
Renderer prismRenderer = element.transform.parent.GetComponent<Renderer> ();
|
||||
if (prismRenderer != null)
|
||||
if (prismRenderer)
|
||||
ChangePrismColor (element, prismRenderer.material.color);
|
||||
}
|
||||
|
||||
@@ -168,31 +192,31 @@ public class ExampleInteractions : MonoBehaviour
|
||||
static void ChangePrismColor (HUDNavigationElement element, Color elementColor)
|
||||
{
|
||||
// change radar color
|
||||
if (element.Radar != null)
|
||||
if (element.Radar)
|
||||
element.Radar.ChangeIconColor (elementColor);
|
||||
|
||||
// change compass bar color
|
||||
if (element.CompassBar != null)
|
||||
if (element.CompassBar)
|
||||
element.CompassBar.ChangeIconColor (elementColor);
|
||||
|
||||
// change indicator colors
|
||||
if (element.Indicator != null) {
|
||||
if (element.Indicator) {
|
||||
element.Indicator.ChangeIconColor (elementColor);
|
||||
element.Indicator.ChangeOffscreenIconColor (elementColor);
|
||||
}
|
||||
|
||||
// change minimap color
|
||||
if (element.Minimap != null)
|
||||
if (element.Minimap)
|
||||
element.Minimap.ChangeIconColor (elementColor);
|
||||
|
||||
// change prism material color
|
||||
Renderer prismRenderer = element.transform.parent.GetComponent<Renderer> ();
|
||||
if (prismRenderer != null)
|
||||
if (prismRenderer)
|
||||
prismRenderer.material.color = new Color (elementColor.r, elementColor.g, elementColor.b, prismRenderer.material.color.a);
|
||||
|
||||
// change prism light (Night Scene)
|
||||
// change prism light (if present)
|
||||
Light prismLight = element.transform.parent.gameObject.GetComponentInChildren<Light> ();
|
||||
if (prismLight != null)
|
||||
if (prismLight)
|
||||
prismLight.color = new Color (elementColor.r, elementColor.g, elementColor.b);
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user