Update
This commit is contained in:
@@ -1,91 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Demo.UI
|
||||
{
|
||||
using Opsive.Shared.Events;
|
||||
using Opsive.UltimateCharacterController.Character;
|
||||
using Opsive.UltimateCharacterController.Character.MovementTypes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Monitors the text components which show the active perspective and movement type.
|
||||
/// </summary>
|
||||
public class CharacterStatusMonitor : MonoBehaviour
|
||||
{
|
||||
[Tooltip("A reference to the perspective UI text.")]
|
||||
[SerializeField] protected Text m_PerspectiveText;
|
||||
[Tooltip("A reference to the movement type UI text.")]
|
||||
[SerializeField] protected Text m_MovementTypeText;
|
||||
|
||||
private UltimateCharacterLocomotion m_CharacterLocomotion;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the default values.
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
var camera = Utility.UnityEngineUtility.FindCamera(null);
|
||||
var character = camera.GetComponent<UltimateCharacterController.Camera.CameraController>().Character;
|
||||
m_CharacterLocomotion = character.GetComponent<UltimateCharacterLocomotion>();
|
||||
|
||||
m_PerspectiveText.text = GetPerspectiveText();
|
||||
m_PerspectiveText.enabled = true;
|
||||
m_MovementTypeText.text = GetMovementTypeText();
|
||||
m_MovementTypeText.enabled = true;
|
||||
|
||||
EventHandler.RegisterEvent<MovementType, bool>(character, "OnCharacterChangeMovementType", OnMovementTypeChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the perspective text.
|
||||
/// </summary>
|
||||
/// <returns>The perspective text.</returns>
|
||||
private string GetPerspectiveText()
|
||||
{
|
||||
return m_CharacterLocomotion.FirstPersonPerspective ? "FIRST PERSON" : "THIRD PERSON";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the movement type text.
|
||||
/// </summary>
|
||||
/// <returns>The movement type text.</returns>
|
||||
private string GetMovementTypeText()
|
||||
{
|
||||
var movementType = m_CharacterLocomotion.ActiveMovementType.GetType().Name.ToUpper();
|
||||
if (movementType == "PSEUDO3D") {
|
||||
return "2.5D";
|
||||
}
|
||||
return movementType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The movement type has changed - update the UI.
|
||||
/// </summary>
|
||||
/// <param name="movementType">The movement type that was changed.</param>
|
||||
/// <param name="activated">Was the specified movement type activated?</param>
|
||||
private void OnMovementTypeChanged(MovementType movementType, bool activated)
|
||||
{
|
||||
if (!activated || m_CharacterLocomotion == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_PerspectiveText.text = GetPerspectiveText();
|
||||
m_MovementTypeText.text = GetMovementTypeText();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The object has been destroyed.
|
||||
/// </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (m_CharacterLocomotion != null) {
|
||||
EventHandler.UnregisterEvent<MovementType, bool>(m_CharacterLocomotion.gameObject, "OnCharacterChangeMovementType", OnMovementTypeChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 261341dd008004e4097f7ac84207e57f
|
||||
timeCreated: 1529062396
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 10200
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,218 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
using Opsive.Shared.Events;
|
||||
using Opsive.Shared.Game;
|
||||
using Opsive.UltimateCharacterController.Camera;
|
||||
using Opsive.UltimateCharacterController.Character;
|
||||
using Opsive.UltimateCharacterController.Character.Abilities.Items;
|
||||
using Opsive.UltimateCharacterController.Inventory;
|
||||
using Opsive.UltimateCharacterController.StateSystem;
|
||||
using Opsive.UltimateCharacterController.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Demo.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages the first person springs zone. Allows switching between various spring types.
|
||||
/// </summary>
|
||||
public class FirstPersonSpringZone : UIZone
|
||||
{
|
||||
private enum SpringType { Modern, OldSchool, CrazyCowboy, Astronaut, DrunkPerson, Giant, SpringsOff, None }
|
||||
|
||||
[Tooltip("A reference to the character used for Astronaut and Drunk Person.")]
|
||||
[SerializeField] protected GameObject m_DrunkAstronautCharacter;
|
||||
[Tooltip("A reference to the character used for Giant.")]
|
||||
[SerializeField] protected GameObject m_GiantCharacter;
|
||||
[Tooltip("The ItemDefinitions that the character should have before entering the room.")]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("m_ItemTypes")]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("m_ItemIdentifiers")]
|
||||
[SerializeField] protected Shared.Inventory.ItemDefinitionBase[] m_ItemDefinitions;
|
||||
[Tooltip("The index of the primary category.")]
|
||||
[SerializeField] protected int m_CategoryIndex = 0;
|
||||
[Tooltip("The ItemSet index that the character should switch to.")]
|
||||
[SerializeField] protected int m_ItemSetIndex = 0;
|
||||
|
||||
private GameObject m_Character;
|
||||
private CameraController m_CameraController;
|
||||
|
||||
private SpringType m_SpringType = SpringType.None;
|
||||
private MovementTypeSwitcher m_MovementTypeSwitcher;
|
||||
private DemoManager m_DemoManager;
|
||||
private DemoZoneTrigger m_DemoZoneTrigger;
|
||||
|
||||
private Vector3 m_DrunkAstronautPosition;
|
||||
private Quaternion m_DrunkAstronautRotation;
|
||||
private Vector3 m_GiantPosition;
|
||||
private Quaternion m_GiantRotation;
|
||||
|
||||
|
||||
private ScheduledEventBase m_EnableStateEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the default values.
|
||||
/// </summary>
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
m_MovementTypeSwitcher = GameObject.FindObjectOfType<MovementTypeSwitcher>();
|
||||
m_DemoManager = GameObject.FindObjectOfType<DemoManager>();
|
||||
m_DemoZoneTrigger = GameObject.FindObjectOfType<DemoZoneTrigger>();
|
||||
|
||||
// Remember the positions/rotations so they can be restored when the character leaves the zone.
|
||||
m_DrunkAstronautPosition = m_DrunkAstronautCharacter.transform.position;
|
||||
m_DrunkAstronautRotation = m_DrunkAstronautCharacter.transform.rotation;
|
||||
m_GiantPosition = m_GiantCharacter.transform.position;
|
||||
m_GiantRotation = m_GiantCharacter.transform.rotation;
|
||||
|
||||
ChangeSpringType(SpringType.Modern);
|
||||
m_DrunkAstronautCharacter.SetActive(false);
|
||||
m_GiantCharacter.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the spring types to the specified type.
|
||||
/// </summary>
|
||||
/// <param name="type">The type to change the value to.</param>
|
||||
public void ChangeSpringType(int type)
|
||||
{
|
||||
ChangeSpringType((SpringType)type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the spring types to the specified type.
|
||||
/// </summary>
|
||||
/// <param name="type">The type to change the value to.</param>
|
||||
private void ChangeSpringType(SpringType type)
|
||||
{
|
||||
// Don't switch types if the type is equal to the current type or if the enable state event is active. This will occur if a new button is pressed
|
||||
// within the time that it takes to invoke the scheduled event.
|
||||
if (m_SpringType == type || m_EnableStateEvent != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset the button color and deactivate the previous character. The same character may be activated again depending on the spring type.
|
||||
if (m_SpringType != SpringType.None) {
|
||||
SetButtonColor((int)m_SpringType, m_NormalColor);
|
||||
if (m_ActiveCharacter != null) {
|
||||
m_ActiveCharacter.GetCachedComponent<UltimateCharacterLocomotion>().SetActive(false);
|
||||
StateManager.SetState(m_ActiveCharacter, System.Enum.GetName(typeof(SpringType), m_SpringType), false);
|
||||
}
|
||||
}
|
||||
|
||||
// Remember the old spring type and activate the new. The button should reflect the selected spring type.
|
||||
var prevSpringType = m_SpringType;
|
||||
m_SpringType = type;
|
||||
SetButtonColor((int)m_SpringType, m_PressedColor);
|
||||
|
||||
// If the previous spring type isn't None then a button was pressed. Activate the new character.
|
||||
if (prevSpringType != SpringType.None) {
|
||||
var prevCharacter = m_ActiveCharacter;
|
||||
|
||||
// The active character depends on the spring type.
|
||||
if (m_SpringType == SpringType.Astronaut || m_SpringType == SpringType.DrunkPerson) {
|
||||
m_ActiveCharacter = m_DrunkAstronautCharacter;
|
||||
} else if (m_SpringType == SpringType.Giant) {
|
||||
m_ActiveCharacter = m_GiantCharacter;
|
||||
} else {
|
||||
m_ActiveCharacter = m_Character;
|
||||
}
|
||||
|
||||
// Activate the correct character and set the camera to the character if that character changed. This shouldn't be done if the character didn't
|
||||
// change so the camera doesn't snap into position.
|
||||
var characterChange = m_ActiveCharacter != prevCharacter;
|
||||
m_ActiveCharacter.GetCachedComponent<UltimateCharacterLocomotion>().SetActive(true);
|
||||
if (characterChange) {
|
||||
m_CameraController.Character = m_ActiveCharacter;
|
||||
}
|
||||
|
||||
// Wait a small amount of time if the springs are off so the item can get back into the correct position while the springs are enabled.
|
||||
m_EnableStateEvent = Scheduler.Schedule(m_SpringType == SpringType.SpringsOff ? 0.4f : 0, EnableSpringState, characterChange);
|
||||
}
|
||||
|
||||
EnableInput();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the current spring type on the active character.
|
||||
/// </summary>
|
||||
/// <param name="characterChange">Did the character GameObject changed?</param>
|
||||
private void EnableSpringState(bool characterChange)
|
||||
{
|
||||
StateManager.SetState(m_ActiveCharacter, System.Enum.GetName(typeof(SpringType), m_SpringType), true);
|
||||
m_EnableStateEvent = null;
|
||||
// If the character changed then the camera should adjust immediately to the new position. This will allow the camera to jump to the correct position
|
||||
// when switching to the giant.
|
||||
if (characterChange) {
|
||||
m_CameraController.PositionImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has entered from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that entered the zone.</param>
|
||||
protected override void CharacterEnter(UltimateCharacterLocomotion characterLocomotion)
|
||||
{
|
||||
// The other collider is the main character.
|
||||
m_Character = characterLocomotion.gameObject;
|
||||
m_CameraController = UnityEngineUtility.FindCamera(m_Character).GetComponent<CameraController>();
|
||||
|
||||
// The character must have the primary item in order for it to be equipped.
|
||||
var inventory = m_Character.GetCachedComponent<InventoryBase>();
|
||||
for (int i = 0; i < m_ItemDefinitions.Length; ++i) {
|
||||
if (m_ItemDefinitions[i] == null) {
|
||||
continue;
|
||||
}
|
||||
inventory.Pickup(m_ItemDefinitions[i].CreateItemIdentifier(), 1, 0, false, true);
|
||||
}
|
||||
|
||||
// Ensure the primary weapon is equipped.
|
||||
var equipUnequipAbilities = characterLocomotion.GetAbilities<EquipUnequip>();
|
||||
for (int i = 0; i < equipUnequipAbilities.Length; ++i) {
|
||||
if (equipUnequipAbilities[i].ItemSetCategoryIndex == m_CategoryIndex) {
|
||||
equipUnequipAbilities[i].StartEquipUnequip(m_ItemSetIndex, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Setup the character for the zone.
|
||||
StateManager.SetState(m_Character, "FirstPersonSpringZone", true);
|
||||
EventHandler.ExecuteEvent(m_Character, "OnShowUI", false);
|
||||
|
||||
// First person perspective is required.
|
||||
m_CameraController.SetPerspective(true);
|
||||
// With the combat movement type.
|
||||
m_MovementTypeSwitcher.UpdateMovementType(true, (int)MovementTypesZone.MovementType.FirstPersonCombat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has exited from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that exited the zone.</param>
|
||||
protected override void CharacterExit(UltimateCharacterLocomotion characterLocomotion)
|
||||
{
|
||||
// The drunk astronaut or giant GameObject may have left the trigger. Set the normal character to the other character's position
|
||||
// so when switching back to the normal character they will be in the same position.
|
||||
if (characterLocomotion.gameObject != m_Character) {
|
||||
m_Character.GetComponent<UltimateCharacterLocomotion>().SetPositionAndRotation(characterLocomotion.transform.position, characterLocomotion.transform.rotation);
|
||||
}
|
||||
// The modern type should activate when leaving the zone.
|
||||
ChangeSpringType(SpringType.Modern);
|
||||
|
||||
// Disable the states that were enabled when entering the zone.
|
||||
StateManager.SetState(m_Character, "FirstPersonSpringZone", false);
|
||||
EventHandler.ExecuteEvent(m_Character, "OnShowUI", true);
|
||||
|
||||
// Ensure the character exited the demo zone.
|
||||
m_DemoManager.ExitedTriggerZone(m_DemoZoneTrigger);
|
||||
|
||||
// Restore the other character positions/rotations.
|
||||
m_DrunkAstronautCharacter.GetComponent<UltimateCharacterLocomotion>().SetPositionAndRotation(m_DrunkAstronautPosition, m_DrunkAstronautRotation);
|
||||
m_GiantCharacter.GetComponent<UltimateCharacterLocomotion>().SetPositionAndRotation(m_GiantPosition, m_GiantRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d79e5edbc803f454da6c485141fc3391
|
||||
timeCreated: 1523973525
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,119 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Demo.UI
|
||||
{
|
||||
using Opsive.Shared.Inventory;
|
||||
using Opsive.UltimateCharacterController.Character;
|
||||
using Opsive.UltimateCharacterController.Character.Abilities.Items;
|
||||
using Opsive.UltimateCharacterController.Inventory;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Manages the magic zone. Allows switching between magic items.
|
||||
/// </summary>
|
||||
public class MagicZone : UIZone
|
||||
{
|
||||
[Tooltip("A mapping of the ItemDefinitions to the button.")]
|
||||
[SerializeField] protected ItemDefinitionBase[] m_ItemDefinitions;
|
||||
[Tooltip("The parent GameObject that should be enabled when the corresponding ItemDefinition is enabled.")]
|
||||
[SerializeField] protected GameObject[] m_Objects;
|
||||
[Tooltip("The Particle Stream Item Definition.")]
|
||||
[SerializeField] protected ItemDefinitionBase m_ParticleStreamItemDefinition;
|
||||
[Tooltip("A reference to the Attribute Monitor for the Particle Stream.")]
|
||||
[SerializeField] protected GameObject m_ParticleStreamAttributeMonitor;
|
||||
|
||||
private UltimateCharacterLocomotion m_CharacterLocomotion;
|
||||
private InventoryBase m_Inventory;
|
||||
private EquipUnequip[] m_EquipUnequipAbilities;
|
||||
private int[] m_ActiveItemSets;
|
||||
private int m_Index;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the default values.
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
var character = GameObject.FindObjectOfType<DemoManager>().Character;
|
||||
m_CharacterLocomotion = character.GetComponent<UltimateCharacterLocomotion>();
|
||||
m_Inventory = character.GetComponent<InventoryBase>();
|
||||
m_EquipUnequipAbilities = m_CharacterLocomotion.GetAbilities<EquipUnequip>();
|
||||
m_ActiveItemSets = new int[m_EquipUnequipAbilities.Length];
|
||||
m_Index = -1;
|
||||
|
||||
for (int i = 0; i < m_Objects.Length; ++i) {
|
||||
m_Objects[i].SetActive(false);
|
||||
}
|
||||
m_ParticleStreamAttributeMonitor.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has entered from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that entered the zone.</param>
|
||||
protected override void CharacterEnter(UltimateCharacterLocomotion characterLocomotion)
|
||||
{
|
||||
for (int i = 0; i < m_ActiveItemSets.Length; ++i) {
|
||||
m_ActiveItemSets[i] = m_EquipUnequipAbilities[i].ActiveItemSetIndex;
|
||||
}
|
||||
ChangeMagicItem(0); // Start with the first item.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the magic item to the specified item.
|
||||
/// </summary>
|
||||
/// <param name="itemIndex">The item index to change the value to.</param>
|
||||
public void ChangeMagicItem(int itemIndex)
|
||||
{
|
||||
if (itemIndex < 0 || itemIndex >= m_ItemDefinitions.Length || itemIndex == m_Index) {
|
||||
return;
|
||||
}
|
||||
if (m_CharacterLocomotion.IsAbilityTypeActive<Use>()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Index != -1) {
|
||||
m_Objects[m_Index].SetActive(false);
|
||||
m_ParticleStreamAttributeMonitor.SetActive(false);
|
||||
SetButtonColor(m_Index, m_NormalColor);
|
||||
}
|
||||
m_Index = itemIndex;
|
||||
m_Inventory.Pickup(m_ItemDefinitions[itemIndex].CreateItemIdentifier(), 1, 0, false, true);
|
||||
m_Objects[m_Index].SetActive(true);
|
||||
for (int i = 0; i < m_Objects[m_Index].transform.childCount; ++i) {
|
||||
m_Objects[m_Index].transform.GetChild(i).gameObject.SetActive(true);
|
||||
}
|
||||
if (m_ItemDefinitions[itemIndex] == m_ParticleStreamItemDefinition) {
|
||||
m_ParticleStreamAttributeMonitor.SetActive(true);
|
||||
}
|
||||
SetButtonColor(m_Index, m_PressedColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has exited from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that exited the zone.</param>
|
||||
protected override void CharacterExit(UltimateCharacterLocomotion characterLocomotion)
|
||||
{
|
||||
if (m_Index == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_Objects[m_Index].SetActive(false);
|
||||
m_ParticleStreamAttributeMonitor.SetActive(false);
|
||||
SetButtonColor(m_Index, m_NormalColor);
|
||||
m_Index = -1;
|
||||
|
||||
for (int i = 0; i < m_ActiveItemSets.Length; ++i) {
|
||||
if (m_ActiveItemSets[i] == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
m_EquipUnequipAbilities[i].StartEquipUnequip(m_ActiveItemSets[i], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c057edefaa754c4c8910f88b8f741d2
|
||||
timeCreated: 1523973525
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,69 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Demo.UI
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Character;
|
||||
using Opsive.UltimateCharacterController.StateSystem;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Manages the mouse smoothing zone. Allows switching betweening mouse input types.
|
||||
/// </summary>
|
||||
public class MouseSmoothingZone : UIZone
|
||||
{
|
||||
private enum SmoothingType { Raw, Smoothing, LowSensitivity, LowSensitivityAcceleration }
|
||||
|
||||
private SmoothingType m_SmoothingType = SmoothingType.Smoothing;
|
||||
|
||||
/// <summary>
|
||||
/// Change the smoothing type to the specified type.
|
||||
/// </summary>
|
||||
/// <param name="type">The type to change the value to.</param>
|
||||
public void ChangeSmoothingType(int type)
|
||||
{
|
||||
ChangeInputType((SmoothingType)type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the smoothing type to the specified type.
|
||||
/// </summary>
|
||||
/// <param name="type">The type to change the value to.</param>
|
||||
private void ChangeInputType(SmoothingType type)
|
||||
{
|
||||
// Revert the old.
|
||||
SetButtonColor((int)m_SmoothingType, m_NormalColor);
|
||||
StateManager.SetState(m_ActiveCharacter, System.Enum.GetName(typeof(SmoothingType), m_SmoothingType), false);
|
||||
|
||||
// Set the new smoothing type.
|
||||
m_SmoothingType = type;
|
||||
SetButtonColor((int)m_SmoothingType, m_PressedColor);
|
||||
StateManager.SetState(m_ActiveCharacter, System.Enum.GetName(typeof(SmoothingType), type), true);
|
||||
|
||||
EnableInput();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has entered from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that entered the zone.</param>
|
||||
protected override void CharacterEnter(UltimateCharacterLocomotion characterLocomotion)
|
||||
{
|
||||
// The smoothing type is the standard type.
|
||||
ChangeInputType(SmoothingType.Smoothing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has exited from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that exited the zone.</param>
|
||||
protected override void CharacterExit(UltimateCharacterLocomotion characterLocomotion)
|
||||
{
|
||||
// The smoothing type should activate when leaving the zone.
|
||||
ChangeInputType(SmoothingType.Smoothing);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f70fff8b5bccb34589b2174ac55cc16
|
||||
timeCreated: 1523973525
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,195 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Demo.UI
|
||||
{
|
||||
using Opsive.Shared.Events;
|
||||
using Opsive.UltimateCharacterController.Camera;
|
||||
using Opsive.UltimateCharacterController.Character;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Manages the movement types zone. Allows switching between movement types.
|
||||
/// </summary>
|
||||
public class MovementTypesZone : UIZone
|
||||
{
|
||||
public enum MovementType { FirstPersonCombat, FirstPersonFreeLook, ThirdPersonAdventure, ThirdPersonCombat, ThirdPersonRPG, None }
|
||||
|
||||
private MovementType m_MovementType = MovementType.FirstPersonCombat;
|
||||
|
||||
private CameraController m_CameraController;
|
||||
private GameObject m_Character;
|
||||
private UltimateCharacterLocomotion m_CharacterLocomotion;
|
||||
private MovementTypeSwitcher m_MovementTypeSwitcher;
|
||||
private bool m_MovementTypeSwitcherEnabled;
|
||||
private MovementType m_PerspectiveSwitchMovementType = MovementType.None;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the default values.
|
||||
/// </summary>
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
m_MovementTypeSwitcher = GameObject.FindObjectOfType<MovementTypeSwitcher>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the default values.
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
var camera = Utility.UnityEngineUtility.FindCamera(null);
|
||||
m_CameraController = camera.GetComponent<CameraController>();
|
||||
m_Character = GameObject.FindObjectOfType<DemoManager>().Character;
|
||||
m_CharacterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();
|
||||
|
||||
EventHandler.RegisterEvent<UltimateCharacterController.Character.MovementTypes.MovementType, bool>(m_Character, "OnCharacterChangeMovementType", OnMovementTypeChanged);
|
||||
EventHandler.RegisterEvent<bool>(m_Character, "OnCharacterChangePerspectives", OnChangePerspectives);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the movement type to the specified type.
|
||||
/// </summary>
|
||||
/// <param name="type">The type to change the value to.</param>
|
||||
public void ChangeMovementType(int type)
|
||||
{
|
||||
if (m_PerspectiveSwitchMovementType != MovementType.None) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch the camera's perspective if the movement type changes perspective.
|
||||
var movementType = (MovementType)type;
|
||||
if (IsFirstPersonType(movementType) != IsFirstPersonType(m_MovementType)) {
|
||||
m_PerspectiveSwitchMovementType = movementType;
|
||||
m_CameraController.SetPerspective(IsFirstPersonType(movementType));
|
||||
return;
|
||||
}
|
||||
|
||||
ChangeMovementType(movementType, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the movement type to the specified type.
|
||||
/// </summary>
|
||||
/// <param name="type">The type to change the value to.</param>
|
||||
private void ChangeMovementType(MovementType type, bool updateSwitcher)
|
||||
{
|
||||
// Revert the old.
|
||||
if (m_ButtonImages[(int)m_MovementType] != null) {
|
||||
SetButtonColor((int)m_MovementType, m_NormalColor);
|
||||
}
|
||||
|
||||
m_MovementType = type;
|
||||
SetButtonColor((int)m_MovementType, m_PressedColor);
|
||||
|
||||
// Set the new movement type with the Movement Type Switcher.
|
||||
if (updateSwitcher) {
|
||||
if (IsFirstPersonType(type)) {
|
||||
m_MovementTypeSwitcher.UpdateMovementType(true, (int)type);
|
||||
} else {
|
||||
m_MovementTypeSwitcher.UpdateMovementType(false, (int)type - 2);
|
||||
}
|
||||
}
|
||||
|
||||
EnableInput();
|
||||
m_PerspectiveSwitchMovementType = MovementType.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the type is a first person type.
|
||||
/// </summary>
|
||||
/// <param name="type">The Movement Type to compare against.</param>
|
||||
/// <returns>True if the type is a first person type.</returns>
|
||||
private bool IsFirstPersonType(MovementType type)
|
||||
{
|
||||
return (type == MovementType.FirstPersonCombat || type == MovementType.FirstPersonFreeLook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has entered from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that entered the zone.</param>
|
||||
protected override void CharacterEnter(UltimateCharacterLocomotion characterLocomotion)
|
||||
{
|
||||
UpdateMovementType();
|
||||
|
||||
// The buttons will change the movement types.
|
||||
m_MovementTypeSwitcherEnabled = m_MovementTypeSwitcher.enabled;
|
||||
m_MovementTypeSwitcher.enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The movement type has changed.
|
||||
/// </summary>
|
||||
/// <param name="movementType">The movement type that was changed.</param>
|
||||
/// <param name="activated">Was the specified movement type activated?</param>
|
||||
private void OnMovementTypeChanged(UltimateCharacterController.Character.MovementTypes.MovementType movementType, bool activated)
|
||||
{
|
||||
if (!activated || m_ActiveCharacter != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateMovementType();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The camera perspective between first and third person has changed.
|
||||
/// </summary>
|
||||
/// <param name="inFirstPerson">Is the camera in a first person view?</param>
|
||||
private void OnChangePerspectives(bool firstPersonPerspective)
|
||||
{
|
||||
if (m_PerspectiveSwitchMovementType != MovementType.None) {
|
||||
ChangeMovementType(m_PerspectiveSwitchMovementType, true);
|
||||
m_PerspectiveSwitchMovementType = MovementType.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the MovementType enum to the character's current movement type.
|
||||
/// </summary>
|
||||
private void UpdateMovementType()
|
||||
{
|
||||
var movementType = m_CharacterLocomotion.ActiveMovementType;
|
||||
#if FIRST_PERSON_CONTROLLER
|
||||
if (movementType is FirstPersonController.Character.MovementTypes.Combat) {
|
||||
ChangeMovementType(MovementType.FirstPersonCombat, false);
|
||||
} else if (movementType is FirstPersonController.Character.MovementTypes.FreeLook) {
|
||||
ChangeMovementType(MovementType.FirstPersonFreeLook, false);
|
||||
}
|
||||
#endif
|
||||
#if THIRD_PERSON_CONTROLLER
|
||||
if (movementType is ThirdPersonController.Character.MovementTypes.Adventure) {
|
||||
ChangeMovementType(MovementType.ThirdPersonAdventure, false);
|
||||
} else if (movementType is ThirdPersonController.Character.MovementTypes.Combat) {
|
||||
ChangeMovementType(MovementType.ThirdPersonCombat, false);
|
||||
} else if (movementType is ThirdPersonController.Character.MovementTypes.RPG) {
|
||||
ChangeMovementType(MovementType.ThirdPersonRPG, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has exited from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that exited the zone.</param>
|
||||
protected override void CharacterExit(UltimateCharacterLocomotion characterLocomotion)
|
||||
{
|
||||
if (m_MovementTypeSwitcherEnabled) {
|
||||
m_MovementTypeSwitcher.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The object has been destroyed.
|
||||
/// </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
EventHandler.UnregisterEvent<UltimateCharacterController.Character.MovementTypes.MovementType, bool>(m_Character, "OnCharacterChangeMovementType", OnMovementTypeChanged);
|
||||
EventHandler.UnregisterEvent<bool>(m_Character, "OnCharacterChangePerspectives", OnChangePerspectives);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d6e89e726dc9b443a5cccd1f18a41c4
|
||||
timeCreated: 1523973525
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,170 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Demo.UI
|
||||
{
|
||||
using Opsive.Shared.Events;
|
||||
using Opsive.UltimateCharacterController.Input;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the UI that shows the help for the control mappings.
|
||||
/// </summary>
|
||||
public class ToggleControlHelp : MonoBehaviour
|
||||
{
|
||||
[Tooltip("The UI that should be toggled.")]
|
||||
[SerializeField] protected GameObject m_ControlUI;
|
||||
[Tooltip("The keycode that should enable the UI.")]
|
||||
[SerializeField] protected KeyCode m_EnableKeyCode = KeyCode.Escape;
|
||||
[Tooltip("A reference to the keyboard controls sprite.")]
|
||||
[SerializeField] protected GameObject m_KeyboardUI;
|
||||
[Tooltip("A reference to the controller controls sprite.")]
|
||||
[SerializeField] protected GameObject m_ControllerUI;
|
||||
[Tooltip("A reference to the Resume button")]
|
||||
[SerializeField] protected Button m_ResumeButton;
|
||||
[Tooltip("A reference to the Quit button")]
|
||||
[SerializeField] protected Button m_QuitButton;
|
||||
[Tooltip("A reference to the displays that contain button selections.")]
|
||||
[SerializeField] protected GameObject[] m_ButtonMenus;
|
||||
|
||||
private GameObject m_Character;
|
||||
private UnityInput m_UnityInput;
|
||||
private bool m_Active;
|
||||
private float m_PrevTimeScale;
|
||||
private bool m_VisibleCursor;
|
||||
private bool m_InUIZone;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the default values.
|
||||
/// </summary>
|
||||
private void Awake()
|
||||
{
|
||||
m_ControlUI.SetActive(m_Active);
|
||||
var demoManager = GetComponent<DemoManager>();
|
||||
m_Character = demoManager.Character;
|
||||
m_UnityInput = m_Character.GetComponent<UnityInput>();
|
||||
|
||||
m_ResumeButton.onClick.AddListener(Resume);
|
||||
#if UNITY_STANDALONE || UNITY_EDITOR
|
||||
m_QuitButton.onClick.AddListener(Quit);
|
||||
#else
|
||||
// The application can't quit on the target platform.
|
||||
m_QuitButton.gameObject.SetActive(false);
|
||||
|
||||
// Center the Resume button.
|
||||
var rectTransform = m_ResumeButton.GetComponent<RectTransform>();
|
||||
var position = rectTransform.localPosition;
|
||||
position.x = rectTransform.rect.width / 2;
|
||||
rectTransform.localPosition = position;
|
||||
#endif
|
||||
|
||||
OnControllerConnected(m_UnityInput.ControllerConnected);
|
||||
EventHandler.RegisterEvent<bool>(m_Character, "OnInputControllerConnected", OnControllerConnected);
|
||||
EventHandler.RegisterEvent<bool>(m_Character, "OnCharacterEnterUIZone", OnEnterUIZone);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resumes the game.
|
||||
/// </summary>
|
||||
public void Resume()
|
||||
{
|
||||
m_Active = false;
|
||||
m_ControlUI.SetActive(false);
|
||||
Time.timeScale = m_PrevTimeScale;
|
||||
|
||||
EventHandler.ExecuteEvent(m_Character, "OnEnableGameplayInput", true);
|
||||
if (m_InUIZone) {
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_STANDALONE || UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// Quits the game.
|
||||
/// </summary>
|
||||
public void Quit()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the UI.
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
if (m_Active) {
|
||||
if (Input.GetKeyDown(KeyCode.Escape)) {
|
||||
Resume();
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep the cursor visible while the UI is active.
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
} else if ((m_VisibleCursor && Input.GetKeyDown(m_EnableKeyCode)) || Input.GetKeyDown(KeyCode.Joystick1Button6)) {
|
||||
ShowControls();
|
||||
}
|
||||
|
||||
// Store the cursor state so the controls don't appear on the same frame that the cursor was enabled.
|
||||
m_VisibleCursor = Cursor.visible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the controls.
|
||||
/// </summary>
|
||||
public void ShowControls()
|
||||
{
|
||||
m_Active = true;
|
||||
EventHandler.ExecuteEvent(m_Character, "OnEnableGameplayInput", false);
|
||||
m_ControlUI.SetActive(true);
|
||||
m_PrevTimeScale = Time.timeScale;
|
||||
Time.timeScale = 0;
|
||||
m_KeyboardUI.SetActive(!m_UnityInput.ControllerConnected);
|
||||
m_ControllerUI.SetActive(m_UnityInput.ControllerConnected);
|
||||
|
||||
UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(m_ResumeButton.gameObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A controller has been connected or disconnected.
|
||||
/// </summary>
|
||||
/// <param name="controllerConnected">True if a controller has been connected.</param>
|
||||
private void OnControllerConnected(bool controllerConnected)
|
||||
{
|
||||
if (!m_Active) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_KeyboardUI.SetActive(controllerConnected);
|
||||
m_ControllerUI.SetActive(controllerConnected);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has entered or left a zone which should show the UI and cursor.
|
||||
/// </summary>
|
||||
/// <param name="inUIZone">Did the character enter the UI zone?</param>
|
||||
private void OnEnterUIZone(bool inUIZone)
|
||||
{
|
||||
m_InUIZone = inUIZone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The object has been destroyed.
|
||||
/// </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
EventHandler.UnregisterEvent<bool>(m_Character, "OnInputControllerConnected", OnControllerConnected);
|
||||
EventHandler.UnregisterEvent<bool>(m_Character, "OnCharacterEnterUIZone", OnEnterUIZone);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f2ed13889ee85d44aa0e68800aae84f
|
||||
timeCreated: 1529062396
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 10200
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,146 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Demo.UI
|
||||
{
|
||||
using Opsive.Shared.Events;
|
||||
using Opsive.UltimateCharacterController.Character;
|
||||
using Opsive.UltimateCharacterController.Game;
|
||||
using Opsive.UltimateCharacterController.Utility;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Abstract class which manages the UI for the demo zones.
|
||||
/// </summary>
|
||||
public abstract class UIZone : MonoBehaviour
|
||||
{
|
||||
[Tooltip("A reference to the UI parent GameObject.")]
|
||||
[SerializeField] protected GameObject m_UIParent;
|
||||
[Tooltip("A reference to the buttons that correspond to the InputTypes. These buttons must be in the same order as the enum.")]
|
||||
[SerializeField] protected Image[] m_ButtonImages;
|
||||
|
||||
protected Color m_NormalColor;
|
||||
protected Color m_PressedColor;
|
||||
protected Button[] m_Buttons;
|
||||
|
||||
protected GameObject m_ActiveCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the default values.
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
m_Buttons = new Button[m_ButtonImages.Length];
|
||||
var firstIndex = -1;
|
||||
for (int i = 0; i < m_Buttons.Length; ++i) {
|
||||
if (m_ButtonImages[i] == null) {
|
||||
continue;
|
||||
}
|
||||
if (firstIndex == -1) {
|
||||
firstIndex = i;
|
||||
}
|
||||
m_Buttons[i] = m_ButtonImages[i].GetComponent<Button>();
|
||||
}
|
||||
m_NormalColor = m_Buttons[firstIndex].colors.normalColor;
|
||||
m_PressedColor = m_Buttons[firstIndex].colors.pressedColor;
|
||||
m_UIParent.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An object has entered the trigger.
|
||||
/// </summary>
|
||||
/// <param name="other">The object that entered the trigger.</param>
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
// If the active character GameObject isn't null then the character is already within the trigger (and may just be activated again).
|
||||
if (m_ActiveCharacter != null || !MathUtility.InLayerMask(other.gameObject.layer, 1 << LayerManager.Character)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var characterLocomotion = other.GetComponentInParent<UltimateCharacterLocomotion>();
|
||||
if (characterLocomotion == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The other collider is the main character.
|
||||
m_ActiveCharacter = characterLocomotion.gameObject;
|
||||
|
||||
// The subclass can handle initializing the character.
|
||||
CharacterEnter(characterLocomotion);
|
||||
|
||||
// Enable the UI that is specific for the zone.
|
||||
m_UIParent.SetActive(true);
|
||||
|
||||
EventHandler.ExecuteEvent(m_ActiveCharacter, "OnCharacterEnterUIZone", true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has entered from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that entered the zone.</param>
|
||||
protected virtual void CharacterEnter(UltimateCharacterLocomotion characterLocomotion) { }
|
||||
|
||||
/// <summary>
|
||||
/// Enables the input after a button has been selected.
|
||||
/// </summary>
|
||||
protected void EnableInput()
|
||||
{
|
||||
if (m_ActiveCharacter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Give control back to the player and lock the cursor after a selection. It can be unlocked again by pressing escape.
|
||||
EventHandler.ExecuteEvent(m_ActiveCharacter, "OnEnableGameplayInput", true);
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the UI button color.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the button to set.</param>
|
||||
/// <param name="color">The color of the button.</param>
|
||||
protected void SetButtonColor(int index, Color color)
|
||||
{
|
||||
m_ButtonImages[index].color = color;
|
||||
var buttonColors = m_Buttons[index].colors;
|
||||
buttonColors.normalColor = color;
|
||||
m_Buttons[index].colors = buttonColors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An object has exited the trigger.
|
||||
/// </summary>
|
||||
/// <param name="other">The collider that exited the trigger.</param>
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (!MathUtility.InLayerMask(other.gameObject.layer, 1 << LayerManager.Character)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var characterLocomotion = other.GetComponentInParent<UltimateCharacterLocomotion>();
|
||||
if (characterLocomotion == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The subclass can handle resetting the states.
|
||||
CharacterExit(characterLocomotion);
|
||||
|
||||
// Reset the UI and active character.
|
||||
m_UIParent.SetActive(false);
|
||||
|
||||
EventHandler.ExecuteEvent(m_ActiveCharacter, "OnCharacterEnterUIZone", false);
|
||||
m_ActiveCharacter = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character has exited from the zone.
|
||||
/// </summary>
|
||||
/// <param name="characterLocomotion">The character that exited the zone.</param>
|
||||
protected virtual void CharacterExit(UltimateCharacterLocomotion characterLocomotion) { }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b7990f7795f7fa41b2f0da8179e0e64
|
||||
timeCreated: 1523973525
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user