This commit is contained in:
2026-06-02 08:27:03 +07:00
parent 7889064469
commit a48cd962e1
4232 changed files with 2 additions and 36881 deletions

View File

@@ -0,0 +1,46 @@
using System.Collections;
using UnityEngine;
namespace Invector.vCamera
{
public class vChangeCameraAngleTrigger : MonoBehaviour
{
public bool applyY, applyX;
public Vector2 angle;
public vThirdPersonCamera tpCamera;
public bool useSelfWorldAngle;
private void OnDrawGizmos()
{
if(useSelfWorldAngle)
{
angle.x = transform.eulerAngles.y;
angle.y = transform.eulerAngles.x;
}
}
IEnumerator Start()
{
tpCamera = FindObjectOfType<vThirdPersonCamera>();
var collider = GetComponent<Collider>();
if (collider)
{
collider.isTrigger = true;
collider.enabled = false;
yield return new WaitForEndOfFrame();
collider.enabled = true;
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player") && tpCamera)
{
if (applyX)
tpCamera.lerpState.fixedAngle.x = angle.x;
if (applyY)
tpCamera.lerpState.fixedAngle.y = angle.y;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0537d2eef0080a74b8c6735fad669b1c
timeCreated: 1502241772
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
using UnityEngine;
using Invector.vCharacterController;
using UnityEngine.Events;
namespace Invector.vItemManager
{
public class vChangeInputTypeTrigger : MonoBehaviour
{
[Header("Events called when InputType changed")]
public UnityEvent OnChangeToKeyboard;
public UnityEvent OnChangeToMobile;
public UnityEvent OnChangeToJoystick;
void Start()
{
vInput.instance.onChangeInputType -= OnChangeInput;
vInput.instance.onChangeInputType += OnChangeInput;
OnChangeInput(vInput.instance.inputDevice);
}
public void OnChangeInput(InputDevice type)
{
switch (type)
{
case InputDevice.MouseKeyboard:
OnChangeToKeyboard.Invoke();
break;
case InputDevice.Mobile:
OnChangeToMobile.Invoke();
break;
case InputDevice.Joystick:
OnChangeToJoystick.Invoke();
break;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 60254cc56f3d5d04896861196a404996
timeCreated: 1473183929
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using Invector.vCharacterController;
using UnityEngine;
using UnityEngine.Events;
namespace Invector.Utils
{
/// <summary>
/// Simple Checkpoint Example, works by updating the vGameController SpawnPoint to this transform position/rotation.
/// </summary>
[RequireComponent(typeof(BoxCollider))]
public class vCheckpointExample : MonoBehaviour
{
vGameController gm;
public UnityEvent onTriggerEnter;
void Start()
{
gm = GetComponentInParent<vGameController>();
this.GetComponent<BoxCollider>().isTrigger = true;
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
vHUDController.instance.ShowText("Checkpoint reached!");
gm.spawnPoint = this.gameObject.transform;
onTriggerEnter.Invoke();
this.gameObject.SetActive(false);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 635c97f4e78e0be4d877f3bf36a12fec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using System.Collections.Generic;
namespace Invector
{
public class vDestroyOnTrigger : MonoBehaviour
{
public List<string> targsToDestroy;
public float destroyDelayTime;
void OnTriggerEnter(Collider other)
{
if (targsToDestroy.Contains(other.gameObject.tag))
{
Destroy(other.gameObject, destroyDelayTime);
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d0c11f15937f63143a72017227af6d09
timeCreated: 1492574925
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using UnityEngine;
#if UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
namespace Invector.vCharacterController
{
public class vFindSpawnPoint : MonoBehaviour
{
public Transform spawnPoint;
public string spawnPointName;
public GameObject target;
public void AlighObjetToSpawnPoint(GameObject target, string spawnPointName)
{
this.target = target;
this.spawnPointName = spawnPointName;
// Debug.Log(spawnPointName+" "+gameObject.name);
#if UNITY_5_4_OR_NEWER
SceneManager.sceneLoaded += OnLevelFinishedLoading;
#endif
DontDestroyOnLoad(gameObject);
}
#if UNITY_5_4_OR_NEWER
void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
{
var spawnPoint = GameObject.Find(spawnPointName);
if (spawnPoint && target)
{
target.transform.position = spawnPoint.transform.position;
target.transform.rotation = spawnPoint.transform.rotation;
}
else
{
try
{
Destroy(gameObject);
}
catch { }
}
}
#else
public void OnLevelWasLoaded(int level)
{
var spawnPoint = GameObject.Find(spawnPointName);
if(spawnPoint && target)
{
target.transform.position = spawnPoint.transform.position;
target.transform.rotation = spawnPoint.transform.rotation;
}
else
{
try
{
Destroy(gameObject);
}
catch { }
}
}
#endif
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e7b9865493b1d374fbe1fad5a9ae959c
timeCreated: 1476905194
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using UnityEngine;
namespace Invector.vCharacterController
{
public class vJumpMultiplierTrigger : MonoBehaviour
{
public float multiplier = 5;
public float timeToReset = 0.5f;
void OnTriggerStay(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
var motor = other.GetComponent<vThirdPersonController>();
if (motor && (motor.isJumping || !motor.isGrounded) && motor._rigidbody.linearVelocity.y <= 0)
{
motor.SetJumpMultiplier(multiplier, timeToReset);
motor.isJumping = false;
motor.verticalVelocity = 0;
motor.heightReached = transform.position.y;
motor.isGrounded = true;
motor.Jump();
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d1699aaa48361ae468e588c4ed21b5b2
timeCreated: 1517405472
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using UnityEngine;
namespace Invector.Utils
{ [vClassHeader("Load Level",openClose =false)]
public class vLoadLevel : vMonoBehaviour
{
[Tooltip("Write the name of the level you want to load")]
public string levelToLoad;
[Tooltip("Assign here the spawnPoint name of the scene that you will load")]
public string spawnPointName;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
var thirdPerson = other.transform.gameObject.GetComponent<vCharacterController.vThirdPersonInput>();
LoadLevelHelper.LoadScene(levelToLoad, spawnPointName, thirdPerson);
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 306b1f07aee1a504fb94659520fc9287
timeCreated: 1476895792
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,106 @@
using Invector.vCharacterController;
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Invector.Utils
{
public interface vISceneLoadListener
{
void OnStartLoadScene(string sceneName);
void OnFinishLoadScene(string sceneName);
}
public static class LoadLevelHelper
{
public static vThirdPersonInput targetCharacter;
public static string spawnPointName;
public static string sceneName;
public static bool isLoading;
public static void LoadScene(string _sceneName, string _spawnPointName, vThirdPersonInput tpInput)
{
if (!tpInput) return;
targetCharacter = tpInput;
spawnPointName = _spawnPointName;
sceneName = _sceneName;
if (targetCharacter.tpCamera)
{
targetCharacter.tpCamera.transform.parent = targetCharacter.transform;
}
var listeners = targetCharacter.GetComponents<vISceneLoadListener>();
foreach (var listener in listeners)
{
listener.OnStartLoadScene(_sceneName);
}
targetCharacter.StartCoroutine(LoadAsyncScene());
}
static IEnumerator LoadAsyncScene()
{
// Ensure targetCharacter is still valid
if (targetCharacter == null|| isLoading) yield break;
isLoading = true;
Scene currentScene = SceneManager.GetActiveScene();
if (!currentScene.name.Equals(sceneName))
{
SceneManager.sceneUnloaded += OnSceneUnloaded;
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
while (!asyncLoad.isDone)
{
yield return null;
}
SceneManager.MoveGameObjectToScene(targetCharacter.gameObject, SceneManager.GetSceneByName(sceneName));
SceneManager.UnloadSceneAsync(currentScene);
}
else
{
MoveCharacterToSpawnPoint();
}
isLoading = false;
}
static void OnSceneUnloaded(Scene unloadedScene)
{
var listeners = targetCharacter.GetComponents<vISceneLoadListener>();
foreach (var listener in listeners)
{
listener.OnFinishLoadScene(unloadedScene.name);
}
MoveCharacterToSpawnPoint();
SceneManager.sceneUnloaded -= OnSceneUnloaded;
}
static void MoveCharacterToSpawnPoint()
{
var spawnPoint = GameObject.Find(spawnPointName);
if (spawnPoint && targetCharacter)
{
targetCharacter.lockCameraInput = true;
if (targetCharacter.tpCamera)
{
targetCharacter.tpCamera.FreezeCamera();
}
targetCharacter.transform.position = spawnPoint.transform.position;
targetCharacter.transform.rotation = spawnPoint.transform.rotation;
if (targetCharacter.tpCamera)
{
targetCharacter.tpCamera.transform.parent = null;
targetCharacter.tpCamera.UnFreezeCamera();
}
targetCharacter.lockCameraInput = false;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 70971e1dc4e369f489c5d747b53633f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,191 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace Invector
{
[vClassHeader("SimpleTrigger", openClose = false, useHelpBox = true, helpBoxText = "Tags and Layer To Detect : Use this to filter tags and layer that can interact with trigger, Select Nothing to ignore filter")]
public class vSimpleTrigger : vMonoBehaviour
{
public static bool drawGizmos = true;
[System.Serializable]
public class vTriggerEvent : UnityEvent<Collider> { }
[vButton("ToggleGizmos", "ToggleGizmos", typeof(vSimpleTrigger), false)]
public bool useFilter = true;
public bool ignoreIsTriggerColliders;
public bool debugMode;
public vTagMask tagsToDetect = new List<string>() { "Player" };
public LayerMask layersToDetect = 0;
public vTriggerEvent onTriggerEnter;
public vTriggerEvent onTriggerExit;
public vTriggerEvent onTriggerStay;
protected bool inCollision;
protected bool triggerStay;
protected Collider other;
protected Collider _selfCollider;
public void ToggleGizmos()
{
drawGizmos = !drawGizmos;
}
public virtual Collider selfCollider
{
get
{
if (!_selfCollider && transform.GetComponent<Collider>() == null)
{
_selfCollider = gameObject.AddComponent<BoxCollider>();
}
else if (!_selfCollider)
{
_selfCollider = transform.GetComponent<Collider>();
}
return _selfCollider;
}
protected set
{
_selfCollider = value;
}
}
protected virtual void OnDrawGizmos()
{
if (!drawGizmos)
{
return;
}
Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, (transform.lossyScale));
Vector3 position = transform.InverseTransformPoint(selfCollider.bounds.center);
Vector3 size = GetColliderSize();
Color red = new Color(1, 0, 0, 0.2f);
Color green = new Color(0, 1, 0, 0.2f);
Gizmos.color = inCollision && Application.isPlaying ? red : green;
if (selfCollider is BoxCollider)
Gizmos.DrawCube(position, size);
else if (selfCollider is SphereCollider)
{
Gizmos.DrawSphere(position, (selfCollider as SphereCollider).radius);
}
else if (selfCollider is CapsuleCollider)
{
Gizmos.DrawCube(position, size * 2);
}
else if(selfCollider is MeshCollider)
{
Gizmos.DrawMesh((selfCollider as MeshCollider).sharedMesh, position);
}
}
Vector3 GetColliderSize()
{
if (selfCollider is BoxCollider)
{
return (selfCollider as BoxCollider).size;
}
else if(selfCollider is SphereCollider)
{
return Vector3.one;
}
else if (selfCollider is CapsuleCollider)
{
var size = Vector3.zero;
size.x = (selfCollider as CapsuleCollider).radius;
size.z = (selfCollider as CapsuleCollider).radius;
size.y = (selfCollider as CapsuleCollider).height*0.5f;
return size;
}
return Vector3.one;
}
protected virtual void Start()
{
inCollision = false;
selfCollider.isTrigger = true;
}
protected virtual void OnTriggerEnter(Collider other)
{
if (this.enabled && this.other == null && CanTrigger(other) && IsInTagMask(other.gameObject.tag) && IsInLayerMask(other.gameObject.layer))
{
inCollision = true;
this.other = other;
onTriggerEnter.Invoke(other);
if (debugMode)
{
Debug.Log(other.gameObject.name + "TriggerEnter");
}
if (this.enabled && gameObject.activeInHierarchy)
{
StartCoroutine(TriggerStayRoutine());
}
}
}
private bool CanTrigger(Collider other)
{
return ignoreIsTriggerColliders ? !other.isTrigger : true;
}
protected virtual void OnTriggerExit(Collider other)
{
if (this.enabled && this.other != null && CanTrigger(other) && this.other.gameObject == other.gameObject)
{
inCollision = false;
onTriggerExit.Invoke(other);
if (debugMode)
{
Debug.Log(other.gameObject.name + "TriggerExit");
}
this.other = null;
}
}
protected virtual bool IsInTagMask(string tag)
{
if (tagsToDetect.Count == 0)
{
return true;
}
else
{
return tagsToDetect.Contains(tag);
}
}
protected virtual bool IsInLayerMask(int layer)
{
return (layersToDetect.value == 0 || (layersToDetect.value & (1 << layer)) > 0);
}
protected IEnumerator TriggerStayRoutine()
{
while (other != null)
{
if (other == null || !other.gameObject.activeInHierarchy)
{
OnTriggerExit(other);
break;
}
else
{
onTriggerStay.Invoke(other);
if (debugMode)
{
Debug.Log(other.gameObject.name + "TriggerStay");
}
}
yield return null;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8f6b16cef2c9411428b90020bea51fe0
timeCreated: 1496273030
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,112 @@
using Invector;
using Invector.vCharacterController;
using UnityEngine;
using UnityEngine.Events;
[vClassHeader("Simple Trigger Input")]
public class vSimpleTriggerWithInput : vSimpleTrigger
{
public InputType inputType = InputType.GetButtonDown;
[Tooltip("Input to make the action")]
public GenericInput actionInput = new GenericInput("E", "A", "A");
public enum InputType
{
GetButtonDown,
GetDoubleButton,
GetButtonTimer
};
[vHelpBox("Time you have to hold the button *Only for GetButtonTimer*")]
public float buttonTimer = 3f;
[vHelpBox("Add delay to start the input count *Only for GetButtonTimer*")]
public float inputDelay = 0.1f;
[vHelpBox("Time to press the button twice *Only for GetDoubleButton*")]
public float doubleButtomTime = 0.25f;
public float _currentInputDelay;
public float currentButtonTimer;
public UnityEvent OnPressButton;
public UnityEvent OnCancelButtonTimer;
public OnUpdateValue OnUpdateButtonTimer;
void Update()
{
if (!other)
{
_currentInputDelay = inputDelay;
return;
}
// GetButtonDown
if (inputType == InputType.GetButtonDown)
{
if (actionInput.GetButtonDown())
{
OnPressButton.Invoke();
}
}
// GetDoubleButton
else if (inputType == InputType.GetDoubleButton)
{
if (actionInput.GetDoubleButtonDown(doubleButtomTime))
{
OnPressButton.Invoke();
}
}
// GetButtonTimer (Hold Button)
else if (inputType == InputType.GetButtonTimer)
{
if (_currentInputDelay <= 0)
{
var up = false;
var t = 0f;
// call the OnPressButton event after the buttomTimer is finished
if (actionInput.GetButtonTimer(ref t, ref up, buttonTimer))
{
_currentInputDelay = inputDelay;
OnPressButton.Invoke();
}
// update the button timer
if (actionInput.inButtomTimer)
{
UpdateButtonTimer(t);
}
// reset the buttonTimer if you release the button before finishing
if (up)
CancelButtonTimer();
}
else
{
_currentInputDelay -= Time.deltaTime;
}
}
}
public void UpdateButtonTimer(float value)
{
if (value != currentButtonTimer)
{
currentButtonTimer = value;
OnUpdateButtonTimer.Invoke(value);
}
}
private void CancelButtonTimer()
{
OnCancelButtonTimer.Invoke();
_currentInputDelay = inputDelay;
UpdateButtonTimer(0);
}
[System.Serializable]
public class OnUpdateValue : UnityEvent<float>
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cd7027ac3df66894a9772c31dde5e330
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,105 @@
using UnityEngine;
namespace Invector.vCharacterController
{
[vClassHeader("Trigger Change Camera State", openClose = false)]
public class vTriggerChangeCameraState : vMonoBehaviour
{
[Tooltip("Check if you want to lerp the state transitions, you can change the lerp value on the TPCamera - Smooth Follow variable")]
public bool smoothTransition = true;
public bool keepDirection = true;
[vHelpBox("Keep it empty to Reset back to Default")]
[Tooltip("Check your CameraState List and set the State here, use the same String value.\n*Leave this field empty to return the original state")]
public string cameraState;
public bool resetCameraStateOnExitTrigger;
[Tooltip("Set a new target for the camera.\n*Leave this field empty to return the original target (Player)")]
public string customCameraPoint;
public Color gizmoColor = Color.green;
private Component comp = null;
public vThirdPersonInput tpInput;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
if (tpInput == null || tpInput.gameObject != other.gameObject)
{
tpInput = other.GetComponent<vThirdPersonInput>();
}
if (tpInput != null)
{
if (cameraState != string.Empty)
{
tpInput.ChangeCameraState(cameraState, smoothTransition);
}
else if (cameraState == string.Empty)
{
tpInput.ResetCameraState();
}
if (!string.IsNullOrEmpty(customCameraPoint))
{
tpInput.customlookAtPoint = customCameraPoint;
}
tpInput.cc.keepDirection = keepDirection;/// set Input to keep Direction
}
}
}
private void OnTriggerExit(Collider other)
{
if (resetCameraStateOnExitTrigger && other.gameObject.CompareTag("Player"))
{
if (tpInput != null)
{
tpInput.ResetCameraState();
}
}
}
void OnDrawGizmos()
{
Gizmos.color = gizmoColor;
comp = gameObject.GetComponent<BoxCollider>();
if (comp != null)
{
gameObject.GetComponent<BoxCollider>().isTrigger = true;
gameObject.GetComponent<BoxCollider>().center = Vector3.zero;
gameObject.GetComponent<BoxCollider>().size = Vector3.one;
}
Gizmos.matrix = transform.localToWorldMatrix;
if (comp == null)
{
gameObject.AddComponent<BoxCollider>();
}
Gizmos.DrawCube(Vector3.zero, Vector3.one);
}
Vector3 getLargerScale(Vector3 value)
{
if (value.x > value.y || value.x > value.z)
{
return new Vector3(value.x, value.x, value.x);
}
if (value.y > value.x || value.y > value.z)
{
return new Vector3(value.y, value.y, value.y);
}
if (value.z > value.y || value.z > value.x)
{
return new Vector3(value.z, value.z, value.z);
}
return transform.localScale;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6b6328f54892e2649ab39b27d4793dd2
timeCreated: 1449855461
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
using UnityEngine;
using UnityEngine.UI;
namespace Invector
{
public class vTutorialTextTrigger : MonoBehaviour
{
[TextAreaAttribute(5, 3000), Multiline]
public string text;
public Text _textUI;
public GameObject painel;
protected virtual void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
EnableTutorialPanel();
}
}
public virtual void EnableTutorialPanel()
{
painel.SetActive(true);
_textUI.gameObject.SetActive(true);
_textUI.text = text;
}
protected virtual void OnTriggerExit(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
DisableTutorialPanel();
}
}
public virtual void DisableTutorialPanel()
{
painel.SetActive(false);
_textUI.gameObject.SetActive(false);
_textUI.text = " ";
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c758cdae3ce328c4d8184cba5fc44c4a
timeCreated: 1487617601
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: