plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent ed7b223c04
commit fd87a6ffd5
14441 changed files with 13711084 additions and 20 deletions

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5d3d2f4285b12834cb544c89cdb0e553
folderAsset: yes
timeCreated: 1584940060
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7f4bf552baf1d274783f699d48933df3
folderAsset: yes
timeCreated: 1584940566
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,216 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class grapplingHookEffect : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
[Tooltip ("The speed of the entire effect.")]
public float Speed = 3f;
[Tooltip ("The speed of the spiral offset (relative to 'Speed').")]
public float SpiralSpeed = 4f;
[Tooltip ("The speed that the end of the line moves to the target point (relative to 'Speed')")]
public float DistanceSpeed = 2f;
[Tooltip ("A multiplier for the pull of gravity.")]
public float Gravity = 0.5f;
[Tooltip ("The number of points to be drawn by the line renderer. \nUpdates every time the effect is triggered.")]
public int Segments = 100;
public LayerMask layerMask;
[Space]
[Header ("Spiral Settings")]
[Space]
[Tooltip ("The strength of the spiral.")]
public Vector2 Magnitude = Vector2.one;
[Tooltip ("The number of 'Curve' repetitions per world-unit.")]
public float Frequency = 0.5f;
[Tooltip ("The amount the horizontal part of the spiral is offset along 'Curve.' \nIf 'Curve' is a sine wave, 0.25 will result in a perfect spiral.")]
public float HorizontalOffset = 0.25f;
[Space]
[Header ("Noise Settings")]
[Space]
[Tooltip ("The strength of the noise.")]
public float Strength = 0.5f;
[Tooltip ("The scale of the noise samples. \nHigher = smoother.")]
public float Scale = 0.25f;
[Space]
[Header ("Curves Settings")]
[Space]
[Tooltip ("The base curve that the points will be offset along. \nA sine wave will make it look like a grapple spiral.")]
public AnimationCurve Curve = new AnimationCurve ();
[Tooltip ("The strength of the spiral and noise over time.")]
public AnimationCurve MagnitudeOverTime = new AnimationCurve ();
[Tooltip ("The strength of the spiral and noise from the start to current end point within a 0 to 1 range.")]
public AnimationCurve MagnitudeOverDistance = new AnimationCurve ();
[Tooltip ("The vertical offset applied in world space to the line from the start to current end point within a 0 to 1 range.")]
public AnimationCurve GravityOverDistance = new AnimationCurve ();
[Tooltip ("The strength of the gravity over time.")]
public AnimationCurve GravityOverTime = new AnimationCurve ();
[Space]
[Header ("Debug")]
[Space]
public bool showGizmo;
public bool grapplingHookEffectActive;
public bool fixedUpdateActive;
[Space]
[Header ("Components")]
[Space]
public LineRenderer lineRenderer;
public Transform mainCameraTransform;
public Transform lineRendererOriginPositionTransform;
public Transform lineRendererTargetPositionTransform;
public Transform playerControllerTransform;
float scaledTimeOffset = 0f;
float spiralTimeOffset = 0f;
float lastGrappleTime = 0f;
Vector3 grapplePoint;
RaycastHit hit;
Vector3 currentPosition;
public void activateGrapplingHookEffect (Vector3 raycastDirection)
{
if (Physics.Raycast (mainCameraTransform.position, raycastDirection, out hit, Mathf.Infinity, layerMask)) {
lineRenderer.enabled = true;
DoGrapple (hit.point);
grapplingHookEffectActive = true;
}
if (showGizmo) {
Debug.DrawLine (mainCameraTransform.position, mainCameraTransform.position + raycastDirection * 1000, Color.red, 5);
}
}
public void activateGrapplingHookEffect ()
{
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.forward, out hit, Mathf.Infinity, layerMask)) {
lineRenderer.enabled = true;
DoGrapple (hit.point);
grapplingHookEffectActive = true;
}
}
public void deactivateGrapplingHookEffect ()
{
grapplingHookEffectActive = false;
lineRenderer.enabled = false;
for (int i = 0; i < lineRenderer.positionCount; i++) {
lineRenderer.SetPosition (i, lineRendererOriginPositionTransform.position);
}
}
public void DoGrapple (Vector3 newWrapplePoint)
{
grapplePoint = newWrapplePoint;
scaledTimeOffset = spiralTimeOffset = 0f;
if (lineRenderer.positionCount != Segments)
lineRenderer.positionCount = Segments;
lastGrappleTime = Time.time * 10f;
}
public void setFixedUpdateActiveState (bool state)
{
fixedUpdateActive = state;
}
void Update ()
{
if (!fixedUpdateActive) {
updateEffect ();
}
}
void FixedUpdate ()
{
if (fixedUpdateActive) {
updateEffect ();
}
}
void updateEffect ()
{
if (grapplingHookEffectActive) {
if (lineRendererTargetPositionTransform == null) {
deactivateGrapplingHookEffect ();
return;
}
grapplePoint = lineRendererTargetPositionTransform.position;
lineRendererOriginPositionTransform.LookAt (grapplePoint);
var difference = grapplePoint - lineRendererOriginPositionTransform.position;
var direction = difference.normalized;
var distanceMultiplier = Mathf.Clamp01 (scaledTimeOffset * DistanceSpeed);
var distance = difference.magnitude * distanceMultiplier;
scaledTimeOffset += Speed * Time.deltaTime;
if (distanceMultiplier < 1f) {
spiralTimeOffset += Speed * SpiralSpeed * Time.deltaTime;
}
for (int i = 0; i < lineRenderer.positionCount; i++) {
var t = (float)i / lineRenderer.positionCount;
currentPosition = lineRendererOriginPositionTransform.position;
var forwardOffset = direction * (t * distance);
currentPosition += forwardOffset;
var curveSamplePosition = forwardOffset.magnitude * Frequency - spiralTimeOffset;
var verticalOffset = lineRendererOriginPositionTransform.up * Curve.Evaluate (curveSamplePosition);
var horizontalOffset = lineRendererOriginPositionTransform.right * Curve.Evaluate (curveSamplePosition + HorizontalOffset);
verticalOffset *= Magnitude.y;
horizontalOffset *= Magnitude.x;
var noiseSamplePosition = -t * Scale + scaledTimeOffset + lastGrappleTime;
verticalOffset += lineRendererOriginPositionTransform.up * ((Mathf.PerlinNoise (0f, noiseSamplePosition) - 0.5f) * 2f * Strength);
horizontalOffset += lineRendererOriginPositionTransform.right * ((Mathf.PerlinNoise (noiseSamplePosition, 0f) - 0.5f) * 2f * Strength);
var magnitude = MagnitudeOverTime.Evaluate (scaledTimeOffset) * MagnitudeOverDistance.Evaluate (t);
verticalOffset *= magnitude;
horizontalOffset *= magnitude;
currentPosition += verticalOffset;
currentPosition += horizontalOffset;
currentPosition += Vector3.up * (GravityOverDistance.Evaluate (t) * GravityOverTime.Evaluate (scaledTimeOffset) * Gravity);
lineRenderer.SetPosition (i, currentPosition);
}
}
}
public void changeLineRendererOriginPositionParent (Transform newParent)
{
lineRendererOriginPositionTransform.SetParent (newParent);
lineRendererOriginPositionTransform.localPosition = Vector3.zero;
}
public void setNewlineRendererTargetPositionTransform (Transform newObject)
{
lineRendererTargetPositionTransform = newObject;
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 8a55238d07af02149ac7ad442bf3acca
timeCreated: 1581945381
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/Grappling
Hook System/grapplingHookEffect.cs
uploadId: 814740

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 12e8b09b03a5ec14faa0cfc3861a18fd
timeCreated: 1581811914
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/Grappling
Hook System/grapplingHookSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,170 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class grapplingHookTarget : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool grapplingHookTargetEnabled = true;
public List<string> tagsToCheck = new List<string> ();
public LayerMask layermaskToCheck;
[Space]
[Header ("Custom Hook Transform Settings")]
[Space]
public bool useCustomTransformTarget;
public Transform customTransformTarget;
[Space]
[Header ("Event Settings")]
[Space]
public bool useEventOnHookReceived;
public UnityEvent eventOnHookReceived;
[Space]
public bool useEventOnSwingReceived;
public UnityEvent eventOnSwingReceived;
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
public Color gizmoLabelColor = Color.green;
public Color gizmoColor = Color.white;
public float gizmoRadius = 0.3f;
[Space]
[Header ("Components")]
[Space]
public SphereCollider mainSphereCollider;
Transform targetTransform;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!grapplingHookTargetEnabled) {
return;
}
if ((1 << col.gameObject.layer & layermaskToCheck.value) == 1 << col.gameObject.layer) {
if (isEnter) {
if (tagsToCheck.Contains (col.tag)) {
GameObject currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
grapplingHookTargetsSystem currentGrapplingHookTargetsSystem = currentPlayerComponentsManager.getGrapplingHookTargetsSystem ();
if (currentGrapplingHookTargetsSystem != null) {
if (targetTransform == null) {
if (useCustomTransformTarget) {
targetTransform = customTransformTarget;
} else {
targetTransform = transform;
}
}
currentGrapplingHookTargetsSystem.addNewGrapplingHookTarget (targetTransform);
}
}
}
} else {
if (tagsToCheck.Contains (col.tag)) {
GameObject currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
grapplingHookTargetsSystem currentGrapplingHookTargetsSystem = currentPlayerComponentsManager.getGrapplingHookTargetsSystem ();
if (currentGrapplingHookTargetsSystem != null) {
if (targetTransform == null) {
if (useCustomTransformTarget) {
targetTransform = customTransformTarget;
} else {
targetTransform = transform;
}
}
currentGrapplingHookTargetsSystem.removeNewGrapplingHookTarget (targetTransform);
}
}
}
}
}
}
public void checkEventOnHookReceived ()
{
if (useEventOnHookReceived) {
eventOnHookReceived.Invoke ();
}
}
public void checkEventOnSwingReceived ()
{
if (useEventOnSwingReceived) {
eventOnSwingReceived.Invoke ();
}
}
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
Gizmos.color = gizmoColor;
if (useCustomTransformTarget) {
Gizmos.DrawWireSphere (customTransformTarget.position, gizmoRadius);
} else {
Gizmos.DrawWireSphere (transform.position, gizmoRadius);
}
if (mainSphereCollider != null) {
mainSphereCollider.radius = gizmoRadius;
}
}
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 5976360ec5494bf4cb381f61cab8b332
timeCreated: 1583300762
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/Grappling
Hook System/grapplingHookTarget.cs
uploadId: 814740

View File

@@ -0,0 +1,352 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class grapplingHookTargetsSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool showGrapplingHookTargetsActive = true;
public LayerMask layerForThirdPerson;
public LayerMask layerForFirstPerson;
public bool checkObstaclesToGrapplingHookTargets;
[Space]
public List<grapplingHookSystem> grapplingHookSystemList = new List<grapplingHookSystem> ();
[Space]
[Header ("Debug")]
[Space]
public bool showGrapplingHookTargetsPaused;
public Transform closestTarget;
public List<grapplingHookTargetInfo> grapplingHookTargetInfoList = new List<grapplingHookTargetInfo> ();
[Space]
[Header ("Components")]
[Space]
public GameObject grapplingHookTargetIconPrefab;
public Camera mainCamera;
public Transform mainCameraTransform;
public GameObject playerGameObject;
public playerCamera mainPlayerCamera;
public Transform grapplingHookTargetIconsParent;
public playerTeleportSystem mainPlayerTeleportSystem;
Vector3 screenPoint;
Vector3 currentPosition;
Vector3 mainCameraPosition;
Vector3 direction;
float distanceToMainCamera;
bool layerForThirdPersonAssigned;
bool layerForFirstPersonAssigned;
LayerMask currentLayer;
bool activeIcon;
Vector2 mainCanvasSizeDelta;
Vector2 halfMainCanvasSizeDelta;
Vector2 iconPosition2d;
Vector3 currentTargetPosition;
bool usingScreenSpaceCamera;
bool targetOnScreen;
float screenWidth;
float screenHeight;
grapplingHookTargetInfo currentGrapplingHookTargetInfo;
Transform previousClosestTarget;
Vector3 centerScreen;
float currentDistanceToTarget;
float minDistanceToTarget;
[HideInInspector] public grapplingHookTargetInfo closestTargetInfo;
grapplingHookTargetInfo previousClosestTargetInfo;
bool hookTargetsDetected;
int grapplingHookTargetInfoListCount;
void Start ()
{
mainCanvasSizeDelta = mainPlayerCamera.getMainCanvasSizeDelta ();
halfMainCanvasSizeDelta = mainCanvasSizeDelta * 0.5f;
usingScreenSpaceCamera = mainPlayerCamera.isUsingScreenSpaceCamera ();
if (mainCamera == null) {
mainCamera = mainPlayerCamera.getMainCamera ();
}
}
void LateUpdate ()
{
if (!showGrapplingHookTargetsActive || showGrapplingHookTargetsPaused || !hookTargetsDetected) {
return;
}
if (mainPlayerCamera.isFirstPersonActive ()) {
if (!layerForThirdPersonAssigned) {
currentLayer = layerForFirstPerson;
layerForThirdPersonAssigned = true;
layerForFirstPersonAssigned = false;
}
} else {
if (!layerForFirstPersonAssigned) {
currentLayer = layerForThirdPerson;
layerForFirstPersonAssigned = true;
layerForThirdPersonAssigned = false;
}
}
if (!usingScreenSpaceCamera) {
screenWidth = Screen.width;
screenHeight = Screen.height;
}
mainCameraPosition = mainCameraTransform.position;
minDistanceToTarget = Mathf.Infinity;
centerScreen = new Vector3 (screenWidth / 2, screenHeight / 2, 0);
bool anyTargetVisible = false;
grapplingHookTargetInfoListCount = grapplingHookTargetInfoList.Count;
for (int i = 0; i < grapplingHookTargetInfoListCount; i++) {
currentGrapplingHookTargetInfo = grapplingHookTargetInfoList [i];
if (currentGrapplingHookTargetInfo.targetCanBeShown) {
currentPosition = currentGrapplingHookTargetInfo.targetTransform.position;
currentTargetPosition = currentPosition + currentGrapplingHookTargetInfo.positionOffset;
if (usingScreenSpaceCamera) {
screenPoint = mainCamera.WorldToViewportPoint (currentTargetPosition);
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1;
} else {
screenPoint = mainCamera.WorldToScreenPoint (currentTargetPosition);
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < screenWidth && screenPoint.y > 0 && screenPoint.y < screenHeight;
}
if (targetOnScreen) {
if (currentGrapplingHookTargetInfo.iconCurrentlyEnabled) {
if (usingScreenSpaceCamera) {
iconPosition2d = new Vector2 ((screenPoint.x * mainCanvasSizeDelta.x) - halfMainCanvasSizeDelta.x, (screenPoint.y * mainCanvasSizeDelta.y) - halfMainCanvasSizeDelta.y);
currentGrapplingHookTargetInfo.targetRectTransform.anchoredPosition = iconPosition2d;
} else {
currentGrapplingHookTargetInfo.targetRectTransform.position = new Vector3 (screenPoint.x, screenPoint.y, 0);
}
}
if (checkObstaclesToGrapplingHookTargets) {
//set the direction of the raycast
direction = currentTargetPosition - mainCameraPosition;
direction = direction / direction.magnitude;
activeIcon = false;
distanceToMainCamera = GKC_Utils.distance (mainCameraPosition, currentTargetPosition);
//if the raycast find an obstacle between the enemy and the camera, disable the icon
//if the distance from the camera to the enemy is higher than 100, disable the raycast and the icon
if (Physics.Raycast (currentTargetPosition, -direction, distanceToMainCamera, currentLayer)) {
activeIcon = false;
} else {
//else, the raycast reachs the camera, so enable the pick up icon
activeIcon = true;
}
currentGrapplingHookTargetInfo.targetVisible = activeIcon;
} else {
currentGrapplingHookTargetInfo.targetVisible = true;
}
if (currentGrapplingHookTargetInfo.targetVisible) {
screenPoint = mainCamera.WorldToScreenPoint (currentPosition);
currentDistanceToTarget = GKC_Utils.distance (screenPoint, centerScreen);
if (currentDistanceToTarget < minDistanceToTarget) {
minDistanceToTarget = currentDistanceToTarget;
closestTargetInfo = currentGrapplingHookTargetInfo;
}
anyTargetVisible = true;
}
} else {
currentGrapplingHookTargetInfo.targetVisible = false;
}
} else {
currentGrapplingHookTargetInfo.targetVisible = false;
}
}
if (anyTargetVisible) {
if (closestTargetInfo != null) {
closestTarget = closestTargetInfo.targetTransform;
if (closestTarget != previousClosestTarget) {
previousClosestTarget = closestTarget;
if (previousClosestTargetInfo != null) {
if (previousClosestTargetInfo.iconCurrentlyEnabled) {
previousClosestTargetInfo.targetRectTransform.gameObject.SetActive (false);
previousClosestTargetInfo.iconCurrentlyEnabled = false;
}
}
previousClosestTargetInfo = closestTargetInfo;
closestTargetInfo.targetRectTransform.gameObject.SetActive (true);
closestTargetInfo.iconCurrentlyEnabled = true;
for (int i = 0; i < grapplingHookSystemList.Count; i++) {
if (grapplingHookSystemList [i] != null) {
grapplingHookSystemList [i].setGrapplingHookTarget (closestTarget);
}
}
mainPlayerTeleportSystem.setTeleportHookTarget (closestTarget);
}
}
} else {
if (closestTargetInfo != null && closestTargetInfo.targetRectTransform != null) {
closestTargetInfo.targetRectTransform.gameObject.SetActive (false);
closestTargetInfo.iconCurrentlyEnabled = false;
closestTargetInfo = null;
closestTarget = null;
previousClosestTarget = null;
for (int i = 0; i < grapplingHookSystemList.Count; i++) {
if (grapplingHookSystemList [i] != null) {
grapplingHookSystemList [i].setGrapplingHookTarget (null);
}
}
mainPlayerTeleportSystem.setTeleportHookTarget (null);
}
}
}
public void setCurrentGrapplingHookTargetState (bool state)
{
currentGrapplingHookTargetInfo.targetRectTransform.gameObject.SetActive (state);
currentGrapplingHookTargetInfo.iconCurrentlyEnabled = state;
}
public void disableGrapplingHookTargets ()
{
enableOrDisableGrapplingHookTargets (false);
}
public void enableGrapplingHookTargets ()
{
enableOrDisableGrapplingHookTargets (true);
}
public void enableOrDisableGrapplingHookTargets (bool state)
{
for (int i = 0; i < grapplingHookTargetInfoList.Count; i++) {
currentGrapplingHookTargetInfo = grapplingHookTargetInfoList [i];
if (currentGrapplingHookTargetInfo.targetTransform != null) {
currentGrapplingHookTargetInfo.targetTransform.gameObject.SetActive (state);
currentGrapplingHookTargetInfo.iconCurrentlyEnabled = state;
}
}
}
public void addNewGrapplingHookTarget (Transform targetTransform)
{
grapplingHookTargetInfo newGrapplingHookTargetInfo = new grapplingHookTargetInfo ();
GameObject grapplingHookTargetGameObject = Instantiate (grapplingHookTargetIconPrefab);
grapplingHookTargetGameObject.name = "Grappling Hook Target " + grapplingHookTargetInfoList.Count;
grapplingHookTargetGameObject.transform.SetParent (grapplingHookTargetIconsParent);
grapplingHookTargetGameObject.transform.localScale = Vector3.one;
grapplingHookTargetGameObject.transform.localPosition = Vector3.zero;
grapplingHookTargetGameObject.transform.localRotation = Quaternion.identity;
newGrapplingHookTargetInfo.targetTransform = targetTransform;
newGrapplingHookTargetInfo.iconCurrentlyEnabled = false;
newGrapplingHookTargetInfo.targetRectTransform = grapplingHookTargetGameObject.GetComponent<RectTransform> ();
grapplingHookTargetInfoList.Add (newGrapplingHookTargetInfo);
hookTargetsDetected = true;
}
public void removeNewGrapplingHookTarget (Transform targetTransform)
{
for (int i = 0; i < grapplingHookTargetInfoList.Count; i++) {
if (grapplingHookTargetInfoList [i].targetTransform == targetTransform) {
grapplingHookTargetInfoList [i].iconCurrentlyEnabled = false;
Destroy (grapplingHookTargetInfoList [i].targetRectTransform.gameObject);
grapplingHookTargetInfoList.RemoveAt (i);
if (grapplingHookTargetInfoList.Count == 0) {
for (int j = 0; j < grapplingHookSystemList.Count; j++) {
if (grapplingHookSystemList [i] != null) {
grapplingHookSystemList [j].setGrapplingHookTarget (null);
}
}
mainPlayerTeleportSystem.setTeleportHookTarget (null);
hookTargetsDetected = false;
}
return;
}
}
}
public void pauseOrResumeShowGrapplingHookTargets (bool state)
{
showGrapplingHookTargetsPaused = state;
grapplingHookTargetIconsParent.gameObject.SetActive (!showGrapplingHookTargetsPaused);
}
[System.Serializable]
public class grapplingHookTargetInfo
{
public Transform targetTransform;
public RectTransform targetRectTransform;
public bool targetCanBeShown = true;
public Vector3 positionOffset;
public bool targetVisible;
public bool iconCurrentlyEnabled;
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 13b53c5db8fa6b149835cb3bece40846
timeCreated: 1583300680
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/Grappling
Hook System/grapplingHookTargetsSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,369 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class objectToAttractWithGrapplingHook : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool attractObjectEnabled = true;
public bool attractPlayerEnabled;
public bool enableGravityOnDeactivateAttract = true;
public bool useReducedVelocityOnDisableAttract;
public float maxReducedSpeed;
public float reducedSpeedDuration;
public float newSpeedAfterReducedDurationMultiplier = 1;
public bool ignoreApplySpeedOnHookStopOnPlayer;
public bool resetPlayerSpeedOnHookStop;
[Space]
[Header ("Auto Grab Settings")]
[Space]
public bool autoGrabObjectOnCloseDistance;
public float minDistanceToAutoGrab;
[Space]
[Header ("Activate Interaction Action Settings")]
[Space]
public bool activateInteractionActionWithObject;
public float minDistanceToActivateInteractionActionWithObject;
public GameObject objectToActivate;
[Space]
[Header ("Offset Position Settings")]
[Space]
public bool useHookTargetPostionOffset;
public Vector3 hookTargetPositionOffset;
public bool useObjectTargetPositionTransform;
public Transform objectTargetPositionTransform;
[Space]
[Header ("Rigidbody Elements")]
[Space]
public Rigidbody mainRigidbody;
public bool useRigidbodyList;
public List<Rigidbody> rigidbodyList = new List<Rigidbody> ();
[Space]
[Header ("Custom Settings")]
[Space]
public bool useCustomForceAttractionValues;
public float customMinDistanceToStopAttractObject = 5;
public bool customAddUpForceForAttraction;
public float customUpForceForAttraction;
public float customAddUpForceForAttractionDuration;
[Space]
[Header ("Debug")]
[Space]
public bool attractingObjectActive;
[Space]
[Header ("Event Settings")]
[Space]
public bool useEventsOnAttractState;
public UnityEvent eventOnActivateAttract;
public UnityEvent eventOnDeactivateAttract;
public bool useEventAfterReduceSpeed;
public UnityEvent eventAfterReduceSpeed;
[Space]
[Header ("Remote Event Settings")]
[Space]
public bool useRemoteEventsOnStateChange;
public List<string> remoteEventNameListOnStart = new List<string> ();
public List<string> remoteEventNameListOnEnd = new List<string> ();
[Space]
[Header ("Components")]
[Space]
public Transform mainTransform;
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
public Color gizmoLabelColor = Color.green;
public Color gizmoColor = Color.white;
public float gizmoRadius = 0.3f;
Coroutine reduceSpeedCoroutine;
bool attractionHookRemovedByDistance;
bool reducedSpeedInProcess;
Vector3 speedDirection;
Vector3 previousAngularVelocity;
float previousSpeed;
public void setAttractionHookRemovedByDistanceState (bool state)
{
attractionHookRemovedByDistance = state;
}
public bool setAttractObjectState (bool state)
{
if (attractObjectEnabled) {
attractingObjectActive = state;
if (enableGravityOnDeactivateAttract) {
if (useRigidbodyList) {
for (int i = 0; i < rigidbodyList.Count; i++) {
if (rigidbodyList [i] != null) {
rigidbodyList [i].useGravity = !state;
}
}
} else {
mainRigidbody.useGravity = !state;
}
}
if (useEventsOnAttractState) {
if (attractingObjectActive) {
eventOnActivateAttract.Invoke ();
} else {
eventOnDeactivateAttract.Invoke ();
}
}
if (!attractingObjectActive) {
checkToReduceSpeed ();
}
return attractingObjectActive;
} else {
return false;
}
}
public Rigidbody getRigidbodyToAttract ()
{
return mainRigidbody;
}
public void checkToReduceSpeed ()
{
if (useReducedVelocityOnDisableAttract) {
if (gameObject.activeInHierarchy) {
stopCheckToReduceSpeed ();
reduceSpeedCoroutine = StartCoroutine (checkToReduceSpeedCoroutine ());
}
}
}
public void stopCheckToReduceSpeed ()
{
if (reduceSpeedCoroutine != null) {
StopCoroutine (reduceSpeedCoroutine);
}
}
IEnumerator checkToReduceSpeedCoroutine ()
{
if (!attractionHookRemovedByDistance) {
yield return null;
} else {
reducedSpeedInProcess = true;
previousSpeed = mainRigidbody.linearVelocity.magnitude;
speedDirection = mainRigidbody.linearVelocity.normalized;
previousAngularVelocity = mainRigidbody.angularVelocity;
float t = 0;
bool targetReached = false;
while (!targetReached) {
t += Time.deltaTime;
if (t >= reducedSpeedDuration) {
targetReached = true;
}
if (useRigidbodyList) {
for (int i = 0; i < rigidbodyList.Count; i++) {
if (rigidbodyList [i] != null) {
rigidbodyList [i].linearVelocity = speedDirection * maxReducedSpeed;
rigidbodyList [i].angularVelocity = previousAngularVelocity * maxReducedSpeed;
}
}
} else {
mainRigidbody.linearVelocity = speedDirection * maxReducedSpeed;
mainRigidbody.angularVelocity = previousAngularVelocity * maxReducedSpeed;
}
yield return null;
}
resumeSpeed ();
}
if (useEventAfterReduceSpeed) {
eventAfterReduceSpeed.Invoke ();
}
attractionHookRemovedByDistance = false;
reducedSpeedInProcess = false;
}
public void stopGrapplingHookAndResumeValuesWithoutForce ()
{
speedDirection = Vector3.zero;
previousAngularVelocity = Vector3.zero;
previousSpeed = 0;
stopGrapplingHookAndResumeValues ();
}
public void stopGrapplingHookAndResumeValues ()
{
if (!reducedSpeedInProcess) {
return;
}
stopCheckToReduceSpeed ();
resumeSpeed ();
if (useEventAfterReduceSpeed) {
eventAfterReduceSpeed.Invoke ();
}
attractionHookRemovedByDistance = false;
reducedSpeedInProcess = false;
}
public void stopGrapplingHookIfActiveOnGrabObject ()
{
if (!reducedSpeedInProcess) {
return;
}
stopCheckToReduceSpeed ();
attractionHookRemovedByDistance = false;
reducedSpeedInProcess = false;
speedDirection = Vector3.zero;
previousAngularVelocity = Vector3.zero;
previousSpeed = 0;
}
void resumeSpeed ()
{
if (useRigidbodyList) {
for (int i = 0; i < rigidbodyList.Count; i++) {
if (rigidbodyList [i] != null) {
rigidbodyList [i].linearVelocity = speedDirection * (previousSpeed * newSpeedAfterReducedDurationMultiplier);
}
}
} else {
mainRigidbody.linearVelocity = speedDirection * (previousSpeed * newSpeedAfterReducedDurationMultiplier);
mainRigidbody.angularVelocity = previousAngularVelocity * newSpeedAfterReducedDurationMultiplier;
}
speedDirection = Vector3.zero;
previousAngularVelocity = Vector3.zero;
previousSpeed = 0;
}
public void searchRigidbodyElements ()
{
useRigidbodyList = true;
rigidbodyList.Clear ();
mainRigidbody = null;
if (mainTransform == null) {
mainTransform = transform;
}
Component[] childrens = mainTransform.GetComponentsInChildren (typeof(Rigidbody));
foreach (Rigidbody child in childrens) {
if (child.transform != mainTransform) {
Collider currentCollider = child.GetComponent<Collider> ();
if (currentCollider != null && !currentCollider.isTrigger) {
if (mainRigidbody == null) {
mainRigidbody = child;
}
rigidbodyList.Add (child);
}
}
}
updateComponent ();
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Object To Attract with Grappling Hook", gameObject);
}
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
Gizmos.color = gizmoColor;
if (useHookTargetPostionOffset) {
if (mainTransform == null) {
mainTransform = transform;
}
if (mainTransform != null) {
Gizmos.DrawWireSphere (mainTransform.position + hookTargetPositionOffset, gizmoRadius);
}
}
}
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 3439ef56462ca91469ca7959ad11fc4c
timeCreated: 1585265866
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/Grappling
Hook System/objectToAttractWithGrapplingHook.cs
uploadId: 814740

View File

@@ -0,0 +1,163 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class customAbilitySystem : abilityInfo
{
[Space]
[Header ("Custom Settings")]
[Space]
public bool useEventOnPressDown;
public UnityEvent eventOnPressDown;
public bool useEventOnPressHold;
public UnityEvent eventOnPressHold;
public bool useEventOnPressUp;
public UnityEvent eventOnPressUp;
public bool showDebugPrint;
[Space]
[Header ("Press Delay Settings")]
[Space]
public bool useDelayTimeToUseEventOnPressUp;
public float delayTimeToUseEventOnPressUp;
public bool useEventOnPressUpBeforeAndAfter;
public UnityEvent eventOnPressUpBefore;
public UnityEvent eventOnPressUpAfter;
public float delayTimeToUseEventOnPressUpBefore;
public float delayTimeToUseEventOnPressUpAfter;
public bool useDelayTimeToUseEventOnPressHold;
public float delayTimeToUseEventOnPressHold;
public bool useEventOnPressHoldJustOnce;
[Space]
[Header ("Other Events Settings")]
[Space]
public bool useEventOnUpdateAbilityState;
public UnityEvent eventOnUpdateAbilityState;
public bool useEventOnEnableAbility;
public UnityEvent eventOnEnableAbility;
public bool useEventOnDisableAbility;
public UnityEvent eventOnDisableAbility;
public bool useEventOnDeactivateAbility;
public UnityEvent eventOnDeactivateAbility;
float lastTimePressDownUsed;
bool eventTriggeredOnPressHold;
public override void updateAbilityState ()
{
if (useEventOnUpdateAbilityState) {
eventOnUpdateAbilityState.Invoke ();
}
bool updateAbilityEnergyResult =
mainPlayerAbilitiesSystem.checkAbilityUseEnergyInUpdate (useEnergyOnAbility, useEnergyWithRate, energyAmountUsed);
if (!updateAbilityEnergyResult) {
mainPlayerAbilitiesSystem.deactivateAbilityByName (Name);
}
}
public override void enableAbility ()
{
if (useEventOnEnableAbility) {
eventOnEnableAbility.Invoke ();
}
}
public override void disableAbility ()
{
if (useEventOnDisableAbility) {
eventOnDisableAbility.Invoke ();
}
}
public override void deactivateAbility ()
{
if (useEventOnDeactivateAbility) {
eventOnDeactivateAbility.Invoke ();
}
}
public override void activateSecondaryActionOnAbility ()
{
}
public override void useAbilityPressDown ()
{
if (useEventOnPressDown) {
eventOnPressDown.Invoke ();
}
lastTimePressDownUsed = Time.time;
eventTriggeredOnPressHold = false;
checkUseEventOnUseAbility ();
if (showDebugPrint) {
print ("down");
}
}
public override void useAbilityPressHold ()
{
if (useEventOnPressHold) {
if (useDelayTimeToUseEventOnPressHold) {
if (!useEventOnPressHoldJustOnce || !eventTriggeredOnPressHold) {
if (Time.time > delayTimeToUseEventOnPressHold + lastTimePressDownUsed) {
eventOnPressHold.Invoke ();
if (useEventOnPressHoldJustOnce) {
eventTriggeredOnPressHold = true;
}
}
}
} else {
eventOnPressHold.Invoke ();
}
}
}
public override void useAbilityPressUp ()
{
if (useEventOnPressUp) {
if (!useEventOnPressHoldJustOnce || !eventTriggeredOnPressHold) {
if (useEventOnPressUpBeforeAndAfter) {
if (Time.time < delayTimeToUseEventOnPressUpBefore + lastTimePressDownUsed) {
eventOnPressUpBefore.Invoke ();
} else if (Time.time > delayTimeToUseEventOnPressUpAfter + lastTimePressDownUsed) {
eventOnPressUpAfter.Invoke ();
}
} else {
if (useDelayTimeToUseEventOnPressUp) {
if (Time.time > delayTimeToUseEventOnPressUp + lastTimePressDownUsed) {
eventOnPressUp.Invoke ();
}
} else {
eventOnPressUp.Invoke ();
}
}
if (showDebugPrint) {
print ("up");
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 9e6044932f8c2004fb0e860fea6bc6a7
timeCreated: 1579567359
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/customAbilitySystem.cs
uploadId: 814740

View File

@@ -0,0 +1,387 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class drainStatSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool drainEnabled;
public LayerMask layerToCheck;
public bool useSphereCastAll;
public float sphereCastAllRadius;
[Space]
[Header ("Drain Settings")]
[Space]
public bool drainStatsEnabled = true;
public bool activateDrainCoroutineDirectly;
public float drainStatRate = 0.3f;
public float maxDrainDistance = 20;
public bool moveObjectCloserToPlayer;
public float moveObjectSpeed = 5;
public float lookObjectSpeed = 5;
public float minDistanceToMove = 3;
public float startDrainDelay;
public bool stopDrainDirectly = true;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool drainActive;
public bool drainActionPaused;
public bool moveObjectActive;
public List<GameObject> detectedGameObjectList = new List<GameObject> ();
[Space]
[Header ("Stats Settings")]
[Space]
public List<statsInfo> statsInfoList = new List<statsInfo> ();
[Space]
[Header ("Remote Event Settings")]
[Space]
public bool useRemoteEventOnObjectsFound;
public List<string> remoteEventNameListOnStart = new List<string> ();
public List<string> remoteEventNameListOnEnd = new List<string> ();
[Space]
[Header ("Event Settings")]
[Space]
public UnityEvent eventOnStartDrain;
public UnityEvent envetOnEndDrain;
public UnityEvent eventToStopDrainManually;
[Space]
[Header ("Components")]
[Space]
public Transform mainCameraTransform;
public Transform playerTransform;
public playerStatsSystem mainPlayerStatsSystem;
List<playerStatsSystem> playerStatsSystemList = new List<playerStatsSystem> ();
RaycastHit hit;
Coroutine drainCoroutine;
remoteEventSystem currentRemoteEventSystem;
RaycastHit [] hitsList;
Coroutine moveCoroutine;
public void stopDrainManually ()
{
if (drainActive) {
eventToStopDrainManually.Invoke ();
}
}
public void stopDrainIfActive ()
{
if (drainActive) {
stopDrain ();
if (!stopDrainDirectly) {
envetOnEndDrain.Invoke ();
}
}
}
public void checkTargetToDrain ()
{
if (!drainEnabled) {
return;
}
if (drainActionPaused) {
return;
}
if (drainActive) {
stopDrainManually ();
return;
}
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.forward, out hit, maxDrainDistance, layerToCheck)) {
bool startDrain = false;
detectedGameObjectList.Clear ();
playerStatsSystemList.Clear ();
if (useSphereCastAll) {
Ray newRay = new Ray (hit.point, mainCameraTransform.forward);
hitsList = Physics.SphereCastAll (newRay, sphereCastAllRadius, maxDrainDistance, layerToCheck);
List<GameObject> temporalGameObjectList = new List<GameObject> ();
for (int i = 0; i < hitsList.Length; i++) {
temporalGameObjectList.Add (hitsList [i].collider.gameObject);
}
for (int i = 0; i < temporalGameObjectList.Count; i++) {
playerComponentsManager currentPlayerComponentsManager = temporalGameObjectList [i].GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
playerStatsSystem statsSystemDetected = currentPlayerComponentsManager.getPlayerStatsSystem ();
if (statsSystemDetected != null) {
playerStatsSystemList.Add (statsSystemDetected);
detectedGameObjectList.Add (temporalGameObjectList [i]);
startDrain = true;
}
}
}
} else {
playerComponentsManager currentPlayerComponentsManager = hit.collider.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
playerStatsSystem statsSystemDetected = currentPlayerComponentsManager.getPlayerStatsSystem ();
if (statsSystemDetected != null) {
playerStatsSystemList.Add (statsSystemDetected);
detectedGameObjectList.Add (hit.collider.gameObject);
startDrain = true;
}
}
}
if (startDrain) {
if (showDebugPrint) {
print ("start drain");
}
eventOnStartDrain.Invoke ();
drainActive = true;
if (activateDrainCoroutineDirectly) {
startDrainCoroutine ();
}
}
}
}
public void startDrainCoroutine ()
{
stopActivateDrainStatCoroutine ();
drainCoroutine = StartCoroutine (activateDrainStatCoroutine ());
}
public void stopActivateDrainStatCoroutine ()
{
if (drainCoroutine != null) {
StopCoroutine (drainCoroutine);
}
}
IEnumerator activateDrainStatCoroutine ()
{
yield return new WaitForSeconds (startDrainDelay);
if (drainStatsEnabled) {
bool statTotallyDrained = false;
int statsDrainedAmount = 0;
while (!statTotallyDrained) {
yield return new WaitForSeconds (drainStatRate);
for (int i = 0; i < statsInfoList.Count; i++) {
mainPlayerStatsSystem.addOrRemovePlayerStatAmount (statsInfoList [i].statToIncrease, statsInfoList [i].increaseStatAmount);
statsDrainedAmount = 0;
for (int j = 0; j < statsInfoList [i].statToDrainList.Count; j++) {
for (int k = 0; k < playerStatsSystemList.Count; k++) {
playerStatsSystemList [k].addOrRemovePlayerStatAmount (statsInfoList [i].statToDrainList [j], statsInfoList [i].drainStatAmount);
if (playerStatsSystemList [k].getStatValue (statsInfoList [i].statToDrainList [j]) <= 0) {
statsDrainedAmount++;
}
}
}
if (useSphereCastAll) {
if (statsDrainedAmount >= statsInfoList [i].statToDrainList.Count * playerStatsSystemList.Count) {
statTotallyDrained = true;
}
} else {
if (statsDrainedAmount >= statsInfoList [i].statToDrainList.Count) {
statTotallyDrained = true;
}
}
}
yield return null;
}
}
yield return null;
stopDrain ();
if (!stopDrainDirectly) {
envetOnEndDrain.Invoke ();
}
}
public void stopDrain ()
{
if (!drainEnabled) {
return;
}
if (drainActive) {
if (showDebugPrint) {
print ("stop drain");
}
stopActivateDrainStatCoroutine ();
if (stopDrainDirectly) {
envetOnEndDrain.Invoke ();
}
drainActive = false;
checkRemoteEventOnEnd ();
moveObjectActive = false;
stopMoveObjectCoroutine ();
drainActionPaused = false;
}
}
public void checkRemoteEventOnStart ()
{
if (useRemoteEventOnObjectsFound) {
for (int i = 0; i < detectedGameObjectList.Count; i++) {
currentRemoteEventSystem = detectedGameObjectList [i].GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int j = 0; j < remoteEventNameListOnStart.Count; j++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnStart [j]);
}
}
}
}
}
public void checkRemoteEventOnEnd ()
{
if (useRemoteEventOnObjectsFound) {
for (int i = 0; i < detectedGameObjectList.Count; i++) {
currentRemoteEventSystem = detectedGameObjectList [i].GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int j = 0; j < remoteEventNameListOnEnd.Count; j++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnEnd [j]);
}
}
}
}
}
public void startMoveObjectCoroutine ()
{
stopMoveObjectCoroutine ();
moveCoroutine = StartCoroutine (moveObjectCoroutine ());
}
public void stopMoveObjectCoroutine ()
{
if (moveCoroutine != null) {
StopCoroutine (moveCoroutine);
}
}
IEnumerator moveObjectCoroutine ()
{
while (drainActive) {
if (moveObjectCloserToPlayer && moveObjectActive) {
for (int i = 0; i < detectedGameObjectList.Count; i++) {
moveObject (detectedGameObjectList [i].transform);
}
}
yield return null;
}
}
void moveObject (Transform objectToMove)
{
float currentDistance = GKC_Utils.distance (playerTransform.position, objectToMove.position);
if (currentDistance > minDistanceToMove) {
objectToMove.position = Vector3.Lerp (objectToMove.position, playerTransform.position, Time.deltaTime * moveObjectSpeed);
}
Vector3 lookDirection = playerTransform.position - objectToMove.position;
lookDirection = lookDirection / lookDirection.magnitude;
Quaternion targetRotation = Quaternion.LookRotation (lookDirection);
objectToMove.rotation = Quaternion.Lerp (objectToMove.rotation, targetRotation, Time.deltaTime * lookObjectSpeed);
}
public void setDrainActionPausedState (bool state)
{
drainActionPaused = state;
}
public void setMoveObjectActiveState (bool state)
{
moveObjectActive = state;
if (moveObjectActive) {
startMoveObjectCoroutine ();
}
}
[System.Serializable]
public class statsInfo
{
public string statToIncrease;
public float increaseStatAmount = 5;
public float drainStatAmount = 5;
public List<string> statToDrainList = new List<string> ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: cbf20afedae3a434bba41b0d9d4e5077
timeCreated: 1589011574
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/drainStatSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,311 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class laserPlayer : laser
{
[Space]
[Header ("Main Settings")]
[Space]
public float laserDamage = 0.3f;
public bool ignoreShield;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
[Space]
[Header ("Other Settings")]
[Space]
public LayerMask layer;
public GameObject hitSmoke;
public GameObject hitSparks;
public laserDevice.laserType lasertype;
public int reflactionLimit = 10;
public Transform mainCameraTransform;
public GameObject player;
Vector3 inDirection;
Vector3 laserHitPosition;
public GameObject currentLaser;
RaycastHit hit;
Ray ray;
int nPoints;
Renderer currentLaserRenderer;
int propertyNameID;
void Start ()
{
propertyNameID = Shader.PropertyToID ("_TintColor");
StartCoroutine (laserAnimation ());
reflactionLimit++;
}
void Update ()
{
//the player's laser can be reflected, so the linerenderer has reflactionLimit vertex
if (lasertype == laserDevice.laserType.refraction) {
reflactionLimit = Mathf.Clamp (reflactionLimit, 1, reflactionLimit);
ray = new Ray (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward));
nPoints = reflactionLimit;
//make the lineRenderer have nPoints
lRenderer.positionCount = reflactionLimit;
//set the first point of the line it its current positions
lRenderer.SetPosition (0, transform.position);
for (int i = 0; i < reflactionLimit; i++) {
//if the ray has not be reflected yet
if (i == 0) {
//check if the ray has hit something
if (Physics.Raycast (ray.origin, ray.direction, out hit, Mathf.Infinity, layer)) {
//the reflection direction is the reflection of the current ray direction flipped at the hit normal
inDirection = Vector3.Reflect (ray.direction, hit.normal);
//cast the reflected ray, using the hit point as the origin and the reflected direction as the direction
ray = new Ray (hit.point, inDirection);
//if the number of reflections is set to 1
if (reflactionLimit == 1) {
//add a new vertex to the line renderer
lRenderer.positionCount = nPoints++;
}
//set the position of the next vertex at the line renderer to be the same as the hit point
lRenderer.SetPosition (i + 1, hit.point);
laserDistance = hit.distance;
} else {
//if the rays does not hit anything, set as a single straight line in the camera direction and disable the smoke
laserDistance = 1000;
transform.rotation = mainCameraTransform.rotation;
if (hitSmoke.activeSelf) {
hitSmoke.SetActive (false);
}
if (hitSparks.activeSelf) {
hitSparks.SetActive (false);
}
lRenderer.positionCount = 2;
lRenderer.SetPosition (0, transform.position);
lRenderer.SetPosition (1, (laserDistance * transform.forward));
}
} else if (i > 0) {
//check if the ray has hit something
if (Physics.Raycast (ray.origin, ray.direction, out hit, Mathf.Infinity, layer)) {
//the refletion direction is the reflection of the ray's direction at the hit normal
inDirection = Vector3.Reflect (inDirection, hit.normal);
//cast the reflected ray, using the hit point as the origin and the reflected direction as the direction
ray = new Ray (hit.point, inDirection);
lRenderer.positionCount = nPoints++;
//set the position of the next vertex at the line renderer to be the same as the hit point
lRenderer.SetPosition (i + 1, hit.point);
if (i + 1 == reflactionLimit) {
//if this linerenderer vertex is the last, set the smoke in its position and check for a refraction cube or a laser receiver
if (!hitSparks.activeSelf) {
hitSparks.SetActive (true);
}
if (!hitSmoke.activeSelf) {
hitSmoke.SetActive (true);
}
hitSmoke.transform.position = hit.point;
hitSmoke.transform.rotation = Quaternion.identity;
hitSparks.transform.rotation = Quaternion.LookRotation (hit.normal, transform.up);
if (hit.collider.GetComponent<laserReceiver> () || hit.collider.GetComponent<refractionCube> ()) {
connectLasers (hit.collider.gameObject);
}
//check if the laser hits an object with a health component different from the player
if (hit.collider.gameObject != player) {
applyDamage.checkHealth (gameObject, hit.collider.gameObject, laserDamage, -transform.forward, hit.point, player,
true, true, ignoreShield, false, damageCanBeBlocked, false, -1, damageTypeID);
}
}
laserDistance = hit.distance;
}
}
}
}
//the player's laser cannot be reflected, so the linerenderer only has 2 vertex
if (lasertype == laserDevice.laserType.simple) {
animateLaser ();
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, Mathf.Infinity, layer)) {
//set the direction of the laser in the hit point direction
transform.LookAt (hit.point);
//check with a raycast if the laser hits a receiver, a refraction cube or a gameObject with a health component or a vehicle damage receiver
//Debug.DrawRay (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward)*hit.distance, Color.yellow);
if (hit.collider.GetComponent<laserReceiver> () || hit.collider.GetComponent<refractionCube> ()) {
connectLasers (hit.collider.gameObject);
}
if (hit.collider.gameObject != player) {
applyDamage.checkHealth (gameObject, hit.collider.gameObject, laserDamage, -transform.forward, hit.point, player,
true, true, ignoreShield, false, damageCanBeBlocked, false, -1, damageTypeID);
}
//get the hit position to set the particles of smoke and sparks
laserDistance = hit.distance;
if (!hitSparks.activeSelf) {
hitSparks.SetActive (true);
}
if (!hitSmoke.activeSelf) {
hitSmoke.SetActive (true);
}
hitSmoke.transform.position = hit.point - transform.forward * 0.02f;
hitSmoke.transform.rotation = Quaternion.identity;
hitSparks.transform.rotation = Quaternion.LookRotation (hit.normal, transform.up);
lRenderer.positionCount = 2;
lRenderer.SetPosition (0, transform.position);
lRenderer.SetPosition (1, hit.point);
//set the laser size
} else {
//set the direction of the laser in the camera forward
Quaternion lookDir = Quaternion.LookRotation (mainCameraTransform.TransformDirection (Vector3.forward));
transform.rotation = lookDir;
if (hitSparks.activeSelf) {
hitSmoke.SetActive (false);
}
if (hitSmoke.activeSelf) {
hitSparks.SetActive (false);
}
laserDistance = 1000;
lRenderer.positionCount = 2;
lRenderer.SetPosition (0, transform.position);
lRenderer.SetPosition (1, (laserDistance * transform.forward));
}
}
}
void connectLasers (GameObject hitObject)
{
//check if the object touched with the laser is a laser receiver, to check if the current color of the laser is equal to the color needed
//in the laser receiver
laserReceiver currentLaserReceiver = hitObject.GetComponent<laserReceiver> ();
refractionCube currentRefractionCube = hitObject.GetComponent<refractionCube> ();
if (currentLaserReceiver != null) {
if (currentLaserReceiver.colorNeeded == mainRenderer.material.GetColor (propertyNameID)) {
currentLaserReceiver.laserConnected (mainRenderer.material.GetColor (propertyNameID));
} else {
//else the laser is not reflected
return;
}
}
//if the object is not a laser receiver or a refraction cube, the laser is not refrated
else if (currentRefractionCube == null) {
return;
} else {
//if the cube is already being used by another laser, cancel the action
if (currentRefractionCube.isRefracting ()) {
return;
}
}
if (gameObject.activeSelf) {
gameObject.SetActive (false);
}
//deflect the laser and enable the laser connector
GameObject baseLaserConnector = currentLaser.GetComponent<laserDevice> ().laserConnector;
if (!baseLaserConnector.activeSelf) {
baseLaserConnector.SetActive (true);
}
baseLaserConnector.transform.position = laserHitPosition;
baseLaserConnector.transform.LookAt (hitObject.transform.position);
laserConnector currentLaserConnector = baseLaserConnector.GetComponent<laserConnector> ();
if (currentRefractionCube != null) {
//if the hitted objects is a cube refraction, enable the laser inside it
if (!currentRefractionCube.isRefracting ()) {
currentLaserConnector.setCubeRefractionLaser (hitObject);
currentRefractionCube.cubeLaserDeviceGameObject.transform.rotation = baseLaserConnector.transform.rotation;
currentRefractionCube.setRefractingLaserState (true);
} else {
if (baseLaserConnector.activeSelf) {
baseLaserConnector.SetActive (false);
}
currentRefractionCube.setRefractingLaserState (false);
return;
}
}
//stop the laser that hits the player from detect any other collision, to deflect it
currentLaser.SendMessage ("assignLaser");
currentLaserConnector.setCurrentLaser (currentLaser);
currentLaserConnector.setColor ();
currentLaser = null;
}
//set the color of the laser according to the color of the laser device
void setColor ()
{
if (currentLaserRenderer.material.HasProperty (propertyNameID)) {
Color c = currentLaserRenderer.material.GetColor (propertyNameID);
mainRenderer.material.SetColor (propertyNameID, c);
}
}
public void setLaserInfo (laserDevice.laserType type, GameObject laser, Vector3 pos)
{
//get the position where the lasers hits the player,
laserHitPosition = pos;
//get the laser that it is hitting the player
currentLaser = laser;
if (currentLaserRenderer == null) {
currentLaserRenderer = currentLaser.GetComponent<Renderer> ();
}
setColor ();
lasertype = type;
if (lasertype == laserDevice.laserType.refraction) {
//lRenderer.useWorldSpace=true;
} else {
lRenderer.positionCount = 2;
lRenderer.SetPosition (0, Vector3.zero);
//lRenderer.useWorldSpace=false;
}
}
public void removeLaserInfo ()
{
currentLaserRenderer = null;
}
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 0ccc7bcacb4d85448a48fc505bcf22ed
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/laserPlayer.cs
uploadId: 814740

View File

