add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f4bf552baf1d274783f699d48933df3
|
||||
folderAsset: yes
|
||||
timeCreated: 1584940566
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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> ();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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 ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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 ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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 ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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 ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user