@@ -0,0 +1,128 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class laserVisionSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool laserVisionEnabled = true;
public bool sliceWithLaserEnabled = true;
public float sliceObjectsActiveRate = 0.5f;
public LayerMask mainLayermask;
public float laserRaycastDistance;
public float minLaserMovementToActivateSlice;
[Space]
[Header ("Debug")]
[Space]
public bool laserVisionActive;
[Space]
[Header ("Event Settings")]
[Space]
public UnityEvent eventOnLaserVisionEnabled;
public UnityEvent eventOnLaserVisionDisabled;
public Transform cutParentRefence;
[Space]
[Header ("Components")]
[Space]
public sliceSystem mainSliceSystem;
public Transform laserPositionTransform;
public Transform laserDirectionTransform;
public GameObject laserGameObject;
public Vector3 cutOverlapBoxSize;
public Transform cutPositionTransform;
public Transform cutDirectionTransform;
public Transform planeDefiner1;
public Transform planeDefiner2;
public Transform planeDefiner3;
float lastTimeSliceActive;
Vector3 currentLaserPosition;
Vector3 previousLaserPosition;
RaycastHit hit;
void Update ()
{
if (laserVisionActive && sliceWithLaserEnabled) {
if (Time.time > sliceObjectsActiveRate + lastTimeSliceActive) {
if (GKC_Utils.distance (currentLaserPosition, previousLaserPosition) > minLaserMovementToActivateSlice) {
Vector3 laserDirection = currentLaserPosition - previousLaserPosition;
float laserAngle = Vector3.SignedAngle (cutParentRefence.right, laserDirection, cutParentRefence.forward);
cutParentRefence.eulerAngles = cutParentRefence.forward * laserAngle;
cutParentRefence.localEulerAngles = new Vector3 (0, 0, cutParentRefence.localEulerAngles.z);
mainSliceSystem.setCustomCutTransformValues (cutOverlapBoxSize, cutPositionTransform, cutDirectionTransform,
planeDefiner1, planeDefiner2, planeDefiner3);
mainSliceSystem.activateCutExternally ();
lastTimeSliceActive = Time.time;
previousLaserPosition = currentLaserPosition;
}
}
if (Physics.Raycast (laserPositionTransform.position, laserDirectionTransform.forward, out hit, laserRaycastDistance, mainLayermask)) {
currentLaserPosition = hit.point;
cutParentRefence.position = hit.point - cutParentRefence.forward * 1.5f;
if (previousLaserPosition == Vector3.zero) {
previousLaserPosition = hit.point;
}
}
}
}
public void setLaserVisionActiveState (bool state)
{
if (!laserVisionEnabled) {
return;
}
laserVisionActive = state;
laserGameObject.SetActive (state);
lastTimeSliceActive = 0;
previousLaserPosition = Vector3.zero;
if (laserVisionActive) {
eventOnLaserVisionEnabled.Invoke ();
} else {
eventOnLaserVisionDisabled.Invoke ();
}
}
public void toggleLaserVisionActiveState ()
{
setLaserVisionActiveState (!laserVisionActive);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: cf826632d1714334faa3f861382ba2a1
timeCreated: 1609728589
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/laserVisionSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class manualDetonationMineObject : MonoBehaviour
{
public UnityEvent eventToActivateMine;
manualDetonationMineSystem mainManualDetonationMineSystem;
public void activateMine ()
{
eventToActivateMine.Invoke ();
}
public void removeMine ()
{
if (mainManualDetonationMineSystem != null) {
mainManualDetonationMineSystem.removeCurrentMine ();
}
}
public void setManualDetonationMineSystem (manualDetonationMineSystem newManualDetonationMineSystem)
{
mainManualDetonationMineSystem = newManualDetonationMineSystem;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: e2de4a6a7b7659e4d9953414d7ee10cd
timeCreated: 1617360644
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/manualDetonationMineObject.cs
uploadId: 814740

View File

@@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class manualDetonationMineSystem : MonoBehaviour
{
public float minDelayToActivateMine;
public UnityEvent eventToPlaceNewMine;
public GameObject currentMine;
manualDetonationMineObject currentManualDetonationMineObject;
float lastTimeMinePlaced;
public void placeNewMine ()
{
if (currentMine == null) {
eventToPlaceNewMine.Invoke ();
}
}
public void setCurrentMine (GameObject newMineObject)
{
currentMine = newMineObject;
currentManualDetonationMineObject = currentMine.GetComponent<manualDetonationMineObject> ();
currentManualDetonationMineObject.setManualDetonationMineSystem (this);
lastTimeMinePlaced = Time.time;
}
public void activateCurrentMine ()
{
if (currentMine != null) {
if (Time.time > minDelayToActivateMine + lastTimeMinePlaced) {
currentManualDetonationMineObject.activateMine ();
removeCurrentMine ();
}
}
}
public void removeCurrentMine ()
{
currentMine = null;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 71998c6f123759b4c8b1b9e7f0d00de8
timeCreated: 1617360374
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/manualDetonationMineSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerGravitySystem : abilityInfo
{
[Header ("Custom Settings")]
[Space]
public bool gravitySystemEnabled = true;
public gravitySystem mainGravitySystem;
public override void updateAbilityState ()
{
}
public override void enableAbility ()
{
}
public override void disableAbility ()
{
gravitySystemEnabled = false;
}
public override void deactivateAbility ()
{
}
public override void activateSecondaryActionOnAbility ()
{
}
public override void useAbilityPressDown ()
{
checkUseEventOnUseAbility ();
}
public override void useAbilityPressHold ()
{
}
public override void useAbilityPressUp ()
{
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 4b801f036562be64684e602a6cbcd1ad
timeCreated: 1579561928
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/playerGravitySystem.cs
uploadId: 814740

View File

@@ -0,0 +1,291 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerShieldSystem : abilityInfo
{
[Header ("Custom Settings")]
[Space]
public bool shieldEnabled;
public bool shieldActive;
public bool laserActive;
public bool laserAbilityEnabled = true;
public LayerMask layerToDamage;
public bool returnProjectilesDetectedEnabled = true;
public bool destroProjectilesStoredIfShieldDisabled;
[Space]
[Header ("Component Elements")]
[Space]
public GameObject shield;
public armorSurfaceSystem armorSurfaceManager;
public GameObject playerLaserGameObject;
public laserPlayer laserPlayerManager;
public otherPowers mainOtherPowers;
public Transform pivotCameraTransform;
public Transform playerCameraTransform;
public Transform mainCameraTransform;
public Collider playerCollider;
GameObject currentLaser;
Vector3 laserPosition;
laserDevice.laserType lasertype;
RaycastHit hit;
public override void updateAbilityState ()
{
//enable shield when the player touch a laser
if (shield.activeSelf && currentLaser != null) {
Vector3 targetDir = currentLaser.transform.position - shield.transform.position;
Quaternion qTo = Quaternion.LookRotation (targetDir);
shield.transform.rotation = Quaternion.Slerp (shield.transform.rotation, qTo, 10 * Time.deltaTime);
}
//if the shield is enabled, the power decreases
if (shield.activeSelf && shieldActive && !laserActive) {
//also, rotates the shield towards the camera direction
if (pivotCameraTransform.localRotation.x < 0) {
shield.transform.rotation = pivotCameraTransform.rotation;
} else {
shield.transform.rotation = Quaternion.Euler (playerCameraTransform.eulerAngles);
}
bool updateAbilityEnergyResult =
mainPlayerAbilitiesSystem.checkAbilityUseEnergyInUpdate (useEnergyOnAbility, useEnergyWithRate, energyAmountUsed);
if (!updateAbilityEnergyResult) {
deactivateAbility ();
}
}
if (mainOtherPowers.isAimingPower ()) {
//if the player is touching by a laser device, enable the laser in the player
if (laserActive && !playerLaserGameObject.activeSelf) {
playerLaserGameObject.SetActive (true);
}
//else disable the laser
if (!laserActive && playerLaserGameObject.activeSelf) {
playerLaserGameObject.SetActive (false);
}
} else {
if (playerLaserGameObject.activeSelf) {
playerLaserGameObject.SetActive (false);
}
}
}
//enable and disable the shield when the player want to stop attacks or when he touchs a laser
public void setActiveShieldState (bool state)
{
//enable or disable the shield
if (!mainPlayerAbilitiesSystem.isPlayerCurrentlyBusy ()) {
setShieldState (state);
}
}
public void setShieldState (bool state)
{
if (!laserActive && mainPlayerAbilitiesSystem.canMove && shieldEnabled) {
shieldActive = state;
if (shield.activeSelf != shieldActive) {
shield.SetActive (shieldActive);
}
checkIfDestroyProjectiles ();
}
}
//enable disable the laser in the hand of the player, when he is in the range of one
public void activateLaserForceField (Vector3 pos)
{
if (!laserAbilityEnabled) {
return;
}
if (!isCurrentAbility) {
return;
}
//print ("enable laser force field");
shieldActive = false;
laserActive = true;
disableAbilityCurrentActiveFromPressState ();
if (laserActive) {
if (!shield.activeSelf) {
shield.SetActive (true);
}
laserPosition = pos;
}
if (playerLaserGameObject.activeSelf) {
laserPlayerManager.setLaserInfo (lasertype, currentLaser, laserPosition);
}
checkIfDestroyProjectiles ();
}
void checkIfDestroyProjectiles ()
{
if (destroProjectilesStoredIfShieldDisabled) {
armorSurfaceManager.destroyProjetilesOnShield ();
}
}
public void deactivateLaserForceField ()
{
//print ("disable laser force field");
laserActive = false;
if (shield.activeSelf) {
shield.SetActive (false);
}
if (playerLaserGameObject.activeSelf) {
playerLaserGameObject.SetActive (false);
}
laserPlayerManager.removeLaserInfo ();
}
public void setShieldEnabledState (bool state)
{
shieldEnabled = state;
}
//shoot the bullets and missiles catched by the shield
public void returnEnemyProjectiles ()
{
//the bullets and missiles from the enemies are stored in the shield, so if the player press the right button of the mouse
//the shoots are sent to its owners if they still alive, else, the shoots are launched in the camera direction
if (!mainPlayerAbilitiesSystem.isPlayerCurrentlyBusy () && shield.activeSelf && shieldActive && !laserActive) {
if (armorSurfaceManager.thereAreProjectilesStored ()) {
//check if a raycast hits a surface from the center of the screen to forward
//to set the direction of the projectiles in the shield
Vector3 direction = mainCameraTransform.TransformDirection (Vector3.forward);
bool surfaceFound = false;
Vector3 raycastPosition = mainCameraTransform.position;
if (Physics.Raycast (raycastPosition, direction, out hit, Mathf.Infinity, layerToDamage)) {
if (hit.collider != playerCollider) {
surfaceFound = true;
} else {
raycastPosition = hit.point + direction * 0.2f;
if (Physics.Raycast (raycastPosition, direction, out hit, Mathf.Infinity, layerToDamage)) {
surfaceFound = true;
}
}
}
if (surfaceFound) {
direction = hit.point;
}
armorSurfaceManager.throwProjectilesStored (direction);
}
}
}
//get the laser device that touch the player, not enemy lasers, and if the laser reflects in other surfaces or not
public void setLaser (GameObject l, laserDevice.laserType type)
{
currentLaser = l;
lasertype = type;
}
//set the number of refractions in the laser in another function
public void setLaserRefractionLimit (int value)
{
laserPlayerManager.reflactionLimit = value + 1;
}
public void setLaserAbilityEnabledState (bool state)
{
laserAbilityEnabled = state;
}
public override void enableAbility ()
{
shieldEnabled = true;
}
public override void disableAbility ()
{
shieldEnabled = false;
if (shieldActive) {
setShieldState (false);
}
deactivateLaserForceField ();
}
public override void deactivateAbility ()
{
if (shieldActive) {
setShieldState (false);
}
deactivateLaserForceField ();
}
public override void activateSecondaryActionOnAbility ()
{
returnEnemyProjectiles ();
}
public override void useAbilityPressDown ()
{
if (shieldActive) {
if (armorSurfaceManager.thereAreProjectilesStored ()) {
if (returnProjectilesDetectedEnabled) {
returnEnemyProjectiles ();
return;
}
}
}
setActiveShieldState (!shieldActive);
checkUseEventOnUseAbility ();
}
public override void useAbilityPressHold ()
{
}
public override void useAbilityPressUp ()
{
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8ac08eada254e994cbfca977d470c9b9
timeCreated: 1579404488
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/playerShieldSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,105 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class playerStealthSystem : abilityInfo
{
[Header ("Custom Settings")]
[Space]
public bool stealthModeEnabled = true;
public bool stealthModeActive;
public UnityEvent eventToActivateStealthMode;
public UnityEvent eventToDeactivateStealthMode;
public override void updateAbilityState ()
{
}
public void setStealthModeState (bool state)
{
if (!stealthModeEnabled) {
return;
}
stealthModeActive = state;
if (stealthModeActive) {
eventToActivateStealthMode.Invoke ();
} else {
eventToDeactivateStealthMode.Invoke ();
}
}
Coroutine timeLimitCoroutine;
public void stopSetStealthModeTimeLimit ()
{
if (timeLimitCoroutine != null) {
StopCoroutine (timeLimitCoroutine);
}
}
public void setStealthModeTimeLimit ()
{
stopSetStealthModeTimeLimit ();
timeLimitCoroutine = StartCoroutine (setStealthModeTimeLimitCoroutine ());
}
IEnumerator setStealthModeTimeLimitCoroutine ()
{
yield return new WaitForSeconds (timeLimit);
setStealthModeState (false);
}
public override void enableAbility ()
{
stealthModeEnabled = true;
}
public override void disableAbility ()
{
if (stealthModeActive) {
setStealthModeState (false);
}
stealthModeEnabled = false;
}
public override void deactivateAbility ()
{
if (stealthModeActive) {
setStealthModeState (false);
}
}
public override void activateSecondaryActionOnAbility ()
{
}
public override void useAbilityPressDown ()
{
if (!mainPlayerAbilitiesSystem.isPlayerCurrentlyBusy () || stealthModeActive) {
setStealthModeState (!stealthModeActive);
checkUseEventOnUseAbility ();
}
}
public override void useAbilityPressHold ()
{
}
public override void useAbilityPressUp ()
{
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: fd163d4e2fec8f049a38fbd4a7d124bd
timeCreated: 1579402602
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/playerStealthSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,721 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UIElements;
public class playerTeleportSystem : abilityInfo
{
[Header ("Custom Settings")]
[Space]
//Teleport ability variables
public bool teleportingEnabled;
public LayerMask teleportLayerMask;
[Space]
public float maxDistanceToTeleport = 100;
public bool useTeleportIfSurfaceNotFound = true;
public float maxDistanceToTeleportAir = 10;
[Space]
public float holdButtonTimeToActivateTeleport = 0.4f;
public bool stopTeleportIfMoving;
public bool addForceIfTeleportStops;
public float forceIfTeleportStops;
public bool canTeleportOnZeroGravity;
public bool teleportInstantlyToPosition;
public bool useFixedTeleportHookPointsEnabled = true;
[Space]
[Header ("Capsule Cast Settings")]
[Space]
public bool useCapsuleCastToCheckTargetReached = true;
public float capsuleCastRadius = 0.5f;
public float maxCapsuleCastDistance = 1.3f;
[Space]
[Header ("Camera Settings")]
[Space]
public bool useSmoothCameraFollowStateOnTeleport = true;
public float smoothCameraFollowDuration = 3;
[Space]
public bool allowQuickTeleportIfLockonTargetActive;
public LayerMask checkLockonTargetsLayermask;
[Space]
[Header ("Movement/Rotation Settings")]
[Space]
public float teleportSpeed = 10;
public bool rotateTowardTeleportPosition;
public float teleportRotationSpeed = 5;
public float minAngleToRotateTowardTeleportDirection = 15;
[Space]
[Header ("Effect Settings")]
[Space]
public bool useBulletTimeOnTeleport;
public float bulletTimeScaleOnTeleport = 0.5f;
public bool useTeleportMark;
public bool changeCameraFovOnTeleport;
public float cameraFovOnTeleport;
public float cameraFovOnTeleportSpeed;
[Space]
[Header ("Animation Settings")]
[Space]
public bool useActionSystemOnTeleport = true;
public string actionNameUsedOnTeleport = "Teleport Pose";
[Space]
[Header ("Debug")]
[Space]
public bool teleportCanBeExecuted;
public bool searchingForTeleport;
public bool teleportSurfaceFound;
public bool teleportInProcess;
public Transform currentTeleportHookTarget;
public bool teleportActivateByHookTarget;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventsOnStartTeleport;
public UnityEvent eventsOnStartTeleport;
public bool useEventsOnEndTeleport;
public UnityEvent eventsOnEndTeleport;
[Space]
[Header ("Component Elements")]
[Space]
public GameObject teleportMark;
public Transform playerControllerTransform;
public Transform mainCameraTransform;
public gravitySystem mainGravitySystem;
public playerController mainPlayerController;
public timeBullet mainTimeBullet;
public playerCamera mainPlayerCamera;
float lastTimeTeleportButtonPressed;
Coroutine teleportCoroutine;
Vector3 currentTeleportPosition;
Vector3 teleportMarkDirection;
Vector3 currentTeleportPositionNormal;
RaycastHit hit;
public override void updateAbilityState ()
{
if (teleportingEnabled && !mainGravitySystem.isSearchingSurface () && (!mainPlayerController.isPlayerOnZeroGravityMode () || canTeleportOnZeroGravity)) {
if (searchingForTeleport) {
bool activateTeleportResult = false;
if (!teleportCanBeExecuted) {
if (Time.time > lastTimeTeleportButtonPressed + holdButtonTimeToActivateTeleport || teleportInProcess) {
activateTeleportResult = true;
}
if (!teleportInProcess && currentTeleportHookTarget != null) {
activateTeleportResult = true;
teleportActivateByHookTarget = true;
}
}
if (activateTeleportResult) {
teleportCanBeExecuted = true;
if (useTeleportMark) {
teleportMark.SetActive (true);
}
bool canActivateTeleportOnAir = teleportInProcess || !mainPlayerController.isPlayerOnGround ();
if (canActivateTeleportOnAir) {
stopTeleporting ();
}
if (useBulletTimeOnTeleport) {
mainTimeBullet.setBulletTimeState (true, bulletTimeScaleOnTeleport);
}
if (canActivateTeleportOnAir) {
setPlayerControlState (false);
}
}
if (teleportCanBeExecuted && useTeleportMark) {
Vector3 raycastDirection = Vector3.zero;
Vector3 raycastPosition = Vector3.zero;
bool isCameraTypeFree = mainPlayerCamera.isCameraTypeFree ();
if (currentTeleportHookTarget != null) {
raycastPosition = playerControllerTransform.position + playerControllerTransform.up;
raycastDirection = currentTeleportHookTarget.position - raycastPosition;
raycastDirection.Normalize ();
} else {
if (isCameraTypeFree) {
raycastDirection = mainCameraTransform.TransformDirection (Vector3.forward);
raycastPosition = mainCameraTransform.position;
} else {
raycastDirection = playerControllerTransform.forward;
raycastPosition = playerControllerTransform.position + playerControllerTransform.up;
}
}
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, maxDistanceToTeleport, teleportLayerMask)) {
currentTeleportPosition = hit.point + hit.normal * 0.4f;
teleportMark.transform.position = hit.point + hit.normal * 0.1f;
currentTeleportPositionNormal = hit.normal;
teleportSurfaceFound = true;
} else {
teleportSurfaceFound = false;
if (isCameraTypeFree) {
currentTeleportPosition = mainCameraTransform.position + mainCameraTransform.forward * maxDistanceToTeleportAir;
} else {
currentTeleportPosition = playerControllerTransform.position + playerControllerTransform.forward * maxDistanceToTeleportAir;
}
teleportMark.transform.position = currentTeleportPosition;
currentTeleportPositionNormal = Vector3.up;
}
if (useTeleportIfSurfaceNotFound || (!useTeleportIfSurfaceNotFound && teleportSurfaceFound)) {
Quaternion teleportMarkTargetRotation = Quaternion.LookRotation (currentTeleportPositionNormal);
teleportMark.transform.rotation = teleportMarkTargetRotation;
if (!teleportMark.activeSelf) {
teleportMark.SetActive (true);
}
} else {
if (teleportMark.activeSelf) {
teleportMark.SetActive (false);
}
}
}
if (mainPlayerAbilitiesSystem.isPlayerCurrentlyBusy () ||
(stopTeleportIfMoving && mainPlayerController.isPlayerUsingInput () && !teleportActivateByHookTarget)) {
stopTeleportInProcess ();
}
}
if (teleportInProcess && stopTeleportIfMoving && mainPlayerController.isPlayerUsingInput () && !teleportActivateByHookTarget) {
stopTeleporting ();
setTeleportEndState ();
if (addForceIfTeleportStops) {
Vector3 targetPositionDirection = currentTeleportPosition - playerControllerTransform.position;
targetPositionDirection = targetPositionDirection / targetPositionDirection.magnitude;
mainPlayerController.addExternalForce (targetPositionDirection * forceIfTeleportStops);
}
}
}
}
public void stopTeleportInProcess ()
{
if (teleportInProcess || searchingForTeleport) {
teleportCanBeExecuted = false;
if (useBulletTimeOnTeleport) {
mainTimeBullet.disableTimeBulletTotally ();
}
teleportActivateByHookTarget = false;
searchingForTeleport = false;
if (useTeleportMark) {
teleportMark.SetActive (false);
}
stopTeleporting ();
}
}
public void teleportPlayer (Transform objectToMove, Vector3 teleportPosition, bool checkPositionAngle, bool changeFov,
float newFovValue, float fovChangeSpeed, float teleportSpeed, bool rotatePlayerTowardPosition,
bool teleportInstantlyToPositionValue, bool useActionSystemOnTeleportValue,
bool useSmoothCameraFollowStateOnTeleportValue, float smoothCameraFollowDurationValue,
float teleportDistanceOffsetValue, LayerMask layermaskToDetect, bool checkPlayerHeightToTeleportPosition)
{
stopTeleporting ();
teleportCoroutine = StartCoroutine (teleportPlayerCoroutine (objectToMove, teleportPosition, checkPositionAngle,
changeFov, newFovValue, fovChangeSpeed, teleportSpeed, rotatePlayerTowardPosition, teleportInstantlyToPositionValue,
useActionSystemOnTeleportValue, useSmoothCameraFollowStateOnTeleportValue, smoothCameraFollowDurationValue,
teleportDistanceOffsetValue, layermaskToDetect, checkPlayerHeightToTeleportPosition));
}
public void stopTeleporting ()
{
if (teleportCoroutine != null) {
StopCoroutine (teleportCoroutine);
}
setPlayerControlState (true);
}
public void resumeIfTeleportActive ()
{
if (teleportInProcess) {
stopTeleporting ();
setTeleportEndState ();
}
}
bool currentUseActionSystemOnTeleportValue;
public void setTeleportEndState ()
{
if (teleportInProcess) {
teleportInProcess = false;
if (currentUseActionSystemOnTeleportValue && actionNameUsedOnTeleport != "") {
mainPlayerController.stopCustomAction (actionNameUsedOnTeleport);
}
if (changeCameraFovOnTeleport) {
mainPlayerCamera.setOriginalCameraFov ();
}
checkEventOnTeleport (false);
}
}
public void setPlayerControlState (bool state)
{
if (state) {
mainPlayerController.setFallDamageCheckPausedState (true);
}
mainPlayerController.changeScriptState (state);
mainPlayerController.setGravityForcePuase (!state);
mainPlayerController.setRigidbodyVelocityToZero ();
mainPlayerController.setPhysicMaterialAssigmentPausedState (!state);
mainPlayerController.setUsingAbilityActiveState (!state);
mainPlayerController.setCheckOnGroungPausedState (!state);
if (!state) {
mainPlayerController.setZeroFrictionMaterial ();
mainPlayerController.setPlayerOnGroundState (false);
mainPlayerController.setLastTimeFalling ();
mainPlayerController.setFallDamageCheckPausedState (false);
}
}
IEnumerator teleportPlayerCoroutine (Transform objectToMove, Vector3 targetPosition, bool checkPositionAngle,
bool changeFov, float newFovValue, float fovChangeSpeed, float currentTeleportSpeed,
bool rotatePlayerTowardPosition, bool teleportInstantlyToPositionValue, bool useActionSystemOnTeleportValue,
bool useSmoothCameraFollowStateOnTeleportValue, float smoothCameraFollowDurationValue,
float teleportDistanceOffsetValue, LayerMask layermaskToDetect, bool checkPlayerHeightToTeleportPosition)
{
teleportInProcess = true;
checkEventOnTeleport (true);
currentUseActionSystemOnTeleportValue = useActionSystemOnTeleportValue;
if (currentUseActionSystemOnTeleportValue && actionNameUsedOnTeleport != "") {
mainPlayerController.activateCustomAction (actionNameUsedOnTeleport);
}
if (useSmoothCameraFollowStateOnTeleportValue) {
mainPlayerCamera.activateUseSmoothCameraFollowStateDuration (smoothCameraFollowDurationValue);
}
setPlayerControlState (false);
if (changeCameraFovOnTeleport && changeFov) {
mainPlayerCamera.setMainCameraFov (newFovValue, fovChangeSpeed);
}
if (checkPlayerHeightToTeleportPosition) {
Vector3 currentNormal = mainGravitySystem.getCurrentNormal ();
Vector3 raycastDirection = targetPosition - currentNormal * 0.5f;
Vector3 raycastPosition = targetPosition;
float raycastDistance = mainPlayerController.getCharacterHeight () + 0.2f;
//Debug.DrawRay (raycastPosition, raycastDirection * 2, Color.green, 10);
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, layermaskToDetect)) {
targetPosition -= currentNormal * raycastDistance;
// print ("adjusting teleport position to player height");
} else {
raycastDirection = targetPosition + currentNormal * 0.5f;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, layermaskToDetect)) {
targetPosition -= currentNormal * raycastDistance;
// print ("adjusting teleport position to player height");
}
}
}
float dist = GKC_Utils.distance (objectToMove.position, targetPosition);
float duration = dist / currentTeleportSpeed;
float t = 0;
Vector3 targetPositionDirection = targetPosition - objectToMove.position;
targetPositionDirection = targetPositionDirection / targetPositionDirection.magnitude;
if (checkPositionAngle) {
float targetNormalAngle = Vector3.Angle (objectToMove.up, currentTeleportPositionNormal);
if (targetNormalAngle > 150) {
targetPosition += currentTeleportPositionNormal * 2;
}
}
float targetEulerRotation = 0;
bool targetReached = false;
float movementTimer = 0;
float positionDifference = 0;
float positionDifferenceAmount = 0.01f;
if (teleportDistanceOffsetValue > 0) {
positionDifferenceAmount = teleportDistanceOffsetValue;
}
float lastTimeDistanceChecked = 0;
bool isPlayerMovingOn3dWorld = mainPlayerController.isPlayerMovingOn3dWorld ();
if (teleportInstantlyToPositionValue) {
if (positionDifferenceAmount > 0) {
targetPosition -= targetPositionDirection * positionDifferenceAmount;
}
objectToMove.position = targetPosition;
if (rotatePlayerTowardPosition && isPlayerMovingOn3dWorld) {
Vector3 teleportDirection = targetPositionDirection;
teleportDirection = teleportDirection - objectToMove.up * objectToMove.InverseTransformDirection (teleportDirection).y;
targetEulerRotation = Vector3.SignedAngle (objectToMove.forward, teleportDirection, objectToMove.up);
objectToMove.Rotate (0, targetEulerRotation, 0);
}
yield return null;
} else {
while (!targetReached) {
t += Time.deltaTime / duration;
objectToMove.position = Vector3.Lerp (objectToMove.position, targetPosition, t);
if (rotatePlayerTowardPosition && isPlayerMovingOn3dWorld) {
Vector3 teleportDirection = targetPosition - objectToMove.position;
teleportDirection = teleportDirection / teleportDirection.magnitude;
teleportDirection = teleportDirection - objectToMove.up * objectToMove.InverseTransformDirection (teleportDirection).y;
targetEulerRotation = Vector3.SignedAngle (objectToMove.forward, teleportDirection, objectToMove.up);
if (Mathf.Abs (targetEulerRotation) > minAngleToRotateTowardTeleportDirection) {
objectToMove.Rotate (0, (targetEulerRotation / 2) * teleportRotationSpeed * Time.deltaTime, 0);
}
}
positionDifference = GKC_Utils.distance (objectToMove.position, targetPosition);
if (lastTimeDistanceChecked == 0) {
if (positionDifference < 1) {
lastTimeDistanceChecked = Time.time;
}
} else {
if (Time.time > lastTimeDistanceChecked + 0.5f) {
// print ("too much time without moving");
targetReached = true;
}
}
movementTimer += Time.deltaTime;
if (positionDifference < positionDifferenceAmount || movementTimer > (duration + 0.5f)) {
targetReached = true;
}
if (useCapsuleCastToCheckTargetReached) {
if (movementTimer > 0.7f) {
Vector3 currentObjectPosition = objectToMove.position;
Vector3 point1 = currentObjectPosition;
Vector3 point2 = currentObjectPosition + objectToMove.up * 2;
if (Physics.CapsuleCast (point1, point2, capsuleCastRadius, targetPositionDirection, out hit, maxCapsuleCastDistance, teleportLayerMask)) {
// print ("surface detected");
targetReached = true;
}
}
}
yield return null;
}
}
setPlayerControlState (true);
setTeleportEndState ();
}
public void holdTeleport ()
{
if (!mainPlayerAbilitiesSystem.isPlayerCurrentlyBusy () &&
teleportingEnabled &&
(!mainPlayerController.isPlayerUsingInput () || currentTeleportHookTarget != null) &&
!mainGravitySystem.isSearchingSurface () &&
(!mainPlayerController.isPlayerOnZeroGravityMode () || canTeleportOnZeroGravity)) {
searchingForTeleport = true;
lastTimeTeleportButtonPressed = Time.time;
}
}
LayerMask currentLayermask;
public void releaseTeleport ()
{
if (!mainPlayerAbilitiesSystem.isPlayerCurrentlyBusy () && teleportingEnabled) {
currentLayermask = teleportLayerMask;
bool checkPositionAngleValue = true;
if (allowQuickTeleportIfLockonTargetActive) {
if (mainPlayerCamera.isPlayerLookingAtTarget ()) {
Transform currentTargetToLook = mainPlayerCamera.getLastCharacterToLook ();
Vector3 raycastDirection = Vector3.zero;
Vector3 raycastPosition = Vector3.zero;
Vector3 targetPositionDirection = currentTargetToLook.position - mainCameraTransform.position;
targetPositionDirection = targetPositionDirection / targetPositionDirection.magnitude;
raycastDirection = targetPositionDirection;
raycastPosition = mainCameraTransform.position;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, maxDistanceToTeleport, checkLockonTargetsLayermask)) {
bool checkResult = false;
if (hit.collider.transform == currentTargetToLook) {
checkResult = true;
}
if (!checkResult) {
Transform [] children = hit.collider.transform.GetComponentsInChildren<Transform> ();
if (children.Contains (currentTargetToLook)) {
checkResult = true;
}
}
if (checkResult) {
Vector3 currentPosition = playerControllerTransform.position;
Vector3 targetToUsePosition = hit.collider.transform.position;
float distanceToTarget = GKC_Utils.distance (targetToUsePosition, currentPosition);
Vector3 direction = targetToUsePosition - currentPosition;
direction = direction / direction.magnitude;
Vector3 targetPosition = currentPosition + direction * (distanceToTarget - 1);
currentTeleportPosition = targetPosition;
currentTeleportPositionNormal = hit.collider.transform.up;
teleportCanBeExecuted = true;
currentLayermask = checkLockonTargetsLayermask;
checkPositionAngleValue = false;
//Debug.DrawLine (currentPosition, currentTeleportPosition, Color.green, 10);
}
}
}
}
if (teleportCanBeExecuted) {
if (useTeleportIfSurfaceNotFound || (!useTeleportIfSurfaceNotFound && teleportSurfaceFound)) {
teleportPlayer (playerControllerTransform, currentTeleportPosition, checkPositionAngleValue, true, cameraFovOnTeleport,
cameraFovOnTeleportSpeed, teleportSpeed, rotateTowardTeleportPosition, teleportInstantlyToPosition,
useActionSystemOnTeleport, useSmoothCameraFollowStateOnTeleport, smoothCameraFollowDuration, 0,
currentLayermask, false);
mainPlayerController.setCheckOnGroungPausedState (true);
mainPlayerController.setPlayerOnGroundState (false);
} else {
stopTeleporting ();
}
if (useBulletTimeOnTeleport) {
mainTimeBullet.setBulletTimeState (false, 1);
}
}
teleportCanBeExecuted = false;
searchingForTeleport = false;
if (useTeleportMark) {
teleportMark.SetActive (false);
}
}
}
public void setTeleportingEnabledState (bool state)
{
teleportingEnabled = state;
}
public bool isTeleportInProcess ()
{
return teleportInProcess;
}
public bool isSearchingForTeleport ()
{
return searchingForTeleport;
}
public bool getTeleportCanBeExecutedState ()
{
return teleportCanBeExecuted;
}
public override void enableAbility ()
{
}
public override void disableAbility ()
{
stopTeleportInProcess ();
teleportingEnabled = false;
}
public override void deactivateAbility ()
{
stopTeleportInProcess ();
}
public override void activateSecondaryActionOnAbility ()
{
}
public override void useAbilityPressDown ()
{
holdTeleport ();
checkUseEventOnUseAbility ();
}
public override void useAbilityPressHold ()
{
}
public override void useAbilityPressUp ()
{
releaseTeleport ();
disableAbilityCurrentActiveFromPressState ();
}
void checkEventOnTeleport (bool state)
{
if (state) {
if (useEventsOnStartTeleport) {
eventsOnStartTeleport.Invoke ();
}
} else {
if (useEventsOnEndTeleport) {
eventsOnEndTeleport.Invoke ();
}
}
}
public void setTeleportHookTarget (Transform newTarget)
{
if (!useFixedTeleportHookPointsEnabled) {
return;
}
currentTeleportHookTarget = newTarget;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 923b94b7cff81df46a570506ebef8221
timeCreated: 1579543561
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/playerTeleportSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,94 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class removeGravityFromCharacterSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public float removeGravityDuration = 5;
public float extraGravityForce = 5;
public float extraTorqueForce = 8;
public ForceMode torqueForceMode;
public bool pauseExtraForceAfterDelay;
public float pauseExtraForceDelay;
public float pauseExtraForceSpeed = 3;
[Space]
[Header ("Components")]
[Space]
public ragdollActivator mainRagdollActivator;
public Transform characterTransform;
Coroutine removeGravityCoroutine;
public void activateRemoveGravity ()
{
if (removeGravityCoroutine != null) {
StopCoroutine (removeGravityCoroutine);
}
removeGravityCoroutine = StartCoroutine (activateRemoveGravityCoroutine ());
}
IEnumerator activateRemoveGravityCoroutine ()
{
mainRagdollActivator.pushCharacterWithoutForceXAmountOfTime (removeGravityDuration);
mainRagdollActivator.enableOrDisableRagdollGravityState (false);
Vector3 initialForce = characterTransform.up * extraGravityForce;
mainRagdollActivator.setVelocityToRagdollInDirection (initialForce);
Rigidbody hipsRigidbody = mainRagdollActivator.getHipsRigidbody ();
if (hipsRigidbody != null) {
hipsRigidbody.AddRelativeTorque (characterTransform.forward * extraTorqueForce, torqueForceMode);
hipsRigidbody.AddRelativeTorque (characterTransform.right * extraTorqueForce, torqueForceMode);
// hipsRigidbody.AddTorque (hipsRigidbody.transform.up * extraTorqueForce);
}
// yield return new WaitForSeconds (removeGravityDuration);
bool targetReached = false;
float timer = 0;
bool pauseExtraForceActivated = false;
while (!targetReached) {
timer += Time.deltaTime;
if (pauseExtraForceAfterDelay) {
if (pauseExtraForceActivated) {
if (GKC_Utils.distance (initialForce, Vector3.zero) > 0.05f) {
initialForce = Vector3.MoveTowards (initialForce, Vector3.zero, timer * pauseExtraForceSpeed);
mainRagdollActivator.setVelocityToRagdollInDirection (initialForce);
}
} else {
if (timer >= pauseExtraForceDelay) {
pauseExtraForceActivated = true;
}
}
}
if (timer >= removeGravityDuration) {
targetReached = true;
}
yield return null;
}
mainRagdollActivator.enableOrDisableRagdollGravityState (true);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b00ae2400faa91e43942bcb5090eccf4
timeCreated: 1614624739
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/removeGravityFromCharacterSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,331 @@
using UnityEngine;
using System.Collections;
using UnityEngine.Events;
using System.Collections.Generic;
public class simpleLaser : laser
{
[Space]
[Header ("Main Settings")]
[Space]
public bool laserEnabled = true;
public float laserRotationSpeed = 20;
public bool useForwardDirection;
public bool useInfiniteRaycastDistance = true;
public float raycastDistance = 400;
[Space]
[Header ("Objects To Affect Settings")]
[Space]
public LayerMask layer;
public bool useObjectsToIgnoreList;
public List<GameObject> objectsToIgnoreList = new List<GameObject> ();
[Space]
[Header ("Damage Settings")]
[Space]
public bool applyDamageActive;
public float damageAmount;
public bool ignoreShield;
public float applyDamageRate;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
[Space]
[Header ("Events Settings")]
[Space]
public bool sendMessageOnContact;
public UnityEvent contactFunctions = new UnityEvent ();
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEventOnObjectsFound;
public List<string> remoteEventNameList = new List<string> ();
[Space]
[Header ("Debug")]
[Space]
public bool sameObjectFound;
public bool hittingSurface;
public bool laserCanBeUsed;
[Space]
[Header ("Components")]
[Space]
public Vector3 hitPointOffset;
public Transform offsetReference;
public bool useLaserDot;
public bool useLaserDotIconOnScreen;
public GameObject laserDot;
public laserDotOnScreenSystem mainLaserDotOnScreenSystem;
public Transform mainCameraTransform;
RaycastHit hit;
Vector3 hitPointPosition;
GameObject lastObjectDetected;
Quaternion targetRotation;
Vector3 direction;
GameObject objectDetectedByCamera;
GameObject objectDetectedByLaser;
Vector3 hitPointCameraDirection;
bool laserDotActive;
Vector3 currentHitNormal;
Vector3 currentTransformPosition;
Vector3 currentCameraPosition;
Vector3 currentForwardDirection;
bool firstPersonActive;
float lastTimeDamageApplied;
GameObject lastSurfaceDetected;
float infiniteRaycastDistance = Mathf.Infinity;
float currentRaycastDistance;
void Update ()
{
if (laserEnabled) {
animateLaser ();
currentTransformPosition = transform.position;
currentCameraPosition = mainCameraTransform.position;
if (useInfiniteRaycastDistance) {
currentRaycastDistance = infiniteRaycastDistance;
} else {
currentRaycastDistance = raycastDistance;
}
if (laserCanBeUsed) {
if (Physics.Raycast (currentCameraPosition, mainCameraTransform.TransformDirection (Vector3.forward), out hit, currentRaycastDistance, layer)) {
//Debug.DrawLine (mainCameraTransform.position, hit.point, Color.white, 2);
direction = hit.point - currentTransformPosition;
direction = direction / direction.magnitude;
targetRotation = Quaternion.LookRotation (direction);
objectDetectedByCamera = hit.collider.gameObject;
hitPointCameraDirection = direction;
currentHitNormal = hit.normal;
} else {
targetRotation = Quaternion.LookRotation (mainCameraTransform.forward);
objectDetectedByCamera = null;
direction = currentTransformPosition + mainCameraTransform.position * laserDistance;
direction = direction / direction.magnitude;
hitPointCameraDirection = direction;
}
if (sameObjectFound) {
transform.rotation = Quaternion.Slerp (transform.rotation, targetRotation, Time.deltaTime * laserRotationSpeed);
}
} else {
if (sameObjectFound) {
targetRotation = Quaternion.identity;
transform.localRotation = Quaternion.Slerp (transform.localRotation, targetRotation, Time.deltaTime * laserRotationSpeed);
}
objectDetectedByCamera = null;
}
lRenderer.positionCount = 2;
lRenderer.SetPosition (0, currentTransformPosition);
if (useForwardDirection) {
currentForwardDirection = transform.forward;
} else {
currentForwardDirection = hitPointCameraDirection;
}
if (Physics.Raycast (currentTransformPosition, currentForwardDirection, out hit, currentRaycastDistance, layer)) {
hittingSurface = true;
hitPointPosition = hit.point;
if (hitPointOffset != Vector3.zero && offsetReference) {
hitPointPosition += Vector3.Scale (offsetReference.up, hitPointOffset);
}
if (hit.collider.gameObject != lastObjectDetected) {
lastObjectDetected = hit.collider.gameObject;
if (sendMessageOnContact) {
if (contactFunctions.GetPersistentEventCount () > 0) {
contactFunctions.Invoke ();
}
}
}
currentHitNormal = hit.normal;
if (applyDamageActive) {
if (Time.time > applyDamageRate + lastTimeDamageApplied) {
bool canApplyDamage = true;
if (useObjectsToIgnoreList) {
if (objectsToIgnoreList.Contains (hit.transform.gameObject)) {
canApplyDamage = false;
}
}
if (canApplyDamage) {
applyDamage.checkHealth (gameObject, hit.transform.gameObject, damageAmount, -transform.forward, hit.point,
gameObject, true, true, ignoreShield, false, damageCanBeBlocked, false, -1, damageTypeID);
}
lastTimeDamageApplied = Time.time;
}
}
} else {
//the laser does not hit anything, so disable the shield if it was enabled
hittingSurface = false;
}
if (Physics.Raycast (currentTransformPosition, hitPointCameraDirection, out hit, currentRaycastDistance, layer)) {
objectDetectedByLaser = hit.collider.gameObject;
//Debug.DrawLine (transform.position, hit.point, Color.red, 2);
} else {
objectDetectedByLaser = null;
}
if (objectDetectedByCamera == objectDetectedByLaser || (objectDetectedByCamera == null && objectDetectedByLaser == null)) {
sameObjectFound = true;
} else {
sameObjectFound = false;
}
if (lastSurfaceDetected != objectDetectedByLaser) {
lastSurfaceDetected = objectDetectedByLaser;
if (useRemoteEventOnObjectsFound && lastSurfaceDetected != null) {
bool canActivateRemoteEvent = true;
if (useObjectsToIgnoreList) {
if (objectsToIgnoreList.Contains (lastSurfaceDetected)) {
canActivateRemoteEvent = false;
}
}
if (canActivateRemoteEvent) {
remoteEventSystem currentRemoteEventSystem = lastSurfaceDetected.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameList.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameList [i]);
}
}
}
}
}
if (!sameObjectFound) {
hittingSurface = false;
targetRotation = Quaternion.identity;
transform.localRotation = Quaternion.Slerp (transform.localRotation, targetRotation, Time.deltaTime * laserRotationSpeed);
}
if (hittingSurface) {
lRenderer.SetPosition (1, hitPointPosition);
if (useLaserDot) {
if (!laserDotActive) {
if (useLaserDotIconOnScreen) {
mainLaserDotOnScreenSystem.setLasetDotIconActiveState (true);
} else {
laserDot.SetActive (true);
}
laserDotActive = true;
}
laserDot.transform.position = hitPointPosition + currentHitNormal * 0.01f;
laserDot.transform.rotation = Quaternion.LookRotation (currentHitNormal, transform.up);
if (useLaserDotIconOnScreen) {
mainLaserDotOnScreenSystem.updateLaserDotPosition (hitPointPosition);
}
}
} else {
laserDistance = 1000;
if (laserCanBeUsed) {
lRenderer.SetPosition (1, (mainCameraTransform.position + laserDistance * mainCameraTransform.forward));
} else {
lRenderer.SetPosition (1, (currentTransformPosition + laserDistance * transform.forward));
}
if (useLaserDot) {
if (laserDotActive) {
if (useLaserDotIconOnScreen) {
mainLaserDotOnScreenSystem.setLasetDotIconActiveState (false);
} else {
laserDot.SetActive (false);
}
laserDotActive = false;
}
}
}
}
}
public void setLaserEnabledState (bool state)
{
laserEnabled = state;
if (lRenderer != null) {
lRenderer.enabled = state;
}
transform.localRotation = Quaternion.identity;
if (useLaserDot) {
if (!laserEnabled) {
if (useLaserDotIconOnScreen) {
mainLaserDotOnScreenSystem.setLasetDotIconActiveState (false);
} else {
laserDot.SetActive (false);
}
}
}
lastTimeDamageApplied = 0;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 0d9f65378370a0742849b5d63f3867e2
timeCreated: 1609734560
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/simpleLaser.cs
uploadId: 814740

View File

@@ -0,0 +1,59 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class slowDownAllAIOnSceneSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool slowDownEnabled = true;
public string playerFactionName = "Player";
public bool slowDownOnlyEnemies;
public int pauseCharacterPriority = 1;
[Space]
[Header ("Debug")]
[Space]
public bool slowDownActive;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnStart;
public UnityEvent eventOnEnd;
public void toggleSlowDownState ()
{
setSlowDownState (!slowDownActive);
}
public void setSlowDownState (bool state)
{
if (slowDownEnabled) {
if (slowDownActive == state) {
return;
}
slowDownActive = state;
if (slowDownActive) {
eventOnStart.Invoke ();
} else {
eventOnEnd.Invoke ();
}
if (slowDownOnlyEnemies) {
GKC_Utils.pauseOrResumeEnemyAIOnScene (slowDownActive, playerFactionName, pauseCharacterPriority);
} else {
GKC_Utils.pauseOrResumeAIOnScene (slowDownActive, pauseCharacterPriority);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: eef113322986d3748886fd1061a75bc1
timeCreated: 1644989842
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/slowDownAllAIOnSceneSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,263 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class stealObjectFromCharacterSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool stealEnabled = true;
[Range (0, 100)] public float probabilityToStealWeapon = 0;
public bool stealWeaponOnlyIfNotPickupsLocated;
public bool useMaxDistanceToStealWeapon;
public float maxDistanceToGetStealWeapon;
public bool useMaxDistanceToCameraCenter;
public float maxDistanceToCameraCenter;
public float minWaitTimeToActivateSteal = 2;
[Space]
[Header ("Weapon Settings")]
[Space]
public bool stealCurrentWeapon = true;
public bool ignoreDrawOnStealWeapon = true;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
[Space]
[Header ("Event Settings")]
[Space]
public bool useEventOnSteal;
public UnityEvent eventOnStealWeapon;
[Space]
[Header ("Components")]
[Space]
public AIAroundManager mainAIAroundManager;
public playerController mainPlayerController;
public inventoryManager mainInventoryManager;
public playerCamera mainPlayerCamera;
public Camera mainCamera;
Vector3 centerScreen;
float lastTimeObjectStolen;
public void activateStealFromCharacter ()
{
if (!stealEnabled) {
return;
}
if (lastTimeObjectStolen > 0) {
if (Time.time < minWaitTimeToActivateSteal + lastTimeObjectStolen) {
return;
}
}
if (stealCurrentWeapon) {
if (checkIfStealWeaponFromCurrentTarget ()) {
lastTimeObjectStolen = Time.time;
}
}
}
bool checkIfStealWeaponFromCurrentTarget ()
{
if (showDebugPrint) {
print ("Checking probability to steal weapon");
}
float currentProbability = Random.Range (0, 100);
if (currentProbability < probabilityToStealWeapon) {
if (showDebugPrint) {
print ("AI can check if steal object, checking target state");
}
Transform currentTarget = null;
if (mainPlayerController.isPlayerLookingAtTarget ()) {
currentTarget = mainPlayerController.getCurrentTargetToLook ();
}
Vector3 currentPlayerPosition = mainPlayerController.transform.position;
if (currentTarget == null) {
List<Transform> charactersAround = mainAIAroundManager.getCharactersAround ();
float currentDistance = 0;
float maxDistanceToTarget = 10000;
Vector3 characterPosition = Vector3.zero;
Vector3 screenPoint = Vector3.zero;
centerScreen = mainPlayerCamera.getScreenCenter ();
float currentDistanceToScreenCenter = 0;
for (int i = charactersAround.Count - 1; i >= 0; i--) {
if (charactersAround [i] != null) {
if (!applyDamage.checkIfDead (charactersAround [i].gameObject)) {
characterPosition = charactersAround [i].position;
screenPoint = mainCamera.WorldToScreenPoint (characterPosition);
currentDistanceToScreenCenter = GKC_Utils.distance (screenPoint, centerScreen);
bool canBeChecked = false;
if (useMaxDistanceToCameraCenter && mainPlayerCamera.isCameraTypeFree ()) {
if (currentDistanceToScreenCenter < maxDistanceToCameraCenter) {
canBeChecked = true;
}
} else {
canBeChecked = true;
}
if (canBeChecked) {
currentDistance = GKC_Utils.distance (characterPosition, currentPlayerPosition);
if (currentDistance < maxDistanceToTarget) {
maxDistanceToTarget = currentDistance;
currentTarget = charactersAround [i];
}
}
} else {
charactersAround.RemoveAt (i);
}
} else {
charactersAround.RemoveAt (i);
}
}
}
if (currentTarget != null) {
if (useMaxDistanceToStealWeapon) {
float distance = GKC_Utils.distance (currentTarget.transform.position, currentPlayerPosition);
if (distance > maxDistanceToGetStealWeapon) {
return false;
}
}
playerComponentsManager currentPlayerComponentsManager = currentTarget.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
playerController currentPlayerController = currentPlayerComponentsManager.getPlayerController ();
if (currentPlayerController.isPlayerUsingMeleeWeapons () || currentPlayerController.isPlayerUsingWeapons ()) {
if (showDebugPrint) {
print ("target is using weapons, checking weapon it self");
}
if (currentPlayerController.isPlayerUsingMeleeWeapons ()) {
grabbedObjectMeleeAttackSystem currentGrabbedObjectMeleeAttackSystem = currentPlayerComponentsManager.getGrabbedObjectMeleeAttackSystem ();
if (currentGrabbedObjectMeleeAttackSystem.canWeaponsBeStolenFromCharacter ()) {
string currentWeaponName = currentGrabbedObjectMeleeAttackSystem.getCurrentMeleeWeaponName ();
if (currentPlayerController.isCharacterUsedByAI ()) {
currentGrabbedObjectMeleeAttackSystem.dropMeleeWeaponsExternallyWithoutResultAndDestroyIt ();
} else {
inventoryManager currentInventoryManager = currentPlayerComponentsManager.getInventoryManager ();
if (currentInventoryManager != null) {
currentInventoryManager.removeObjectAmountFromInventoryByName (currentWeaponName, 1);
}
}
if (ignoreDrawOnStealWeapon) {
mainInventoryManager.mainMeleeWeaponsGrabbedManager.setCheckDrawKeepWeaponAnimationPauseState (true);
}
mainInventoryManager.addObjectAmountToInventoryByName (currentWeaponName, 1);
currentGrabbedObjectMeleeAttackSystem.mainMeleeWeaponsGrabbedManager.checkEventOnWeaponStolen ();
if (showDebugPrint) {
print ("weapon stolen from target");
}
if (useEventOnSteal) {
eventOnStealWeapon.Invoke ();
}
return true;
}
} else {
if (showDebugPrint) {
print ("target is not using weapons");
}
}
} else {
if (currentPlayerController.isPlayerUsingWeapons ()) {
playerWeaponsManager currentPlayerWeaponsManager = currentPlayerComponentsManager.getPlayerWeaponsManager ();
if (currentPlayerWeaponsManager.canWeaponsBeStolenFromCharacter ()) {
string currentWeaponName = currentPlayerWeaponsManager.getCurrentWeaponName ();
if (showDebugPrint) {
print (currentWeaponName + " is the weapon detected, checking if can be picked");
}
if (mainInventoryManager.weaponsManager.checkIfWeaponCanBePicked (currentWeaponName)) {
if (currentPlayerController.isCharacterUsedByAI ()) {
currentPlayerWeaponsManager.dropCurrentWeaponExternallyWithoutResultAndDestroyIt ();
} else {
inventoryManager currentInventoryManager = currentPlayerComponentsManager.getInventoryManager ();
if (currentInventoryManager != null) {
currentInventoryManager.removeObjectAmountFromInventoryByName (currentWeaponName, 1);
}
}
mainInventoryManager.addObjectAmountToInventoryByName (currentWeaponName, 1);
currentPlayerWeaponsManager.checkEventOnWeaponStolen ();
if (showDebugPrint) {
print ("weapon stolen from target");
}
if (useEventOnSteal) {
eventOnStealWeapon.Invoke ();
}
return true;
} else {
if (showDebugPrint) {
print ("can't use weapon from target");
}
}
}
}
}
}
}
}
return false;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 29cb0d7a76ace464f86724879b7c4426
timeCreated: 1668393686
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/stealObjectFromCharacterSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class templateAbilitySystem : abilityInfo
{
public override void updateAbilityState ()
{
}
public override void enableAbility ()
{
}
public override void disableAbility ()
{
}
public override void deactivateAbility ()
{
}
public override void activateSecondaryActionOnAbility ()
{
}
public override void useAbilityPressDown ()
{
//base.useAbilityPressDown ();
checkUseEventOnUseAbility ();
}
public override void useAbilityPressHold ()
{
}
public override void useAbilityPressUp ()
{
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 92218992d5077054cb01d5fbdd621394
timeCreated: 1579561993
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/Custom Abilities/templateAbilitySystem.cs
uploadId: 814740

View File

@@ -0,0 +1,513 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class abilityInfo : MonoBehaviour
{
[Header ("Ability Settings")]
[Space]
public string Name;
public bool abilityEnabled;
[Space]
public Texture abilityTexture;
public Sprite abilitySprite;
[Space]
public bool addAbilityToUIWheelActive = true;
public bool updateAbilityActive;
public bool deactivateAbilityWhenChangeToAnother;
public bool disableAbilityInputInUseStateOnPressDown;
public bool canBeUsedOnlyOnGround;
[Space]
public bool showAbilityDescription;
[TextArea (3, 10)] public string abilityDescription;
[Space]
[Header ("Ability UI Settings")]
[Space]
public bool abilityVisibleOnWheelSelection = true;
public bool abilityCanBeShownOnWheelSelection = true;
[Space]
[Header ("Ability Limit/Duration Settings")]
[Space]
public bool useTimeLimit;
public float timeLimit;
public bool useLimitWhenAbilityCurrentActiveFromPress;
public bool callInputToDeactivateAbilityOnTimeLimit;
[Space]
public UnityEvent eventOnTimeLimitBefore;
public UnityEvent eventOnTimeLimitAfter;
[Space]
public bool useTimeLimitOnPressDown;
public bool useTimeLimitOnPressUp;
public bool avoidAbilityInputWhileLimitActive;
public bool resetAbilityCurrentlyActiveFromPressStateOnTimeLimit;
public bool avoidToUseOtherAbilitiesWhileLimitActive;
[Space]
[Header ("Ability Cool Down Settings")]
[Space]
public bool useCoolDown;
public float coolDownDuration;
public bool useCoolDownWhenAbilityCurrentlyActiveFromPress;
public UnityEvent eventOnCoolDownActivate;
public bool useCoolDownOnPressDown;
public bool useCoolDownOnPressUp;
public bool activateCoolDownAfterTimeLimit;
[HideInInspector] public float lastTimeActive;
public float coolDownMultiplier = 1;
[Space]
[Header ("Ability Input Settings")]
[Space]
public bool useInputOnPressDown;
public bool useInputOnPressHold;
public bool useInputOnPressUp;
public bool checkIfInputPressDownBeforeActivateUp;
public bool canUsePressDownInputIfPlayerBusy;
public bool canStopAbilityIfActionActive;
[Space]
public bool ignoreSetAbilityCurrentlyActiveFromPressDown;
[Space]
[Header ("Ability Energy Settings")]
[Space]
public bool useEnergyOnAbility;
public bool useEnergyWithRate;
public float energyAmountUsed;
public bool useEnergyOnPressDown;
public bool useEnergyOnPressHold;
public bool useEnergyOnPressUp;
public bool useEnergyOnceOnPressDown;
public bool useEnergyOnceOnPressUp;
[Space]
[Header ("Ability Components")]
[Space]
public playerAbilitiesSystem mainPlayerAbilitiesSystem;
[Space]
[Header ("Event Settings")]
[Space]
public bool useEventsOnSetCurrentAbility;
public UnityEvent eventOnSetCurrentAbility;
[Space]
public bool useEventOnUseAbility;
public UnityEvent eventOnUseAbility;
[Space]
public UnityEvent eventToDeactivateAbility;
[Space]
public bool useConditionCheckToActivateAbilityOnPressDown;
public UnityEvent eventToCallToCheckConditionOnPressDown;
[Space]
public bool useConditionCheckToActivateAbilityOnPressUp;
public UnityEvent eventToCallToCheckConditionOnPressUp;
[Space]
[Header ("Debug")]
[Space]
public bool abilityCurrentlyActiveFromPressDown;
public bool abilityCurrentlyActiveFromPressUp;
public bool isCurrentAbility;
public bool coolDownInProcess;
public bool timeLimitInProcess;
public float currentCoolDownDuration;
public bool updateAbilityInProcess;
Coroutine updateAbilityCoroutine;
Coroutine coolDownCoroutine;
Coroutine timeLimitCoroutine;
public void disableAbilityCurrentActiveFromPressState ()
{
abilityCurrentlyActiveFromPressDown = false;
abilityCurrentlyActiveFromPressUp = false;
}
public void enableOrDisableAbilityExternally (bool state)
{
if (state) {
enableAbilityExternally ();
} else {
disableAbilityExternally ();
}
}
public void setAbilityEnabledState (bool state)
{
abilityEnabled = state;
}
public bool isAbilityEnabled ()
{
return abilityEnabled;
}
public void enableAbilityExternally ()
{
setAbilityEnabledState (true);
enableAbility ();
}
public void disableAbilityExternally ()
{
setAbilityEnabledState (false);
disableAbility ();
isCurrentAbility = false;
stopActivateUpdateAbility ();
disableAbilityCurrentActiveFromPressState ();
}
public void setAbilityVisibleOnWheelSelectionState (bool state)
{
abilityVisibleOnWheelSelection = state;
}
public void setAbilityCanBeShownOnWheelSelectionState (bool state)
{
abilityCanBeShownOnWheelSelection = state;
}
public virtual void updateAbilityState ()
{
}
public virtual void enableAbility ()
{
}
public virtual void disableAbility ()
{
}
public virtual void deactivateAbility ()
{
}
public virtual void activateSecondaryActionOnAbility ()
{
}
public void checkEventOnSetCurrentAbility ()
{
if (useEventsOnSetCurrentAbility) {
eventOnSetCurrentAbility.Invoke ();
}
}
public void checkUseEventOnUseAbility ()
{
if (useEventOnUseAbility) {
eventOnUseAbility.Invoke ();
}
}
public void checkEventToDeactivateAbility ()
{
eventToDeactivateAbility.Invoke ();
}
public virtual void useAbilityPressDown ()
{
}
public virtual void useAbilityPressHold ()
{
}
public virtual void useAbilityPressUp ()
{
}
public void activateCoolDown ()
{
if (!useCoolDown) {
return;
}
stopActivateCoolDown ();
stopActivateTimeLimit ();
coolDownCoroutine = StartCoroutine (activateCoolDownCoroutine ());
}
public void stopActivateCoolDown ()
{
if (coolDownCoroutine != null) {
StopCoroutine (coolDownCoroutine);
}
}
IEnumerator activateCoolDownCoroutine ()
{
eventOnCoolDownActivate.Invoke ();
coolDownInProcess = true;
// WaitForSeconds delay = new WaitForSeconds (coolDownDuration);
//
// yield return delay;
bool coolDownFinished = false;
currentCoolDownDuration = coolDownDuration;
while (!coolDownFinished) {
currentCoolDownDuration -= Time.deltaTime * coolDownMultiplier;
if (currentCoolDownDuration <= 0) {
coolDownFinished = true;
}
yield return null;
}
coolDownInProcess = false;
}
public void activateTimeLimit ()
{
if (!useTimeLimit) {
return;
}
stopActivateTimeLimit ();
timeLimitCoroutine = StartCoroutine (activateTimeLimitCoroutine ());
}
public void stopActivateTimeLimit ()
{
if (timeLimitCoroutine != null) {
StopCoroutine (timeLimitCoroutine);
}
timeLimitInProcess = false;
}
IEnumerator activateTimeLimitCoroutine ()
{
eventOnTimeLimitBefore.Invoke ();
timeLimitInProcess = true;
WaitForSeconds delay = new WaitForSeconds (timeLimit);
yield return delay;
timeLimitInProcess = false;
eventOnTimeLimitAfter.Invoke ();
if (callInputToDeactivateAbilityOnTimeLimit) {
if (abilityCurrentlyActiveFromPressDown) {
abilityCurrentlyActiveFromPressDown = false;
useAbilityPressDown ();
}
if (abilityCurrentlyActiveFromPressUp) {
abilityCurrentlyActiveFromPressUp = false;
useAbilityPressUp ();
}
}
if (resetAbilityCurrentlyActiveFromPressStateOnTimeLimit) {
disableAbilityCurrentActiveFromPressState ();
}
if (activateCoolDownAfterTimeLimit) {
activateCoolDown ();
}
}
public void activateUpdateAbility ()
{
if (!updateAbilityActive) {
return;
}
stopActivateUpdateAbility ();
updateAbilityCoroutine = StartCoroutine (activateUpdateAbilityCoroutine ());
updateAbilityInProcess = true;
}
public void stopActivateUpdateAbility ()
{
if (updateAbilityCoroutine != null) {
StopCoroutine (updateAbilityCoroutine);
}
updateAbilityInProcess = false;
}
IEnumerator activateUpdateAbilityCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
yield return waitTime;
updateAbilityState ();
}
}
public void setCoolDownDurationValue (float newValue)
{
coolDownDuration = newValue;
}
public float getCoolDownDurationValue ()
{
return coolDownDuration;
}
public void setTimeLimitValue (float newValue)
{
timeLimit = newValue;
}
public float getTimeLimitValue ()
{
return timeLimit;
}
public void setUseCoolDownValue (bool state)
{
useCoolDown = state;
}
public void setUseTimeLimitValue (bool state)
{
useTimeLimit = state;
}
public void setUseEnergyOnAbilityValue (bool state)
{
useEnergyOnAbility = state;
}
public void setEnergyAmountUsedValue (float newValue)
{
energyAmountUsed = newValue;
}
public void setUseInputOnPressDownState (bool state)
{
useInputOnPressDown = state;
}
public void setUseInputOnPressHoldState (bool state)
{
useInputOnPressHold = state;
}
public void setUseInputOnPressUpState (bool state)
{
useInputOnPressUp = state;
}
public bool isCoolDownInProcess ()
{
return coolDownInProcess;
}
public bool isTimeLimitInProcess ()
{
return timeLimitInProcess;
}
//EDITOR FUNCTIONS
public void enableOrDisableAbilityFromEditor (bool state)
{
setAbilityEnabledState (state);
updateComponent ();
}
public void enableOrDisableAllAbilitiesCanBeShownOnWheelFromEditor (bool state)
{
abilityCanBeShownOnWheelSelection = state;
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Abilities Enabled State " + Name, gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: fa3c73b766d26754db82856c3b3373d3
timeCreated: 1579405925
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/abilityInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class abilitySlotElement : MonoBehaviour
{
public playerAbilitiesUISystem.abilitySlotInfo slotInfo;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d7362d7c561d68447807b5ec18888494
timeCreated: 1579416138
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/abilitySlotElement.cs
uploadId: 814740

View File

@@ -0,0 +1,807 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class dashSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool dashEnabled = true;
public float maxTimeBetweenInputPress;
public bool useDashCoolDown;
public float dashCoolDownTime;
public bool canUseDashWhileActionActive;
public List<string> actionCategoryToUseDash = new List<string> ();
[Space]
[Header ("Dash In First Person Settings")]
[Space]
public bool useDashOnFirstPerson = true;
public float dashDuration;
public float dashSpeed;
public string dashCameraState;
public float timeToDisableDashCamera;
public bool onlyDashOnGround;
public bool useDoubleTapToDashOnFirstPersonEnabled;
[Space]
[Header ("Dash In Third Person Settings")]
[Space]
public bool useDashOnThirdPerson;
[Space]
[Header ("Dash Info List Settings")]
[Space]
public int currentDashID;
[Space]
[Space]
public List<dashInfo> dashInfoList = new List<dashInfo> ();
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool dashActive;
public bool dashCanBeUsedCurrently;
public bool dashOnThirdPersonInTransition;
public bool checkGroundPaused;
public bool overrideStrafeModeActiveState;
[Space]
[Header ("Components")]
[Space]
public playerController mainPlayerController;
public playerInputManager playerInput;
public playerCamera mainPlayerCamera;
public staminaSystem mainStaminaSystem;
Vector2 dashMovementDirection;
float lastTimeRightInput;
float lastTimeLeftInput;
float lastTimeUpInput;
float lastTimeDownInput;
bool rightInputPressed;
bool leftInputPressed;
bool upInputPressed;
bool downInputPressed;
Vector2 rawAxisValues;
float lastTimeDashActive;
float originalNoAnimatorSpeedValue;
string originalCameraStateName;
bool dashCameraActive;
bool dashActivatedOnFirstPerson;
thirdPersonStrafeDashDirection thirdPersonStrafeDashDirectionResult;
enum thirdPersonStrafeDashDirection
{
forward,
backward,
right,
left,
forwardRight,
forwardLeft,
backwardRight,
backwardLeft
}
bool dashOnThirdPersonPaused;
bool initialized;
bool customDashDirectionActive;
Vector3 customDashDirection;
dashInfo currentDashInfo;
void Update ()
{
if (dashEnabled) {
if (!initialized) {
setCurrentDashID (currentDashID);
initialized = true;
}
dashCanBeUsedCurrently = canUseDash ();
if (dashCanBeUsedCurrently) {
rawAxisValues = mainPlayerController.getRawAxisValues ();
if (canUseDashWhileActionActive && mainPlayerController.isActionActive ()) {
rawAxisValues = playerInput.getPlayerRawMovementAxis ();
}
if (rawAxisValues.x > 0) {
if (!rightInputPressed) {
rightInputPressed = true;
}
if (lastTimeRightInput > 0) {
if (Time.time < lastTimeRightInput + maxTimeBetweenInputPress) {
checkDoubleTapDash ();
}
lastTimeRightInput = 0;
}
} else if (rawAxisValues.x == 0) {
if (rightInputPressed) {
rightInputPressed = false;
lastTimeRightInput = Time.time;
}
}
if (rawAxisValues.x < 0) {
if (!leftInputPressed) {
leftInputPressed = true;
}
if (lastTimeLeftInput > 0) {
if (Time.time < lastTimeLeftInput + maxTimeBetweenInputPress) {
checkDoubleTapDash ();
}
lastTimeLeftInput = 0;
}
} else if (rawAxisValues.x == 0) {
if (leftInputPressed) {
leftInputPressed = false;
lastTimeLeftInput = Time.time;
}
}
if (rawAxisValues.y > 0) {
if (!upInputPressed) {
upInputPressed = true;
}
if (lastTimeUpInput > 0) {
if (Time.time < lastTimeUpInput + maxTimeBetweenInputPress) {
checkDoubleTapDash ();
}
lastTimeUpInput = 0;
}
} else if (rawAxisValues.y == 0) {
if (upInputPressed) {
upInputPressed = false;
lastTimeUpInput = Time.time;
}
}
if (rawAxisValues.y < 0) {
if (!downInputPressed) {
downInputPressed = true;
}
if (lastTimeDownInput > 0) {
if (Time.time < lastTimeDownInput + maxTimeBetweenInputPress) {
checkDoubleTapDash ();
}
lastTimeDownInput = 0;
}
} else if (rawAxisValues.y == 0) {
if (downInputPressed) {
downInputPressed = false;
lastTimeDownInput = Time.time;
}
}
}
if (dashActive) {
if (dashActivatedOnFirstPerson) {
if (Time.time > lastTimeDashActive + dashDuration) {
disableDashState ();
} else {
playerInput.overrideInputValues (dashMovementDirection, true);
mainPlayerController.inputStartToRun ();
if (dashCameraActive && Time.time > lastTimeDashActive + timeToDisableDashCamera) {
mainPlayerCamera.setCameraStateExternally (originalCameraStateName);
dashCameraActive = false;
}
}
} else {
if (useDashOnThirdPerson) {
if (Time.time > lastTimeDashActive + currentDashInfo.dashDurationOnThirdPerson) {
disableDashState ();
}
}
}
}
}
}
public void checkDoubleTapDash ()
{
if (!canUseDash ()) {
return;
}
bool isFirstPersonActive = mainPlayerController.isPlayerOnFirstPerson ();
if (isFirstPersonActive) {
if (useDoubleTapToDashOnFirstPersonEnabled) {
enableDashState ();
}
} else {
if (currentDashInfo.useDoubleTapToDashOnThirdPersonEnabled) {
enableDashState ();
}
}
}
public void enableDashState ()
{
if (dashActive) {
return;
}
dashActivatedOnFirstPerson = mainPlayerController.isPlayerOnFirstPerson ();
dashActive = true;
lastTimeDashActive = Time.time;
dashMovementDirection = mainPlayerController.getRawAxisValues ();
if (canUseDashWhileActionActive && mainPlayerController.isActionActive ()) {
dashMovementDirection = playerInput.getPlayerRawMovementAxis ();
}
if (dashMovementDirection == Vector2.zero) {
dashMovementDirection = new Vector2 (0, 1);
}
originalNoAnimatorSpeedValue = mainPlayerController.noAnimatorSpeed;
if (dashActivatedOnFirstPerson) {
mainPlayerController.setNoAnimatorSpeedValue (dashSpeed);
originalCameraStateName = mainPlayerCamera.getCurrentStateName ();
mainPlayerCamera.setCameraStateExternally (dashCameraState);
} else {
if (useDashOnThirdPerson) {
bool dashCanBeMadeResult = (!mainPlayerController.isActionActive () || canUseDashWhileActionActive);
if (currentDashInfo.useStamina) {
float remainStamina = mainStaminaSystem.getCurrentStaminaAmount ();
if (remainStamina < currentDashInfo.amountOfStaminaToUse) {
dashCanBeMadeResult = false;
}
}
if (showDebugPrint) {
print ("dash result " + dashCanBeMadeResult);
}
if (!dashCanBeMadeResult) {
dashActive = false;
lastTimeDashActive = 0;
return;
}
bool strafeModeActive = false;
if (currentDashInfo.dashOnThirdPersonPaused) {
return;
}
if (currentDashInfo.checkDashInStrafeState) {
if (mainPlayerController.isStrafeModeActive ()) {
strafeModeActive = true;
} else {
if (mainPlayerController.iscloseCombatAttackInProcess () ||
mainPlayerController.isMeleeAttackInProcess ()) {
strafeModeActive = true;
}
}
}
if (overrideStrafeModeActiveState) {
strafeModeActive = true;
}
if (strafeModeActive) {
Vector2 axisValues = mainPlayerController.getRawAxisValues ();
if (canUseDashWhileActionActive && mainPlayerController.isActionActive ()) {
axisValues = playerInput.getPlayerRawMovementAxis ();
}
if (customDashDirectionActive) {
axisValues = customDashDirection;
customDashDirectionActive = false;
rawAxisValues = axisValues;
}
float angle = Vector2.SignedAngle (axisValues, Vector2.up);
if (!mainPlayerCamera.isCameraTypeFree ()) {
Transform currentLockedCameraAxis = mainPlayerCamera.getCurrentLockedCameraAxis ();
Vector3 direction = axisValues.y * currentLockedCameraAxis.forward + axisValues.x * currentLockedCameraAxis.right;
angle = Vector3.SignedAngle (direction, mainPlayerController.transform.forward, mainPlayerCamera.transform.up);
if (currentLockedCameraAxis.eulerAngles.y > 0 || currentLockedCameraAxis.eulerAngles.y == 0) {
angle = -angle;
} else {
angle = Mathf.Abs (angle);
}
}
float ABSAngle = Mathf.Abs (angle);
bool checkDiagonals = false;
if (currentDashInfo.checkDiagonalInputInStrafeState) {
checkDiagonals = true;
}
if (checkDiagonals) {
if (angle > 0) {
if (ABSAngle < 35) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.forward;
} else if (angle > 35 && angle < 80) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.forwardRight;
} else if (angle > 80 && angle < 125) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.right;
} else if (angle > 125 && angle < 170) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.backwardRight;
} else {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.backward;
}
} else {
if (ABSAngle < 35) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.forward;
} else if (ABSAngle > 35 && ABSAngle < 80) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.forwardLeft;
} else if (ABSAngle > 80 && ABSAngle < 125) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.left;
} else if (ABSAngle > 125 && ABSAngle < 170) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.backwardLeft;
} else {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.backward;
}
}
} else {
if (angle > 0) {
if (ABSAngle < 80) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.forward;
} else if (angle > 80 && angle < 170) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.right;
} else {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.backward;
}
} else {
if (ABSAngle < 80) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.forward;
} else if (ABSAngle > 80 && ABSAngle < 170) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.left;
} else {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.backward;
}
}
}
if (rawAxisValues == Vector2.zero) {
thirdPersonStrafeDashDirectionResult = thirdPersonStrafeDashDirection.forward;
}
if (showDebugPrint) {
print (angle + " " + thirdPersonStrafeDashDirectionResult);
}
switch (thirdPersonStrafeDashDirectionResult) {
case thirdPersonStrafeDashDirection.forward:
currentDashInfo.eventOnDashOnThirdPersonForward.Invoke ();
if (showDebugPrint) {
print ("movement forward");
}
break;
case thirdPersonStrafeDashDirection.backward:
currentDashInfo.eventOnDashOnThirdPersonBackward.Invoke ();
if (showDebugPrint) {
print ("movement backward");
}
break;
case thirdPersonStrafeDashDirection.right:
currentDashInfo.eventOnDashOnThirdPersonRight.Invoke ();
if (showDebugPrint) {
print ("movement right");
}
break;
case thirdPersonStrafeDashDirection.left:
currentDashInfo.eventOnDashOnThirdPersonLeft.Invoke ();
if (showDebugPrint) {
print ("movement left");
}
break;
case thirdPersonStrafeDashDirection.forwardRight:
currentDashInfo.eventOnDashOnThirdPersonForwardRight.Invoke ();
if (showDebugPrint) {
print ("movement forwardRight");
}
break;
case thirdPersonStrafeDashDirection.forwardLeft:
currentDashInfo.eventOnDashOnThirdPersonForwardLeft.Invoke ();
if (showDebugPrint) {
print ("movement forwardLeft");
}
break;
case thirdPersonStrafeDashDirection.backwardRight:
currentDashInfo.eventOnDashOnThirdPersonBackwardRight.Invoke ();
if (showDebugPrint) {
print ("movement backwardRight");
}
break;
case thirdPersonStrafeDashDirection.backwardLeft:
currentDashInfo.eventOnDashOnThirdPersonBackwardLeft.Invoke ();
if (showDebugPrint) {
print ("movement backwardLeft");
}
break;
}
} else {
currentDashInfo.eventOnDashOnThirdPerson.Invoke ();
}
if (currentDashInfo.useGeneralEventOnDashOnThirdPerson) {
currentDashInfo.generalEventOnDashOnThirdPerson.Invoke ();
}
if (currentDashInfo.useStamina) {
mainStaminaSystem.setCustomRefillStaminaDelayAfterUseValue (currentDashInfo.refillStaminaWaitTime);
mainStaminaSystem.useStaminaAmountExternally (currentDashInfo.amountOfStaminaToUse);
}
}
}
dashCameraActive = true;
if (dashActivatedOnFirstPerson) {
mainPlayerCamera.setCameraPositionMouseWheelEnabledState (false);
mainPlayerCamera.enableOrDisableChangeCameraView (false);
}
}
public void setOverrideStrafeModeActiveStateResult (bool state)
{
overrideStrafeModeActiveState = state;
}
public void disableDashState ()
{
dashActive = false;
if (dashActivatedOnFirstPerson) {
playerInput.overrideInputValues (Vector2.zero, false);
mainPlayerController.inputStopToRun ();
mainPlayerController.setNoAnimatorSpeedValue (originalNoAnimatorSpeedValue);
mainPlayerCamera.setCameraPositionMouseWheelEnabledState (true);
mainPlayerCamera.setOriginalchangeCameraViewEnabledValue ();
}
}
public void setDashEnabledState (bool state)
{
dashEnabled = state;
}
public void inputActivateDashState ()
{
if (enabled && dashEnabled && canUseDash ()) {
enableDashState ();
}
}
public void activateDashStateWithoutGroundCheck ()
{
checkGroundPaused = true;
inputActivateDashState ();
checkGroundPaused = false;
}
public void setCheckGroundPausedState (bool state)
{
checkGroundPaused = state;
}
public void activateDashStateWithCustomDirection (Vector3 dashDirection)
{
if (enabled && dashEnabled && canUseDash ()) {
customDashDirectionActive = true;
customDashDirection = dashDirection;
enableDashState ();
}
}
public bool canUseDash ()
{
if (mainPlayerController.canPlayerMove () ||
(canUseDashWhileActionActive && mainPlayerController.isActionActive () && checkIfActionToUseOnDashIsOnCategoryList ())) {
if (mainPlayerController.isPlayerOnFirstPerson ()) {
if (useDashOnFirstPerson) {
if (!dashActive && (!useDashCoolDown || Time.time > dashCoolDownTime + lastTimeDashActive)) {
if (mainPlayerController.isPlayerOnGround () || !onlyDashOnGround || checkGroundPaused) {
return true;
}
}
}
} else {
if (useDashOnThirdPerson) {
if (dashOnThirdPersonPaused) {
return false;
}
if (!dashActive && (!useDashCoolDown || Time.time > dashCoolDownTime + lastTimeDashActive)) {
if (mainPlayerController.isPlayerOnGround () || checkGroundPaused) {
return true;
}
}
}
}
}
return false;
}
public void setUseDashOnFirstPersonState (bool state)
{
useDashOnFirstPerson = state;
}
public void setUseDashOnThirdPersonState (bool state)
{
useDashOnThirdPerson = state;
}
public void setDashOnThirdPersonInTransitionState (bool state)
{
dashOnThirdPersonInTransition = state;
if (!dashOnThirdPersonInTransition) {
disableDashState ();
}
}
public bool checkIfActionToUseOnDashIsOnCategoryList ()
{
if (actionCategoryToUseDash.Contains (mainPlayerController.getCurrentActionCategoryActive ())) {
return true;
}
return false;
}
public void setDashOnThirdPersonPausedState (bool state)
{
dashOnThirdPersonPaused = state;
}
public void setDashInfoOnThirdPersonPausedState (bool state, string dashInfoName)
{
for (int i = 0; i < dashInfoList.Count; i++) {
if (dashInfoList [i].Name.Equals (dashInfoName)) {
dashInfoList [i].dashOnThirdPersonPaused = state;
return;
}
}
}
public void pauseDashInfoOnThirdPerson (string dashInfoName)
{
setDashInfoOnThirdPersonPausedState (true, dashInfoName);
}
public void resumeDashInfoOnThirdPerson (string dashInfoName)
{
setDashInfoOnThirdPersonPausedState (false, dashInfoName);
}
public void setDashInfoOnThirdPersonPausedByStaminaState (bool state, string dashInfoName)
{
for (int i = 0; i < dashInfoList.Count; i++) {
if (dashInfoList [i].useStamina && dashInfoList [i].Name.Equals (dashInfoName)) {
dashInfoList [i].dashOnThirdPersonPaused = state;
return;
}
}
}
public void pauseByStaminaDashInfoOnThirdPerson (string dashInfoName)
{
setDashInfoOnThirdPersonPausedByStaminaState (true, dashInfoName);
}
public void resumeByStaminaDashInfoOnThirdPerson (string dashInfoName)
{
setDashInfoOnThirdPersonPausedByStaminaState (false, dashInfoName);
}
public int getCurrentDashID ()
{
return currentDashID;
}
public void setCurrentDashID (int newValue)
{
currentDashID = newValue;
if (showDebugPrint) {
print ("Setting new dash id " + currentDashID);
}
for (int i = 0; i < dashInfoList.Count; i++) {
if (dashInfoList [i].dashID == currentDashID) {
currentDashInfo = dashInfoList [i];
dashInfoList [i].isCurrentState = true;
if (showDebugPrint) {
print ("Setting new dash " + dashInfoList [i].Name);
}
} else {
dashInfoList [i].isCurrentState = false;
}
}
}
//EDITOR FUNCTIONS
public void setUseDashOnFirstPersonStateFromEditor (bool state)
{
setUseDashOnFirstPersonState (state);
updateComponent ();
}
public void setUseDashOnThirdPersonStateFromEditor (bool state)
{
setUseDashOnThirdPersonState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Dash System", gameObject);
}
[System.Serializable]
public class dashInfo
{
public string Name;
public int dashID;
public bool isCurrentState;
[Space]
[Header ("Regular Dash Events Settings")]
[Space]
public UnityEvent eventOnDashOnThirdPerson;
public float dashDurationOnThirdPerson;
public bool useDoubleTapToDashOnThirdPersonEnabled;
[Space]
[Header ("Strafe Dash Events Settings")]
[Space]
public bool checkDashInStrafeState = true;
public UnityEvent eventOnDashOnThirdPersonForward;
public UnityEvent eventOnDashOnThirdPersonBackward;
public UnityEvent eventOnDashOnThirdPersonLeft;
public UnityEvent eventOnDashOnThirdPersonRight;
[Space]
[Header ("Diagonal Dash Events Settings")]
[Space]
public bool checkDiagonalInputInStrafeState = true;
public UnityEvent eventOnDashOnThirdPersonForwardRight;
public UnityEvent eventOnDashOnThirdPersonForwardLeft;
public UnityEvent eventOnDashOnThirdPersonBackwardRight;
public UnityEvent eventOnDashOnThirdPersonBackwardLeft;
[Space]
[Header ("General Events Settings")]
[Space]
public bool useGeneralEventOnDashOnThirdPerson;
public UnityEvent generalEventOnDashOnThirdPerson;
[Space]
[Header ("Stamina Settings")]
[Space]
public bool useStamina;
public float amountOfStaminaToUse;
public float refillStaminaWaitTime;
[Space]
[Header ("Debug")]
[Space]
public bool dashOnThirdPersonPaused;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 4b96731af5885994ca63e44890065074
timeCreated: 1567045917
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/dashSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,590 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class magicSpellActionSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool magicSystemEnabled = true;
public bool resetIndexIfNotAttackAfterDelay;
public float delayToResetIndexAfterAttack;
public float generalEnergyUseMultiplier = 1;
[Space]
[Header ("Attack Selection Settings")]
[Space]
public bool useAttackTypes;
public bool useRandomAttackIndex;
public bool useEnergyOnMagic;
public bool useNextMagicSpellOnListForNextAttackEnabled = true;
[Space]
public bool avoidActivateAbilityIfAnotherInProcessEnabled = true;
[Space]
[Header ("Movement Settings")]
[Space]
public bool useStrafeMode;
public int strafeIDUsed;
public bool setPreviousStrafeModeOnDisableMagicSystem;
public bool activateStrafeModeOnLockOnTargetActive;
public bool deactivateStrafeModeOnLockOnTargetDeactivate;
public bool toggleStrafeModeIfRunningActive;
public bool setNewCrouchID;
public int crouchIDUsed;
[Space]
[Header ("Magic Action List Settings")]
[Space]
public List<magicSpellActionInfo> magicSpellActionInfoList = new List<magicSpellActionInfo> ();
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
[Space]
public bool previousStrafeMode;
public int previousStrafeID = -1;
public bool magicSystemActive;
[Space]
public int currentAttackIndex;
public bool attackInProcess;
[Space]
[Header ("Event Settings")]
[Space]
public bool useEventsOnAttack;
public UnityEvent eventOnAttackStart;
public UnityEvent eventOnAttackEnd;
public bool useEventsOnEnableDisableMagicSystem;
public UnityEvent eventOnEnableMagicSystem;
public UnityEvent eventOnDisableMagicSystem;
[Space]
[Header ("Components")]
[Space]
public otherPowers mainOtherPowers;
public playerController mainPlayerController;
public remoteEventSystem mainRemoteEventSystem;
magicSpellActionInfo currentMagicSpellActionInfo;
float lastTimeAttackActive;
float lastTimeAttackComplete;
Coroutine magicCoroutine;
Coroutine magicEventCoroutine;
public void enableOrDisableMagicSystem (bool state)
{
if (!magicSystemEnabled) {
return;
}
bool previouslyActive = magicSystemActive;
magicSystemActive = state;
checkEventsOnEnableDisableMagicSystem (magicSystemActive);
mainOtherPowers.enableOrDisablePowersInfoPanel (magicSystemActive);
if (magicSystemActive) {
checkMagicStateAtStart ();
} else {
if (previouslyActive) {
checkMagicStateAtEnd ();
resumeState ();
}
}
}
public void useMagicSpell (string magicTypeName)
{
if (showDebugPrint) {
print ("input activated");
}
if (!magicSystemActive) {
return;
}
if (!canUseInput ()) {
return;
}
if (currentAttackIndex > 0 && currentMagicSpellActionInfo != null) {
// print (currentAttackInfo.minDelayBeforeNextAttack);
if (Time.time < lastTimeAttackActive + currentMagicSpellActionInfo.minDelayBeforeNextAttack) {
return;
}
}
if (attackInProcess && avoidActivateAbilityIfAnotherInProcessEnabled) {
if (showDebugPrint) {
print ("attack in process, cancelling");
}
return;
}
if (resetIndexIfNotAttackAfterDelay && !attackInProcess) {
if (Time.time > lastTimeAttackComplete + delayToResetIndexAfterAttack) {
// print ("reset attack index");
currentAttackIndex = 0;
}
}
if (useAttackTypes) {
if (showDebugPrint) {
print ("attack all conditions checked");
}
int numberOfAttacksSameType = 0;
int numberOfAttacksAvailable = magicSpellActionInfoList.Count;
for (int i = 0; i < numberOfAttacksAvailable; i++) {
if (magicSpellActionInfoList [i].magicTypeName.Equals (magicTypeName) &&
magicSpellActionInfoList [i].magicEnabled) {
numberOfAttacksSameType++;
}
}
if (numberOfAttacksSameType == 1) {
bool cancelAttack = false;
if (attackInProcess &&
currentMagicSpellActionInfo != null &&
currentMagicSpellActionInfo.magicTypeName.Equals (magicTypeName)) {
cancelAttack = true;
if (showDebugPrint) {
print ("same attack type already in process with just 1 type configured, so " +
"the system is trying to activate the same magic attack which is already in process");
}
}
if (Time.time < lastTimeAttackComplete + 0.4f) {
cancelAttack = true;
}
if (cancelAttack) {
if (showDebugPrint) {
print ("just one attack type available and it is in process, avoiding to play it again");
}
return;
}
}
bool attackFound = false;
setNextAttackIndex ();
while (!attackFound) {
currentMagicSpellActionInfo = magicSpellActionInfoList [currentAttackIndex];
// print (currentAttackInfo.magicTypeName + " " + magicTypeName);
if (currentMagicSpellActionInfo.magicTypeName.Equals (magicTypeName) &&
currentMagicSpellActionInfo.magicEnabled) {
attackFound = true;
} else {
setNextAttackIndex ();
numberOfAttacksAvailable--;
if (numberOfAttacksAvailable < 0) {
return;
}
}
}
} else {
bool attackFound = false;
int numberOfAttacksAvailable = magicSpellActionInfoList.Count;
while (!attackFound) {
currentMagicSpellActionInfo = magicSpellActionInfoList [currentAttackIndex];
// print (currentAttackInfo.magicTypeName + " " + magicTypeName);
if (currentMagicSpellActionInfo.magicEnabled) {
attackFound = true;
} else {
setNextAttackIndex ();
numberOfAttacksAvailable--;
if (numberOfAttacksAvailable < 0) {
return;
}
}
}
currentMagicSpellActionInfo = magicSpellActionInfoList [currentAttackIndex];
}
if (useEnergyOnMagic) {
float energyUsed = currentMagicSpellActionInfo.energyAmountUsed * generalEnergyUseMultiplier;
if (energyUsed > 0) {
mainOtherPowers.usePowerBar ((energyUsed));
}
}
// print ("Magic used " + currentMagicSpellActionInfo.Name);
stopActivateMagicSpellAction ();
magicCoroutine = StartCoroutine (activateMagicSpellAction ());
stopActivateMagicSpellEvent ();
magicEventCoroutine = StartCoroutine (activateMagicSpellEvent ());
if (!useAttackTypes && useNextMagicSpellOnListForNextAttackEnabled) {
setNextAttackIndex ();
}
}
public void enableMagicByName (string magicName)
{
enableOrDisableMagicByName (magicName, true);
}
public void disableMagicByName (string magicName)
{
enableOrDisableMagicByName (magicName, false);
}
public void enableOrDisableMagicByName (string magicName, bool state)
{
int weaponIdex = magicSpellActionInfoList.FindIndex (s => s.Name.Equals (magicName));
if (weaponIdex > -1) {
magicSpellActionInfoList [weaponIdex].magicEnabled = state;
}
}
public void setNextAttackIndex ()
{
if (useRandomAttackIndex) {
currentAttackIndex = Random.Range (0, magicSpellActionInfoList.Count - 1);
} else {
currentAttackIndex++;
if (currentAttackIndex >= magicSpellActionInfoList.Count) {
currentAttackIndex = 0;
}
}
}
public void setPreviousAttackIndex ()
{
if (useRandomAttackIndex) {
currentAttackIndex = Random.Range (0, magicSpellActionInfoList.Count - 1);
} else {
currentAttackIndex--;
if (currentAttackIndex <= 0) {
currentAttackIndex = magicSpellActionInfoList.Count - 1;
}
}
}
public void stopActivateMagicSpellAction ()
{
if (magicCoroutine != null) {
StopCoroutine (magicCoroutine);
}
}
IEnumerator activateMagicSpellAction ()
{
checkEventsOnAttack (true);
lastTimeAttackActive = Time.time;
attackInProcess = true;
if (currentMagicSpellActionInfo.useRemoteEvent) {
for (int i = 0; i < currentMagicSpellActionInfo.remoteEventNameList.Count; i++) {
mainRemoteEventSystem.callRemoteEvent (currentMagicSpellActionInfo.remoteEventNameList [i]);
}
}
if (currentMagicSpellActionInfo.useCustomAction) {
mainPlayerController.activateCustomAction (currentMagicSpellActionInfo.customActionName);
if (showDebugPrint) {
print ("attack activated :" + mainPlayerController.getCurrentActionName ());
}
}
yield return new WaitForSeconds (currentMagicSpellActionInfo.attackDuration);
lastTimeAttackComplete = Time.time;
resumeState ();
if (showDebugPrint) {
print ("end of attack");
}
yield return null;
}
public void stopActivateMagicSpellEvent ()
{
if (magicEventCoroutine != null) {
StopCoroutine (magicEventCoroutine);
}
}
IEnumerator activateMagicSpellEvent ()
{
yield return new WaitForSeconds (currentMagicSpellActionInfo.delayToActiveEvent);
currentMagicSpellActionInfo.eventOnMagicUsed.Invoke ();
}
public void resumeState ()
{
attackInProcess = false;
checkEventsOnAttack (false);
}
public void checkEventsOnAttack (bool state)
{
if (useEventsOnAttack) {
if (state) {
eventOnAttackStart.Invoke ();
} else {
eventOnAttackEnd.Invoke ();
}
}
}
public void checkMagicStateAtStart ()
{
previousStrafeMode = mainPlayerController.isStrafeModeActive ();
if (previousStrafeID == -1) {
previousStrafeID = mainPlayerController.getCurrentStrafeIDValue ();
}
if (useStrafeMode) {
mainPlayerController.activateOrDeactivateStrafeMode (true);
} else {
if (showDebugPrint) {
print ("checking strafe mode when returning thrown weapon");
}
previousStrafeMode = false;
previousStrafeID = -1;
mainPlayerController.activateOrDeactivateStrafeMode (false);
}
if (toggleStrafeModeIfRunningActive) {
mainPlayerController.setDisableStrafeModeExternallyIfIncreaseWalkSpeedActiveState (true);
}
mainPlayerController.setCurrentStrafeIDValue (strafeIDUsed);
if (setNewCrouchID) {
mainPlayerController.setCurrentCrouchIDValue (crouchIDUsed);
}
}
public void checkMagicStateAtEnd ()
{
if (setPreviousStrafeModeOnDisableMagicSystem) {
mainPlayerController.activateOrDeactivateStrafeMode (previousStrafeMode);
} else {
mainPlayerController.setOriginalLookAlwaysInCameraDirectionState ();
}
if (previousStrafeID != -1) {
mainPlayerController.setCurrentStrafeIDValue (previousStrafeID);
}
if (toggleStrafeModeIfRunningActive) {
mainPlayerController.setDisableStrafeModeExternallyIfIncreaseWalkSpeedActiveState (false);
}
previousStrafeMode = false;
previousStrafeID = -1;
if (setNewCrouchID) {
mainPlayerController.setCurrentCrouchIDValue (0);
}
}
public void checkLookAtTargetActiveState ()
{
if (magicSystemActive) {
bool lookingAtTarget = mainPlayerController.isPlayerLookingAtTarget ();
if (lookingAtTarget) {
if (activateStrafeModeOnLockOnTargetActive) {
mainPlayerController.activateOrDeactivateStrafeMode (true);
}
} else {
if (activateStrafeModeOnLockOnTargetActive) {
mainPlayerController.activateOrDeactivateStrafeMode (false);
}
}
}
}
public void checkLookAtTargetDeactivateState ()
{
if (activateStrafeModeOnLockOnTargetActive) {
mainPlayerController.activateOrDeactivateStrafeMode (false);
}
}
public bool canUseInput ()
{
if (!playerIsBusy ()) {
return true;
}
return false;
}
public bool playerIsBusy ()
{
if (mainPlayerController.isUsingDevice ()) {
return true;
}
if (mainPlayerController.isTurnBasedCombatActionActive ()) {
return false;
}
if (mainPlayerController.isUsingSubMenu ()) {
return true;
}
if (mainPlayerController.isPlayerMenuActive ()) {
return true;
}
return false;
}
public void checkEventsOnEnableDisableMagicSystem (bool state)
{
if (useEventsOnEnableDisableMagicSystem) {
if (state) {
eventOnEnableMagicSystem.Invoke ();
} else {
eventOnDisableMagicSystem.Invoke ();
}
}
}
public void inputSetNextOrPreviousAttackIndex (bool useNextAttack)
{
if (!magicSystemActive) {
return;
}
if (!canUseInput ()) {
return;
}
if (useNextAttack) {
setNextAttackIndex ();
} else {
setPreviousAttackIndex ();
}
}
[System.Serializable]
public class magicSpellActionInfo
{
[Header ("Main Settings")]
[Space]
public string Name;
public bool magicEnabled = true;
public float energyAmountUsed;
public string magicTypeName;
[Space]
[Header ("Other Settings")]
[Space]
public float attackDuration;
public float minDelayBeforeNextAttack;
public bool useCustomAction;
public string customActionName;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEvent;
public List<string> remoteEventNameList = new List<string> ();
public float delayToActiveEvent;
public UnityEvent eventOnMagicUsed;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 44810e0276be6834aaf56e2fac05a31a
timeCreated: 1605702847
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/magicSpellActionSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,587 @@
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class oxygenSystem : MonoBehaviour {
[Header ("Main Settings")]
[Space]
public bool oxygenSystemEnabled = true;
public float oxygenUseRate;
public float closeToEmptyOxygenAmount;
public float oxygenAmount;
public float refillOxygenRate = 18;
public float refillOxygenDelayAfterUse;
public bool oxygenObjectAlwaysActive;
public float timeToDisableOxygenObject;
public bool waitToOxygenFilledToUseAgain;
public float eventOnOxygenDepletedRate;
public bool useOxygenUIOnScreenOnAnyView;
[Space]
[Header ("UI Settings")]
[Space]
public Color regularOxygenColor;
public Color closeToEmptyOxygenColor;
public Color regularOxygenTextColor;
public Color closeToEmptyOxygenTextColor;
[Space]
[Header ("Oxygen States Settings")]
[Space]
public List<oxygenStateInfo> oxygenStateInfoList = new List<oxygenStateInfo> ();
public string oxygenStateNameByDefault = "Oxygen On Space";
[Space]
[Header ("Debug")]
[Space]
public bool oxygenEmpty;
public bool refillingOxygen;
public bool usingOxygen;
public bool oxygenRefilled = true;
public bool firstPersonActive;
public oxygenStateInfo currentOxygenStateInfo;
[Space]
[Header ("Event Settings")]
[Space]
public UnityEvent eventOnOxygenRefilled;
public UnityEvent eventOnOxygenEmpty;
public UnityEvent eventOnOxygenDepleted;
public UnityEvent eventOnOxygenActive;
public UnityEvent eventOnOxygenDeactivate;
public UnityEvent eventOnOxygenEmptyDeath;
[Space]
[Header ("Components")]
[Space]
public Image oxygenSlider;
public Text oxygenAmountText;
public GameObject oxygenObject;
public GameObject firstPersonOxygenPanel;
public Text firstPersonOxygenAmountText;
public health mainHealth;
float originalOxygenAmount;
float lastTimeOxygenRefilled;
Coroutine refillCoroutine;
bool oxygenSliderHidden;
float lastTimeOxygenDepleted;
float auxOxygenAmount;
float lastTimeOxygenSoundPlayed;
float curretnOxygenSoundRate;
float lastTimeOxygenStateDepleted;
private void InitializeAudioElements ()
{
foreach (var oxygenStateInfo in oxygenStateInfoList) {
if (oxygenStateInfo.oxygenSoundSource != null) {
oxygenStateInfo.oxygenSoundAudioElement.audioSource = oxygenStateInfo.oxygenSoundSource;
}
if (oxygenStateInfo.clipToUseOnOxygenSound != null) {
oxygenStateInfo.oxygenSoundAudioElement.clip = oxygenStateInfo.clipToUseOnOxygenSound;
}
}
}
void Start ()
{
InitializeAudioElements ();
originalOxygenAmount = oxygenAmount;
auxOxygenAmount = oxygenAmount;
if (oxygenObject.activeSelf) {
oxygenObject.SetActive (false);
}
setOxygenStateByName (oxygenStateNameByDefault);
}
void FixedUpdate ()
{
if (!oxygenSystemEnabled) {
return;
}
if (!oxygenObjectAlwaysActive) {
if (!refillingOxygen) {
if (oxygenRefilled && !oxygenSliderHidden) {
if (Time.time > lastTimeOxygenRefilled + timeToDisableOxygenObject) {
if (!oxygenSliderHidden) {
if (oxygenObject.activeSelf) {
oxygenObject.SetActive (false);
}
oxygenSliderHidden = true;
}
}
}
}
}
if (!refillingOxygen && usingOxygen) {
if (mainHealth.isDead ()) {
disableOxygenOnDeath ();
}
if (useOxygenUIOnScreenOnAnyView) {
if (!firstPersonOxygenPanel.activeSelf) {
firstPersonOxygenPanel.SetActive (true);
}
} else {
if (firstPersonActive) {
if (oxygenObject.activeSelf) {
oxygenObject.SetActive (false);
}
} else {
if (!oxygenObject.activeSelf) {
oxygenObject.SetActive (true);
}
}
}
oxygenSliderHidden = false;
oxygenAmount -= oxygenUseRate * Time.fixedDeltaTime;
oxygenAmount = Mathf.Clamp (oxygenAmount, 0, originalOxygenAmount);
if (oxygenAmount <= closeToEmptyOxygenAmount) {
oxygenSlider.color = closeToEmptyOxygenColor;
oxygenAmountText.color = closeToEmptyOxygenTextColor;
}
oxygenSlider.fillAmount = oxygenAmount / originalOxygenAmount;
if (oxygenAmountText != null) {
string oxygenAmountString = oxygenAmount.ToString ("##.0");
if (oxygenAmount == 0) {
oxygenAmountString = "0";
}
oxygenAmountText.text = oxygenAmountString;
if (useOxygenUIOnScreenOnAnyView) {
if (!firstPersonOxygenPanel.activeSelf) {
firstPersonOxygenPanel.SetActive (true);
}
firstPersonOxygenAmountText.text = oxygenAmountString;
} else {
if (firstPersonActive) {
if (!firstPersonOxygenPanel.activeSelf) {
firstPersonOxygenPanel.SetActive (true);
}
firstPersonOxygenAmountText.text = oxygenAmountString;
} else {
if (firstPersonOxygenPanel.activeSelf) {
firstPersonOxygenPanel.SetActive (false);
}
}
}
}
auxOxygenAmount = oxygenAmount;
if (oxygenAmount <= 0) {
if (!oxygenEmpty) {
eventOnOxygenEmpty.Invoke ();
currentOxygenStateInfo.eventOnOxygenEmpty.Invoke ();
}
oxygenEmpty = true;
if (Time.time > eventOnOxygenDepletedRate + lastTimeOxygenDepleted) {
eventOnOxygenDepleted.Invoke ();
lastTimeOxygenDepleted = Time.time;
}
if (currentOxygenStateInfo.killPlayerOnOxygenEmpty) {
if (currentOxygenStateInfo.useEventBeforeKillingPlayer) {
currentOxygenStateInfo.eventBeforeKillingPlayer.Invoke ();
}
mainHealth.killCharacter ();
} else {
if (Time.time > currentOxygenStateInfo.damagePlayerOnOxygenEmptyRate + lastTimeOxygenStateDepleted) {
mainHealth.takeConstantDamageWithoutShield (currentOxygenStateInfo.damagePlayerOnOxygenEmptyAmount);
lastTimeOxygenStateDepleted = Time.time;
}
}
}
if (currentOxygenStateInfo.useOxygenSound) {
if (oxygenAmount > currentOxygenStateInfo.oxygenAmountToIncreaseSoundRate) {
curretnOxygenSoundRate = currentOxygenStateInfo.oxygenSoundRate;
} else {
curretnOxygenSoundRate = currentOxygenStateInfo.oxygenSoundIncreasedRate;
}
if (Time.time > lastTimeOxygenSoundPlayed + curretnOxygenSoundRate) {
lastTimeOxygenSoundPlayed = Time.time;
if (currentOxygenStateInfo.oxygenSoundAudioElement != null) {
AudioPlayer.PlayOneShot (currentOxygenStateInfo.oxygenSoundAudioElement, gameObject);
}
}
}
}
}
void setOxygenStateByName (string oxygenStateName)
{
for (int i = 0; i < oxygenStateInfoList.Count; i++) {
if (oxygenStateInfoList[i].stateEnabled && oxygenStateInfoList[i].Name.Equals (oxygenStateName)) {
currentOxygenStateInfo = oxygenStateInfoList[i];
}
}
}
public void activateOxygenState (string oxygenStateName)
{
setOxygenStateByName (oxygenStateName);
activeOxygenState ();
}
public void disableOxygenState (string oxygenStateName)
{
setOxygenStateByName (oxygenStateName);
disableOxygenState ();
}
public void activeOxygenState ()
{
if (!oxygenSystemEnabled) {
return;
}
if (usingOxygen) {
return;
}
if (oxygenEmpty && ( waitToOxygenFilledToUseAgain || oxygenAmount <= 0 )) {
return;
}
stopRefillCoroutine ();
refillingOxygen = false;
oxygenRefilled = false;
usingOxygen = true;
eventOnOxygenActive.Invoke ();
currentOxygenStateInfo.eventOnOxygenActive.Invoke ();
}
public void disableOxygenState ()
{
if (!oxygenSystemEnabled) {
return;
}
if (!usingOxygen) {
return;
}
lastTimeOxygenDepleted = 0;
lastTimeOxygenStateDepleted = 0;
if (usingOxygen) {
refillOxygen (refillOxygenDelayAfterUse);
}
usingOxygen = false;
eventOnOxygenDeactivate.Invoke ();
if (firstPersonOxygenPanel.activeSelf) {
firstPersonOxygenPanel.SetActive (false);
}
currentOxygenStateInfo.eventOnOxygenDeactivate.Invoke ();
}
public void refillOxygen (float refillDelay)
{
stopRefillCoroutine ();
refillCoroutine = StartCoroutine (refillOxygenCoroutine (refillDelay));
}
public void stopRefillCoroutine ()
{
if (refillCoroutine != null) {
StopCoroutine (refillCoroutine);
}
}
IEnumerator refillOxygenCoroutine (float refillDelay)
{
refillingOxygen = true;
yield return new WaitForSeconds (refillDelay);
if (!waitToOxygenFilledToUseAgain) {
eventOnOxygenRefilled.Invoke ();
currentOxygenStateInfo.eventOnOxygenRefilled.Invoke ();
}
while (oxygenAmount < originalOxygenAmount) {
oxygenAmount += Time.deltaTime * refillOxygenRate;
updateOxygenState ();
yield return null;
}
if (waitToOxygenFilledToUseAgain) {
eventOnOxygenRefilled.Invoke ();
currentOxygenStateInfo.eventOnOxygenRefilled.Invoke ();
}
refillingOxygen = false;
lastTimeOxygenRefilled = Time.time;
oxygenRefilled = true;
oxygenEmpty = false;
}
public void refillOxygenDirectly ()
{
if (oxygenEmpty || usingOxygen) {
oxygenAmount = originalOxygenAmount;
updateOxygenState ();
lastTimeOxygenRefilled = Time.time;
oxygenRefilled = true;
oxygenEmpty = false;
}
}
public void increaseTotalOxygenAmount (float extraValue)
{
oxygenAmount = originalOxygenAmount + extraValue;
originalOxygenAmount = oxygenAmount;
auxOxygenAmount = oxygenAmount;
}
public void initializeOxygenAmount (float newValue)
{
oxygenAmount = newValue;
}
public void initializeOxygenUseRate (float newValue)
{
oxygenUseRate = newValue;
}
public void increaseOxygenUseRate (float newValue)
{
oxygenUseRate += newValue;
}
public void updateOxygenAmountWithoutUpdatingStatManager (int statId, float amount)
{
oxygenAmount = amount;
originalOxygenAmount = oxygenAmount;
auxOxygenAmount = oxygenAmount;
}
public void updateOxygenUseRateAmountWithoutUpdatingStatManager (int statId, float amount)
{
oxygenUseRate = amount;
}
public void getOxygen (float amount)
{
if (!waitToOxygenFilledToUseAgain) {
eventOnOxygenRefilled.Invoke ();
currentOxygenStateInfo.eventOnOxygenRefilled.Invoke ();
}
oxygenAmount += amount;
updateOxygenState ();
if (waitToOxygenFilledToUseAgain) {
eventOnOxygenRefilled.Invoke ();
currentOxygenStateInfo.eventOnOxygenRefilled.Invoke ();
}
oxygenEmpty = false;
}
void updateOxygenState ()
{
oxygenSlider.fillAmount = oxygenAmount / originalOxygenAmount;
if (oxygenAmountText != null) {
oxygenAmountText.text = Mathf.RoundToInt (oxygenAmount).ToString ();
}
if (oxygenAmount > closeToEmptyOxygenAmount) {
oxygenSlider.color = regularOxygenColor;
oxygenAmountText.color = regularOxygenTextColor;
}
if (oxygenAmount >= originalOxygenAmount) {
oxygenAmount = originalOxygenAmount;
}
auxOxygenAmount = oxygenAmount;
}
public float getOxygenAmountToLimit ()
{
return originalOxygenAmount - auxOxygenAmount;
}
public void addAuxOxygenAmount (float amount)
{
auxOxygenAmount += amount;
}
public void disableOxygenOnDeath ()
{
lastTimeOxygenDepleted = 0;
lastTimeOxygenStateDepleted = 0;
usingOxygen = false;
eventOnOxygenDeactivate.Invoke ();
currentOxygenStateInfo.eventOnOxygenDeactivate.Invoke ();
eventOnOxygenEmptyDeath.Invoke ();
}
public void setFirstPersonActiveState (bool state)
{
firstPersonActive = state;
}
public void setOxygenSystemEnabledState (bool state)
{
oxygenSystemEnabled = state;
}
public void setOxygenSystemEnabledStateFromEditor (bool state)
{
setOxygenSystemEnabledState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Oxygen System", gameObject);
}
[System.Serializable]
public class oxygenStateInfo {
[Header ("Main Settings")]
[Space]
public string Name;
public bool stateEnabled = true;
public float damagePlayerOnOxygenEmptyRate;
public float damagePlayerOnOxygenEmptyAmount;
public bool killPlayerOnOxygenEmpty;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnOxygenActive;
public UnityEvent eventOnOxygenDeactivate;
[Space]
public UnityEvent eventOnOxygenEmpty;
public UnityEvent eventOnOxygenRefilled;
[Space]
public bool useEventBeforeKillingPlayer;
public UnityEvent eventBeforeKillingPlayer;
[Space]
[Header ("Sounds Settings")]
[Space]
public bool useOxygenSound = true;
public float oxygenSoundRate = 2;
public float oxygenAmountToIncreaseSoundRate = 15;
public float oxygenSoundIncreasedRate = 1;
public AudioSource oxygenSoundSource;
public AudioClip clipToUseOnOxygenSound;
public AudioElement oxygenSoundAudioElement;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d339b2c1c78460d43b9cbb805e46d542
timeCreated: 1564715137
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/oxygenSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,102 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class particleCollisionDetection : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool detectionEnabled = true;
public bool useLayermaskOnObjectsDetected;
public LayerMask layermaskToCheck;
[Space]
[Header ("Collision Max Amount Settings")]
[Space]
public bool useCollisionMaxAmount;
public int collisionMaxAmount;
[Space]
[Header ("Components")]
[Space]
public ParticleSystem mainParticleSystem;
[Space]
[Header ("Debug")]
[Space]
public bool debugCollisionPrintActive;
public int currentCollisionCounter;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnCollision = true;
public eventParameters.eventToCallWithVector3 eventOnCollision;
[Space]
public bool useEventOnCollisionWithGameObject;
public eventParameters.eventToCallWithGameObject eventOnCollisionWithGameObject;
public List<ParticleCollisionEvent> collisionEvents = new List<ParticleCollisionEvent> ();
void OnParticleCollision (GameObject obj)
{
if (!detectionEnabled) {
return;
}
int numCollisionEvents = mainParticleSystem.GetCollisionEvents (obj, collisionEvents);
if (debugCollisionPrintActive) {
print (numCollisionEvents);
}
if (numCollisionEvents > 0) {
if (useLayermaskOnObjectsDetected) {
if ((1 << obj.layer & layermaskToCheck.value) != 1 << obj.layer) {
return;
}
}
if (useCollisionMaxAmount) {
if (currentCollisionCounter >= collisionMaxAmount) {
return;
}
currentCollisionCounter++;
}
if (useEventOnCollision) {
eventOnCollision.Invoke (collisionEvents [0].intersection);
}
if (useEventOnCollisionWithGameObject) {
eventOnCollisionWithGameObject.Invoke (obj);
}
if (debugCollisionPrintActive) {
print (collisionEvents [0].intersection);
print ("Particle Collision Detected with object " + obj.name);
}
}
}
public void setDetectionEnabledState (bool state)
{
detectionEnabled = state;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c46fb0a7598458d4790285e99c63ab0e
timeCreated: 1580387881
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/particleCollisionDetection.cs
uploadId: 814740

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class particleTriggerDetection : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c375a8a6fb43f1c46abcbd0ab0440a4a
timeCreated: 1627285536
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/particleTriggerDetection.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a0a2d761904db114890169585dfb1c4b
timeCreated: 1579406091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/playerAbilitiesSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,515 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class playerAbilitiesUIEditorSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public float abilitiesWheelScale;
[Space]
[Header ("Debug")]
[Space]
public bool abilitiesUIEditorActive;
public bool movingSlotFromFullAbilitiesPanel;
public bool movingSlotFromCurrentAbilitiesPanel;
[Space]
[Header ("UI Elements")]
[Space]
public GameObject abilitiesUIEditorObject;
public ScrollRect fullAbilitiesUIEditorListScrollRect;
public Scrollbar fullAbilitiesUIEditorScrollbar;
public Transform fullAbilitiesUIEditorContent;
public Transform currentWheelAbilitiesPanelBackgroundTransform;
public Transform currentGridAbilitiesPanelBackgroundTransform;
public Transform fullAbilitiesPanelTransform;
public Transform mainAbilitiesWheelTransform;
public Transform originalAbilitiesWheelParent;
public Transform abilitiesWheelPosition;
public GameObject abilityListElement;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public List<playerAbilitiesUISystem.abilitySlotInfo> abilitySlotInfoList = new List<playerAbilitiesUISystem.abilitySlotInfo> ();
public List<playerAbilitiesUISystem.abilitySlotInfo> temporalAbilitySlotInfoList = new List<playerAbilitiesUISystem.abilitySlotInfo> ();
[Space]
[Header ("Components")]
[Space]
public playerAbilitiesUISystem mainPlayerAbilitiesUISystem;
public playerAbilitiesSystem mainPlayerAbilitiesSystem;
bool fullAbilitiesUIEditorContentCreated;
bool slotDroppedOnFullAbilitiesPanel;
bool slotDroppedOnCurrentAbilitiesPanel;
readonly List<RaycastResult> captureRaycastResults = new List<RaycastResult> ();
bool touchPlatform;
Touch currentTouch;
Vector2 currentTouchPosition;
bool touching;
GameObject buttonToMove;
RectTransform buttonToMoveRectTransform;
playerAbilitiesUISystem.abilitySlotInfo currentSlotSelected;
void Start ()
{
touchPlatform = touchJoystick.checkTouchPlatform ();
}
void Update ()
{
if (abilitiesUIEditorActive) {
int touchCount = Input.touchCount;
if (!touchPlatform) {
touchCount++;
}
for (int i = 0; i < touchCount; i++) {
if (!touchPlatform) {
currentTouch = touchJoystick.convertMouseIntoFinger ();
} else {
currentTouch = Input.GetTouch (i);
}
currentTouchPosition = currentTouch.position;
if (currentTouch.phase == TouchPhase.Began) {
touching = true;
//if the edit powers manager is open, then
movingSlotFromFullAbilitiesPanel = false;
movingSlotFromCurrentAbilitiesPanel = false;
//check where the mouse or the finger press, to get a power list element, to edit the powers
captureRaycastResults.Clear ();
PointerEventData p = new PointerEventData (EventSystem.current);
p.position = currentTouchPosition;
p.clickCount = i;
p.dragging = false;
EventSystem.current.RaycastAll (p, captureRaycastResults);
foreach (RaycastResult r in captureRaycastResults) {
for (int k = 0; k < abilitySlotInfoList.Count; k++) {
if (abilitySlotInfoList [k].slotActive) {
if (abilitySlotInfoList [k].slot == r.gameObject) {
if (showDebugPrint) {
print ("comparing slot to object pressed " + r.gameObject.name + " " + abilitySlotInfoList [k].Name);
}
buttonToMove = (GameObject)Instantiate (r.gameObject, r.gameObject.transform.position, Quaternion.identity);
buttonToMove.transform.SetParent (abilitiesUIEditorObject.transform.parent);
currentSlotSelected = abilitySlotInfoList [k];
buttonToMoveRectTransform = buttonToMove.GetComponent<RectTransform> ();
movingSlotFromFullAbilitiesPanel = true;
movingSlotFromCurrentAbilitiesPanel = false;
if (showDebugPrint) {
print ("slot found from full panel");
}
return;
}
}
}
temporalAbilitySlotInfoList = mainPlayerAbilitiesUISystem.getAbilitySlotInfoList ();
for (int k = 0; k < temporalAbilitySlotInfoList.Count; k++) {
if (temporalAbilitySlotInfoList [k].slotActive) {
if (showDebugPrint) {
print ("comparing slot to object pressed " + r.gameObject.name + " " + temporalAbilitySlotInfoList [k].Name);
}
if (temporalAbilitySlotInfoList [k].abilityIcon.gameObject == r.gameObject) {
if (showDebugPrint) {
print ("comparing slot to object pressed " + r.gameObject.name + " " + temporalAbilitySlotInfoList [k].Name);
}
buttonToMove = (GameObject)Instantiate (temporalAbilitySlotInfoList [k].innerSlot.gameObject, r.gameObject.transform.position, Quaternion.identity);
buttonToMove.transform.SetParent (abilitiesUIEditorObject.transform.parent);
currentSlotSelected = temporalAbilitySlotInfoList [k];
buttonToMoveRectTransform = buttonToMove.GetComponent<RectTransform> ();
movingSlotFromFullAbilitiesPanel = false;
movingSlotFromCurrentAbilitiesPanel = true;
if (showDebugPrint) {
print ("slot found from current panel");
}
return;
}
}
}
}
}
//if the power list element is grabbed, follow the mouse/finger position in screen
if ((currentTouch.phase == TouchPhase.Stationary || currentTouch.phase == TouchPhase.Moved)) {
if (buttonToMove != null) {
buttonToMoveRectTransform.position = currentTouchPosition;
}
}
//if the mouse/finger press is released, then
if (currentTouch.phase == TouchPhase.Ended && touching) {
touching = false;
slotDroppedOnFullAbilitiesPanel = false;
slotDroppedOnCurrentAbilitiesPanel = false;
//if the player was editing the powers
if (buttonToMove != null) {
//get the elements in the position where the player released the power element
captureRaycastResults.Clear ();
PointerEventData p = new PointerEventData (EventSystem.current);
p.position = currentTouchPosition;
p.clickCount = i;
p.dragging = false;
EventSystem.current.RaycastAll (p, captureRaycastResults);
string currentAbilityName = currentSlotSelected.Name;
if (showDebugPrint) {
print (currentAbilityName);
}
int abilityIndexByName = mainPlayerAbilitiesUISystem.getAbilityIndexByName (currentAbilityName);
foreach (RaycastResult r in captureRaycastResults) {
if (r.gameObject != buttonToMove) {
//if the power element was released above other power element from the wheel, store the power element from the wheel
if (fullAbilitiesPanelTransform.gameObject == r.gameObject) {
slotDroppedOnFullAbilitiesPanel = true;
} else {
if (mainPlayerAbilitiesUISystem.isUseWheelMenuActive ()) {
if (currentWheelAbilitiesPanelBackgroundTransform.gameObject == r.gameObject) {
slotDroppedOnCurrentAbilitiesPanel = true;
}
} else {
if (currentGridAbilitiesPanelBackgroundTransform.gameObject == r.gameObject) {
slotDroppedOnCurrentAbilitiesPanel = true;
}
}
}
}
}
bool fullAbilitiesPanelChanged = false;
if (slotDroppedOnFullAbilitiesPanel) {
if (movingSlotFromFullAbilitiesPanel) {
if (showDebugPrint) {
print ("slot dropped on full abilities panel and moving slot from full abilities panel");
}
}
if (movingSlotFromCurrentAbilitiesPanel) {
if (abilityIndexByName > -1) {
mainPlayerAbilitiesSystem.abilityInfoList [abilityIndexByName].setAbilityCanBeShownOnWheelSelectionState (false);
} else {
print ("ability index not found");
}
if (showDebugPrint) {
print ("slot dropped on full abilities panel and moving slot from current abilities panel");
}
int abilityIndex = abilitySlotInfoList.FindIndex (a => a.Name == currentAbilityName);
if (abilityIndex > -1) {
abilitySlotInfoList [abilityIndex].slotVisible = true;
}
fullAbilitiesPanelChanged = true;
mainPlayerAbilitiesUISystem.checkIfAssignActivatedAbilitiesToFreeDpadSlots (currentAbilityName, abilityIndex, false);
mainPlayerAbilitiesUISystem.updateSlotsInfo ();
}
}
if (slotDroppedOnCurrentAbilitiesPanel) {
if (movingSlotFromFullAbilitiesPanel) {
if (abilityIndexByName > -1) {
mainPlayerAbilitiesSystem.abilityInfoList [abilityIndexByName].setAbilityCanBeShownOnWheelSelectionState (true);
} else {
print ("ability index not found");
}
if (showDebugPrint) {
print ("slot dropped on current abilities panel and moving slot from full abilities panel");
}
int abilityIndex = abilitySlotInfoList.FindIndex (a => a.Name == currentAbilityName);
if (abilityIndex > -1) {
abilitySlotInfoList [abilityIndex].slotVisible = false;
}
fullAbilitiesPanelChanged = true;
mainPlayerAbilitiesUISystem.checkIfAssignActivatedAbilitiesToFreeDpadSlots (currentAbilityName, abilityIndex, true);
mainPlayerAbilitiesUISystem.updateSlotsInfo ();
}
if (movingSlotFromCurrentAbilitiesPanel) {
if (showDebugPrint) {
print ("slot dropped on current abilities panel and moving slot from current abilities panel");
}
}
}
if (!slotDroppedOnFullAbilitiesPanel && !slotDroppedOnCurrentAbilitiesPanel) {
if (movingSlotFromCurrentAbilitiesPanel) {
if (abilityIndexByName > -1) {
mainPlayerAbilitiesSystem.abilityInfoList [abilityIndexByName].setAbilityCanBeShownOnWheelSelectionState (false);
} else {
print ("ability index not found");
}
if (showDebugPrint) {
print ("slot dropped outside and moving slot from current abilities panel");
}
int abilityIndex = abilitySlotInfoList.FindIndex (a => a.Name == currentAbilityName);
if (abilityIndex > -1) {
abilitySlotInfoList [abilityIndex].slotVisible = true;
}
fullAbilitiesPanelChanged = true;
mainPlayerAbilitiesUISystem.checkIfAssignActivatedAbilitiesToFreeDpadSlots (currentAbilityName, abilityIndex, false);
mainPlayerAbilitiesUISystem.updateSlotsInfo ();
}
if (movingSlotFromFullAbilitiesPanel) {
if (showDebugPrint) {
print ("slot dropped outside and moving slot from full abilities panel ");
}
}
}
//remove the dragged object
Destroy (buttonToMove);
buttonToMoveRectTransform = null;
updateAbilitiesUIEditorValues ();
if (fullAbilitiesPanelChanged) {
if (showDebugPrint) {
print ("update full abilities panel");
}
resetScroll (fullAbilitiesUIEditorScrollbar);
resetInventorySlotsRectTransform ();
}
}
if (showDebugPrint) {
print ("end of press");
}
}
}
}
}
public void openOrCloseAbilitiesUIEditor (bool state)
{
if (abilitiesUIEditorActive == state) {
return;
}
abilitiesUIEditorActive = state;
abilitiesUIEditorObject.SetActive (abilitiesUIEditorActive);
if (abilitiesUIEditorActive) {
updateAbilitiesUIEditorValues ();
mainAbilitiesWheelTransform.SetParent (abilitiesWheelPosition);
mainAbilitiesWheelTransform.localPosition = Vector3.zero;
mainAbilitiesWheelTransform.localScale = Vector3.one * abilitiesWheelScale;
mainAbilitiesWheelTransform.gameObject.SetActive (true);
mainPlayerAbilitiesUISystem.updateSlotsInfo ();
CanvasGroup abilitiesWheelCanvasGroup = mainAbilitiesWheelTransform.GetComponent<CanvasGroup> ();
if (abilitiesWheelCanvasGroup != null) {
abilitiesWheelCanvasGroup.alpha = 1;
}
resetScroll (fullAbilitiesUIEditorScrollbar);
resetInventorySlotsRectTransform ();
} else {
mainAbilitiesWheelTransform.SetParent (originalAbilitiesWheelParent);
mainAbilitiesWheelTransform.localPosition = Vector3.zero;
mainAbilitiesWheelTransform.localScale = Vector3.one;
mainAbilitiesWheelTransform.gameObject.SetActive (false);
}
mainPlayerAbilitiesUISystem.enableOrDisableExtraElementsOnAbilitiesUI (!abilitiesUIEditorActive);
}
public void updateAbilitiesUIEditorValues ()
{
if (!fullAbilitiesUIEditorContentCreated) {
int abilitySlotInfoListCount = mainPlayerAbilitiesSystem.abilityInfoList.Count;
for (int i = 0; i < abilitySlotInfoListCount; i++) {
GameObject newAbilityListElement = (GameObject)Instantiate (abilityListElement, Vector3.zero, Quaternion.identity);
newAbilityListElement.name = "Ability Slot " + (i + 1);
newAbilityListElement.transform.SetParent (fullAbilitiesUIEditorContent);
newAbilityListElement.transform.localScale = Vector3.one;
newAbilityListElement.transform.position = abilityListElement.transform.position;
playerAbilitiesUISystem.abilitySlotInfo newAbilitySlotInfo = newAbilityListElement.GetComponent<abilitySlotElement> ().slotInfo;
abilityInfo currentAbilityInfo = mainPlayerAbilitiesSystem.abilityInfoList [i];
newAbilitySlotInfo.Name = currentAbilityInfo.Name;
newAbilitySlotInfo.abilityIcon.texture = currentAbilityInfo.abilityTexture;
newAbilitySlotInfo.abilityIndex = i;
//add this element to the list
abilitySlotInfoList.Add (newAbilitySlotInfo);
}
abilityListElement.SetActive (false);
fullAbilitiesUIEditorContentCreated = true;
}
for (int i = 0; i < mainPlayerAbilitiesSystem.abilityInfoList.Count; i++) {
abilityInfo currentAbilityInfo = mainPlayerAbilitiesSystem.abilityInfoList [i];
if (currentAbilityInfo.isAbilityEnabled ()) {
playerAbilitiesUISystem.abilitySlotInfo newAbilitySlotInfo = abilitySlotInfoList [i];
if (!newAbilitySlotInfo.slotActive && currentAbilityInfo.abilityVisibleOnWheelSelection) {
newAbilitySlotInfo.slotActive = true;
newAbilitySlotInfo.slotVisible = !currentAbilityInfo.abilityCanBeShownOnWheelSelection;
}
} else {
playerAbilitiesUISystem.abilitySlotInfo newAbilitySlotInfo = abilitySlotInfoList [i];
newAbilitySlotInfo.slotVisible = false;
}
}
for (int i = 0; i < abilitySlotInfoList.Count; i++) {
playerAbilitiesUISystem.abilitySlotInfo newAbilitySlotInfo = abilitySlotInfoList [i];
if (newAbilitySlotInfo.slot.activeSelf != newAbilitySlotInfo.slotVisible) {
newAbilitySlotInfo.slot.SetActive (newAbilitySlotInfo.slotVisible);
}
}
}
public void resetScroll (Scrollbar scrollBarToReset)
{
StartCoroutine (resetScrollCoroutine (scrollBarToReset));
}
IEnumerator resetScrollCoroutine (Scrollbar scrollBarToReset)
{
yield return new WaitForEndOfFrame ();
yield return new WaitForEndOfFrame ();
scrollBarToReset.value = 1;
}
public void resetInventorySlotsRectTransform ()
{
StartCoroutine (resetRectTransformCoroutine ());
}
IEnumerator resetRectTransformCoroutine ()
{
LayoutRebuilder.ForceRebuildLayoutImmediate (fullAbilitiesUIEditorContent.GetComponent<RectTransform> ());
yield return new WaitForEndOfFrame ();
yield return new WaitForEndOfFrame ();
if (fullAbilitiesUIEditorListScrollRect != null) {
fullAbilitiesUIEditorListScrollRect.verticalNormalizedPosition = 1;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b42a2524b96b05645a6e19aa260dadd2
timeCreated: 1629875598
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/playerAbilitiesUIEditorSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 00eda0f186a583548baaab988b73b1a8
timeCreated: 1579415125
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/playerAbilitiesUISystem.cs
uploadId: 814740

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class simpleAimAndThrowObjectState : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 7daf1755bfa1baf4283b3dffb185000b
timeCreated: 1715258794
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/simpleAimAndThrowObjectState.cs
uploadId: 814740

View File

@@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class simpleThrowFireWaveAbility : MonoBehaviour
{
public bool currentState;
public UnityEvent eventOnActivateState;
public UnityEvent eventOnDeactivateState;
public void toggleCurrentState ()
{
setCurrentState (!currentState);
}
public void setCurrentState (bool state)
{
if (currentState == state) {
return;
}
currentState = state;
if (currentState) {
eventOnActivateState.Invoke ();
} else {
eventOnDeactivateState.Invoke ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 94d02a4885cb6f8459e14a9dd4089f15
timeCreated: 1651174376
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/simpleThrowFireWaveAbility.cs
uploadId: 814740

View File

@@ -0,0 +1,778 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class staminaSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool useStaminaEnabled = true;
public bool showStaminaUIEnabled = true;
public Color regularStaminaColor;
public Color closeToEmptyStaminaColor;
public float closeToEmptyStaminaAmount;
public float staminaAmount;
[Space]
[Header ("Refill Settings")]
[Space]
public bool autoRefillStaminaEnabled = true;
public bool hideStaminaUIAfterDelayIfNoAutoRefillEnabled;
public float refillStaminaRate = 18;
public float refillStaminaDelayAfterUse;
public float refillStaminaDelayAfterEmpty;
public bool waitToStaminaFilledToUseAgain;
[Space]
[Header ("Stamina UI Settings")]
[Space]
public bool staminaObjectAlwaysActive;
public float timeToDisableStaminaObject;
public bool useFade;
public float fadeSpeed;
public float enabledAlphaValue;
public bool useSliderCircle = true;
[Space]
[Header ("Stamina States Settings")]
[Space]
public List<staminaStateInfo> staminaStateInfoList = new List<staminaStateInfo> ();
[Space]
[Header ("Debug")]
[Space]
public bool staminaEmpty;
public bool refillingStamina;
public bool usingStamina;
public bool staminaRefilled = true;
public bool staminaUsePaused;
public float totalStaminaRateAmount;
public float customRefillStaminaDelayAfterUse;
[Space]
[Header ("Components")]
[Space]
public bool UIElementsAssigned = true;
public Image circleStaminaSlider;
public Text staminaAmountText;
public GameObject staminaPanel;
public Slider regularStaminaSlider;
public CanvasGroup staminaCanvasGroup;
float originalStaminaAmount;
float lastTimeStaminaRefilled;
float lastTimeStaminaUsed;
Coroutine refillCoroutine;
bool staminaSliderHidden;
float auxStaminaAmount;
bool useStaminaStateOnce;
void Start ()
{
originalStaminaAmount = staminaAmount;
auxStaminaAmount = staminaAmount;
if (UIElementsAssigned) {
if (!staminaObjectAlwaysActive || !showStaminaUIEnabled || !useStaminaEnabled) {
if (staminaPanel.activeSelf) {
staminaPanel.SetActive (false);
}
}
regularStaminaColor.a = enabledAlphaValue;
closeToEmptyStaminaColor.a = enabledAlphaValue;
if (useSliderCircle) {
if (staminaAmountText != null) {
staminaAmountText.text = Mathf.RoundToInt (staminaAmount).ToString ();
}
circleStaminaSlider.color = regularStaminaColor;
} else {
regularStaminaSlider.maxValue = staminaAmount;
regularStaminaSlider.value = staminaAmount;
}
}
}
void FixedUpdate ()
{
if (!useStaminaEnabled) {
return;
}
if (!staminaObjectAlwaysActive) {
if (!refillingStamina) {
if (UIElementsAssigned && !staminaSliderHidden) {
bool updateUIStateResult = false;
updateUIStateResult = (!autoRefillStaminaEnabled || staminaRefilled);
if (!autoRefillStaminaEnabled && !staminaRefilled) {
if (hideStaminaUIAfterDelayIfNoAutoRefillEnabled) {
updateUIStateResult = true;
} else {
updateUIStateResult = false;
}
}
if (updateUIStateResult) {
if (Time.time > lastTimeStaminaRefilled + timeToDisableStaminaObject || useFade) {
if (useFade) {
staminaCanvasGroup.alpha -= Time.deltaTime / fadeSpeed;
if (staminaCanvasGroup.alpha <= 0) {
staminaSliderHidden = true;
}
} else {
if (!staminaSliderHidden) {
if (staminaPanel.activeSelf) {
staminaPanel.SetActive (false);
}
staminaSliderHidden = true;
}
}
}
}
}
}
}
if (autoRefillStaminaEnabled) {
if (!refillingStamina) {
if (!staminaRefilled && !usingStamina) {
if (Time.time > lastTimeStaminaUsed + refillStaminaDelayAfterUse && Time.time > lastTimeStaminaUsed + customRefillStaminaDelayAfterUse) {
if (!anyStaminaStateInUse ()) {
refillStamina (0);
}
}
}
}
}
if (!refillingStamina && usingStamina && !staminaUsePaused) {
useStaminaAmount (totalStaminaRateAmount * Time.fixedDeltaTime);
}
}
public bool anyStaminaStateInUse ()
{
for (int i = 0; i < staminaStateInfoList.Count; i++) {
if (staminaStateInfoList [i].staminaStateInUse) {
return true;
}
}
return false;
}
public void activeStaminaStateWithCustomAmount (string staminaName, float customAmountToUse, float newDelayAfterUse)
{
if (!useStaminaEnabled) {
return;
}
if (staminaEmpty && (waitToStaminaFilledToUseAgain || staminaAmount <= 0) || customAmountToUse <= 0) {
return;
}
for (int i = 0; i < staminaStateInfoList.Count; i++) {
staminaStateInfo currentStaminaStateInfoToCheck = staminaStateInfoList [i];
if (currentStaminaStateInfoToCheck.Name.Equals (staminaName)) {
if (!currentStaminaStateInfoToCheck.stateEnabled) {
return;
}
stopRefillCoroutine ();
refillingStamina = false;
staminaRefilled = false;
if (currentStaminaStateInfoToCheck.useCustomRefillStaminaDelayAfterUse) {
if (newDelayAfterUse > 0) {
if (newDelayAfterUse > customRefillStaminaDelayAfterUse) {
customRefillStaminaDelayAfterUse = newDelayAfterUse;
}
} else {
if (currentStaminaStateInfoToCheck.customRefillStaminaDelayAfterUse > customRefillStaminaDelayAfterUse) {
customRefillStaminaDelayAfterUse = currentStaminaStateInfoToCheck.customRefillStaminaDelayAfterUse;
}
}
} else {
if (newDelayAfterUse > 0) {
if (newDelayAfterUse > customRefillStaminaDelayAfterUse) {
customRefillStaminaDelayAfterUse = newDelayAfterUse;
}
} else {
customRefillStaminaDelayAfterUse = 0;
}
}
useStaminaAmount (customAmountToUse);
}
}
}
public void activeStaminaState (string staminaName)
{
if (!useStaminaEnabled) {
return;
}
if (staminaEmpty && (waitToStaminaFilledToUseAgain || staminaAmount <= 0)) {
for (int i = 0; i < staminaStateInfoList.Count; i++) {
staminaStateInfo currentStaminaStateInfoToCheck = staminaStateInfoList [i];
if (currentStaminaStateInfoToCheck.stateEnabled &&
!currentStaminaStateInfoToCheck.stateInPause &&
currentStaminaStateInfoToCheck.Name.Equals (staminaName)) {
currentStaminaStateInfoToCheck.eventOnStaminaEmpty.Invoke ();
return;
}
}
return;
}
int stateIndex = staminaStateInfoList.FindIndex (s => s.Name == staminaName);
if (stateIndex > -1) {
staminaStateInfo currentStaminaStateInfoToCheck = staminaStateInfoList [stateIndex];
if (!currentStaminaStateInfoToCheck.stateInPause) {
if (!currentStaminaStateInfoToCheck.stateEnabled) {
return;
}
if (!useStaminaStateOnce) {
currentStaminaStateInfoToCheck.staminaStateInUse = true;
}
totalStaminaRateAmount += currentStaminaStateInfoToCheck.staminaUseRate;
if (useStaminaStateOnce) {
useStaminaAmount (currentStaminaStateInfoToCheck.staminaAmountToUseOnce);
}
stopRefillCoroutine ();
refillingStamina = false;
staminaRefilled = false;
if (currentStaminaStateInfoToCheck.useCustomRefillStaminaDelayAfterUse) {
if (currentStaminaStateInfoToCheck.customRefillStaminaDelayAfterUse > customRefillStaminaDelayAfterUse) {
customRefillStaminaDelayAfterUse = currentStaminaStateInfoToCheck.customRefillStaminaDelayAfterUse;
}
} else {
customRefillStaminaDelayAfterUse = 0;
}
if (!useStaminaStateOnce) {
usingStamina = true;
}
}
}
}
public void useStaminaStateByName (string staminaName)
{
useStaminaStateOnce = true;
activeStaminaState (staminaName);
useStaminaStateOnce = false;
}
public void setStaminaStateAsPaused (string staminaName)
{
setStaminaPausedState (true, staminaName);
}
public void setStaminaStateAsNotPaused (string staminaName)
{
setStaminaPausedState (false, staminaName);
}
public void setStaminaPausedState (bool state, string staminaName)
{
if (!useStaminaEnabled) {
return;
}
int stateIndex = staminaStateInfoList.FindIndex (s => s.Name == staminaName);
if (stateIndex > -1) {
staminaStateInfo currentStaminaStateInfoToCheck = staminaStateInfoList [stateIndex];
currentStaminaStateInfoToCheck.stateInPause = state;
if (state) {
if (currentStaminaStateInfoToCheck.stopStaminaStateIfPaused && currentStaminaStateInfoToCheck.staminaStateInUse) {
disableStaminaState (staminaName);
}
}
}
}
public void useAllRemainStamina ()
{
if (staminaAmount == 0) {
return;
}
useStaminaAmountExternally (staminaAmount);
}
public void useStaminaAmountExternally (float amount)
{
if (!useStaminaEnabled) {
return;
}
if (amount <= 0) {
return;
}
stopRefillCoroutine ();
refillingStamina = false;
staminaRefilled = false;
customRefillStaminaDelayAfterUse = 1;
useStaminaAmount (amount);
}
public void setCustomRefillStaminaDelayAfterUseValue (float newValue)
{
if (!useStaminaEnabled) {
return;
}
customRefillStaminaDelayAfterUse = newValue;
}
void useStaminaAmount (float amount)
{
lastTimeStaminaUsed = Time.time;
if (UIElementsAssigned && showStaminaUIEnabled) {
if (!staminaPanel.activeSelf) {
staminaPanel.SetActive (true);
}
}
if (useFade) {
setStaminaSliderAlphaValue (enabledAlphaValue);
}
staminaSliderHidden = false;
staminaAmount -= amount;
if (staminaAmount < 0) {
staminaAmount = 0;
}
if (UIElementsAssigned) {
if (useSliderCircle) {
if (staminaAmount <= closeToEmptyStaminaAmount) {
circleStaminaSlider.color = closeToEmptyStaminaColor;
}
circleStaminaSlider.fillAmount = staminaAmount / originalStaminaAmount;
} else {
regularStaminaSlider.value = staminaAmount;
}
if (staminaAmountText != null) {
staminaAmountText.text = Mathf.RoundToInt (staminaAmount).ToString ();
}
}
auxStaminaAmount = staminaAmount;
if (staminaAmount <= 0) {
setStaminaRefilledOrEmptyOnStateList (false);
staminaEmpty = true;
if (autoRefillStaminaEnabled) {
if (!anyStaminaStateInUse ()) {
refillStamina (refillStaminaDelayAfterEmpty);
}
} else {
lastTimeStaminaRefilled = Time.time;
}
}
}
public void disableStaminaState (string staminaName)
{
if (!useStaminaEnabled) {
return;
}
for (int i = 0; i < staminaStateInfoList.Count; i++) {
staminaStateInfo currentStaminaStateInfoToCheck = staminaStateInfoList [i];
if (currentStaminaStateInfoToCheck.stateEnabled) {
if (currentStaminaStateInfoToCheck.Name.Equals (staminaName)) {
currentStaminaStateInfoToCheck.staminaStateInUse = false;
totalStaminaRateAmount -= currentStaminaStateInfoToCheck.staminaUseRate;
if (currentStaminaStateInfoToCheck.useCustomRefillStaminaDelayAfterUse) {
if (currentStaminaStateInfoToCheck.customRefillStaminaDelayAfterUse > customRefillStaminaDelayAfterUse) {
customRefillStaminaDelayAfterUse = currentStaminaStateInfoToCheck.customRefillStaminaDelayAfterUse;
}
} else {
customRefillStaminaDelayAfterUse = 0;
}
}
}
}
if (totalStaminaRateAmount <= 0) {
totalStaminaRateAmount = 0;
usingStamina = false;
}
}
public void disableCurrentStaminaState ()
{
if (!useStaminaEnabled) {
return;
}
if (usingStamina || anyStaminaStateInUse ()) {
for (int i = 0; i < staminaStateInfoList.Count; i++) {
if (staminaStateInfoList [i].staminaStateInUse) {
disableStaminaState (staminaStateInfoList [i].Name);
return;
}
}
}
}
public void refillStamina (float refillDelay)
{
stopRefillCoroutine ();
refillCoroutine = StartCoroutine (refillStaminaCoroutine (refillDelay));
}
public void stopRefillCoroutine ()
{
if (refillCoroutine != null) {
StopCoroutine (refillCoroutine);
}
}
IEnumerator refillStaminaCoroutine (float refillDelay)
{
refillingStamina = true;
WaitForSeconds delay = new WaitForSeconds (refillDelay);
yield return delay;
if (!waitToStaminaFilledToUseAgain) {
setStaminaRefilledOrEmptyOnStateList (true);
}
while (staminaAmount < originalStaminaAmount) {
staminaAmount += Time.deltaTime * refillStaminaRate;
if (UIElementsAssigned) {
if (useSliderCircle) {
circleStaminaSlider.fillAmount = staminaAmount / originalStaminaAmount;
} else {
regularStaminaSlider.value = staminaAmount;
}
}
updateStaminaState ();
yield return null;
}
if (waitToStaminaFilledToUseAgain) {
setStaminaRefilledOrEmptyOnStateList (true);
}
refillingStamina = false;
lastTimeStaminaRefilled = Time.time;
staminaRefilled = true;
staminaEmpty = false;
totalStaminaRateAmount = 0;
}
public void getStamina (float amount)
{
if (!useStaminaEnabled) {
return;
}
if (!waitToStaminaFilledToUseAgain) {
setStaminaRefilledOrEmptyOnStateList (true);
}
staminaAmount += amount;
updateStaminaState ();
if (waitToStaminaFilledToUseAgain) {
setStaminaRefilledOrEmptyOnStateList (true);
}
staminaEmpty = false;
}
public void refillFullStamina ()
{
if (!useStaminaEnabled) {
return;
}
getStamina (originalStaminaAmount);
}
void updateStaminaState ()
{
if (!useStaminaEnabled) {
return;
}
if (UIElementsAssigned) {
if (useSliderCircle) {
circleStaminaSlider.fillAmount = staminaAmount / originalStaminaAmount;
} else {
regularStaminaSlider.value = staminaAmount;
}
if (staminaAmountText != null) {
staminaAmountText.text = Mathf.RoundToInt (staminaAmount).ToString ();
}
if (staminaAmount > closeToEmptyStaminaAmount) {
circleStaminaSlider.color = regularStaminaColor;
}
}
if (staminaAmount >= originalStaminaAmount) {
staminaAmount = originalStaminaAmount;
}
auxStaminaAmount = staminaAmount;
}
public void setStaminaSliderAlphaValue (float value)
{
if (UIElementsAssigned) {
staminaCanvasGroup.alpha = value;
}
}
public void increaseTotalStaminaAmount (float extraValue)
{
staminaAmount = originalStaminaAmount + extraValue;
originalStaminaAmount = staminaAmount;
auxStaminaAmount = staminaAmount;
if (UIElementsAssigned) {
if (!useSliderCircle) {
regularStaminaSlider.maxValue = originalStaminaAmount;
}
}
}
public float getCurrentStaminaAmount ()
{
return staminaAmount;
}
public float getOriginalStaminaAmount ()
{
return originalStaminaAmount;
}
public void initializeStaminaAmount (float newValue)
{
staminaAmount = newValue;
}
public void updateStaminaAmountWithoutUpdatingStatManager (int statId, float amount)
{
staminaAmount = amount;
}
public void updateRefillStaminaRateAmountWithoutUpdatingStatManager (int statId, float amount)
{
refillStaminaRate = amount;
}
public void increaseTotalRefillStaminaRate (float extraValue)
{
refillStaminaRate = refillStaminaRate + extraValue;
}
public void initializeRefillStaminaRate (float newValue)
{
refillStaminaRate = newValue;
}
public void setStaminaUsePausedState (bool state)
{
staminaUsePaused = state;
}
public void setStaminaRefilledOrEmptyOnStateList (bool state)
{
for (int i = 0; i < staminaStateInfoList.Count; i++) {
staminaStateInfo currentStaminaStateInfoToCheck = staminaStateInfoList [i];
if (currentStaminaStateInfoToCheck.stateEnabled) {
if (state) {
currentStaminaStateInfoToCheck.eventOnStaminaRefilled.Invoke ();
} else {
currentStaminaStateInfoToCheck.eventOnStaminaEmpty.Invoke ();
}
}
}
}
public float getStaminaAmountToLimit ()
{
return originalStaminaAmount - auxStaminaAmount;
}
public void addAuxStaminaAmount (float amount)
{
auxStaminaAmount += amount;
}
public void setUseStaminaEnabledState (bool state)
{
useStaminaEnabled = state;
}
public void setShowStaminaUIEnabledState (bool state)
{
showStaminaUIEnabled = state;
if (!showStaminaUIEnabled) {
if (GKC_Utils.isApplicationPlaying ()) {
if (UIElementsAssigned) {
if (staminaPanel.activeSelf) {
staminaPanel.SetActive (false);
}
}
}
}
}
public void setShowStaminaUIEnabledStateOnEditor (bool state)
{
setShowStaminaUIEnabledState (state);
updateComponent ();
}
public void setUseStaminaEnabledStateFromEditor (bool state)
{
setUseStaminaEnabledState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Stamina System", gameObject);
}
[System.Serializable]
public class staminaStateInfo
{
[Header ("Main Settings")]
[Space]
public string Name;
public bool stateEnabled = true;
public float staminaUseRate;
public float staminaAmountToUseOnce;
[Space]
[Header ("Other Settings")]
[Space]
public bool useCustomRefillStaminaDelayAfterUse;
public float customRefillStaminaDelayAfterUse;
public bool stopStaminaStateIfPaused;
[Space]
[Header ("Debug")]
[Space]
public bool staminaStateInUse;
public bool stateInPause;
[Space]
[Header ("Event Settings")]
[Space]
public UnityEvent eventOnStaminaEmpty;
public UnityEvent eventOnStaminaRefilled;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 9c7ca008fffe53c4792cdaec428b4a2b
timeCreated: 1564185174
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/staminaSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,319 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class throwObjectTrayectorySystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool throwObjectEnabled = true;
public LayerMask layerToCheckThrowObject;
public float maxRaycastDistance = 30;
public bool useInfiniteRaycastDistance;
public bool useMaxDistanceWhenNoSurfaceFound;
public float maxDistanceWhenNoSurfaceFound;
[Space]
public Transform throwPosition;
[Space]
public GameObject objectToThrow;
[Space]
[Header ("Other Settings")]
[Space]
public bool addLaunchObjectComponent;
public bool addGrabbedObjectStateComponent;
public bool rotateObjectTowardThrowDirection;
public bool checkIfLockedCameraActive;
public bool ignoreCollisionsWithPlayerEnabled = true;
[Space]
[Header ("Custom Throw Direction Settings")]
[Space]
public bool throwInCustomTransformDirection;
public Transform customTransformDirection;
public float customThrowDirectionAmount = 400;
[Space]
public bool useCustomThrowPosition;
public bool useCustomThrowLocalPosition;
public Vector3 customThrowPosition;
public Vector3 customThrowRotation;
[Space]
[Header ("Debug")]
[Space]
public bool showGizmo;
public GameObject currentObjectToThrow;
public Vector3 currentThrowSpeed;
[Space]
[Header ("Components")]
[Space]
public playerCamera mainPlayerCamera;
public GameObject playerControllerGameObject;
public Transform targetPositionTransform;
public Transform playerCameraGameObject;
public Transform mainCameraTransform;
public Collider playerCollider;
Rigidbody newObjectToThrowRigidbody;
RaycastHit hit;
Vector3 currentTargetPosition;
Vector3 raycastDirection;
Vector3 raycastOrigin;
Ray newRay;
public void setCurrentObjectToThrow (GameObject newObject)
{
if (throwPosition == null) {
throwPosition = transform;
}
currentObjectToThrow = newObject;
currentObjectToThrow.transform.SetParent (throwPosition);
Vector3 objectPosition = throwPosition.position;
if (useCustomThrowPosition) {
objectPosition = customThrowPosition;
}
if (useCustomThrowLocalPosition) {
currentObjectToThrow.transform.localPosition = objectPosition;
currentObjectToThrow.transform.localRotation = Quaternion.Euler (customThrowRotation);
} else {
currentObjectToThrow.transform.position = objectPosition;
}
currentObjectToThrow.SetActive (true);
newObjectToThrowRigidbody = currentObjectToThrow.GetComponent<Rigidbody> ();
if (newObjectToThrowRigidbody != null) {
newObjectToThrowRigidbody.isKinematic = true;
}
if (ignoreCollisionsWithPlayerEnabled) {
if (playerCollider != null) {
Component [] components = currentObjectToThrow.GetComponentsInChildren (typeof (Collider));
foreach (Collider child in components) {
Physics.IgnoreCollision (playerCollider, child, true);
}
}
}
}
public void instantiateObject ()
{
if (currentObjectToThrow == null) {
if (throwPosition == null) {
throwPosition = transform;
}
Vector3 objectPosition = throwPosition.position;
Quaternion objectRotation = throwPosition.rotation;
if (useCustomThrowPosition) {
objectPosition = customThrowPosition;
objectRotation = Quaternion.Euler (customThrowRotation);
}
GameObject newObjectToThrow = (GameObject)Instantiate (objectToThrow, objectPosition, objectRotation);
setCurrentObjectToThrow (newObjectToThrow);
}
}
public void calculateThrowDirection ()
{
raycastDirection = mainCameraTransform.TransformDirection (Vector3.forward);
raycastOrigin = mainCameraTransform.position;
bool isPlayerMovingOn3dWorld = !mainPlayerCamera.is2_5ViewActive ();
if (checkIfLockedCameraActive) {
if (mainPlayerCamera != null) {
if (!mainPlayerCamera.isCameraTypeFree () && isPlayerMovingOn3dWorld) {
newRay = mainPlayerCamera.getCameraRaycastDirection ();
raycastDirection = newRay.direction;
raycastOrigin = newRay.origin;
}
}
}
currentTargetPosition = targetPositionTransform.position;
float currentRaycastDistance = maxRaycastDistance;
if (useInfiniteRaycastDistance) {
currentRaycastDistance = Mathf.Infinity;
}
if (Physics.Raycast (raycastOrigin, raycastDirection, out hit, currentRaycastDistance, layerToCheckThrowObject)) {
currentTargetPosition = hit.point;
if (hit.collider == playerCollider) {
Vector3 newRaycastPosition = hit.point + raycastDirection * 0.2f;
if (Physics.Raycast (newRaycastPosition, raycastDirection, out hit, currentRaycastDistance, layerToCheckThrowObject)) {
currentTargetPosition = hit.point;
}
}
} else {
if (useMaxDistanceWhenNoSurfaceFound) {
currentTargetPosition = raycastOrigin + raycastDirection * maxDistanceWhenNoSurfaceFound;
} else {
if (Physics.Raycast (targetPositionTransform.position, raycastDirection, out hit, Mathf.Infinity, layerToCheckThrowObject)) {
currentTargetPosition = hit.point;
if (hit.collider == playerCollider) {
Vector3 newRaycastPosition = hit.point + raycastDirection * 0.2f;
if (Physics.Raycast (newRaycastPosition, raycastDirection, out hit, Mathf.Infinity, layerToCheckThrowObject)) {
currentTargetPosition = hit.point;
}
}
}
}
}
if (showGizmo) {
Debug.DrawLine (raycastOrigin, currentTargetPosition, Color.black, 5);
}
}
public void throwObject ()
{
if (throwPosition == null) {
throwPosition = transform;
}
if (currentObjectToThrow == null) {
instantiateObject ();
}
if (throwInCustomTransformDirection) {
currentThrowSpeed = customTransformDirection.forward * customThrowDirectionAmount;
} else {
currentThrowSpeed = getParableSpeed (currentObjectToThrow.transform.position, currentTargetPosition);
}
if (showGizmo) {
Debug.DrawLine (currentObjectToThrow.transform.position, currentTargetPosition, Color.black, 5);
}
if (rotateObjectTowardThrowDirection) {
currentObjectToThrow.transform.LookAt (currentTargetPosition);
}
currentObjectToThrow.transform.SetParent (null);
if (currentThrowSpeed == -Vector3.one) {
currentThrowSpeed = currentObjectToThrow.transform.forward * 100;
}
if (newObjectToThrowRigidbody != null) {
newObjectToThrowRigidbody.isKinematic = false;
newObjectToThrowRigidbody.AddForce (currentThrowSpeed, ForceMode.VelocityChange);
}
if (addLaunchObjectComponent) {
launchedObjects currentLaunchedObjects = currentObjectToThrow.GetComponent<launchedObjects> ();
if (currentLaunchedObjects == null) {
currentLaunchedObjects = currentObjectToThrow.AddComponent<launchedObjects> ();
}
currentLaunchedObjects.setCurrentPlayer (playerControllerGameObject);
}
if (addGrabbedObjectStateComponent) {
applyDamage.checkGravityRoomForGrabbedObject (currentObjectToThrow, playerControllerGameObject);
}
currentObjectToThrow = null;
}
//calculate the speed applied to the launched projectile to make a parable according to a hit point
Vector3 getParableSpeed (Vector3 origin, Vector3 target)
{
//get the distance between positions
Vector3 toTarget = target - origin;
Vector3 toTargetXZ = toTarget;
//remove the Y axis value
toTargetXZ -= playerCameraGameObject.transform.InverseTransformDirection (toTargetXZ).y * playerCameraGameObject.transform.up;
float y = playerCameraGameObject.transform.InverseTransformDirection (toTarget).y;
float xz = toTargetXZ.magnitude;
//get the velocity accoring to distance ang gravity
float t = GKC_Utils.distance (origin, target) / 20;
float v0y = y / t + 0.5f * Physics.gravity.magnitude * t;
float v0xz = xz / t;
//create result vector for calculated starting speeds
Vector3 result = toTargetXZ.normalized;
//get direction of xz but with magnitude 1
result *= v0xz;
// set magnitude of xz to v0xz (starting speed in xz plane), setting the local Y value
result -= playerCameraGameObject.transform.InverseTransformDirection (result).y * playerCameraGameObject.transform.up;
result += playerCameraGameObject.transform.up * v0y;
return result;
}
public void inputThrowObject ()
{
if (throwObjectEnabled) {
throwObject ();
}
}
public void inputInstantiateObject ()
{
if (throwObjectEnabled) {
instantiateObject ();
}
}
public void inputCalculateThrowDirection ()
{
if (throwObjectEnabled) {
calculateThrowDirection ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 012974608954bc94bb0bed804ee60fd5
timeCreated: 1581405430
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/throwObjectTrayectorySystem.cs
uploadId: 814740

View File

@@ -0,0 +1,77 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class wallRunningZoneSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool wallRunningZoneActive = true;
public bool wallRunningEnabled = true;
public bool autoUseDownMovementOnWallRunningActive;
public bool autoUseStopWallRunnigAfterDelay;
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!wallRunningZoneActive) {
return;
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior wallRunningExternalControllerBehavior = currentPlayerComponentsManager.getWallRunningExternalControllerBehavior ();
if (wallRunningExternalControllerBehavior != null) {
wallRunningSystem currentwallRunningSystem = wallRunningExternalControllerBehavior.GetComponent<wallRunningSystem> ();
currentwallRunningSystem.setWallRunningEnabledState (wallRunningEnabled);
currentwallRunningSystem.setAutoUseDownMovementOnWallRunningActiveState (autoUseDownMovementOnWallRunningActive);
currentwallRunningSystem.setAutoUseStopWallRunningAfterDelayState (autoUseStopWallRunnigAfterDelay);
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior wallRunningExternalControllerBehavior = currentPlayerComponentsManager.getWallRunningExternalControllerBehavior ();
if (wallRunningExternalControllerBehavior != null) {
wallRunningSystem currentwallRunningSystem = wallRunningExternalControllerBehavior.GetComponent<wallRunningSystem> ();
currentwallRunningSystem.setOriginalWallRunningEnabledState ();
currentwallRunningSystem.setAutoUseDownMovementOnWallRunningActiveState (false);
currentwallRunningSystem.setAutoUseStopWallRunningAfterDelayState (false);
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 336369d399a5a194fb360ae47b635aa2
timeCreated: 1566312960
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Abilities System/wallRunningZoneSystem.cs
uploadId: 814740