add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66ff294393aeeb043ad462eecfcfbe39
|
||||
folderAsset: yes
|
||||
timeCreated: 1538634113
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class attachmentIconInfo : MonoBehaviour
|
||||
{
|
||||
public attachmentIcon attachmentIconManager;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad9b408198411e54aaf771357b837bce
|
||||
timeCreated: 1528919236
|
||||
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/Weapons/Attachments/attachmentIconInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[System.Serializable]
|
||||
public class attachmentInfo
|
||||
{
|
||||
public string Name;
|
||||
public bool attachmentEnabled = true;
|
||||
public bool attachmentActive;
|
||||
public bool currentlyActive;
|
||||
|
||||
public bool attachmentUseHUD;
|
||||
|
||||
public bool onlyEnabledWhileCarrying;
|
||||
public GameObject attachmentGameObject;
|
||||
public UnityEvent activateEvent;
|
||||
public UnityEvent deactivateEvent;
|
||||
public attachmentSlot attachmentSlotManager;
|
||||
public AudioClip selectAttachmentSound;
|
||||
public AudioElement selectAttachmentAudioElement;
|
||||
|
||||
public bool useEventOnPress;
|
||||
public UnityEvent eventOnPress;
|
||||
public bool useEventOnPressDown;
|
||||
public UnityEvent eventOnPressDown;
|
||||
public bool useEventOnPressUp;
|
||||
public UnityEvent eventOnPressUp;
|
||||
|
||||
public bool useEventHandPosition;
|
||||
public UnityEvent activateEventHandPosition;
|
||||
public UnityEvent deactivateEventHandPosition;
|
||||
|
||||
public bool useAttachmentHoverInfo;
|
||||
[TextArea (3, 10)] public string attachmentHoverInfo;
|
||||
|
||||
public void InitializeAudioElements ()
|
||||
{
|
||||
if (selectAttachmentSound != null) {
|
||||
selectAttachmentAudioElement.clip = selectAttachmentSound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class attachmentIcon
|
||||
{
|
||||
public RectTransform iconRectTransform;
|
||||
public Text attachmentNumberText;
|
||||
public Text attachmentNameText;
|
||||
public Transform attachmentContent;
|
||||
public attachmentSlot notAttachmentButton;
|
||||
|
||||
public Transform attachmentPointTransform;
|
||||
public Transform attachmentLineTransform;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class attachmentSlot
|
||||
{
|
||||
public Button slotButton;
|
||||
public Text attachmentNameText;
|
||||
public GameObject attachmentSelectedIcon;
|
||||
|
||||
public RectTransform attachmentHoverInfoPanelPosition;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 205bebad72e06454b9aaf948afc3e049
|
||||
timeCreated: 1529340625
|
||||
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/Weapons/Attachments/attachmentInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class attachmentSlotInfo : MonoBehaviour
|
||||
{
|
||||
public attachmentSlot attachmentSlotManager;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2316ce6373a7288428c3ccdf55d6a187
|
||||
timeCreated: 1528920416
|
||||
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/Weapons/Attachments/attachmentSlotInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,377 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class laserAttachment : laser
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public LayerMask layer;
|
||||
|
||||
public bool laserEnabled = true;
|
||||
public float laserRotationSpeed = 20;
|
||||
public bool alwaysLookInCameraDirection;
|
||||
|
||||
public bool useLaserDot;
|
||||
public bool useLaserDotIconOnScreen;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool sendMessageOnContact;
|
||||
public UnityEvent contantFunctions = new UnityEvent ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool sameObjectFound;
|
||||
public bool hittingSurface;
|
||||
|
||||
public bool laserCanBeUsed;
|
||||
|
||||
public Vector3 hitPointOffset;
|
||||
public Transform offsetReference;
|
||||
|
||||
public bool laserDotActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerWeaponsManager weaponsManager;
|
||||
public playerWeaponSystem weaponManager;
|
||||
public IKWeaponSystem IkWeaponManager;
|
||||
|
||||
public Transform mainCameraTransform;
|
||||
|
||||
public GameObject laserDot;
|
||||
public laserDotOnScreenSystem mainLaserDotOnScreenSystem;
|
||||
|
||||
RaycastHit hit;
|
||||
Vector3 hitPointPosition;
|
||||
float rayDistance;
|
||||
|
||||
GameObject lastObjectDetected;
|
||||
|
||||
Quaternion targetRotation;
|
||||
Vector3 direction;
|
||||
|
||||
GameObject objectDetectedByCamera;
|
||||
GameObject objectDetectedByLaser;
|
||||
|
||||
Vector3 hitPointCameraDirection;
|
||||
|
||||
Vector3 currentHitNormal;
|
||||
|
||||
Vector3 currentTransformPosition;
|
||||
|
||||
Vector3 currentCameraPosition;
|
||||
|
||||
Vector3 currentForwardDirection;
|
||||
|
||||
bool useForwardDirectionOnLaserAttachments;
|
||||
|
||||
bool firstPersonActive;
|
||||
|
||||
bool firstPersonViewFirstCheck;
|
||||
|
||||
bool mainCameraTransformLocated;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
rayDistance = Mathf.Infinity;
|
||||
}
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForSeconds (0.00001f);
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
if (laserEnabled) {
|
||||
|
||||
useForwardDirectionOnLaserAttachments = weaponsManager.isUseForwardDirectionOnLaserAttachmentsActive ();
|
||||
|
||||
if (mainCameraTransformLocated) {
|
||||
|
||||
laserCanBeUsed = !weaponManager.weaponIsMoving () &&
|
||||
(weaponManager.aimingInThirdPerson || weaponManager.carryingWeaponInFirstPerson) &&
|
||||
!weaponsManager.isEditinWeaponAttachments () &&
|
||||
(!weaponManager.isWeaponOnRecoil () || alwaysLookInCameraDirection) &&
|
||||
!IkWeaponManager.isWeaponSurfaceDetected () &&
|
||||
!IkWeaponManager.isWeaponInRunPosition () &&
|
||||
!IkWeaponManager.isMeleeAtacking ();
|
||||
|
||||
currentTransformPosition = transform.position;
|
||||
|
||||
currentCameraPosition = mainCameraTransform.position;
|
||||
|
||||
if (laserCanBeUsed) {
|
||||
if (Physics.Raycast (currentCameraPosition, mainCameraTransform.TransformDirection (Vector3.forward), out hit, rayDistance, 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;
|
||||
|
||||
if (!IkWeaponManager.isWeaponSurfaceDetected ()) {
|
||||
hitPointCameraDirection = direction;
|
||||
} else {
|
||||
hitPointCameraDirection = hit.point - currentCameraPosition;
|
||||
hitPointCameraDirection = hitPointCameraDirection / hitPointCameraDirection.magnitude;
|
||||
}
|
||||
|
||||
currentHitNormal = hit.normal;
|
||||
} else {
|
||||
targetRotation = Quaternion.LookRotation (mainCameraTransform.forward);
|
||||
|
||||
objectDetectedByCamera = null;
|
||||
|
||||
direction = laserDistance * currentTransformPosition + mainCameraTransform.position;
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
mainCameraTransform = weaponManager.getMainCameraTransform ();
|
||||
|
||||
mainCameraTransformLocated = mainCameraTransform != null;
|
||||
}
|
||||
|
||||
lRenderer.positionCount = 2;
|
||||
lRenderer.SetPosition (0, currentTransformPosition);
|
||||
|
||||
if (useForwardDirectionOnLaserAttachments) {
|
||||
currentForwardDirection = transform.forward;
|
||||
} else {
|
||||
currentForwardDirection = hitPointCameraDirection;
|
||||
}
|
||||
|
||||
if (Physics.Raycast (currentTransformPosition, currentForwardDirection, out hit, rayDistance, layer)) {
|
||||
hittingSurface = true;
|
||||
|
||||
hitPointPosition = hit.point;
|
||||
|
||||
if (hitPointOffset != Vector3.zero && offsetReference != null) {
|
||||
hitPointPosition += Vector3.Scale (offsetReference.up, hitPointOffset);
|
||||
}
|
||||
|
||||
if (hit.collider.gameObject != lastObjectDetected) {
|
||||
lastObjectDetected = hit.collider.gameObject;
|
||||
|
||||
if (sendMessageOnContact) {
|
||||
if (contantFunctions.GetPersistentEventCount () > 0) {
|
||||
contantFunctions.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentHitNormal = hit.normal;
|
||||
} else {
|
||||
//the laser does not hit anything, so disable the shield if it was enabled
|
||||
hittingSurface = false;
|
||||
}
|
||||
|
||||
if (Physics.Raycast (currentTransformPosition, hitPointCameraDirection, out hit, rayDistance, layer)) {
|
||||
objectDetectedByLaser = hit.collider.gameObject;
|
||||
|
||||
// Debug.DrawLine (transform.position, hit.point, Color.white, 2);
|
||||
} else {
|
||||
objectDetectedByLaser = null;
|
||||
}
|
||||
|
||||
if (objectDetectedByCamera == objectDetectedByLaser || (objectDetectedByCamera == null && objectDetectedByLaser == null)) {
|
||||
sameObjectFound = true;
|
||||
} else {
|
||||
sameObjectFound = false;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (mainLaserDotOnScreenSystem != null) {
|
||||
mainLaserDotOnScreenSystem.setLasetDotIconActiveState (true);
|
||||
}
|
||||
} else {
|
||||
laserDot.SetActive (true);
|
||||
}
|
||||
|
||||
laserDotActive = true;
|
||||
}
|
||||
|
||||
laserDot.transform.position = hitPointPosition + 0.01f * currentHitNormal;
|
||||
|
||||
laserDot.transform.rotation = Quaternion.LookRotation (currentHitNormal, transform.up);
|
||||
|
||||
if (weaponManager.carryingWeaponInFirstPerson != firstPersonActive || !firstPersonViewFirstCheck) {
|
||||
firstPersonActive = weaponManager.carryingWeaponInFirstPerson;
|
||||
|
||||
if (firstPersonActive) {
|
||||
laserDot.transform.SetParent (transform.parent);
|
||||
|
||||
weaponsManager.setWeaponPartLayerFromCameraView (laserDot, true);
|
||||
} else {
|
||||
laserDot.transform.SetParent (weaponsManager.getTemporalParentForWeapons ());
|
||||
|
||||
weaponsManager.setWeaponPartLayerFromCameraView (laserDot, false);
|
||||
}
|
||||
|
||||
firstPersonViewFirstCheck = true;
|
||||
}
|
||||
|
||||
if (useLaserDotIconOnScreen) {
|
||||
if (mainLaserDotOnScreenSystem != null) {
|
||||
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) {
|
||||
if (mainLaserDotOnScreenSystem != null) {
|
||||
mainLaserDotOnScreenSystem.setLasetDotIconActiveState (false);
|
||||
}
|
||||
} else {
|
||||
laserDot.SetActive (false);
|
||||
}
|
||||
|
||||
laserDotActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setLaserEnabledState (bool state)
|
||||
{
|
||||
laserEnabled = state;
|
||||
|
||||
initializeComponents ();
|
||||
|
||||
if (laserEnabled) {
|
||||
if (weaponsManager == null) {
|
||||
weaponsManager = weaponManager.getPlayerWeaponsManger ();
|
||||
}
|
||||
}
|
||||
|
||||
if (lRenderer) {
|
||||
lRenderer.enabled = state;
|
||||
}
|
||||
|
||||
transform.localRotation = Quaternion.identity;
|
||||
|
||||
if (useLaserDot) {
|
||||
if (!laserEnabled) {
|
||||
if (useLaserDotIconOnScreen) {
|
||||
if (mainLaserDotOnScreenSystem != null) {
|
||||
mainLaserDotOnScreenSystem.setLasetDotIconActiveState (false);
|
||||
}
|
||||
} else {
|
||||
laserDot.SetActive (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
firstPersonViewFirstCheck = false;
|
||||
|
||||
enableAttachmentOnEnableFunctionActive = false;
|
||||
|
||||
if (laserEnabled) {
|
||||
if (gameObject.activeInHierarchy) {
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
} else {
|
||||
enableAttachmentOnEnableFunctionActive = true;
|
||||
}
|
||||
} else {
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
bool enableAttachmentOnEnableFunctionActive;
|
||||
|
||||
void OnEnable ()
|
||||
{
|
||||
if (enableAttachmentOnEnableFunctionActive) {
|
||||
if (laserEnabled) {
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
}
|
||||
|
||||
enableAttachmentOnEnableFunctionActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool componentsInitialized;
|
||||
|
||||
void initializeComponents ()
|
||||
{
|
||||
if (componentsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (weaponManager != null) {
|
||||
GameObject playerControllerGameObject = weaponManager.getPlayerWeaponsManger ().gameObject;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = playerControllerGameObject.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
|
||||
mainCameraTransform = mainPlayerComponentsManager.getPlayerCamera ().getCameraTransform ();
|
||||
|
||||
mainCameraTransformLocated = mainCameraTransform != null;
|
||||
}
|
||||
}
|
||||
|
||||
componentsInitialized = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 140e5806eadf9b54c8c381955a4411c0
|
||||
timeCreated: 1528833896
|
||||
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/Weapons/Attachments/laserAttachment.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,108 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class laserDotOnScreenSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool laserDotEnabled = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool laserDotActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public GameObject laserDotIcon;
|
||||
|
||||
public RectTransform laserDotIconRectTransform;
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
public playerCamera mainPlayerCamera;
|
||||
|
||||
public bool targetOnScreen;
|
||||
|
||||
Vector3 currentIconPosition;
|
||||
|
||||
Vector3 screenPoint;
|
||||
|
||||
float screenWidth;
|
||||
float screenHeight;
|
||||
|
||||
Vector2 iconPosition2d;
|
||||
|
||||
Vector2 mainCanvasSizeDelta;
|
||||
Vector2 halfMainCanvasSizeDelta;
|
||||
|
||||
bool usingScreenSpaceCamera;
|
||||
|
||||
public void updateLaserDotPosition (Vector3 hitPoint)
|
||||
{
|
||||
currentIconPosition = hitPoint;
|
||||
|
||||
screenWidth = Screen.width;
|
||||
screenHeight = Screen.height;
|
||||
|
||||
if (usingScreenSpaceCamera) {
|
||||
screenPoint = mainCamera.WorldToViewportPoint (currentIconPosition);
|
||||
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1;
|
||||
} else {
|
||||
screenPoint = mainCamera.WorldToScreenPoint (currentIconPosition);
|
||||
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < screenWidth && screenPoint.y > 0 && screenPoint.y < screenHeight;
|
||||
}
|
||||
|
||||
if (targetOnScreen) {
|
||||
if (usingScreenSpaceCamera) {
|
||||
iconPosition2d = new Vector2 ((screenPoint.x * mainCanvasSizeDelta.x) - halfMainCanvasSizeDelta.x,
|
||||
(screenPoint.y * mainCanvasSizeDelta.y) - halfMainCanvasSizeDelta.y);
|
||||
|
||||
laserDotIconRectTransform.anchoredPosition = iconPosition2d;
|
||||
} else {
|
||||
laserDotIcon.transform.position = new Vector3 (screenPoint.x, screenPoint.y, 0);
|
||||
}
|
||||
|
||||
if (laserDotActive) {
|
||||
if (!laserDotIcon.activeSelf) {
|
||||
laserDotIcon.SetActive (true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (laserDotActive) {
|
||||
if (laserDotIcon.activeSelf) {
|
||||
laserDotIcon.SetActive (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setLasetDotIconActiveState (bool state)
|
||||
{
|
||||
if (!laserDotEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
laserDotActive = state;
|
||||
|
||||
if (laserDotActive) {
|
||||
mainCanvasSizeDelta = mainPlayerCamera.getMainCanvasSizeDelta ();
|
||||
halfMainCanvasSizeDelta = mainCanvasSizeDelta * 0.5f;
|
||||
usingScreenSpaceCamera = mainPlayerCamera.isUsingScreenSpaceCamera ();
|
||||
|
||||
if (mainCamera == null) {
|
||||
mainCamera = mainPlayerCamera.getMainCamera ();
|
||||
}
|
||||
}
|
||||
|
||||
if (laserDotIcon.activeSelf != laserDotActive) {
|
||||
laserDotIcon.SetActive (laserDotActive);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e571f4e8266e69e44b457b06d5ae9ca1
|
||||
timeCreated: 1607451876
|
||||
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/Weapons/Attachments/laserDotOnScreenSystem.cs
|
||||
uploadId: 814740
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2ab7f27ba2cb6f409e11fc0ab2a406f
|
||||
timeCreated: 1528834845
|
||||
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/Weapons/Attachments/weaponAttachmentSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class weaponsAttachmentUIManager : MonoBehaviour
|
||||
{
|
||||
public GameObject attachmentInfoGameObject;
|
||||
public GameObject attachmentSlotGameObject;
|
||||
|
||||
public GameObject weaponAttachmentsMenu;
|
||||
public Transform attachmentHoverInfoPanelGameObject;
|
||||
public Text attachmentHoverInfoText;
|
||||
|
||||
public Camera weaponsCamera;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 463bc182c376ce44ab822b6b59644ec1
|
||||
timeCreated: 1594768832
|
||||
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/Weapons/Attachments/weaponsAttachmentUIManager.cs
|
||||
uploadId: 814740
|
||||
411
Assets/Game Kit Controller/Scripts/Weapons/IKWeaponInfo.cs
Normal file
411
Assets/Game Kit Controller/Scripts/Weapons/IKWeaponInfo.cs
Normal file
@@ -0,0 +1,411 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
|
||||
[System.Serializable]
|
||||
public class IKWeaponInfo
|
||||
{
|
||||
public GameObject weapon;
|
||||
public Transform aimPosition;
|
||||
public Transform walkPosition;
|
||||
public Transform keepPosition;
|
||||
public Transform aimRecoilPosition;
|
||||
public Transform walkRecoilPosition;
|
||||
|
||||
public bool checkSurfaceCollision;
|
||||
public float collisionRayDistance = 0.54f;
|
||||
public float collisionMovementSpeed = 10;
|
||||
public Transform surfaceCollisionPosition;
|
||||
public Transform surfaceCollisionRayPosition;
|
||||
public bool hideCursorOnCollision;
|
||||
|
||||
public bool checkSurfaceOnlyOnAiming;
|
||||
public bool avoidShootOnSurfaceDetected;
|
||||
public bool avoidAimingIfSurfaceDetected;
|
||||
|
||||
public Transform lowerWeaponPosition;
|
||||
|
||||
public bool useSwayInfo = true;
|
||||
public bool useRunPosition;
|
||||
public float runMovementSpeed = 10;
|
||||
public Transform runPosition;
|
||||
public bool hideCursorOnRun;
|
||||
public bool useRunSwayInfo;
|
||||
|
||||
public bool useJumpPositions;
|
||||
public Transform jumpStartPosition;
|
||||
public Transform jumpEndPosition;
|
||||
public float jumpStartMovementSpeed = 3;
|
||||
public float jumpEndtMovementSpeed = 3;
|
||||
public float resetJumpMovementSped = 3;
|
||||
public float delayAtJumpEnd = 0.4f;
|
||||
|
||||
public bool useReloadMovement;
|
||||
public BezierSpline reloadSpline;
|
||||
public float reloadDuration = 1;
|
||||
public float reloadLookDirectionSpeed = 11;
|
||||
|
||||
public bool useNewFovOnRun;
|
||||
public float changeFovSpeed;
|
||||
public float newFovOnRun;
|
||||
|
||||
|
||||
|
||||
public bool useMeleeAttack;
|
||||
public bool useCustomMeleeAttackLayer;
|
||||
public LayerMask customMeleeAttackLayer;
|
||||
public bool useCapsuleRaycast;
|
||||
public Transform meleeAttackPosition;
|
||||
public float meleeAttackStartMovementSpeed;
|
||||
public float meleeAttackEndMovementSpeed;
|
||||
public float meleeAttackEndDelay;
|
||||
public Transform meleeAttackRaycastPosition;
|
||||
public float meleeAttackRaycastDistance;
|
||||
public float meleeAttackCapsuleDistance = 1.5f;
|
||||
public float meleeAttackRaycastRadius;
|
||||
public float meleeAttackDamageAmount;
|
||||
public bool meleeAttackIgnoreShield;
|
||||
public bool useMeleeAttackShakeInfo;
|
||||
public bool applyMeleeAtackForce;
|
||||
public float meleeAttackForceAmount;
|
||||
public ForceMode meleeAttackForceMode;
|
||||
public bool meleeAttackApplyForceToVehicles;
|
||||
public float meleAttackForceToVehicles;
|
||||
public bool useMeleeAttackSound;
|
||||
public AudioClip meleeAttackSurfaceSound;
|
||||
public AudioElement meleeAttackSurfaceAudioElement;
|
||||
public AudioClip meleeAttackAirSound;
|
||||
public AudioElement meleeAttackAirAudioElement;
|
||||
public bool useMeleeAttackParticles;
|
||||
public GameObject meleeAttackParticles;
|
||||
public bool canActivateReactionSystemTemporally;
|
||||
public int damageReactionID = -1;
|
||||
|
||||
public int damageTypeID = -1;
|
||||
|
||||
public bool damageCanBeBlocked = true;
|
||||
|
||||
public bool useActionSystemForMeleeAttack;
|
||||
public string meleeAttackActionName;
|
||||
|
||||
public bool ignoreDamageValueOnLayer;
|
||||
public LayerMask layerToIgnoreDamage;
|
||||
|
||||
|
||||
public bool checkObjectsToUseRemoteEventsOnDamage;
|
||||
public LayerMask layerToUseRemoteEventsOnDamage;
|
||||
|
||||
public bool useRemoteEvent;
|
||||
public List<string> remoteEventNameList;
|
||||
|
||||
public bool useRemoteEventToEnableParryInteraction;
|
||||
public List<string> remoteEventToEnableParryInteractionNameList;
|
||||
|
||||
public bool showMeleeAttackGizmo;
|
||||
|
||||
public bool hasAttachments;
|
||||
public Transform editAttachmentPosition;
|
||||
public Transform attachmentCameraPosition;
|
||||
|
||||
public GameObject leftHandMesh;
|
||||
public GameObject extraLeftHandMesh;
|
||||
|
||||
public Transform leftHandEditPosition;
|
||||
|
||||
public Transform leftHandParent;
|
||||
public Transform extraLeftHandMeshParent;
|
||||
|
||||
public float editAttachmentMovementSpeed = 2;
|
||||
public float editAttachmentHandSpeed = 6;
|
||||
public bool usingSecondPositionForHand;
|
||||
public Transform secondPositionForHand;
|
||||
|
||||
public bool useSightPosition;
|
||||
public Transform sightPosition;
|
||||
public Transform sightRecoilPosition;
|
||||
|
||||
public bool canRunWhileCarrying = true;
|
||||
public bool canRunWhileAiming = true;
|
||||
public bool useNewCarrySpeed;
|
||||
public float newCarrySpeed;
|
||||
public bool useNewAimSpeed;
|
||||
public float newAimSpeed;
|
||||
|
||||
public bool deactivateIKIfNotAiming;
|
||||
public bool placeWeaponOnWalkPositionBeforeDeactivateIK = true;
|
||||
public List<Transform> deactivateIKDrawPath = new List<Transform> ();
|
||||
public Transform weaponPositionInHandForDeactivateIK;
|
||||
|
||||
public float drawWeaponMovementSpeed = 2;
|
||||
public float aimMovementSpeed;
|
||||
public bool weaponHasRecoil = true;
|
||||
public float recoilSpeed = 5;
|
||||
public float endRecoilSpeed = 4;
|
||||
public bool useExtraRandomRecoil;
|
||||
public bool useExtraRandomRecoilPosition = true;
|
||||
public Vector3 extraRandomRecoilPosition;
|
||||
public bool useExtraRandomRecoilRotation = true;
|
||||
public Vector3 extraRandomRecoilRotation;
|
||||
|
||||
public float resetWeaponPositionAfterReloadSpeed = 3;
|
||||
|
||||
public float resetWeaponPositionAfterActionSpeed = 5;
|
||||
|
||||
public float resumeWeaponIKPositionAfterActionSpeed = 8;
|
||||
|
||||
public bool useQuickDrawKeepWeapon;
|
||||
|
||||
public bool useBezierCurve;
|
||||
public BezierSpline spline;
|
||||
public float bezierDuration = 0.5f;
|
||||
public float lookDirectionSpeed = 11;
|
||||
|
||||
public List<Transform> keepPath = new List<Transform> ();
|
||||
public List<IKWeaponsPosition> handsInfo = new List<IKWeaponsPosition> ();
|
||||
public bool handsInPosition;
|
||||
|
||||
public bool useWeaponRotationPoint;
|
||||
public Transform weaponRotationPoint;
|
||||
public Transform weaponRotationPointHolder;
|
||||
public Transform weaponRotationPointHeadLookTarget;
|
||||
public weaponRotationPointInfo rotationPointInfo;
|
||||
public Transform weaponPivotPoint;
|
||||
|
||||
public bool useCrouchPosition;
|
||||
public Transform crouchPosition;
|
||||
public Transform crouchRecoilPosition;
|
||||
public float crouchMovementSpeed = 5;
|
||||
|
||||
public bool useHandle;
|
||||
[Range (0, 0.1f)] public float handleRadius;
|
||||
public Color handleGizmoColor;
|
||||
|
||||
public bool usePositionHandle = true;
|
||||
|
||||
public bool dualWeaponActive;
|
||||
|
||||
public bool usedOnRightHand;
|
||||
|
||||
public bool canBeUsedAsDualWeapon;
|
||||
public dualWeaponInfo rightHandDualWeaopnInfo;
|
||||
public dualWeaponInfo leftHandDualWeaponInfo;
|
||||
|
||||
public float changeOneOrTwoHandWieldSpeed = 5;
|
||||
|
||||
public bool usingWeaponAsOneHandWield;
|
||||
|
||||
public bool showSingleWeaponSettings;
|
||||
|
||||
public bool showDualWeaponSettings;
|
||||
|
||||
public bool useCustomThirdPersonAimActive;
|
||||
public string customDefaultThirdPersonAimRightStateName;
|
||||
public string customDefaultThirdPersonAimLeftStateName;
|
||||
|
||||
public bool useCustomThirdPersonAimCrouchActive;
|
||||
public string customDefaultThirdPersonAimRightCrouchStateName;
|
||||
public string customDefaultThirdPersonAimLeftCrouchStateName;
|
||||
|
||||
public bool useCustomThirdPersonWithoutAimActive;
|
||||
public string customDefaultThirdPersonWithoutAimRightStateName;
|
||||
public string customDefaultThirdPersonWithoutAimLeftStateName;
|
||||
|
||||
public bool useCustomThirdPersonWithoutAimCrouchActive;
|
||||
public string customDefaultThirdPersonWithoutAimRightCrouchStateName;
|
||||
public string customDefaultThirdPersonWithoutAimLeftCrouchStateName;
|
||||
|
||||
public bool useNewIdleID;
|
||||
public int newIdleID;
|
||||
|
||||
public bool useDrawKeepWeaponAnimation;
|
||||
public string drawWeaponActionName;
|
||||
public string keepWeaponActionName;
|
||||
|
||||
public float delayToPlaceWeaponOnHandOnDrawAnimation = 1;
|
||||
public float delayToPlaceWeaponOnKeepAnimation = 1;
|
||||
|
||||
public Vector3 FBAWalkPositionOffset;
|
||||
public Vector3 FBAWalkRotationOffset;
|
||||
|
||||
public Vector3 FBAWalkRecoilPositionOffset;
|
||||
public Vector3 FBAWalkRecoilRotationOffset;
|
||||
|
||||
public Vector3 FBARunPositionOffset;
|
||||
public Vector3 FBARunRotationOffset;
|
||||
|
||||
public Vector3 FBAAimPositionOffset;
|
||||
public Vector3 FBAAimRotationOffset;
|
||||
|
||||
public Vector3 FBAAimRecoilPositionOffset;
|
||||
public Vector3 FBAAimRecoilRotationOffset;
|
||||
|
||||
public Vector3 FBACrouchPositionOffset;
|
||||
public Vector3 FBACrouchRotationOffset;
|
||||
|
||||
public Vector3 FBACrouchRecoilPositionOffset;
|
||||
public Vector3 FBACrouchRecoilRotationOffset;
|
||||
|
||||
public Vector3 FBAJumpStartPositionOffset;
|
||||
public Vector3 FBAJumpStartRotationOffset;
|
||||
|
||||
public Vector3 FBAJumpEndPositionOffset;
|
||||
public Vector3 FBAJumpEndRotationOffset;
|
||||
|
||||
public Vector3 FBAObstaclePositionOffset;
|
||||
public Vector3 FBAObstacleRotationOffset;
|
||||
|
||||
|
||||
public float FBAMoveWalkPositionSpeed = 20;
|
||||
|
||||
public bool overrideFBAValuesForOffset;
|
||||
|
||||
public float FBARandomRecoilWalkPositionMultiplier = 1;
|
||||
public float FBARandomRecoilAimPositionMultiplier = 1;
|
||||
|
||||
public bool useFBARunPosition;
|
||||
|
||||
public bool ignoreIKElbowsOnFBA;
|
||||
|
||||
public List<FBAAimInfo> FBAAimInfoList = new List<FBAAimInfo> ();
|
||||
|
||||
public void InitializeAudioElements ()
|
||||
{
|
||||
if (meleeAttackSurfaceSound != null) {
|
||||
meleeAttackSurfaceAudioElement.clip = meleeAttackSurfaceSound;
|
||||
}
|
||||
|
||||
if (meleeAttackAirSound != null) {
|
||||
meleeAttackAirAudioElement.clip = meleeAttackAirSound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class FBAAimInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public Vector3 FBAAimPositionOffset;
|
||||
public Vector3 FBAAimRotationOffset;
|
||||
|
||||
public Vector3 FBAAimRecoilPositionOffset;
|
||||
public Vector3 FBAAimRecoilRotationOffset;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class dualWeaponInfo
|
||||
{
|
||||
public Transform aimPosition;
|
||||
public Transform aimRecoilPosition;
|
||||
|
||||
public Transform walkPosition;
|
||||
public Transform walkRecoilPosition;
|
||||
|
||||
public Transform keepPosition;
|
||||
|
||||
public Transform crouchPosition;
|
||||
public Transform crouchRecoilPosition;
|
||||
|
||||
public float collisionRayDistance = 0.54f;
|
||||
public Transform surfaceCollisionPosition;
|
||||
public Transform surfaceCollisionRayPosition;
|
||||
|
||||
public Transform lowerWeaponPosition;
|
||||
public Transform runPosition;
|
||||
|
||||
public Transform jumpStartPosition;
|
||||
public Transform jumpEndPosition;
|
||||
|
||||
public Transform meleeAttackPosition;
|
||||
public Transform meleeAttackRaycastPosition;
|
||||
|
||||
public GameObject firstPersonHandMesh;
|
||||
|
||||
public Transform editAttachmentPosition;
|
||||
public Transform attachmentCameraPosition;
|
||||
|
||||
public bool deactivateIKIfNotAiming;
|
||||
public List<Transform> deactivateIKDrawPath = new List<Transform> ();
|
||||
public Transform weaponPositionInHandForDeactivateIK;
|
||||
public bool placeWeaponOnWalkPositionBeforeDeactivateIK = true;
|
||||
|
||||
public bool useDualRotationPoint;
|
||||
public Transform weaponRotationPoint;
|
||||
public Transform weaponRotationPointHolder;
|
||||
|
||||
public bool useBezierCurve;
|
||||
public BezierSpline spline;
|
||||
public float bezierDuration = 0.5f;
|
||||
public float lookDirectionSpeed = 11;
|
||||
|
||||
public List<Transform> keepPath = new List<Transform> ();
|
||||
public List<IKWeaponsPosition> handsInfo = new List<IKWeaponsPosition> ();
|
||||
public bool handsInPosition;
|
||||
|
||||
public bool useQuickDrawKeepWeapon;
|
||||
|
||||
public bool placeWeaponOnKeepPositionSideBeforeDraw;
|
||||
|
||||
public bool useReloadMovement;
|
||||
public BezierSpline reloadSpline;
|
||||
public float reloadDuration = 1;
|
||||
public float reloadLookDirectionSpeed = 11;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class IKWeaponsPosition
|
||||
{
|
||||
public string Name;
|
||||
public Transform handTransform;
|
||||
public AvatarIKGoal limb;
|
||||
public Transform position;
|
||||
public float HandIKWeight;
|
||||
public float targetValue;
|
||||
|
||||
public float IKSpeed = 5;
|
||||
|
||||
public float handMovementSpeed = 2;
|
||||
public Transform waypointFollower;
|
||||
public List<Transform> wayPoints = new List<Transform> ();
|
||||
public bool handInPositionToAim;
|
||||
public Transform transformFollowByHand;
|
||||
public bool usedToDrawWeapon;
|
||||
public IKWeaponsPositionElbow elbowInfo;
|
||||
public bool showElbowInfo;
|
||||
public Coroutine handMovementCoroutine;
|
||||
public bool handUsedInWeapon = true;
|
||||
|
||||
public bool ignoreIKWeight;
|
||||
|
||||
public bool useBezierCurve;
|
||||
public BezierSpline spline;
|
||||
public float bezierDuration = 0.5f;
|
||||
public float lookDirectionSpeed = 11;
|
||||
|
||||
public bool useGrabbingHandID;
|
||||
public int grabbingHandID = 1;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class IKWeaponsPositionElbow
|
||||
{
|
||||
public string Name;
|
||||
public AvatarIKHint elbow;
|
||||
public Transform position;
|
||||
public float elbowIKWeight;
|
||||
public float targetValue;
|
||||
public Transform elbowOriginalPosition;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class weaponRotationPointInfo
|
||||
{
|
||||
public float rotationUpPointAmountMultiplier = 1.5f;
|
||||
public float rotationDownPointAmountMultiplier = 1.5f;
|
||||
public float rotationPointSpeed = 20;
|
||||
public bool useRotationUpClamp = true;
|
||||
public float rotationUpClampAmount = 50;
|
||||
public bool useRotationDownClamp = true;
|
||||
public float rotationDownClamp = 31;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bd9e2d7c48d0ef4db2b6617586ff989
|
||||
timeCreated: 1494178066
|
||||
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/Weapons/IKWeaponInfo.cs
|
||||
uploadId: 814740
|
||||
9286
Assets/Game Kit Controller/Scripts/Weapons/IKWeaponSystem.cs
Normal file
9286
Assets/Game Kit Controller/Scripts/Weapons/IKWeaponSystem.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9a5139f09ab1c74581f0456dcca953b
|
||||
timeCreated: 1466089230
|
||||
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/Weapons/IKWeaponSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55650d03438f6504eb70bee70f59af32
|
||||
folderAsset: yes
|
||||
timeCreated: 1526529132
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,483 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class attrackObjectsSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool attractionEnabled;
|
||||
|
||||
public bool attractionApplyForce = true;
|
||||
public bool attractionActive;
|
||||
public float attractionRadius = 20;
|
||||
|
||||
public LayerMask layerToSearch;
|
||||
|
||||
public float attractionVelocity = 10;
|
||||
public float attractionForce = 1000;
|
||||
public ForceMode forceMode;
|
||||
|
||||
public float maxThrowForce = 3500;
|
||||
public float increaseThrowForceSpeed = 1500;
|
||||
|
||||
public List<string> tagToLocate = new List<string> ();
|
||||
|
||||
public LayerMask layerToDamage;
|
||||
|
||||
[Space]
|
||||
[Header ("Remote Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useRemoteEventOnObjectsFound;
|
||||
public List<string> remoteEventNameListOnGrabObject = new List<string> ();
|
||||
public List<string> remoteEventNameListOnDropObject = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool carryingObjects;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventsOnActivateAttraction;
|
||||
public UnityEvent eventOnDeactivateAttraction;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Slider powerSlider;
|
||||
public Transform mainCameraTransform;
|
||||
public Transform attractionPosition;
|
||||
public Collider playerCollider;
|
||||
public GameObject playerGameObject;
|
||||
|
||||
public playerWeaponSystem mainPlayerWeaponSystem;
|
||||
|
||||
float currentForceToLaunchObjects;
|
||||
|
||||
Rigidbody currentRigidbody;
|
||||
|
||||
Vector3 attractDirection;
|
||||
|
||||
Vector3 currentPosition;
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
List<grabbedObject> grabbedObjectList = new List<grabbedObject> ();
|
||||
|
||||
float lastTimeActivateAttraction;
|
||||
|
||||
Vector3 nextObjectHeldPosition;
|
||||
Vector3 currentObjectHeldPosition;
|
||||
|
||||
Coroutine grabObjectsCoroutine;
|
||||
|
||||
bool componentsInitialized;
|
||||
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
if (mainCameraTransform == null) {
|
||||
mainCameraTransform = transform;
|
||||
}
|
||||
|
||||
if (playerGameObject == null) {
|
||||
playerGameObject = gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
void FixedUpdate ()
|
||||
{
|
||||
if (attractionActive) {
|
||||
|
||||
if (!carryingObjects) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentPosition = attractionPosition.position;
|
||||
|
||||
for (int i = 0; i < grabbedObjectList.Count; i++) {
|
||||
if (grabbedObjectList [i].objectToMove != null) {
|
||||
currentRigidbody = grabbedObjectList [i].mainRigidbody;
|
||||
|
||||
if (currentRigidbody != null) {
|
||||
|
||||
if (attractionApplyForce) {
|
||||
attractDirection = currentPosition - currentRigidbody.position;
|
||||
currentRigidbody.AddForce (attractDirection.normalized * (attractionForce * currentRigidbody.mass * Time.fixedDeltaTime), forceMode);
|
||||
} else {
|
||||
nextObjectHeldPosition = currentPosition + attractionPosition.forward;
|
||||
|
||||
currentObjectHeldPosition = currentRigidbody.position;
|
||||
|
||||
currentRigidbody.linearVelocity = (nextObjectHeldPosition - currentObjectHeldPosition) * attractionVelocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttractionEnabledState (bool state)
|
||||
{
|
||||
attractionEnabled = state;
|
||||
}
|
||||
|
||||
public void checkGrabObject ()
|
||||
{
|
||||
if (grabObjectsCoroutine != null) {
|
||||
StopCoroutine (grabObjectsCoroutine);
|
||||
}
|
||||
|
||||
grabObjectsCoroutine = StartCoroutine (checkGrabObjectCoroutine ());
|
||||
}
|
||||
|
||||
IEnumerator checkGrabObjectCoroutine ()
|
||||
{
|
||||
yield return new WaitForSeconds (0.05f);
|
||||
|
||||
if (attractionEnabled && !carryingObjects) {
|
||||
lastTimeActivateAttraction = Time.time;
|
||||
|
||||
initializeComponents ();
|
||||
|
||||
attractionActive = true;
|
||||
|
||||
grabCloseObjects ();
|
||||
|
||||
if (carryingObjects) {
|
||||
eventsOnActivateAttraction.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputGrabObjects ()
|
||||
{
|
||||
checkGrabObject ();
|
||||
}
|
||||
|
||||
public void inputHoldToLaunchObject ()
|
||||
{
|
||||
if (!attractionEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (carryingObjects) {
|
||||
if (Time.time > lastTimeActivateAttraction + 0.5f) {
|
||||
addForceToLaunchObjects ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputReleaseToLaunchObject ()
|
||||
{
|
||||
if (!attractionEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (carryingObjects) {
|
||||
if (Time.time > lastTimeActivateAttraction + 0.5f) {
|
||||
dropObjects ();
|
||||
|
||||
attractionActive = false;
|
||||
|
||||
eventOnDeactivateAttraction.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void grabCloseObjects ()
|
||||
{
|
||||
//if the player has not grabbedObjects, store them
|
||||
if (grabbedObjectList.Count == 0) {
|
||||
//check in a radius, the close objects which can be grabbed
|
||||
currentPosition = attractionPosition.position;
|
||||
|
||||
int ignoreRaycastLayerIndex = LayerMask.NameToLayer ("Ignore Raycast");
|
||||
|
||||
Collider[] objects = Physics.OverlapSphere (currentPosition, attractionRadius, layerToSearch);
|
||||
foreach (Collider currentCollider in objects) {
|
||||
|
||||
Rigidbody currentRigidbody = currentCollider.GetComponent<Rigidbody> ();
|
||||
|
||||
if (tagToLocate.Contains (currentCollider.tag) && currentRigidbody != null) {
|
||||
if (currentRigidbody.isKinematic) {
|
||||
currentRigidbody.isKinematic = false;
|
||||
}
|
||||
|
||||
grabbedObject newGrabbedObject = new grabbedObject ();
|
||||
//removed tag and layer after store them, so the camera can still use raycast properly
|
||||
|
||||
GameObject currentObject = currentCollider.gameObject;
|
||||
newGrabbedObject.objectToMove = currentObject;
|
||||
newGrabbedObject.objectTag = currentObject.tag;
|
||||
newGrabbedObject.objectLayer = currentObject.layer;
|
||||
newGrabbedObject.mainRigidbody = currentRigidbody;
|
||||
|
||||
if (useRemoteEventOnObjectsFound) {
|
||||
remoteEventSystem currentRemoteEventSystem = currentObject.GetComponent<remoteEventSystem> ();
|
||||
|
||||
if (currentRemoteEventSystem != null) {
|
||||
for (int i = 0; i < remoteEventNameListOnGrabObject.Count; i++) {
|
||||
|
||||
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnGrabObject [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentObject.tag = "Untagged";
|
||||
|
||||
currentObject.layer = ignoreRaycastLayerIndex;
|
||||
|
||||
currentRigidbody.useGravity = false;
|
||||
|
||||
//get the distance from every object to left and right side of the player, to set every side as parent of every object
|
||||
//disable collisions between the player and the objects, to avoid issues
|
||||
if (playerCollider != null) {
|
||||
Physics.IgnoreCollision (currentCollider, playerCollider, true);
|
||||
}
|
||||
|
||||
//if any object grabbed has its own gravity, paused the script to move the object properly
|
||||
artificialObjectGravity currentArtificialObjectGravity = currentObject.GetComponent<artificialObjectGravity> ();
|
||||
|
||||
if (currentArtificialObjectGravity != null) {
|
||||
currentArtificialObjectGravity.setActiveState (false);
|
||||
}
|
||||
|
||||
grabObjectProperties currentGrabObjectProperties = currentObject.GetComponent<grabObjectProperties> ();
|
||||
|
||||
if (currentGrabObjectProperties != null) {
|
||||
currentGrabObjectProperties.checkEventsOnGrabObject ();
|
||||
}
|
||||
|
||||
grabbedObjectState currentGrabbedObjectState = currentObject.GetComponent<grabbedObjectState> ();
|
||||
|
||||
if (currentGrabbedObjectState == null) {
|
||||
currentGrabbedObjectState = currentObject.AddComponent<grabbedObjectState> ();
|
||||
}
|
||||
|
||||
objectToPlaceSystem currentObjectToPlaceSystem = currentObject.GetComponent<objectToPlaceSystem> ();
|
||||
|
||||
if (currentObjectToPlaceSystem != null) {
|
||||
currentObjectToPlaceSystem.setObjectInGrabbedState (true);
|
||||
}
|
||||
|
||||
//if any object is pickable and is inside an opened chest, activate its trigger or if it has been grabbed by the player, remove of the list
|
||||
pickUpObject currentPickUpObject = currentObject.GetComponent<pickUpObject> ();
|
||||
|
||||
if (currentPickUpObject) {
|
||||
currentPickUpObject.activateObjectTrigger ();
|
||||
}
|
||||
|
||||
deviceStringAction currentDeviceStringAction = currentObject.GetComponentInChildren<deviceStringAction> ();
|
||||
|
||||
if (currentDeviceStringAction != null) {
|
||||
currentDeviceStringAction.setIconEnabledState (false);
|
||||
}
|
||||
|
||||
if (currentGrabbedObjectState != null) {
|
||||
currentGrabbedObjectState.setCurrentHolder (gameObject);
|
||||
|
||||
currentGrabbedObjectState.setGrabbedState (true);
|
||||
}
|
||||
|
||||
grabbedObjectList.Add (newGrabbedObject);
|
||||
}
|
||||
}
|
||||
|
||||
//if there are not any object close to the player, cancel
|
||||
if (grabbedObjectList.Count > 0) {
|
||||
carryingObjects = true;
|
||||
} else {
|
||||
attractionActive = false;
|
||||
}
|
||||
|
||||
powerSlider.maxValue = maxThrowForce;
|
||||
|
||||
currentForceToLaunchObjects = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//drop or throw the current grabbed objects
|
||||
public void dropObjects ()
|
||||
{
|
||||
//get the point at which the camera is looking, to throw the objects in that direction
|
||||
Vector3 hitDirection = Vector3.zero;
|
||||
|
||||
bool surfaceFound = false;
|
||||
|
||||
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.forward, out hit, Mathf.Infinity, layerToDamage)) {
|
||||
if (hit.collider != playerCollider) {
|
||||
surfaceFound = true;
|
||||
} else {
|
||||
if (Physics.Raycast (hit.point + mainCameraTransform.forward, mainCameraTransform.forward, out hit, Mathf.Infinity, layerToDamage)) {
|
||||
surfaceFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (surfaceFound) {
|
||||
hitDirection = hit.point;
|
||||
}
|
||||
|
||||
for (int j = 0; j < grabbedObjectList.Count; j++) {
|
||||
dropObject (grabbedObjectList [j], hitDirection);
|
||||
}
|
||||
|
||||
carryingObjects = false;
|
||||
grabbedObjectList.Clear ();
|
||||
|
||||
powerSlider.value = 0;
|
||||
}
|
||||
|
||||
public void addForceToLaunchObjects ()
|
||||
{
|
||||
if (currentForceToLaunchObjects < maxThrowForce) {
|
||||
//enable the power slider in the center of the screen
|
||||
currentForceToLaunchObjects += Time.deltaTime * increaseThrowForceSpeed;
|
||||
|
||||
if (currentForceToLaunchObjects > 300) {
|
||||
|
||||
powerSlider.value = currentForceToLaunchObjects;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dropObject (grabbedObject currentGrabbedObject, Vector3 launchDirection)
|
||||
{
|
||||
GameObject currentObject = currentGrabbedObject.objectToMove;
|
||||
|
||||
Rigidbody currentRigidbody = currentGrabbedObject.mainRigidbody;
|
||||
|
||||
if (useRemoteEventOnObjectsFound) {
|
||||
remoteEventSystem currentRemoteEventSystem = currentObject.GetComponent<remoteEventSystem> ();
|
||||
|
||||
if (currentRemoteEventSystem != null) {
|
||||
for (int i = 0; i < remoteEventNameListOnDropObject.Count; i++) {
|
||||
|
||||
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnDropObject [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentObject.transform.SetParent (null);
|
||||
|
||||
currentObject.tag = currentGrabbedObject.objectTag;
|
||||
currentObject.layer = currentGrabbedObject.objectLayer;
|
||||
|
||||
//drop the objects, because the grab objects button has been pressed quickly
|
||||
if (currentForceToLaunchObjects < 300) {
|
||||
if (playerCollider != null) {
|
||||
Physics.IgnoreCollision (currentObject.GetComponent<Collider> (), playerCollider, false);
|
||||
}
|
||||
}
|
||||
|
||||
//launch the objects according to the amount of time that the player has held the buttton
|
||||
if (currentForceToLaunchObjects > 300) {
|
||||
//if the objects are launched, add the script launchedObject, to damage any enemy that the object would touch
|
||||
|
||||
currentObject.AddComponent<launchedObjects> ().setCurrentPlayerAndCollider (playerGameObject, playerCollider);
|
||||
|
||||
//if there are any collider in from of the camera, use the hit point, else, use the camera direciton
|
||||
if (launchDirection != Vector3.zero) {
|
||||
Vector3 throwDirection = launchDirection - currentObject.transform.position;
|
||||
throwDirection = throwDirection / throwDirection.magnitude;
|
||||
currentRigidbody.AddForce (throwDirection * currentForceToLaunchObjects * currentRigidbody.mass);
|
||||
} else {
|
||||
currentRigidbody.AddForce (mainCameraTransform.TransformDirection (Vector3.forward) * currentForceToLaunchObjects * currentRigidbody.mass);
|
||||
}
|
||||
}
|
||||
|
||||
//set again the custom gravity of the object
|
||||
artificialObjectGravity currentArtificialObjectGravity = currentObject.GetComponent<artificialObjectGravity> ();
|
||||
|
||||
if (currentArtificialObjectGravity != null) {
|
||||
currentArtificialObjectGravity.setActiveState (true);
|
||||
}
|
||||
|
||||
grabObjectProperties currentGrabObjectProperties = currentObject.GetComponent<grabObjectProperties> ();
|
||||
|
||||
if (currentGrabObjectProperties != null) {
|
||||
currentGrabObjectProperties.checkEventsOnDropObject ();
|
||||
}
|
||||
|
||||
deviceStringAction currentDeviceStringAction = currentObject.GetComponentInChildren<deviceStringAction> ();
|
||||
|
||||
if (currentDeviceStringAction != null) {
|
||||
currentDeviceStringAction.setIconEnabledState (true);
|
||||
}
|
||||
|
||||
objectToPlaceSystem currentObjectToPlaceSystem = currentObject.GetComponent<objectToPlaceSystem> ();
|
||||
|
||||
if (currentObjectToPlaceSystem != null) {
|
||||
currentObjectToPlaceSystem.setObjectInGrabbedState (false);
|
||||
}
|
||||
|
||||
grabbedObjectState currentGrabbedObjectState = currentObject.GetComponent<grabbedObjectState> ();
|
||||
|
||||
if (currentGrabbedObjectState != null) {
|
||||
bool currentObjectWasInsideGravityRoom = currentGrabbedObjectState.isInsideZeroGravityRoom ();
|
||||
|
||||
currentGrabbedObjectState.checkGravityRoomState ();
|
||||
|
||||
currentGrabbedObjectState.setGrabbedState (false);
|
||||
|
||||
if (!currentObjectWasInsideGravityRoom) {
|
||||
currentGrabbedObjectState.removeGrabbedObjectComponent ();
|
||||
|
||||
currentRigidbody.useGravity = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfDropObject (GameObject objectToCheck)
|
||||
{
|
||||
for (int j = 0; j < grabbedObjectList.Count; j++) {
|
||||
if (grabbedObjectList [j].objectToMove == objectToCheck) {
|
||||
dropObject (grabbedObjectList [j], Vector3.zero);
|
||||
|
||||
grabbedObjectList [j].objectToMove = null;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void initializeComponents ()
|
||||
{
|
||||
if (componentsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainPlayerWeaponSystem != null) {
|
||||
playerGameObject = mainPlayerWeaponSystem.getPlayerWeaponsManger ().gameObject;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = playerGameObject.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
playerCollider = mainPlayerComponentsManager.getPlayerController ().getMainCollider ();
|
||||
|
||||
mainCameraTransform = mainPlayerComponentsManager.getPlayerCamera ().getCameraTransform ();
|
||||
}
|
||||
}
|
||||
|
||||
componentsInitialized = true;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class grabbedObject
|
||||
{
|
||||
public GameObject objectToMove;
|
||||
public string objectTag;
|
||||
public int objectLayer;
|
||||
public Rigidbody mainRigidbody;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c4ed1378b9b48f4baad80588ea81c88
|
||||
timeCreated: 1561244023
|
||||
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/Weapons/New Weapon Behaviors/attrackObjectsSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,295 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class dragObjectSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public float distanceToPlayer;
|
||||
|
||||
public float checkObstacleRaycastDistance;
|
||||
|
||||
public float dragObjectSpeed = 36;
|
||||
|
||||
public bool obstacleFound;
|
||||
|
||||
public float minDistanceToDropObject = 1;
|
||||
|
||||
public float playerDistance;
|
||||
|
||||
public float adjustObjectPositionSpeed = 5;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public bool objectGrabbed;
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnFarFromObject;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Rigidbody mainRigidbody;
|
||||
|
||||
public Transform playerDragPosition;
|
||||
public Transform rightIKHandPosition;
|
||||
public Transform leftIKHandPosition;
|
||||
|
||||
public Transform mainTransform;
|
||||
|
||||
public Collider obstacleTrigger;
|
||||
|
||||
|
||||
Transform currentPlayerTransform;
|
||||
|
||||
Vector2 axisValues;
|
||||
|
||||
playerInputManager playerInput;
|
||||
|
||||
Ray ray;
|
||||
|
||||
Vector3 rigidbodyPosition;
|
||||
Vector3 currentPoint;
|
||||
Vector3 objectPosition;
|
||||
Vector3 objectDirection;
|
||||
Vector3 objectRotation;
|
||||
|
||||
float objectXPosition;
|
||||
float objectZPosition;
|
||||
|
||||
Coroutine objectMovement;
|
||||
|
||||
bool adjustingObjectPosition;
|
||||
|
||||
float extraAngle;
|
||||
|
||||
Coroutine mainUpdateCoroutine;
|
||||
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (mainUpdateCoroutine != null) {
|
||||
StopCoroutine (mainUpdateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
if (objectGrabbed) {
|
||||
dragObject ();
|
||||
}
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void dragObject ()
|
||||
{
|
||||
if (adjustingObjectPosition) {
|
||||
return;
|
||||
}
|
||||
|
||||
ray = new Ray (currentPlayerTransform.position, currentPlayerTransform.forward);
|
||||
|
||||
axisValues = playerInput.getPlayerMovementAxis ();
|
||||
|
||||
currentPoint = ray.GetPoint (distanceToPlayer);
|
||||
|
||||
objectPosition = new Vector3 (currentPoint.x, mainTransform.position.y, currentPoint.z);
|
||||
objectDirection = Quaternion.Euler (currentPlayerTransform.eulerAngles) * new Vector3 (axisValues.x, 0, axisValues.y);
|
||||
|
||||
ray = new Ray (mainTransform.position, objectDirection);
|
||||
|
||||
currentPoint = ray.GetPoint (checkObstacleRaycastDistance);
|
||||
|
||||
if (objectDirection.magnitude > 0) {
|
||||
obstacleTrigger.transform.position = currentPoint;
|
||||
} else {
|
||||
obstacleTrigger.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
rigidbodyPosition = mainRigidbody.position;
|
||||
|
||||
objectXPosition = Mathf.Clamp (rigidbodyPosition.x - objectPosition.x, -0.1f, 0.1f);
|
||||
objectZPosition = Mathf.Clamp (rigidbodyPosition.z - objectPosition.z, -0.1f, 0.1f);
|
||||
|
||||
objectPosition = new Vector3 (objectPosition.x + objectXPosition, mainTransform.position.y, objectPosition.z + objectZPosition);
|
||||
|
||||
mainRigidbody.position = Vector3.Lerp (mainTransform.position, objectPosition, dragObjectSpeed * Time.fixedDeltaTime);
|
||||
|
||||
objectRotation = mainTransform.eulerAngles;
|
||||
objectRotation.y = (currentPlayerTransform.eulerAngles).y + extraAngle;
|
||||
mainTransform.eulerAngles = objectRotation;
|
||||
|
||||
playerDistance = GKC_Utils.distance (playerDragPosition.position, currentPlayerTransform.position);
|
||||
|
||||
if (playerDistance >= minDistanceToDropObject) {
|
||||
eventOnFarFromObject.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentPlayer (GameObject newPlayer)
|
||||
{
|
||||
currentPlayerTransform = newPlayer.transform;
|
||||
|
||||
playerInput = currentPlayerTransform.GetComponent<playerInputManager> ();
|
||||
}
|
||||
|
||||
public void grabObject ()
|
||||
{
|
||||
translateObjectToGrabPosition ();
|
||||
|
||||
if (mainTransform == null) {
|
||||
mainTransform = transform;
|
||||
}
|
||||
|
||||
objectGrabbed = true;
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
mainUpdateCoroutine = StartCoroutine (updateCoroutine ());
|
||||
}
|
||||
|
||||
public void dropObject ()
|
||||
{
|
||||
objectGrabbed = false;
|
||||
|
||||
if (adjustingObjectPosition) {
|
||||
stopTranslateObjectToGrabPosition ();
|
||||
|
||||
adjustingObjectPosition = false;
|
||||
}
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
|
||||
public void setObstacleFoundState (bool state)
|
||||
{
|
||||
obstacleFound = state;
|
||||
|
||||
mainRigidbody.isKinematic = state;
|
||||
}
|
||||
|
||||
public void translateObjectToGrabPosition ()
|
||||
{
|
||||
stopTranslateObjectToGrabPosition ();
|
||||
|
||||
objectMovement = StartCoroutine (translateObjectToGrabPositionCoroutine ());
|
||||
}
|
||||
|
||||
public void stopTranslateObjectToGrabPosition ()
|
||||
{
|
||||
if (objectMovement != null) {
|
||||
StopCoroutine (objectMovement);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator translateObjectToGrabPositionCoroutine ()
|
||||
{
|
||||
float dist = GKC_Utils.distance (mainTransform.position, currentPlayerTransform.position);
|
||||
float duration = dist / adjustObjectPositionSpeed;
|
||||
float t = 0;
|
||||
|
||||
float movementTimer = 0;
|
||||
|
||||
bool targetReached = false;
|
||||
|
||||
adjustingObjectPosition = true;
|
||||
|
||||
ray = new Ray (currentPlayerTransform.position, currentPlayerTransform.forward);
|
||||
|
||||
currentPoint = ray.GetPoint (distanceToPlayer);
|
||||
|
||||
objectPosition = new Vector3 (currentPoint.x, mainTransform.position.y, currentPoint.z);
|
||||
|
||||
rigidbodyPosition = mainRigidbody.position;
|
||||
objectXPosition = Mathf.Clamp (rigidbodyPosition.x - objectPosition.x, -0.1f, 0.1f);
|
||||
objectZPosition = Mathf.Clamp (rigidbodyPosition.z - objectPosition.z, -0.1f, 0.1f);
|
||||
|
||||
objectPosition = new Vector3 (objectPosition.x + objectXPosition, mainTransform.position.y, objectPosition.z + objectZPosition);
|
||||
|
||||
Vector3 currentPlayerPosition = currentPlayerTransform.position;
|
||||
currentPlayerPosition.y = 0;
|
||||
|
||||
Vector3 currentObjectPosition = mainTransform.position;
|
||||
currentObjectPosition.y = 0;
|
||||
|
||||
Vector3 playerDirection = (currentObjectPosition - currentPlayerPosition).normalized;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (playerDirection);
|
||||
}
|
||||
|
||||
extraAngle = Vector3.SignedAngle (playerDirection, mainTransform.forward, Vector3.up);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (extraAngle);
|
||||
}
|
||||
|
||||
int orientation = (extraAngle > 0) ? 1 : -1;
|
||||
|
||||
float extraAngleABS = Mathf.Abs (extraAngle);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (extraAngleABS);
|
||||
}
|
||||
|
||||
if (extraAngleABS < 45) {
|
||||
extraAngle = 0;
|
||||
}
|
||||
|
||||
if (extraAngleABS > 45 && extraAngleABS < 135) {
|
||||
extraAngle = 90;
|
||||
}
|
||||
|
||||
if (extraAngleABS > 135 && extraAngleABS < 235) {
|
||||
extraAngle = 180;
|
||||
}
|
||||
|
||||
if (extraAngleABS > 235) {
|
||||
extraAngle = 270;
|
||||
}
|
||||
|
||||
extraAngle *= orientation;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (extraAngle);
|
||||
}
|
||||
|
||||
Vector3 targetEuler = currentPlayerTransform.eulerAngles + mainTransform.up * extraAngle;
|
||||
|
||||
Quaternion targetRotation = Quaternion.Euler (targetEuler);
|
||||
|
||||
while (!targetReached) {
|
||||
t += Time.deltaTime * duration;
|
||||
|
||||
mainTransform.position = Vector3.Lerp (mainTransform.position, objectPosition, t);
|
||||
mainTransform.rotation = Quaternion.Slerp (mainTransform.rotation, targetRotation, t);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
if (GKC_Utils.distance (mainTransform.position, objectPosition) < 0.01f || movementTimer > (duration + 1)) {
|
||||
targetReached = true;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
adjustingObjectPosition = false;
|
||||
|
||||
playerDragPosition.position = currentPlayerTransform.position;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9208c9ad3a1f1744ab44dc960e0dc49
|
||||
timeCreated: 1559702019
|
||||
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/Weapons/New Weapon Behaviors/dragObjectSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,359 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class flamethrowerWeapon : MonoBehaviour
|
||||
{
|
||||
[Space]
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEnergyEnabled = true;
|
||||
public float useEnergyRate;
|
||||
public int amountEnergyUsed;
|
||||
|
||||
[Space]
|
||||
[Header ("Sound Settings")]
|
||||
[Space]
|
||||
|
||||
public float playSoundRate;
|
||||
public float minDelayToPlaySound;
|
||||
|
||||
[Space]
|
||||
|
||||
public AudioClip soundEffect;
|
||||
public AudioElement soundEffectAudioElement;
|
||||
|
||||
public AudioClip startSoundEffect;
|
||||
public AudioElement startSoundEffectAudioElement;
|
||||
|
||||
public AudioClip endSoundEffect;
|
||||
public AudioElement endSoundEffectAudioElement;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool weaponEnabled;
|
||||
|
||||
public bool reloading;
|
||||
|
||||
public bool updateCoroutineActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventsOnWeaponStateChange;
|
||||
public UnityEvent eventOnWeaponEnabled;
|
||||
public UnityEvent eventOnWeaponDisabled;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public bool configuredOnWeapon = true;
|
||||
public playerWeaponSystem weaponManager;
|
||||
|
||||
public ParticleSystem mainParticleSystem;
|
||||
|
||||
public AudioSource mainAudioSource;
|
||||
|
||||
public AudioSource startAudioSource;
|
||||
public AudioSource endAudioSource;
|
||||
|
||||
|
||||
float lastTimeUsed;
|
||||
float lastTimeSoundPlayed;
|
||||
|
||||
bool initialSoundWaitChecked;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
bool ignoreDisableCoroutine;
|
||||
|
||||
bool canPlaySound;
|
||||
|
||||
bool isWeaponReloading;
|
||||
|
||||
bool remainAmmoInClip;
|
||||
|
||||
bool soundEffectAudioElementLocated;
|
||||
bool startSoundEffectAudioElementLocated;
|
||||
bool endSoundEffectAudioElementLocated;
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
|
||||
updateCoroutineActive = false;
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
canPlaySound = true;
|
||||
|
||||
if (configuredOnWeapon) {
|
||||
isWeaponReloading = weaponManager.isWeaponReloading ();
|
||||
|
||||
remainAmmoInClip = weaponManager.remainAmmoInClip ();
|
||||
|
||||
if (reloading) {
|
||||
if (remainAmmoInClip && weaponManager.carryingWeapon () && !isWeaponReloading) {
|
||||
reloading = false;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (reloading) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!weaponEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(useEnergyEnabled){
|
||||
if (Time.time > lastTimeUsed + useEnergyRate) {
|
||||
if (remainAmmoInClip && !isWeaponReloading) {
|
||||
lastTimeUsed = Time.time;
|
||||
|
||||
weaponManager.useAmmo (amountEnergyUsed);
|
||||
|
||||
weaponManager.checkToUpdateInventoryWeaponAmmoTextFromWeaponSystem ();
|
||||
}
|
||||
|
||||
if (!remainAmmoInClip || isWeaponReloading) {
|
||||
ignoreDisableCoroutine = true;
|
||||
|
||||
setWeaponState (false);
|
||||
|
||||
ignoreDisableCoroutine = false;
|
||||
|
||||
reloading = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!remainAmmoInClip || isWeaponReloading) {
|
||||
canPlaySound = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (weaponEnabled && canPlaySound) {
|
||||
if (Time.time > lastTimeSoundPlayed + playSoundRate) {
|
||||
if (initialSoundWaitChecked || Time.time > lastTimeSoundPlayed + minDelayToPlaySound) {
|
||||
lastTimeSoundPlayed = Time.time;
|
||||
|
||||
playWeaponSoundEffect ();
|
||||
|
||||
initialSoundWaitChecked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableWeapon ()
|
||||
{
|
||||
setWeaponState (true);
|
||||
}
|
||||
|
||||
public void disableWeapon ()
|
||||
{
|
||||
setWeaponState (false);
|
||||
|
||||
reloading = false;
|
||||
}
|
||||
|
||||
public void setWeaponState (bool state)
|
||||
{
|
||||
if (reloading) {
|
||||
bool weaponEnabledPreviously = weaponEnabled;
|
||||
|
||||
weaponEnabled = false;
|
||||
|
||||
if (!weaponEnabledPreviously) {
|
||||
return;
|
||||
} else {
|
||||
if (!state) {
|
||||
weaponEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initializeComponents ();
|
||||
|
||||
if (weaponEnabled == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
weaponEnabled = state;
|
||||
|
||||
if (mainParticleSystem != null) {
|
||||
if (weaponEnabled) {
|
||||
mainParticleSystem.Play ();
|
||||
} else {
|
||||
mainParticleSystem.Stop ();
|
||||
}
|
||||
}
|
||||
|
||||
if (weaponEnabled) {
|
||||
playWeaponStartSoundEffect ();
|
||||
} else {
|
||||
playWeaponEndSoundEffect ();
|
||||
}
|
||||
|
||||
checkEventsOnStateChange (weaponEnabled);
|
||||
|
||||
initialSoundWaitChecked = false;
|
||||
|
||||
lastTimeSoundPlayed = 0;
|
||||
|
||||
if (!weaponEnabled) {
|
||||
stopWeaponSoundEffect ();
|
||||
}
|
||||
|
||||
if (ignoreDisableCoroutine) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (weaponEnabled) {
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
|
||||
updateCoroutineActive = true;
|
||||
} else {
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopUpdateCoroutineIfActive ()
|
||||
{
|
||||
if (updateCoroutineActive) {
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
void playWeaponSoundEffect ()
|
||||
{
|
||||
if (soundEffectAudioElementLocated) {
|
||||
AudioPlayer.PlayOneShot (soundEffectAudioElement, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
void stopWeaponSoundEffect ()
|
||||
{
|
||||
if (soundEffectAudioElementLocated) {
|
||||
AudioPlayer.Stop (soundEffectAudioElement, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
void playWeaponStartSoundEffect ()
|
||||
{
|
||||
if (startSoundEffectAudioElementLocated) {
|
||||
AudioPlayer.PlayOneShot (startSoundEffectAudioElement, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
void playWeaponEndSoundEffect ()
|
||||
{
|
||||
if (endSoundEffectAudioElementLocated) {
|
||||
AudioPlayer.PlayOneShot (endSoundEffectAudioElement, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
void checkEventsOnStateChange (bool state)
|
||||
{
|
||||
if (useEventsOnWeaponStateChange) {
|
||||
if (state) {
|
||||
eventOnWeaponEnabled.Invoke ();
|
||||
} else {
|
||||
eventOnWeaponDisabled.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool componentsInitialized;
|
||||
|
||||
void initializeComponents ()
|
||||
{
|
||||
if (componentsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
setObjectParentSystem mainSetObjectParentSystem = GetComponent<setObjectParentSystem> ();
|
||||
|
||||
if (mainSetObjectParentSystem != null) {
|
||||
if (mainSetObjectParentSystem.getParentTransform () == null) {
|
||||
if (weaponManager != null) {
|
||||
playerWeaponsManager mainPlayerWeaponsManager = weaponManager.getPlayerWeaponsManger ();
|
||||
|
||||
GameObject playerControllerGameObject = mainPlayerWeaponsManager.gameObject;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = playerControllerGameObject.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
playerController mainPlayerController = mainPlayerComponentsManager.getPlayerController ();
|
||||
|
||||
if (mainPlayerController != null) {
|
||||
GameObject playerParentGameObject = mainPlayerController.getPlayerManagersParentGameObject ();
|
||||
|
||||
if (playerParentGameObject != null) {
|
||||
mainSetObjectParentSystem.setParentTransform (playerParentGameObject.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (soundEffect != null) {
|
||||
soundEffectAudioElement.clip = soundEffect;
|
||||
|
||||
soundEffectAudioElementLocated = true;
|
||||
}
|
||||
|
||||
if (mainAudioSource != null) {
|
||||
soundEffectAudioElement.audioSource = mainAudioSource;
|
||||
}
|
||||
|
||||
if (startSoundEffect != null) {
|
||||
startSoundEffectAudioElement.clip = startSoundEffect;
|
||||
|
||||
startSoundEffectAudioElementLocated = true;
|
||||
}
|
||||
|
||||
if (startAudioSource != null) {
|
||||
startSoundEffectAudioElement.audioSource = startAudioSource;
|
||||
}
|
||||
|
||||
if (endSoundEffect != null) {
|
||||
endSoundEffectAudioElement.clip = endSoundEffect;
|
||||
|
||||
endSoundEffectAudioElementLocated = true;
|
||||
}
|
||||
|
||||
if (endAudioSource != null) {
|
||||
endSoundEffectAudioElement.audioSource = endAudioSource;
|
||||
}
|
||||
|
||||
componentsInitialized = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7eed63f9b871f940ac453a7c425e4e0
|
||||
timeCreated: 1627291084
|
||||
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/Weapons/New Weapon Behaviors/flamethrowerWeapon.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,347 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class flashlight : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool flashlightEnabled = true;
|
||||
|
||||
public bool infiniteEnergy;
|
||||
public float useEnergyRate;
|
||||
public int amountEnergyUsed;
|
||||
public float lightRotationSpeed = 10;
|
||||
public bool usedThroughWeaponSystem = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Intensity Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useHighIntentity;
|
||||
public float highIntensityAmount;
|
||||
|
||||
[Space]
|
||||
[Header ("Sound Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useSound;
|
||||
public AudioClip turnOnSound;
|
||||
public AudioElement turnOnAudioElement;
|
||||
public AudioClip turnOffSound;
|
||||
public AudioElement turnOffAudioElement;
|
||||
|
||||
[Space]
|
||||
[Header ("UI Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useFlashlightIndicatorPanel;
|
||||
public Slider mainSlider;
|
||||
public GameObject flahslightIndicatorPanel;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool isActivated;
|
||||
|
||||
public bool reloading;
|
||||
|
||||
public bool usingFlashlight;
|
||||
|
||||
public bool flashLightInputPausedState;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerWeaponsManager weaponsManager;
|
||||
public playerWeaponSystem weaponManager;
|
||||
public GameObject mainLight;
|
||||
public Light mainFlashlight;
|
||||
public AudioSource mainAudioSource;
|
||||
public GameObject flashlightMeshes;
|
||||
|
||||
bool highIntensityActivated;
|
||||
|
||||
float lastTimeUsed;
|
||||
Transform mainCameraTransform;
|
||||
float originalIntensity;
|
||||
Quaternion targetRotation;
|
||||
|
||||
bool UIElementsLocated;
|
||||
|
||||
private void InitializeAudioElements ()
|
||||
{
|
||||
if (mainAudioSource == null) {
|
||||
mainAudioSource = GetComponent<AudioSource> ();
|
||||
}
|
||||
|
||||
if (mainAudioSource != null) {
|
||||
turnOnAudioElement.audioSource = mainAudioSource;
|
||||
turnOffAudioElement.audioSource = mainAudioSource;
|
||||
}
|
||||
|
||||
if (turnOnSound != null) {
|
||||
turnOnAudioElement.clip = turnOnSound;
|
||||
}
|
||||
|
||||
if (turnOffSound != null) {
|
||||
turnOffAudioElement.clip = turnOffSound;
|
||||
}
|
||||
}
|
||||
|
||||
void Start ()
|
||||
{
|
||||
InitializeAudioElements ();
|
||||
|
||||
if (weaponManager == null) {
|
||||
weaponManager = GetComponent<playerWeaponSystem> ();
|
||||
}
|
||||
|
||||
if (mainFlashlight == null) {
|
||||
mainFlashlight = mainLight.GetComponent<Light> ();
|
||||
}
|
||||
|
||||
originalIntensity = mainFlashlight.intensity;
|
||||
|
||||
if (!flashlightEnabled) {
|
||||
enableOrDisableFlashlightMeshes (false);
|
||||
}
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (usedThroughWeaponSystem) {
|
||||
if (isActivated) {
|
||||
if (mainCameraTransform != null) {
|
||||
if (!weaponManager.weaponIsMoving () && (weaponManager.aimingInThirdPerson || weaponManager.carryingWeaponInFirstPerson)
|
||||
&& !weaponsManager.isEditinWeaponAttachments ()) {
|
||||
targetRotation = Quaternion.LookRotation (mainCameraTransform.forward);
|
||||
mainLight.transform.rotation = Quaternion.Slerp (mainLight.transform.rotation, targetRotation, Time.deltaTime * lightRotationSpeed);
|
||||
|
||||
//mainLight.transform.rotation = targetRotation;
|
||||
} else {
|
||||
targetRotation = Quaternion.identity;
|
||||
mainLight.transform.localRotation = Quaternion.Slerp (mainLight.transform.localRotation, targetRotation, Time.deltaTime * lightRotationSpeed);
|
||||
|
||||
//mainLight.transform.localRotation = targetRotation;
|
||||
}
|
||||
} else {
|
||||
mainCameraTransform = weaponManager.getMainCameraTransform ();
|
||||
}
|
||||
|
||||
if (infiniteEnergy) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Time.time > lastTimeUsed + useEnergyRate) {
|
||||
if (weaponManager.remainAmmoInClip () && !weaponManager.isWeaponReloading ()) {
|
||||
lastTimeUsed = Time.time;
|
||||
weaponManager.useAmmo (amountEnergyUsed);
|
||||
|
||||
weaponManager.checkToUpdateInventoryWeaponAmmoTextByWeaponNumberKey ();
|
||||
}
|
||||
|
||||
if (!weaponManager.remainAmmoInClip () || weaponManager.isWeaponReloading ()) {
|
||||
setFlashlightState (false);
|
||||
|
||||
reloading = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (reloading) {
|
||||
if (weaponManager.remainAmmoInClip () && weaponManager.carryingWeapon () && !weaponManager.isWeaponReloading ()) {
|
||||
setFlashlightState (true);
|
||||
|
||||
reloading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (usingFlashlight) {
|
||||
if (useFlashlightIndicatorPanel) {
|
||||
if (!infiniteEnergy) {
|
||||
if (UIElementsLocated) {
|
||||
mainSlider.value = weaponManager.getWeaponClipSize ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool checkIfEnoughBattery ()
|
||||
{
|
||||
if (infiniteEnergy) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (usedThroughWeaponSystem) {
|
||||
if (!weaponManager.remainAmmoInClip ()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void changeFlashLightState ()
|
||||
{
|
||||
if (flashLightInputPausedState) {
|
||||
return;
|
||||
}
|
||||
|
||||
setFlashlightState (!isActivated);
|
||||
}
|
||||
|
||||
public void setFlashlightState (bool state)
|
||||
{
|
||||
if (state) {
|
||||
if (!checkIfEnoughBattery ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!flashlightEnabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
initializeComponents ();
|
||||
|
||||
isActivated = state;
|
||||
|
||||
playSound (isActivated);
|
||||
|
||||
if (mainLight.activeSelf != isActivated) {
|
||||
mainLight.SetActive (isActivated);
|
||||
}
|
||||
}
|
||||
|
||||
public void turnOn ()
|
||||
{
|
||||
if (!checkIfEnoughBattery ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!flashlightEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
isActivated = true;
|
||||
|
||||
playSound (isActivated);
|
||||
}
|
||||
|
||||
public void turnOff ()
|
||||
{
|
||||
isActivated = false;
|
||||
|
||||
playSound (isActivated);
|
||||
}
|
||||
|
||||
public void playSound (bool state)
|
||||
{
|
||||
if (useSound) {
|
||||
GKC_Utils.checkAudioSourcePitch (mainAudioSource);
|
||||
|
||||
if (state) {
|
||||
AudioPlayer.PlayOneShot (turnOnAudioElement, gameObject);
|
||||
} else {
|
||||
AudioPlayer.PlayOneShot (turnOffAudioElement, gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void changeLightIntensity (bool state)
|
||||
{
|
||||
if (useHighIntentity) {
|
||||
highIntensityActivated = state;
|
||||
|
||||
if (highIntensityActivated) {
|
||||
mainFlashlight.intensity = highIntensityAmount;
|
||||
} else {
|
||||
mainFlashlight.intensity = originalIntensity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setHighIntensity ()
|
||||
{
|
||||
if (usedThroughWeaponSystem) {
|
||||
if (weaponsManager.isFullBodyAwarenessActive ()) {
|
||||
if (!weaponsManager.isAimModeInputPressed ()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeLightIntensity (true);
|
||||
}
|
||||
|
||||
public void setOriginalIntensity ()
|
||||
{
|
||||
changeLightIntensity (false);
|
||||
}
|
||||
|
||||
public void enableOrDisableFlashlightMeshes (bool state)
|
||||
{
|
||||
if (flashlightMeshes != null) {
|
||||
if (state) {
|
||||
if (!flashlightEnabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (flashlightMeshes.activeSelf != state) {
|
||||
flashlightMeshes.SetActive (state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setFlashLightInputPausedState (bool state)
|
||||
{
|
||||
flashLightInputPausedState = state;
|
||||
}
|
||||
|
||||
public void enableOrDisableFlashlightIndicator (bool state)
|
||||
{
|
||||
usingFlashlight = state;
|
||||
|
||||
if (useFlashlightIndicatorPanel) {
|
||||
if (flahslightIndicatorPanel != null) {
|
||||
if (flahslightIndicatorPanel.activeSelf != state) {
|
||||
flahslightIndicatorPanel.SetActive (state);
|
||||
}
|
||||
}
|
||||
|
||||
if (mainSlider != null) {
|
||||
if (usedThroughWeaponSystem) {
|
||||
mainSlider.maxValue = weaponManager.getMagazineSize ();
|
||||
}
|
||||
|
||||
UIElementsLocated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool componentsInitialized;
|
||||
|
||||
void initializeComponents ()
|
||||
{
|
||||
if (componentsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (usedThroughWeaponSystem) {
|
||||
if (weaponsManager == null) {
|
||||
weaponsManager = weaponManager.getPlayerWeaponsManger ();
|
||||
}
|
||||
}
|
||||
|
||||
componentsInitialized = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 050620af76d73374d8e2a8dd20482d64
|
||||
timeCreated: 1523826769
|
||||
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/Weapons/New Weapon Behaviors/flashlight.cs
|
||||
uploadId: 814740
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0aa790bce1c533499283fa87d92dd8c
|
||||
timeCreated: 1561104315
|
||||
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/Weapons/New Weapon Behaviors/gravityGun.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,436 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
|
||||
public class healerWeapon : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public LayerMask layer;
|
||||
|
||||
public bool canHeal;
|
||||
public float healRate;
|
||||
public float healtAmount;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool canDamage;
|
||||
public float damageRate;
|
||||
public float damageAmount;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool canRefillEnergy;
|
||||
public float energyRate;
|
||||
public float energyAmount;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool canRefillFuel;
|
||||
public float fuelRate;
|
||||
public float fuelAmount;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool canGatherHealth;
|
||||
public bool canGatherEnergy;
|
||||
public bool canGatherFuel;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useWithVehicles;
|
||||
public bool useWithCharacters;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool ignoreShield;
|
||||
|
||||
public int damageTypeID = -1;
|
||||
|
||||
public bool damageCanBeBlocked = true;
|
||||
|
||||
public bool canActivateReactionSystemTemporally;
|
||||
public int damageReactionID = -1;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public GameObject currentObjectToCheck;
|
||||
public GameObject currentHealthElement;
|
||||
public bool targetFound;
|
||||
|
||||
public bool searchingTargets;
|
||||
|
||||
public bool healModeActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Transform mainCameraTransform;
|
||||
public playerWeaponSystem weaponManager;
|
||||
|
||||
|
||||
float lastTime;
|
||||
RaycastHit hit;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
if (searchingTargets) {
|
||||
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, Mathf.Infinity, layer)) {
|
||||
currentObjectToCheck = hit.collider.gameObject;
|
||||
|
||||
if (!targetFound) {
|
||||
checkTarget (currentObjectToCheck);
|
||||
print (currentObjectToCheck.name);
|
||||
|
||||
} else {
|
||||
if (currentHealthElement != currentObjectToCheck) {
|
||||
changeTriggerState (false, null, 0);
|
||||
|
||||
print ("removed");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
targetFound = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetFound && currentHealthElement != null) {
|
||||
if (healModeActive) {
|
||||
if (canHeal) {
|
||||
if (Time.time > lastTime + healRate) {
|
||||
//while the object is not fully healed, then
|
||||
if (!applyDamage.checkIfMaxHealth (currentHealthElement) && weaponManager.remainAmmoInClip ()) {
|
||||
//heal it
|
||||
applyDamage.setHeal (healtAmount, currentHealthElement);
|
||||
|
||||
lastTime = Time.time;
|
||||
|
||||
if (canGatherHealth) {
|
||||
int amountOfAmmo = (int)Mathf.Round (healtAmount);
|
||||
|
||||
weaponManager.useAmmo (amountOfAmmo);
|
||||
|
||||
weaponManager.checkToUpdateInventoryWeaponAmmoTextFromWeaponSystem ();
|
||||
}
|
||||
} else {
|
||||
//else, stop healing it
|
||||
changeTriggerState (false, null, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canRefillFuel) {
|
||||
if (Time.time > lastTime + fuelRate) {
|
||||
//while the vehicle has not the max fuel amount, then
|
||||
if (!applyDamage.checkIfMaxFuel (currentHealthElement) && weaponManager.remainAmmoInClip ()) {
|
||||
//fill it
|
||||
applyDamage.setFuel (fuelAmount, currentHealthElement);
|
||||
|
||||
lastTime = Time.time;
|
||||
|
||||
if (canGatherFuel) {
|
||||
int amountOfAmmo = (int)Mathf.Round (fuelAmount);
|
||||
|
||||
weaponManager.useAmmo (amountOfAmmo);
|
||||
|
||||
weaponManager.checkToUpdateInventoryWeaponAmmoTextFromWeaponSystem ();
|
||||
}
|
||||
} else {
|
||||
//else, stop refill it
|
||||
changeTriggerState (false, null, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canRefillEnergy) {
|
||||
if (Time.time > lastTime + energyRate) {
|
||||
//while the vehicle has not the max fuel amount, then
|
||||
if (!applyDamage.checkIfMaxEnergy (currentHealthElement) && weaponManager.remainAmmoInClip ()) {
|
||||
//fill it
|
||||
applyDamage.setEnergy (energyAmount, currentHealthElement);
|
||||
|
||||
lastTime = Time.time;
|
||||
|
||||
if (canGatherEnergy) {
|
||||
int amountOfAmmo = (int)Mathf.Round (energyAmount);
|
||||
|
||||
weaponManager.useAmmo (amountOfAmmo);
|
||||
|
||||
weaponManager.checkToUpdateInventoryWeaponAmmoTextFromWeaponSystem ();
|
||||
}
|
||||
} else {
|
||||
//else, stop refill it
|
||||
changeTriggerState (false, null, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//apply damage or heal it accordint to the time rate
|
||||
if (Time.time > lastTime + damageRate) {
|
||||
if (canDamage) {
|
||||
//if the object inside the trigger is dead, stop applying damage
|
||||
if (applyDamage.checkIfDead (currentHealthElement)) {
|
||||
changeTriggerState (false, null, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canGatherHealth) {
|
||||
if (!weaponManager.remainAmmoInClip ()) {
|
||||
changeTriggerState (false, null, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//if the trigger damages
|
||||
//apply damage
|
||||
applyDamage.checkHealth (gameObject, currentHealthElement, damageAmount, Vector3.zero,
|
||||
currentHealthElement.transform.position + currentHealthElement.transform.up, gameObject,
|
||||
true, true, ignoreShield, false, damageCanBeBlocked, canActivateReactionSystemTemporally, damageReactionID, damageTypeID);
|
||||
|
||||
lastTime = Time.time;
|
||||
|
||||
if (canGatherHealth) {
|
||||
weaponManager.getAndUpdateAmmo ((int)Mathf.Round (damageAmount));
|
||||
} else {
|
||||
int amountOfAmmo = (int)Mathf.Round (damageAmount);
|
||||
|
||||
weaponManager.useAmmo (amountOfAmmo);
|
||||
|
||||
weaponManager.checkToUpdateInventoryWeaponAmmoTextFromWeaponSystem ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canRefillFuel) {
|
||||
if (Time.time > lastTime + fuelRate) {
|
||||
//while the vehicle has not the max fuel amount, then
|
||||
if (applyDamage.getCurrentFuelAmount (currentHealthElement) > 0) {
|
||||
//fill it
|
||||
applyDamage.removeFuel (fuelAmount, currentHealthElement);
|
||||
|
||||
lastTime = Time.time;
|
||||
|
||||
if (canGatherFuel) {
|
||||
weaponManager.getAndUpdateAmmo ((int)Mathf.Round (fuelAmount));
|
||||
}
|
||||
} else {
|
||||
//else, stop refill it
|
||||
changeTriggerState (false, null, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canRefillEnergy) {
|
||||
if (Time.time > lastTime + energyRate) {
|
||||
//while the vehicle has not the max fuel amount, then
|
||||
if (applyDamage.getCurrentEnergyAmount (currentHealthElement) > 0) {
|
||||
//fill it
|
||||
applyDamage.removeEnergy (energyAmount, currentHealthElement);
|
||||
|
||||
lastTime = Time.time;
|
||||
|
||||
if (canGatherEnergy) {
|
||||
weaponManager.getAndUpdateAmmo ((int)Mathf.Round (energyAmount));
|
||||
}
|
||||
} else {
|
||||
//else, stop refill it
|
||||
changeTriggerState (false, null, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void changeMode ()
|
||||
{
|
||||
initializeComponents ();
|
||||
|
||||
healModeActive = !healModeActive;
|
||||
}
|
||||
|
||||
public void checkTarget (GameObject target)
|
||||
{
|
||||
//else, if a vehicle is inside the trigger and it can be used with vehicles, them
|
||||
if (applyDamage.isVehicle (target) && useWithVehicles) {
|
||||
changeTriggerState (true, target, Time.time);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (applyDamage.isCharacter (target) && useWithCharacters) {
|
||||
changeTriggerState (true, target, Time.time);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//stop or start the heal or damage action
|
||||
void changeTriggerState (bool inside, GameObject obj, float time)
|
||||
{
|
||||
targetFound = inside;
|
||||
|
||||
currentHealthElement = obj;
|
||||
|
||||
lastTime = time;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("target found result " + targetFound);
|
||||
}
|
||||
}
|
||||
|
||||
public void downButtonAction ()
|
||||
{
|
||||
initializeComponents ();
|
||||
|
||||
searchingTargets = true;
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
}
|
||||
|
||||
public void upButtonAction ()
|
||||
{
|
||||
initializeComponents ();
|
||||
|
||||
searchingTargets = false;
|
||||
|
||||
changeTriggerState (false, null, 0);
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
|
||||
bool componentsInitialized;
|
||||
|
||||
void initializeComponents ()
|
||||
{
|
||||
if (componentsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (weaponManager != null) {
|
||||
mainCameraTransform = weaponManager.getMainCameraTransform ();
|
||||
}
|
||||
|
||||
componentsInitialized = true;
|
||||
}
|
||||
|
||||
public void setCanHealState (bool state)
|
||||
{
|
||||
canHeal = state;
|
||||
|
||||
if (state) {
|
||||
|
||||
canDamage = false;
|
||||
|
||||
canRefillEnergy = false;
|
||||
|
||||
canRefillFuel = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCanDamageState (bool state)
|
||||
{
|
||||
canDamage = state;
|
||||
|
||||
if (state) {
|
||||
canHeal = false;
|
||||
|
||||
canRefillEnergy = false;
|
||||
|
||||
canRefillFuel = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCanRefillEnergyState (bool state)
|
||||
{
|
||||
canRefillEnergy = state;
|
||||
|
||||
if (state) {
|
||||
|
||||
canHeal = false;
|
||||
|
||||
canDamage = false;
|
||||
|
||||
canRefillFuel = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCanRefillFuelState (bool state)
|
||||
{
|
||||
canRefillFuel = state;
|
||||
|
||||
if (state) {
|
||||
canHeal = false;
|
||||
|
||||
canDamage = false;
|
||||
|
||||
canRefillEnergy = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void setCanGatherHealthState (bool state)
|
||||
{
|
||||
canGatherHealth = state;
|
||||
}
|
||||
|
||||
public void setCanGatherEnergyState (bool state)
|
||||
{
|
||||
canGatherEnergy = state;
|
||||
}
|
||||
|
||||
public void setCanGatherFuelState (bool state)
|
||||
{
|
||||
canGatherFuel = state;
|
||||
}
|
||||
|
||||
public void setHealModeActiveState (bool state)
|
||||
{
|
||||
healModeActive = state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1c002ea53029eb4e864fa39b9fdcd48
|
||||
timeCreated: 1520367247
|
||||
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/Weapons/New Weapon Behaviors/healerWeapon.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,131 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class plasmaCutterSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public Transform mainRotor;
|
||||
|
||||
public float initialRotorRotation;
|
||||
|
||||
public bool useFixedVerticalHorizontalRotations;
|
||||
|
||||
public float angleRotationAmount;
|
||||
|
||||
public float rotationSpeed;
|
||||
|
||||
public float manualRotationAmount;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnFireWeapon;
|
||||
|
||||
public UnityEvent eventOnRotateWeapon;
|
||||
|
||||
bool rotating;
|
||||
|
||||
bool rotationToggleState;
|
||||
|
||||
Coroutine rotationCoroutine;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
mainRotor.localEulerAngles = new Vector3 (0, 0, initialRotorRotation);
|
||||
}
|
||||
|
||||
public void firePlasmaCutter ()
|
||||
{
|
||||
eventOnFireWeapon.Invoke ();
|
||||
}
|
||||
|
||||
public void rotateRotorToRight ()
|
||||
{
|
||||
mainRotor.Rotate (manualRotationAmount * Vector3.forward);
|
||||
}
|
||||
|
||||
public void rotateRotorToLeft ()
|
||||
{
|
||||
mainRotor.Rotate (manualRotationAmount * (-Vector3.forward));
|
||||
}
|
||||
|
||||
public void changeRotorRotation ()
|
||||
{
|
||||
if (rotating) {
|
||||
return;
|
||||
}
|
||||
|
||||
float rotationAmount = 0;
|
||||
|
||||
if (useFixedVerticalHorizontalRotations) {
|
||||
rotationToggleState = !rotationToggleState;
|
||||
|
||||
if (rotationToggleState) {
|
||||
rotationAmount = 90;
|
||||
} else {
|
||||
rotationAmount = 0;
|
||||
}
|
||||
} else {
|
||||
rotationAmount += angleRotationAmount;
|
||||
|
||||
if (rotationAmount > 360) {
|
||||
rotationAmount = 360 - rotationAmount;
|
||||
}
|
||||
}
|
||||
|
||||
eventOnRotateWeapon.Invoke ();
|
||||
|
||||
stopChangeRotorRotation ();
|
||||
|
||||
rotationCoroutine = StartCoroutine (stopChangeRotorRotationCoroutine (rotationAmount));
|
||||
}
|
||||
|
||||
public void stopChangeRotorRotation ()
|
||||
{
|
||||
if (rotationCoroutine != null) {
|
||||
StopCoroutine (rotationCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator stopChangeRotorRotationCoroutine (float rotationAmount)
|
||||
{
|
||||
rotating = true;
|
||||
|
||||
Vector3 eulerTarget = Vector3.zero;
|
||||
|
||||
eulerTarget.z = rotationAmount;
|
||||
|
||||
Quaternion rotationTarget = Quaternion.Euler (eulerTarget);
|
||||
|
||||
float t = 0;
|
||||
|
||||
float movementTimer = 0;
|
||||
|
||||
bool targetReached = false;
|
||||
|
||||
float angleDifference = 0;
|
||||
|
||||
while (!targetReached) {
|
||||
t += Time.deltaTime * rotationSpeed;
|
||||
mainRotor.localRotation = Quaternion.Lerp (mainRotor.localRotation, rotationTarget, t);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
angleDifference = Quaternion.Angle (mainRotor.localRotation, rotationTarget);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
if (angleDifference < 0.2f || movementTimer > 2) {
|
||||
targetReached = true;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
rotating = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 903868009044f3041913a3269e050ba1
|
||||
timeCreated: 1576806352
|
||||
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/Weapons/New Weapon Behaviors/plasmaCutterSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,294 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class simpleChainSaw : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public Transform mainRotationPivot;
|
||||
|
||||
public float initialPivotRotation;
|
||||
|
||||
public bool useFixedVerticalHorizontalRotations;
|
||||
|
||||
public float angleRotationAmount;
|
||||
|
||||
public float rotationSpeed;
|
||||
|
||||
public float manualRotationAmount;
|
||||
|
||||
public float maxRotationAngle = 80;
|
||||
|
||||
public float minRotationAngle = -10;
|
||||
|
||||
[Space]
|
||||
[Header ("Weapon Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useFuelEnabled = true;
|
||||
public float useFuelRate;
|
||||
public int amountFuelUsed;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool chainsawActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnActivateChainsaw;
|
||||
|
||||
public UnityEvent eventOnDeactivateChainsaw;
|
||||
|
||||
public UnityEvent eventOnRotateWeapon;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerWeaponSystem weaponManager;
|
||||
|
||||
|
||||
bool rotating;
|
||||
|
||||
bool rotationToggleState;
|
||||
|
||||
Coroutine rotationCoroutine;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
bool isWeaponReloading;
|
||||
|
||||
bool remainAmmoInClip;
|
||||
|
||||
bool reloading;
|
||||
|
||||
float lastTimeUsed;
|
||||
|
||||
bool ignoreDisableCoroutine;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
mainRotationPivot.localEulerAngles = new Vector3 (0, 0, initialPivotRotation);
|
||||
}
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
isWeaponReloading = weaponManager.isWeaponReloading ();
|
||||
|
||||
remainAmmoInClip = weaponManager.remainAmmoInClip ();
|
||||
|
||||
if (reloading) {
|
||||
if (remainAmmoInClip && weaponManager.carryingWeapon () && !isWeaponReloading) {
|
||||
reloading = false;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (reloading) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!chainsawActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (useFuelEnabled) {
|
||||
if (Time.time > lastTimeUsed + useFuelRate) {
|
||||
if (remainAmmoInClip && !isWeaponReloading) {
|
||||
lastTimeUsed = Time.time;
|
||||
|
||||
weaponManager.useAmmo (amountFuelUsed);
|
||||
|
||||
weaponManager.checkToUpdateInventoryWeaponAmmoTextFromWeaponSystem ();
|
||||
}
|
||||
|
||||
if (!remainAmmoInClip || isWeaponReloading) {
|
||||
ignoreDisableCoroutine = true;
|
||||
|
||||
activateOrDeactivateChainsaw (false);
|
||||
|
||||
ignoreDisableCoroutine = false;
|
||||
|
||||
reloading = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void activateChainSaw ()
|
||||
{
|
||||
activateOrDeactivateChainsaw (true);
|
||||
}
|
||||
|
||||
public void deactivateChainSaw ()
|
||||
{
|
||||
activateOrDeactivateChainsaw (false);
|
||||
}
|
||||
|
||||
void activateOrDeactivateChainsaw (bool state)
|
||||
{
|
||||
if (chainsawActive == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
chainsawActive = state;
|
||||
|
||||
if (chainsawActive) {
|
||||
eventOnActivateChainsaw.Invoke ();
|
||||
} else {
|
||||
eventOnDeactivateChainsaw.Invoke ();
|
||||
}
|
||||
|
||||
if (ignoreDisableCoroutine) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (chainsawActive) {
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
} else {
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
public void rotatePivotToRight ()
|
||||
{
|
||||
mainRotationPivot.Rotate (manualRotationAmount * Vector3.forward);
|
||||
|
||||
checkMainRotationPivotMaxRotationAngle ();
|
||||
}
|
||||
|
||||
public void rotatePivotToLeft ()
|
||||
{
|
||||
mainRotationPivot.Rotate (manualRotationAmount * (-Vector3.forward));
|
||||
|
||||
checkMainRotationPivotMaxRotationAngle ();
|
||||
}
|
||||
|
||||
void checkMainRotationPivotMaxRotationAngle ()
|
||||
{
|
||||
if (maxRotationAngle == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 mainRotationPivotEulerAngles = mainRotationPivot.localEulerAngles;
|
||||
|
||||
float newZAngle = mainRotationPivotEulerAngles.z;
|
||||
|
||||
if (newZAngle > 0 && newZAngle < 180) {
|
||||
newZAngle = Mathf.Clamp (newZAngle, 0, maxRotationAngle);
|
||||
|
||||
} else {
|
||||
if (newZAngle > 180) {
|
||||
newZAngle -= 360;
|
||||
}
|
||||
|
||||
newZAngle = Mathf.Clamp (newZAngle, minRotationAngle, 0);
|
||||
}
|
||||
|
||||
mainRotationPivot.localEulerAngles = new Vector3 (mainRotationPivotEulerAngles.x, mainRotationPivotEulerAngles.y, newZAngle);
|
||||
}
|
||||
|
||||
public void changePivotRotation ()
|
||||
{
|
||||
if (rotating) {
|
||||
return;
|
||||
}
|
||||
|
||||
float rotationAmount = 0;
|
||||
|
||||
if (useFixedVerticalHorizontalRotations) {
|
||||
rotationToggleState = !rotationToggleState;
|
||||
|
||||
if (rotationToggleState) {
|
||||
rotationAmount = 90;
|
||||
} else {
|
||||
rotationAmount = 0;
|
||||
}
|
||||
} else {
|
||||
rotationAmount += angleRotationAmount;
|
||||
|
||||
if (rotationAmount > 360) {
|
||||
rotationAmount = 360 - rotationAmount;
|
||||
}
|
||||
}
|
||||
|
||||
eventOnRotateWeapon.Invoke ();
|
||||
|
||||
stopChangePivotRotation ();
|
||||
|
||||
rotationCoroutine = StartCoroutine (stopChangePivotRotationCoroutine (rotationAmount));
|
||||
}
|
||||
|
||||
public void stopChangePivotRotation ()
|
||||
{
|
||||
if (rotationCoroutine != null) {
|
||||
StopCoroutine (rotationCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator stopChangePivotRotationCoroutine (float rotationAmount)
|
||||
{
|
||||
rotating = true;
|
||||
|
||||
Vector3 eulerTarget = Vector3.zero;
|
||||
|
||||
eulerTarget.z = rotationAmount;
|
||||
|
||||
Quaternion rotationTarget = Quaternion.Euler (eulerTarget);
|
||||
|
||||
float t = 0;
|
||||
|
||||
float movementTimer = 0;
|
||||
|
||||
bool targetReached = false;
|
||||
|
||||
float angleDifference = 0;
|
||||
|
||||
while (!targetReached) {
|
||||
t += Time.deltaTime * rotationSpeed;
|
||||
mainRotationPivot.localRotation = Quaternion.Lerp (mainRotationPivot.localRotation, rotationTarget, t);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
angleDifference = Quaternion.Angle (mainRotationPivot.localRotation, rotationTarget);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
if (angleDifference < 0.2f || movementTimer > 2) {
|
||||
targetReached = true;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
rotating = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d77a00adcb007cd4393701fa78c2acf3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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/Weapons/New Weapon Behaviors/simpleChainSaw.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,832 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class sliceObject : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool sliceActive;
|
||||
|
||||
public bool disableSliceAfterFirstCutEnabled = true;
|
||||
|
||||
public Material defaultSliceMaterial;
|
||||
|
||||
public Vector3 cutOverlapBoxSize = new Vector3 (5, 0.1f, 5);
|
||||
|
||||
public float minDelayToSliceSameObject = 0.3f;
|
||||
|
||||
public bool activateRigidbodiesOnNewObjects = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool sliceRegularObjectsEnabled = true;
|
||||
public bool sliceCharactersEnabled = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Damage Settings")]
|
||||
[Space]
|
||||
|
||||
public bool activateDamageOnSlice;
|
||||
public float damageAmountToApplyOnSlice;
|
||||
public bool ignoreShieldOnDamage = true;
|
||||
public bool canActivateReactionSystemTemporally;
|
||||
public int damageReactionID = -1;
|
||||
|
||||
public int damageTypeID = -1;
|
||||
|
||||
[Space]
|
||||
[Header ("Physics Settings")]
|
||||
[Space]
|
||||
|
||||
public bool updateLastObjectSpeed;
|
||||
|
||||
public float forceToApplyToCutPart;
|
||||
public ForceMode forceMode;
|
||||
public float forceRadius;
|
||||
public float forceUp;
|
||||
|
||||
public float disableTimeAfterCollision;
|
||||
|
||||
public LayerMask targetToDamageLayer;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool applyForcesOnObjectsDetected;
|
||||
public float addForceMultiplier;
|
||||
public bool applyImpactForceToVehicles;
|
||||
public float impactForceToVehiclesMultiplier;
|
||||
|
||||
public bool checkObjectLayerAndTagToApplyForces;
|
||||
|
||||
public LayerMask targetToApplyForceLayer;
|
||||
public List<string> tagetToApplyForceTagList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool cutMultipleTimesActive = true;
|
||||
|
||||
public bool ignoreObjectsAlreadySlice;
|
||||
|
||||
public float minWaitTimeToActivateSlice = 0.4f;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool useObjectsToIgnoreList;
|
||||
public List<GameObject> objectsToIgnoreList = new List<GameObject> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Bullet Time Settings")]
|
||||
[Space]
|
||||
|
||||
public bool ignoreTimeBulletOnRegularSlice;
|
||||
|
||||
[Space]
|
||||
[Header ("Remote Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useRemoteEventOnObjectsFound;
|
||||
public List<string> remoteEventNameList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public bool showDebugWaitTimePrint;
|
||||
|
||||
public List<GameObject> objectsDetected = new List<GameObject> ();
|
||||
|
||||
public List<Collider> collidersToIgnoreList = new List<Collider> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Gizmo Settings")]
|
||||
[Space]
|
||||
|
||||
public bool showGizmo;
|
||||
public Color gizmoColor = Color.red;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Collider mainCollider;
|
||||
|
||||
public Collider triggerCollider;
|
||||
|
||||
public Transform cutPositionTransform;
|
||||
public Transform cutDirectionTransform;
|
||||
|
||||
public Transform planeDefiner1;
|
||||
public Transform planeDefiner2;
|
||||
public Transform planeDefiner3;
|
||||
|
||||
|
||||
surfaceToSlice currentSurfaceToSlice;
|
||||
|
||||
Collider currentColliderFound;
|
||||
|
||||
Coroutine disableSliceCoroutine;
|
||||
|
||||
float lastTimeSlice;
|
||||
|
||||
Vector3 currentCutPosition;
|
||||
Quaternion currentCutRotation;
|
||||
Vector3 currentCutUp;
|
||||
Vector3 currentCutForward;
|
||||
|
||||
Vector3 currentCutDirection;
|
||||
|
||||
Vector3 currentPlaneDefiner1;
|
||||
Vector3 currentPlaneDefiner2;
|
||||
Vector3 currentPlaneDefiner3;
|
||||
|
||||
Vector3 currentCutOverlapBoxSize;
|
||||
|
||||
|
||||
void setCurrentCutTransformValues ()
|
||||
{
|
||||
if (cutPositionTransform != null) {
|
||||
currentCutPosition = cutPositionTransform.position;
|
||||
currentCutRotation = cutPositionTransform.rotation;
|
||||
currentCutUp = cutPositionTransform.up;
|
||||
currentCutForward = cutPositionTransform.forward;
|
||||
} else {
|
||||
currentCutPosition = cutDirectionTransform.position;
|
||||
currentCutRotation = cutDirectionTransform.rotation;
|
||||
currentCutUp = cutDirectionTransform.up;
|
||||
currentCutForward = cutDirectionTransform.forward;
|
||||
}
|
||||
|
||||
if (cutDirectionTransform != null) {
|
||||
currentCutDirection = cutDirectionTransform.right;
|
||||
}
|
||||
|
||||
if (planeDefiner1 != null) {
|
||||
currentPlaneDefiner1 = planeDefiner1.position;
|
||||
}
|
||||
|
||||
if (planeDefiner2 != null) {
|
||||
currentPlaneDefiner2 = planeDefiner2.position;
|
||||
}
|
||||
|
||||
if (planeDefiner3 != null) {
|
||||
currentPlaneDefiner3 = planeDefiner3.position;
|
||||
}
|
||||
|
||||
currentCutOverlapBoxSize = cutOverlapBoxSize;
|
||||
}
|
||||
|
||||
public void processObject (GameObject obj, Collider objectCollider, Vector3 slicePosition)
|
||||
{
|
||||
if (cutMultipleTimesActive) {
|
||||
if (!ignoreObjectsAlreadySlice && objectsDetected.Contains (obj)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (minWaitTimeToActivateSlice > 0 && lastTimeSlice != 0) {
|
||||
if (showDebugWaitTimePrint) {
|
||||
print ("checking object to process with last time slice");
|
||||
}
|
||||
|
||||
if (Time.time < lastTimeSlice + minWaitTimeToActivateSlice) {
|
||||
if (showDebugWaitTimePrint) {
|
||||
print ("not enough wait time, cancelling check");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
currentSurfaceToSlice = obj.GetComponent<surfaceToSlice> ();
|
||||
|
||||
if (currentSurfaceToSlice == null) {
|
||||
currentSurfaceToSlice = sliceSystemUtils.getSurfaceToSlice (obj);
|
||||
}
|
||||
|
||||
bool isVehicle = applyDamage.isVehicle (obj);
|
||||
|
||||
if (isVehicle) {
|
||||
GameObject currentVehicle = applyDamage.getVehicle (obj);
|
||||
|
||||
if (currentVehicle != null) {
|
||||
currentSurfaceToSlice = currentVehicle.GetComponent<surfaceToSlice> ();
|
||||
|
||||
if (currentSurfaceToSlice != null) {
|
||||
obj = currentVehicle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool objectIsSliceSurfaceDisabled = false;
|
||||
|
||||
bool objectCanBeSliced = false;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("processing object " + obj.name);
|
||||
}
|
||||
|
||||
bool ignoreRegularDamageIfCutSurfaceNotEnabled = false;
|
||||
|
||||
bool isIgnoreDamageIfSliceNotActivatedActive = false;
|
||||
|
||||
if (currentSurfaceToSlice != null) {
|
||||
bool isCutSurfaceEnabled = currentSurfaceToSlice.isCutSurfaceEnabled ();
|
||||
|
||||
bool sliceCanBeActivated = currentSurfaceToSlice.sliceCanBeActivated (minDelayToSliceSameObject);
|
||||
|
||||
bool checkSliceDirectionResult = currentSurfaceToSlice.checkSliceDirectionResult (cutPositionTransform.right, cutPositionTransform.up);
|
||||
|
||||
isIgnoreDamageIfSliceNotActivatedActive = currentSurfaceToSlice.isIgnoreDamageIfSliceNotActivatedActive ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Surface cut enabled state " + isCutSurfaceEnabled +
|
||||
" can activate slice " + sliceCanBeActivated);
|
||||
}
|
||||
|
||||
if (isCutSurfaceEnabled && sliceCanBeActivated && checkSliceDirectionResult) {
|
||||
|
||||
Material crossSectionMaterial = currentSurfaceToSlice.getCrossSectionMaterial ();
|
||||
|
||||
if (crossSectionMaterial == null) {
|
||||
crossSectionMaterial = defaultSliceMaterial;
|
||||
}
|
||||
|
||||
sliceCurrentObject (obj, objectCollider, crossSectionMaterial, slicePosition);
|
||||
|
||||
objectCanBeSliced = true;
|
||||
} else {
|
||||
if (isVehicle && isCutSurfaceEnabled) {
|
||||
objectCanBeSliced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isCutSurfaceEnabled) {
|
||||
objectIsSliceSurfaceDisabled = true;
|
||||
|
||||
ignoreRegularDamageIfCutSurfaceNotEnabled = currentSurfaceToSlice.isIgnoreRegularDamageIfCutSurfaceNotEnabled ();
|
||||
}
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("Surface to slice not found on " + obj.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (objectCanBeSliced + " " + ignoreRegularDamageIfCutSurfaceNotEnabled + " " +
|
||||
activateDamageOnSlice + " " + isIgnoreDamageIfSliceNotActivatedActive);
|
||||
}
|
||||
|
||||
if (!objectCanBeSliced && !ignoreRegularDamageIfCutSurfaceNotEnabled) {
|
||||
if (activateDamageOnSlice && !isIgnoreDamageIfSliceNotActivatedActive) {
|
||||
Vector3 damagePosition = currentCutPosition;
|
||||
|
||||
if (applyDamage.checkIfDead (obj)) {
|
||||
damagePosition = obj.transform.position;
|
||||
}
|
||||
|
||||
applyDamage.checkCanBeDamaged (gameObject, obj, damageAmountToApplyOnSlice, -currentCutForward, damagePosition,
|
||||
gameObject, true, true, ignoreShieldOnDamage, false, true,
|
||||
canActivateReactionSystemTemporally, damageReactionID, damageTypeID);
|
||||
}
|
||||
|
||||
if (applyForcesOnObjectsDetected && !objectIsSliceSurfaceDisabled) {
|
||||
if (!checkObjectLayerAndTagToApplyForces ||
|
||||
((1 << obj.layer & targetToApplyForceLayer.value) == 1 << obj.layer && tagetToApplyForceTagList.Contains (obj.tag))) {
|
||||
checkForceToApplyOnObject (obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useRemoteEventOnObjectsFound) {
|
||||
remoteEventSystem currentRemoteEventSystem = obj.GetComponent<remoteEventSystem> ();
|
||||
|
||||
if (currentRemoteEventSystem == null) {
|
||||
playerComponentsManager currentPlayerComponentsManager = obj.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
currentRemoteEventSystem = currentPlayerComponentsManager.getRemoteEventSystem ();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRemoteEventSystem != null) {
|
||||
for (int i = 0; i < remoteEventNameList.Count; i++) {
|
||||
currentRemoteEventSystem.callRemoteEvent (remoteEventNameList [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter (Collider col)
|
||||
{
|
||||
if (sliceActive) {
|
||||
currentColliderFound = col;
|
||||
|
||||
checkObjectDetected (currentColliderFound);
|
||||
|
||||
if (disableSliceAfterFirstCutEnabled) {
|
||||
disableSliceActiveWithDelay ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleSliceActiveState ()
|
||||
{
|
||||
setSliceActiveState (!sliceActive);
|
||||
}
|
||||
|
||||
public void setSliceActiveState (bool state)
|
||||
{
|
||||
sliceActive = state;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("setSliceActiveState " + sliceActive);
|
||||
}
|
||||
|
||||
stopDisableSliceActiveWithDelay ();
|
||||
|
||||
if (sliceActive) {
|
||||
if (mainCollider != null) {
|
||||
mainCollider.enabled = false;
|
||||
}
|
||||
|
||||
if (triggerCollider != null) {
|
||||
triggerCollider.enabled = true;
|
||||
}
|
||||
} else {
|
||||
disableIgnoreCollisionList ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkObjectDetected (Collider col)
|
||||
{
|
||||
if ((1 << col.gameObject.layer & targetToDamageLayer.value) == 1 << col.gameObject.layer) {
|
||||
|
||||
if (useObjectsToIgnoreList) {
|
||||
if (objectsToIgnoreList.Contains (col.gameObject)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setCurrentCutTransformValues ();
|
||||
|
||||
Collider currentCollider = col.GetComponent<Collider> ();
|
||||
|
||||
if (currentCollider != null) {
|
||||
processObject (currentCollider.gameObject, currentCollider, currentCutPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sliceCurrentObject (GameObject obj, Collider objectCollider, Material crossSectionMaterial, Vector3 slicePosition)
|
||||
{
|
||||
// slice the provided object using the transforms of this object
|
||||
if (currentSurfaceToSlice.isObjectCharacter ()) {
|
||||
|
||||
if (sliceCharactersEnabled) {
|
||||
bool isCharacterOrVehicle = applyDamage.getCharacterOrVehicle (obj) != null;
|
||||
|
||||
bool objectIsDead = applyDamage.checkIfDead (obj);
|
||||
|
||||
if (isCharacterOrVehicle && !objectIsDead) {
|
||||
processCharacter (obj);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("SLICING " + obj.name + " is character " + isCharacterOrVehicle + " is dead" + objectIsDead);
|
||||
}
|
||||
|
||||
Rigidbody mainObject = obj.GetComponent<Rigidbody> ();
|
||||
|
||||
bool mainObjectHasRigidbody = mainObject != null;
|
||||
|
||||
Vector3 lastSpeed = Vector3.zero;
|
||||
|
||||
if (mainObjectHasRigidbody) {
|
||||
lastSpeed = mainObject.linearVelocity;
|
||||
}
|
||||
|
||||
currentSurfaceToSlice.checkEventBeforeSlice ();
|
||||
|
||||
currentSurfaceToSlice.getMainSimpleSliceSystem ().activateSlice (objectCollider,
|
||||
positionInWorldSpace, normalInWorldSpace, slicePosition, updateLastObjectSpeed, lastSpeed);
|
||||
|
||||
currentSurfaceToSlice.checkEventOnCut ();
|
||||
|
||||
bool canCheckTimeBulletResult = true;
|
||||
|
||||
if (ignoreTimeBulletOnRegularSlice) {
|
||||
canCheckTimeBulletResult = false;
|
||||
}
|
||||
|
||||
if (canCheckTimeBulletResult) {
|
||||
currentSurfaceToSlice.checkTimeBulletOnCut ();
|
||||
}
|
||||
|
||||
lastTimeSlice = Time.time;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (sliceRegularObjectsEnabled) {
|
||||
bool objectSliced = false;
|
||||
|
||||
GameObject object1 = null;
|
||||
GameObject object2 = null;
|
||||
|
||||
currentSurfaceToSlice.checkEventBeforeSlice ();
|
||||
|
||||
obj = currentSurfaceToSlice.getMainSurfaceToSlice ();
|
||||
|
||||
// slice the provided object using the transforms of this object
|
||||
sliceSystemUtils.sliceObject (transform.position, obj, currentCutUp, crossSectionMaterial, ref objectSliced, ref object1, ref object2);
|
||||
|
||||
Vector3 objectPosition = obj.transform.position;
|
||||
Quaternion objectRotation = obj.transform.rotation;
|
||||
|
||||
Transform objectParent = obj.transform.parent;
|
||||
|
||||
if (objectSliced) {
|
||||
if (currentSurfaceToSlice.useParticlesOnSlice) {
|
||||
Quaternion particlesRotation = Quaternion.LookRotation (positionInWorldSpace);
|
||||
|
||||
Instantiate (currentSurfaceToSlice.particlesOnSlicePrefab, slicePosition, particlesRotation);
|
||||
}
|
||||
|
||||
currentSurfaceToSlice.checkEventOnCut ();
|
||||
|
||||
currentSurfaceToSlice.checkTimeBulletOnCut ();
|
||||
|
||||
Rigidbody mainObject = obj.GetComponent<Rigidbody> ();
|
||||
|
||||
bool mainObjectHasRigidbody = mainObject != null;
|
||||
|
||||
object1.transform.position = objectPosition;
|
||||
object1.transform.rotation = objectRotation;
|
||||
|
||||
object2.transform.position = objectPosition;
|
||||
object2.transform.rotation = objectRotation;
|
||||
|
||||
if (objectParent != null) {
|
||||
object1.transform.SetParent (objectParent);
|
||||
object2.transform.SetParent (objectParent);
|
||||
}
|
||||
|
||||
surfaceToSlice newSurfaceToSlice1 = object1.AddComponent<surfaceToSlice> ();
|
||||
surfaceToSlice newSurfaceToSlice2 = object2.AddComponent<surfaceToSlice> ();
|
||||
|
||||
currentSurfaceToSlice.copySurfaceInfo (newSurfaceToSlice1);
|
||||
currentSurfaceToSlice.copySurfaceInfo (newSurfaceToSlice2);
|
||||
|
||||
newSurfaceToSlice1.checkDestroySlicedPartsAfterDelay ();
|
||||
newSurfaceToSlice2.checkDestroySlicedPartsAfterDelay ();
|
||||
|
||||
|
||||
float distance1 = GKC_Utils.distance (obj.transform.position, object1.transform.position);
|
||||
float distance2 = GKC_Utils.distance (obj.transform.position, object2.transform.position);
|
||||
|
||||
float currentForceToApply = forceToApplyToCutPart;
|
||||
|
||||
Vector3 lastSpeed = Vector3.zero;
|
||||
|
||||
if (mainObjectHasRigidbody) {
|
||||
lastSpeed = mainObject.linearVelocity;
|
||||
}
|
||||
|
||||
ForceMode currentForceMode = forceMode;
|
||||
|
||||
if (currentSurfaceToSlice.useCustomForceMode) {
|
||||
currentForceMode = currentSurfaceToSlice.customForceMode;
|
||||
}
|
||||
|
||||
if (mainObjectHasRigidbody || activateRigidbodiesOnNewObjects) {
|
||||
|
||||
if (currentSurfaceToSlice.useCustomForceAmount) {
|
||||
currentForceToApply = currentSurfaceToSlice.customForceAmount;
|
||||
}
|
||||
|
||||
Rigidbody object1Rigidbody = object1.AddComponent<Rigidbody> ();
|
||||
|
||||
Rigidbody object2Rigidbody = object2.AddComponent<Rigidbody> ();
|
||||
|
||||
if (updateLastObjectSpeed) {
|
||||
if (lastSpeed != Vector3.zero) {
|
||||
object1Rigidbody.linearVelocity = lastSpeed;
|
||||
|
||||
object2Rigidbody.linearVelocity = lastSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
object2Rigidbody.AddExplosionForce (currentForceToApply, transform.position, forceRadius, forceUp, currentForceMode);
|
||||
|
||||
object1Rigidbody.AddExplosionForce (currentForceToApply, transform.position, forceRadius, forceUp, currentForceMode);
|
||||
} else {
|
||||
if (currentSurfaceToSlice.useCustomForceAmount) {
|
||||
currentForceToApply = currentSurfaceToSlice.customForceAmount;
|
||||
}
|
||||
|
||||
if (distance1 < distance2) {
|
||||
Rigidbody object2Rigidbody = object2.AddComponent<Rigidbody> ();
|
||||
|
||||
object2Rigidbody.AddExplosionForce (currentForceToApply, transform.position, forceRadius, forceUp, currentForceMode);
|
||||
} else {
|
||||
Rigidbody object1Rigidbody = object1.AddComponent<Rigidbody> ();
|
||||
|
||||
object1Rigidbody.AddExplosionForce (currentForceToApply, transform.position, forceRadius, forceUp, currentForceMode);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSurfaceToSlice.useBoxCollider) {
|
||||
object1.AddComponent<BoxCollider> ();
|
||||
object2.AddComponent<BoxCollider> ();
|
||||
} else {
|
||||
MeshCollider object1Collider = object1.AddComponent<MeshCollider> ();
|
||||
MeshCollider object2Collider = object2.AddComponent<MeshCollider> ();
|
||||
|
||||
object1Collider.convex = true;
|
||||
object2Collider.convex = true;
|
||||
}
|
||||
|
||||
Collider collider1 = object1.GetComponent<Collider> ();
|
||||
Collider collider2 = object2.GetComponent<Collider> ();
|
||||
|
||||
|
||||
if (collider1 != null) {
|
||||
collidersToIgnoreList.Add (collider1);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (collider1.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (collider2 != null) {
|
||||
collidersToIgnoreList.Add (collider2);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (collider2.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSurfaceToSlice.setNewLayerOnCut) {
|
||||
object1.layer = LayerMask.NameToLayer (currentSurfaceToSlice.newLayerOnCut);
|
||||
object2.layer = LayerMask.NameToLayer (currentSurfaceToSlice.newLayerOnCut);
|
||||
}
|
||||
|
||||
if (currentSurfaceToSlice.setNewTagOnCut) {
|
||||
object1.tag = currentSurfaceToSlice.tag;
|
||||
object2.tag = currentSurfaceToSlice.tag;
|
||||
}
|
||||
|
||||
if (cutMultipleTimesActive) {
|
||||
if (!objectsDetected.Contains (object1)) {
|
||||
objectsDetected.Add (object1);
|
||||
}
|
||||
|
||||
if (!objectsDetected.Contains (object2)) {
|
||||
objectsDetected.Add (object2);
|
||||
}
|
||||
}
|
||||
|
||||
obj.SetActive (false);
|
||||
|
||||
// obj.SetActive (false);
|
||||
|
||||
lastTimeSlice = Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopDisableSliceActiveWithDelay ()
|
||||
{
|
||||
if (disableSliceCoroutine != null) {
|
||||
StopCoroutine (disableSliceCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
public void disableSliceActiveWithDelay ()
|
||||
{
|
||||
stopDisableSliceActiveWithDelay ();
|
||||
|
||||
disableSliceCoroutine = StartCoroutine (disableSliceActiveWithDelayCoroutine ());
|
||||
}
|
||||
|
||||
IEnumerator disableSliceActiveWithDelayCoroutine ()
|
||||
{
|
||||
WaitForSeconds delay = new WaitForSeconds (0.5f);
|
||||
|
||||
yield return delay;
|
||||
|
||||
delay = new WaitForSeconds (disableTimeAfterCollision);
|
||||
|
||||
yield return delay;
|
||||
|
||||
if (mainCollider != null) {
|
||||
mainCollider.enabled = true;
|
||||
}
|
||||
|
||||
sliceActive = false;
|
||||
|
||||
disableIgnoreCollisionList ();
|
||||
}
|
||||
|
||||
public void disableIgnoreCollisionList ()
|
||||
{
|
||||
collidersToIgnoreList.Clear ();
|
||||
|
||||
if (triggerCollider != null) {
|
||||
triggerCollider.enabled = false;
|
||||
}
|
||||
|
||||
objectsDetected.Clear ();
|
||||
}
|
||||
|
||||
public void checkForceToApplyOnObject (GameObject objectToDamage)
|
||||
{
|
||||
Rigidbody objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
|
||||
|
||||
Vector3 forceDirection = currentCutDirection;
|
||||
|
||||
float forceAmount = addForceMultiplier;
|
||||
|
||||
float forceToVehiclesMultiplier = impactForceToVehiclesMultiplier;
|
||||
|
||||
if (applyImpactForceToVehicles) {
|
||||
Rigidbody objectToDamageMainRigidbody = applyDamage.applyForce (objectToDamage);
|
||||
|
||||
if (objectToDamageMainRigidbody) {
|
||||
Vector3 force = forceAmount * forceDirection;
|
||||
|
||||
bool isVehicle = applyDamage.isVehicle (objectToDamage);
|
||||
|
||||
if (isVehicle) {
|
||||
force *= forceToVehiclesMultiplier;
|
||||
}
|
||||
|
||||
objectToDamageMainRigidbody.AddForce (objectToDamageMainRigidbody.mass * force, forceMode);
|
||||
}
|
||||
} else {
|
||||
if (applyDamage.canApplyForce (objectToDamage)) {
|
||||
if (showDebugPrint) {
|
||||
print (objectToDamage.name);
|
||||
}
|
||||
|
||||
Vector3 force = forceAmount * forceDirection;
|
||||
|
||||
if (objectToDamageRigidbody == null) {
|
||||
objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
|
||||
}
|
||||
|
||||
objectToDamageRigidbody.AddForce (objectToDamageRigidbody.mass * force, forceMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 positionInWorldSpace
|
||||
{
|
||||
get
|
||||
{
|
||||
return (currentPlaneDefiner1 + currentPlaneDefiner2 + currentPlaneDefiner3) / 3f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 normalInWorldSpace
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 t0 = currentPlaneDefiner1;
|
||||
Vector3 t1 = currentPlaneDefiner2;
|
||||
Vector3 t2 = currentPlaneDefiner3;
|
||||
|
||||
Vector3 vectorValue;
|
||||
|
||||
vectorValue.x = t0.y * (t1.z - t2.z) + t1.y * (t2.z - t0.z) + t2.y * (t0.z - t1.z);
|
||||
vectorValue.y = t0.z * (t1.x - t2.x) + t1.z * (t2.x - t0.x) + t2.z * (t0.x - t1.x);
|
||||
vectorValue.z = t0.x * (t1.y - t2.y) + t1.x * (t2.y - t0.y) + t2.x * (t0.y - t1.y);
|
||||
|
||||
return vectorValue;
|
||||
}
|
||||
}
|
||||
|
||||
void processCharacter (GameObject currentCharacter)
|
||||
{
|
||||
StartCoroutine (processCharacterCoroutine (currentCharacter));
|
||||
}
|
||||
|
||||
List<Collider> colliders = new List<Collider> ();
|
||||
|
||||
IEnumerator processCharacterCoroutine (GameObject currentCharacter)
|
||||
{
|
||||
applyDamage.pushCharacterWithoutForceAndPauseGetUp (currentCharacter);
|
||||
|
||||
yield return new WaitForEndOfFrame ();
|
||||
|
||||
Collider [] temporalHits = Physics.OverlapBox (currentCutPosition, currentCutOverlapBoxSize, currentCutRotation, targetToDamageLayer);
|
||||
|
||||
bool bodyPartFound = false;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activating ragdoll on " + currentCharacter.name);
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("\n\n");
|
||||
}
|
||||
|
||||
if (temporalHits.Length > 0) {
|
||||
bool ragdollCollidersFoundOnCharacter = false;
|
||||
|
||||
colliders = null;
|
||||
|
||||
ragdollActivator currentRagdollActivator = currentCharacter.GetComponent<ragdollActivator> ();
|
||||
|
||||
if (currentRagdollActivator != null) {
|
||||
colliders = currentRagdollActivator.getBodyColliderList ();
|
||||
|
||||
if (colliders != null && colliders.Count > 0) {
|
||||
ragdollCollidersFoundOnCharacter = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < temporalHits.Length; i++) {
|
||||
if (!bodyPartFound) {
|
||||
Collider currentCollider = temporalHits [i];
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("checking " + currentCollider.name);
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (currentCollider.name + " body part when killing");
|
||||
}
|
||||
|
||||
bool canActivateSliceResult = false;
|
||||
|
||||
if (ragdollCollidersFoundOnCharacter) {
|
||||
if (showDebugPrint) {
|
||||
print ("ragoll detected");
|
||||
}
|
||||
|
||||
if (colliders.Contains (currentCollider)) {
|
||||
canActivateSliceResult = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("ragdoll part found");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
canActivateSliceResult = true;
|
||||
}
|
||||
|
||||
if (canActivateSliceResult) {
|
||||
if (applyDamage.isCharacter (currentCollider.gameObject)) {
|
||||
bodyPartFound = true;
|
||||
}
|
||||
|
||||
if (currentCharacter != null) {
|
||||
applyDamage.killCharacter (currentCharacter);
|
||||
}
|
||||
|
||||
processObject (currentCollider.gameObject, currentCollider, currentCutPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmos ()
|
||||
{
|
||||
if (!showGizmo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
|
||||
DrawGizmos ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected ()
|
||||
{
|
||||
DrawGizmos ();
|
||||
}
|
||||
|
||||
void DrawGizmos ()
|
||||
{
|
||||
if (showGizmo) {
|
||||
if (cutPositionTransform != null) {
|
||||
GKC_Utils.drawRectangleGizmo (cutPositionTransform.position, cutPositionTransform.rotation, Vector3.zero, cutOverlapBoxSize, gizmoColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fb9e2e7524b1794fb3ce4954555c88b
|
||||
timeCreated: 1578995500
|
||||
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/Weapons/New Weapon Behaviors/sliceObject.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,462 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class smartphoneDevice : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool canMakePhotos;
|
||||
public bool usePhotoSound;
|
||||
public AudioClip photoSound;
|
||||
public AudioElement photoAudioElement;
|
||||
public bool canUseFlash;
|
||||
public float flashDuration = 0.1f;
|
||||
|
||||
public bool storeCapturesEnabled = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Raycast Detection Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useCapsuleRaycast;
|
||||
|
||||
public float capsuleCastRadius;
|
||||
|
||||
[Space]
|
||||
[Header ("Zoom Settings")]
|
||||
[Space]
|
||||
|
||||
public bool canUseZoom;
|
||||
public float maxZoomAmout;
|
||||
public float minZoomAmount;
|
||||
public float zoomSpeed;
|
||||
|
||||
[Space]
|
||||
[Header ("Check Objects On Capture Settings")]
|
||||
[Space]
|
||||
|
||||
public bool checkObjectFoundOnCapture;
|
||||
public LayerMask layerToCheckObjectFound;
|
||||
public float rayDistanceToCheckObjectFound;
|
||||
public Transform raycastTransform;
|
||||
|
||||
public bool useOverrideSystemOnCapture;
|
||||
|
||||
public bool sendObjectOnCapture;
|
||||
public GameObject objectToSendOnCapture;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventOnCapture;
|
||||
public UnityEvent eventOnCapture;
|
||||
|
||||
public bool useEventsOnCameraViewChange;
|
||||
public UnityEvent eventOnCameraViewChangeToThirdPerson;
|
||||
public UnityEvent eventOnCameraViewChangeToFirstPerson;
|
||||
|
||||
public bool useEventsOnSmartphoneTurnOnOff;
|
||||
public UnityEvent eventOnSmartphoneTurnedOn;
|
||||
public UnityEvent eventOnSmartphoneTurnedOff;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public bool firstPersonActive;
|
||||
public bool isActivated;
|
||||
|
||||
public bool perspectiveSystemLocated;
|
||||
|
||||
[Space]
|
||||
[Header ("Smartphone Components")]
|
||||
[Space]
|
||||
|
||||
public GameObject smartphoneCamera;
|
||||
public GameObject smartphoneScreenCanvas;
|
||||
public GameObject smartphoneScreenCenter;
|
||||
|
||||
public GameObject cameraFlash;
|
||||
|
||||
public Transform mainScreenCenter;
|
||||
public Transform screenCenter;
|
||||
|
||||
public AudioSource mainAudioSource;
|
||||
|
||||
public Camera smartphoneMainCamera;
|
||||
|
||||
[Space]
|
||||
[Header ("Player Components")]
|
||||
[Space]
|
||||
|
||||
public Transform playerCameraTransform;
|
||||
public playerWeaponSystem weaponManager;
|
||||
public playerWeaponsManager mainPlayerWeaponsManager;
|
||||
public cameraCaptureSystem cameraCaptureManager;
|
||||
|
||||
public overrideElementControlSystem mainOverrideElementControlSystem;
|
||||
|
||||
public eventObjectFoundOnRaycastSystem mainEventObjectFoundOnRaycastSystem;
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
bool changingZoom;
|
||||
float currentFov;
|
||||
float zoomDirection = -1;
|
||||
cameraPerspectiveSystem currentPerspectiveSystem;
|
||||
|
||||
Coroutine flashCoroutine;
|
||||
|
||||
bool cameraCaptureManagerLocated;
|
||||
|
||||
RaycastHit[] hits;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
|
||||
private void Start ()
|
||||
{
|
||||
if (photoSound != null) {
|
||||
photoAudioElement.clip = photoSound;
|
||||
}
|
||||
|
||||
if (mainAudioSource != null) {
|
||||
photoAudioElement.audioSource = mainAudioSource;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
if (isActivated) {
|
||||
if (canUseZoom && changingZoom) {
|
||||
currentFov = smartphoneMainCamera.fieldOfView + Time.deltaTime * zoomSpeed * zoomDirection;
|
||||
|
||||
if (zoomDirection == -1) {
|
||||
if (currentFov < minZoomAmount) {
|
||||
zoomDirection = 1;
|
||||
}
|
||||
} else {
|
||||
if (currentFov > maxZoomAmout) {
|
||||
zoomDirection = -1;
|
||||
}
|
||||
}
|
||||
|
||||
smartphoneMainCamera.fieldOfView = currentFov;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void takePhoto ()
|
||||
{
|
||||
if (canMakePhotos) {
|
||||
playSound ();
|
||||
|
||||
checkFlash ();
|
||||
|
||||
if (storeCapturesEnabled) {
|
||||
if (cameraCaptureManagerLocated) {
|
||||
cameraCaptureManager.takeCapture (smartphoneMainCamera);
|
||||
}
|
||||
}
|
||||
|
||||
if (perspectiveSystemLocated) {
|
||||
currentPerspectiveSystem.checkCurrentPlayerPosition (playerCameraTransform, weaponManager.getMainCameraTransform (), smartphoneMainCamera);
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Take Photo");
|
||||
}
|
||||
|
||||
if (checkObjectFoundOnCapture) {
|
||||
if (Physics.Raycast (raycastTransform.position, raycastTransform.forward, out hit, rayDistanceToCheckObjectFound, layerToCheckObjectFound)) {
|
||||
if (useCapsuleRaycast) {
|
||||
|
||||
Vector3 currentRayOriginPosition = raycastTransform.position;
|
||||
|
||||
Vector3 currentRayTargetPosition = hit.point;
|
||||
|
||||
float distanceToTarget = GKC_Utils.distance (currentRayOriginPosition, currentRayTargetPosition);
|
||||
Vector3 rayDirection = currentRayOriginPosition - currentRayTargetPosition;
|
||||
rayDirection = rayDirection / rayDirection.magnitude;
|
||||
|
||||
Debug.DrawLine (currentRayTargetPosition, (rayDirection * distanceToTarget) + currentRayTargetPosition, Color.red, 2);
|
||||
|
||||
Vector3 point1 = currentRayOriginPosition - rayDirection * capsuleCastRadius;
|
||||
Vector3 point2 = currentRayTargetPosition + rayDirection * capsuleCastRadius;
|
||||
|
||||
hits = Physics.CapsuleCastAll (point1, point2, capsuleCastRadius, rayDirection, 0, layerToCheckObjectFound);
|
||||
|
||||
for (int i = 0; i < hits.Length; i++) {
|
||||
GameObject currentSurfaceGameObjectFound = hits [i].collider.gameObject;
|
||||
|
||||
checkObjectDetected (currentSurfaceGameObjectFound);
|
||||
}
|
||||
} else {
|
||||
checkObjectDetected (hit.collider.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changingZoom = false;
|
||||
|
||||
if (useEventOnCapture) {
|
||||
eventOnCapture.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Send Event On Capture");
|
||||
}
|
||||
}
|
||||
|
||||
if (useOverrideSystemOnCapture) {
|
||||
if (mainOverrideElementControlSystem != null) {
|
||||
mainOverrideElementControlSystem.checkElementToControl (raycastTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkObjectDetected (GameObject newObject)
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("Object Detected On Photo " + newObject.name);
|
||||
}
|
||||
|
||||
eventObjectFoundOnCaptureSystem currentEventObjectFoundOnCaptureSystem = newObject.GetComponent<eventObjectFoundOnCaptureSystem> ();
|
||||
|
||||
if (currentEventObjectFoundOnCaptureSystem != null) {
|
||||
currentEventObjectFoundOnCaptureSystem.callEventOnCapture ();
|
||||
|
||||
if (sendObjectOnCapture) {
|
||||
currentEventObjectFoundOnCaptureSystem.callEventOnCaptureWithGameObject (objectToSendOnCapture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkFlash ()
|
||||
{
|
||||
if (!canUseFlash) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (flashCoroutine != null) {
|
||||
StopCoroutine (flashCoroutine);
|
||||
}
|
||||
|
||||
flashCoroutine = StartCoroutine (flashCoroutineCoroutine ());
|
||||
}
|
||||
|
||||
IEnumerator flashCoroutineCoroutine ()
|
||||
{
|
||||
cameraFlash.SetActive (true);
|
||||
|
||||
yield return new WaitForSeconds (flashDuration);
|
||||
|
||||
cameraFlash.SetActive (false);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
|
||||
public void changeZoom ()
|
||||
{
|
||||
changingZoom = !changingZoom;
|
||||
}
|
||||
|
||||
public void turnOn ()
|
||||
{
|
||||
isActivated = true;
|
||||
|
||||
setSmartphoneState (isActivated);
|
||||
}
|
||||
|
||||
public void turnOff ()
|
||||
{
|
||||
isActivated = false;
|
||||
|
||||
setSmartphoneState (isActivated);
|
||||
}
|
||||
|
||||
public void changeSmartphoneState ()
|
||||
{
|
||||
setSmartphoneState (!isActivated);
|
||||
}
|
||||
|
||||
public void setSmartphoneState (bool state)
|
||||
{
|
||||
isActivated = state;
|
||||
|
||||
smartphoneScreenCanvas.SetActive (isActivated);
|
||||
|
||||
smartphoneScreenCenter.SetActive (isActivated);
|
||||
|
||||
smartphoneCamera.SetActive (isActivated);
|
||||
|
||||
changingZoom = false;
|
||||
|
||||
initializeComponents ();
|
||||
|
||||
if (isActivated) {
|
||||
if (mainPlayerWeaponsManager != null) {
|
||||
mainPlayerWeaponsManager.setWeaponPartLayer (smartphoneScreenCanvas);
|
||||
|
||||
mainPlayerWeaponsManager.setWeaponPartLayer (smartphoneScreenCenter);
|
||||
}
|
||||
}
|
||||
|
||||
if (useEventsOnSmartphoneTurnOnOff) {
|
||||
if (isActivated) {
|
||||
eventOnSmartphoneTurnedOn.Invoke ();
|
||||
} else {
|
||||
eventOnSmartphoneTurnedOff.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
if (isActivated) {
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
} else {
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
public void playSound ()
|
||||
{
|
||||
if (usePhotoSound) {
|
||||
if (mainAudioSource != null)
|
||||
GKC_Utils.checkAudioSourcePitch (mainAudioSource);
|
||||
|
||||
AudioPlayer.PlayOneShot (photoAudioElement, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentPerspectiveSystem (cameraPerspectiveSystem perspective)
|
||||
{
|
||||
currentPerspectiveSystem = perspective;
|
||||
|
||||
perspectiveSystemLocated = currentPerspectiveSystem != null;
|
||||
}
|
||||
|
||||
public void removeCurrentPerspectiveSystem ()
|
||||
{
|
||||
currentPerspectiveSystem = null;
|
||||
|
||||
perspectiveSystemLocated = false;
|
||||
}
|
||||
|
||||
public Camera getSmarthphoneMainCamera ()
|
||||
{
|
||||
return smartphoneMainCamera;
|
||||
}
|
||||
|
||||
public void setUseEventOnCaptureState (bool state)
|
||||
{
|
||||
useEventOnCapture = state;
|
||||
}
|
||||
|
||||
public void setStoreCapturesEnabledState (bool state)
|
||||
{
|
||||
storeCapturesEnabled = state;
|
||||
}
|
||||
|
||||
public void setUseOverrideSystemOnCaptureState (bool state)
|
||||
{
|
||||
useOverrideSystemOnCapture = state;
|
||||
}
|
||||
|
||||
public void rotateScreenToRight ()
|
||||
{
|
||||
mainScreenCenter.localEulerAngles = Vector3.zero;
|
||||
screenCenter.localEulerAngles = Vector3.zero;
|
||||
smartphoneCamera.transform.localEulerAngles = Vector3.zero;
|
||||
}
|
||||
|
||||
public void rotateScreenToLeft ()
|
||||
{
|
||||
mainScreenCenter.localEulerAngles = new Vector3 (0, 0, 180);
|
||||
screenCenter.localEulerAngles = new Vector3 (0, 0, 180);
|
||||
smartphoneCamera.transform.localEulerAngles = new Vector3 (0, 0, 180);
|
||||
}
|
||||
|
||||
public void setFirstOrThirdPersonViewState (bool state)
|
||||
{
|
||||
firstPersonActive = state;
|
||||
|
||||
if (useEventsOnCameraViewChange) {
|
||||
if (firstPersonActive) {
|
||||
eventOnCameraViewChangeToFirstPerson.Invoke ();
|
||||
} else {
|
||||
eventOnCameraViewChangeToThirdPerson.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool componentsInitialized;
|
||||
|
||||
void initializeComponents ()
|
||||
{
|
||||
if (componentsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainPlayerWeaponsManager == null) {
|
||||
mainPlayerWeaponsManager = weaponManager.getPlayerWeaponsManger ();
|
||||
}
|
||||
|
||||
GameObject playerControllerGameObject = mainPlayerWeaponsManager.getPlayerGameObject ();
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = playerControllerGameObject.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
cameraCaptureManager = mainPlayerComponentsManager.getCameraCaptureSystem ();
|
||||
|
||||
if (cameraCaptureManager != null) {
|
||||
cameraCaptureManagerLocated = true;
|
||||
}
|
||||
|
||||
playerCamera mainPlayerCamera = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
|
||||
playerCameraTransform = mainPlayerCamera.transform;
|
||||
|
||||
raycastTransform = mainPlayerCamera.getMainCamera ().transform;
|
||||
|
||||
mainOverrideElementControlSystem = mainPlayerComponentsManager.getOverrideElementControlSystem ();
|
||||
|
||||
if (mainEventObjectFoundOnRaycastSystem != null) {
|
||||
mainEventObjectFoundOnRaycastSystem.setRaycastTransform (raycastTransform);
|
||||
}
|
||||
|
||||
Canvas mainSmartphoneCanvas = smartphoneScreenCanvas.GetComponent<Canvas> ();
|
||||
|
||||
if (mainSmartphoneCanvas != null) {
|
||||
if (mainSmartphoneCanvas.worldCamera == null) {
|
||||
mainSmartphoneCanvas.worldCamera = mainPlayerCamera.getMainCamera ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentsInitialized = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 323c0278c308c1640b72811d317c0915
|
||||
timeCreated: 1524511111
|
||||
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/Weapons/New Weapon Behaviors/smartphoneDevice.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,390 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class surfaceToSlice : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool cutSurfaceEnabled = true;
|
||||
|
||||
public bool useCustomForceAmount;
|
||||
public float customForceAmount;
|
||||
|
||||
public bool useCustomForceMode;
|
||||
public ForceMode customForceMode;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useBoxCollider;
|
||||
|
||||
public bool ignoreRegularDamageIfCutSurfaceNotEnabled;
|
||||
|
||||
[Space]
|
||||
|
||||
public GameObject mainSurfaceToSlice;
|
||||
|
||||
[Space]
|
||||
[Header ("Material Settings")]
|
||||
[Space]
|
||||
|
||||
public Material crossSectionMaterial;
|
||||
|
||||
[Space]
|
||||
[Header ("Tag and Layer Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setNewTagOnCut;
|
||||
public string newTagOnCut;
|
||||
|
||||
public bool setNewLayerOnCut;
|
||||
public string newLayerOnCut;
|
||||
|
||||
[Space]
|
||||
[Header ("Particle Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useParticlesOnSlice;
|
||||
public GameObject particlesOnSlicePrefab;
|
||||
|
||||
[Space]
|
||||
[Header ("Slice Limit Settings")]
|
||||
[Space]
|
||||
|
||||
public bool cutMultipleTimesActive = true;
|
||||
|
||||
public bool useLimitedNumberOfCuts;
|
||||
public int limitedNumberOfCuts;
|
||||
|
||||
[Space]
|
||||
[Header ("Slice Direction Settings")]
|
||||
[Space]
|
||||
|
||||
public bool checkForCustomSliceDirection;
|
||||
|
||||
public float maxSliceDirectionAngle;
|
||||
public Transform customSliceDirectionUp;
|
||||
public bool allowReverseSliceDirection;
|
||||
|
||||
[Space]
|
||||
[Header ("Character Settings")]
|
||||
[Space]
|
||||
|
||||
public bool objectIsCharacter;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool ignoreDamageIfSliceNotActivated;
|
||||
|
||||
[Space]
|
||||
|
||||
public simpleSliceSystem mainSimpleSliceSystem;
|
||||
|
||||
[Space]
|
||||
[Header ("Bullet Time Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useTimeBulletOnSliceEnabled;
|
||||
public float timeBulletDuration = 3;
|
||||
public float timeScale = 0.2f;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool destroySlicedPartsAfterDelay;
|
||||
public float delayToDestroySlicedParts;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public bool mainSimpleSliceSystemAssigned;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventOnCut;
|
||||
public UnityEvent eventOnCut;
|
||||
|
||||
public bool copyEventOnSlicedObjects;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventBeforeCut;
|
||||
public UnityEvent eventBeforeCut;
|
||||
|
||||
|
||||
|
||||
float lastTimeSliced;
|
||||
|
||||
destroyGameObject mainDestroyGameObject;
|
||||
bool mainDestroyGameObjectAssigned;
|
||||
|
||||
|
||||
public void checkEventBeforeSlice ()
|
||||
{
|
||||
if (useEventBeforeCut) {
|
||||
eventBeforeCut.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnCut ()
|
||||
{
|
||||
if (useEventOnCut) {
|
||||
eventOnCut.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void copySurfaceInfo (surfaceToSlice surfaceToCopy)
|
||||
{
|
||||
lastTimeSliced = Time.time;
|
||||
|
||||
surfaceToCopy.setCrossSectionMaterial (crossSectionMaterial);
|
||||
|
||||
surfaceToCopy.setNewTagOnCut = setNewTagOnCut;
|
||||
surfaceToCopy.newTagOnCut = newTagOnCut;
|
||||
|
||||
surfaceToCopy.setNewLayerOnCut = setNewLayerOnCut;
|
||||
surfaceToCopy.newLayerOnCut = newLayerOnCut;
|
||||
|
||||
if (useParticlesOnSlice) {
|
||||
surfaceToCopy.useParticlesOnSlice = useParticlesOnSlice;
|
||||
surfaceToCopy.particlesOnSlicePrefab = particlesOnSlicePrefab;
|
||||
}
|
||||
|
||||
surfaceToCopy.cutMultipleTimesActive = cutMultipleTimesActive;
|
||||
|
||||
if (useLimitedNumberOfCuts) {
|
||||
surfaceToCopy.useLimitedNumberOfCuts = useLimitedNumberOfCuts;
|
||||
surfaceToCopy.limitedNumberOfCuts = limitedNumberOfCuts - 1;
|
||||
}
|
||||
|
||||
surfaceToCopy.useCustomForceAmount = useCustomForceAmount;
|
||||
|
||||
surfaceToCopy.customForceAmount = customForceAmount;
|
||||
|
||||
surfaceToCopy.useCustomForceMode = useCustomForceMode;
|
||||
|
||||
surfaceToCopy.customForceMode = customForceMode;
|
||||
|
||||
surfaceToCopy.useBoxCollider = useBoxCollider;
|
||||
|
||||
surfaceToCopy.lastTimeSliced = lastTimeSliced;
|
||||
|
||||
surfaceToCopy.destroySlicedPartsAfterDelay = destroySlicedPartsAfterDelay;
|
||||
|
||||
surfaceToCopy.delayToDestroySlicedParts = delayToDestroySlicedParts;
|
||||
|
||||
surfaceToCopy.copyEventOnSlicedObjects = copyEventOnSlicedObjects;
|
||||
|
||||
if (copyEventOnSlicedObjects) {
|
||||
|
||||
surfaceToCopy.useEventOnCut = useEventOnCut;
|
||||
|
||||
surfaceToCopy.eventOnCut = eventOnCut;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isObjectCharacter ()
|
||||
{
|
||||
return objectIsCharacter;
|
||||
}
|
||||
|
||||
public bool isIgnoreDamageIfSliceNotActivatedActive ()
|
||||
{
|
||||
return ignoreDamageIfSliceNotActivated;
|
||||
}
|
||||
|
||||
public bool isCutSurfaceEnabled ()
|
||||
{
|
||||
return cutSurfaceEnabled;
|
||||
}
|
||||
|
||||
public void setCutSurfaceEnabledState (bool state)
|
||||
{
|
||||
cutSurfaceEnabled = state;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Set Cut Surface Enabled State " + cutSurfaceEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIgnoreRegularDamageIfCutSurfaceNotEnabledState (bool state)
|
||||
{
|
||||
ignoreRegularDamageIfCutSurfaceNotEnabled = state;
|
||||
}
|
||||
|
||||
public bool isIgnoreRegularDamageIfCutSurfaceNotEnabled ()
|
||||
{
|
||||
return ignoreRegularDamageIfCutSurfaceNotEnabled;
|
||||
}
|
||||
|
||||
public float getLastTimeSliced ()
|
||||
{
|
||||
return lastTimeSliced;
|
||||
}
|
||||
|
||||
public bool sliceCanBeActivated (float minDelayToSliceSameObject)
|
||||
{
|
||||
if (useLimitedNumberOfCuts) {
|
||||
if (limitedNumberOfCuts <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Time.time > lastTimeSliced + minDelayToSliceSameObject) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool checkSliceDirectionResult (Vector3 sliceDirectionRight, Vector3 sliceDirectionUp)
|
||||
{
|
||||
if (checkForCustomSliceDirection) {
|
||||
float sliceAngleRight =
|
||||
Vector3.SignedAngle (sliceDirectionRight, customSliceDirectionUp.right,
|
||||
customSliceDirectionUp.forward);
|
||||
|
||||
float sliceAngleRightABS = Mathf.Abs (sliceAngleRight);
|
||||
|
||||
float sliceAngleUp =
|
||||
Vector3.SignedAngle (sliceDirectionUp, customSliceDirectionUp.up,
|
||||
customSliceDirectionUp.forward);
|
||||
|
||||
float sliceAngleUpABS = Mathf.Abs (sliceAngleUp);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("checkSliceDirectionResult " + sliceDirectionRight + " " + sliceAngleRight);
|
||||
print (sliceDirectionUp + " " + sliceAngleUp);
|
||||
}
|
||||
|
||||
if (allowReverseSliceDirection) {
|
||||
float oppositeRightAngle = (180 - sliceAngleRightABS);
|
||||
|
||||
if (oppositeRightAngle < maxSliceDirectionAngle) {
|
||||
return true;
|
||||
} else {
|
||||
if (oppositeRightAngle < 90) {
|
||||
float oppositeUpAngle = (180 - sliceAngleUpABS);
|
||||
|
||||
if (oppositeUpAngle < maxSliceDirectionAngle) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sliceAngleRightABS <= maxSliceDirectionAngle) {
|
||||
return true;
|
||||
} else {
|
||||
if (sliceAngleRightABS < 90) {
|
||||
if (sliceAngleUpABS <= maxSliceDirectionAngle) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public simpleSliceSystem getMainSimpleSliceSystem ()
|
||||
{
|
||||
return mainSimpleSliceSystem;
|
||||
}
|
||||
|
||||
public void setMainSimpleSliceSystem (GameObject newObject)
|
||||
{
|
||||
if (newObject != null) {
|
||||
mainSimpleSliceSystem = newObject.GetComponent<simpleSliceSystem> ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDestructionPending (bool state)
|
||||
{
|
||||
if (!mainSimpleSliceSystemAssigned) {
|
||||
mainSimpleSliceSystemAssigned = mainSimpleSliceSystem != null;
|
||||
}
|
||||
|
||||
if (mainSimpleSliceSystemAssigned) {
|
||||
mainSimpleSliceSystem.setDestructionPending (state);
|
||||
}
|
||||
}
|
||||
|
||||
public void setUseTimeBulletValue (bool state)
|
||||
{
|
||||
useTimeBulletOnSliceEnabled = state;
|
||||
}
|
||||
|
||||
public void checkTimeBulletOnCut ()
|
||||
{
|
||||
if (useTimeBulletOnSliceEnabled) {
|
||||
GKC_Utils.activateTimeBulletXSeconds (timeBulletDuration, timeScale);
|
||||
}
|
||||
}
|
||||
|
||||
public Material getCrossSectionMaterial ()
|
||||
{
|
||||
return crossSectionMaterial;
|
||||
}
|
||||
|
||||
public void setCrossSectionMaterial (Material newMaterial)
|
||||
{
|
||||
crossSectionMaterial = newMaterial;
|
||||
}
|
||||
|
||||
public void checkDestroySlicedPartsAfterDelay ()
|
||||
{
|
||||
if (destroySlicedPartsAfterDelay && !objectIsCharacter) {
|
||||
mainDestroyGameObjectAssigned = mainDestroyGameObject != null;
|
||||
|
||||
if (!mainDestroyGameObjectAssigned) {
|
||||
mainDestroyGameObject = gameObject.AddComponent<destroyGameObject> ();
|
||||
|
||||
mainDestroyGameObjectAssigned = true;
|
||||
}
|
||||
|
||||
if (mainDestroyGameObjectAssigned) {
|
||||
mainDestroyGameObject.setTimer (delayToDestroySlicedParts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMainSurfaceToSlice (GameObject newObject)
|
||||
{
|
||||
mainSurfaceToSlice = newObject;
|
||||
}
|
||||
|
||||
public GameObject getMainSurfaceToSlice ()
|
||||
{
|
||||
if (mainSurfaceToSlice == null) {
|
||||
mainSurfaceToSlice = gameObject;
|
||||
}
|
||||
|
||||
return mainSurfaceToSlice;
|
||||
}
|
||||
|
||||
//EDITOR FUNCTIONS
|
||||
public void setCutSurfaceEnabledStateFromEditor (bool state)
|
||||
{
|
||||
setCutSurfaceEnabledState (state);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Surface To Slice", gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec517ad904783e044a7e6bdc3c783099
|
||||
timeCreated: 1576821048
|
||||
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/Weapons/New Weapon Behaviors/surfaceToSlice.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,528 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class vacuumGun : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool vacuumEnabled = true;
|
||||
|
||||
public LayerMask layerToDetect;
|
||||
|
||||
public bool ignoreObjectsTag;
|
||||
|
||||
public List<string> tagsToIgnore = new List<string> ();
|
||||
|
||||
public string layerToSetOnObjectsFound = "Ignore Raycast";
|
||||
|
||||
public float maxDistanceGrab;
|
||||
|
||||
public bool storeObjectsOnInventory;
|
||||
|
||||
public float minDistanceToStoreObjects;
|
||||
|
||||
public float vacuumSpeed = 10;
|
||||
|
||||
public float holdDistance = 3;
|
||||
|
||||
public bool destroyAllObjectsOnReachPosition = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Expel Object Settings")]
|
||||
[Space]
|
||||
|
||||
public bool expelEnabled;
|
||||
|
||||
public Transform expelTransformPosition;
|
||||
|
||||
public float expelRate = 0.5f;
|
||||
|
||||
public float expelForce = 20;
|
||||
|
||||
public bool expelObjectsOneByOne;
|
||||
|
||||
[Space]
|
||||
[Header ("Ignore Expel Object Settings")]
|
||||
[Space]
|
||||
|
||||
public bool ignoreInventoryObjectListToExpel;
|
||||
|
||||
public List<string> ignoreInventoryObjectListToExpelList = new List<string> ();
|
||||
|
||||
public bool ignoreInventoryObjectCategoryListToExpel;
|
||||
|
||||
public List<string> ignoreInventoryObjectCategoryListToExpelList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useRotor = true;
|
||||
public Transform rotor;
|
||||
public float rotorRotationSpeed = 10;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool expelActive;
|
||||
|
||||
public bool vacuumActive;
|
||||
|
||||
public List<Rigidbody> rigidbodyList = new List<Rigidbody> ();
|
||||
|
||||
public List<rigidbodyInfo> rigidbodyInfoList = new List<rigidbodyInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Remote Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useRemoteEvents;
|
||||
public List<string> removeEventNameList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public inventoryManager mainInventoryManager;
|
||||
|
||||
public playerController playerControllerManager;
|
||||
public playerCamera playerCameraManager;
|
||||
|
||||
public playerWeaponSystem mainPlayerWeaponSystem;
|
||||
|
||||
public Transform mainCameraTransform;
|
||||
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
bool componentsInitialized;
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
GameObject currentObjectToGrabFound;
|
||||
|
||||
Vector3 nextObjectHeldPosition;
|
||||
|
||||
Vector3 currentObjectHeldPosition;
|
||||
|
||||
Transform currentHoldTransform;
|
||||
|
||||
float orignalHoldDistance;
|
||||
|
||||
float lastTimeExpel;
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
if (vacuumActive) {
|
||||
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, maxDistanceGrab, layerToDetect)) {
|
||||
if (currentObjectToGrabFound != hit.collider.gameObject) {
|
||||
currentObjectToGrabFound = hit.collider.gameObject;
|
||||
|
||||
bool checkObjectResult = true;
|
||||
|
||||
if (ignoreObjectsTag) {
|
||||
if (tagsToIgnore.Contains (currentObjectToGrabFound.tag)) {
|
||||
checkObjectResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkObjectResult) {
|
||||
return;
|
||||
}
|
||||
|
||||
Rigidbody newRigidbody = currentObjectToGrabFound.GetComponent<Rigidbody> ();
|
||||
|
||||
if (newRigidbody != null) {
|
||||
if (!rigidbodyList.Contains (newRigidbody)) {
|
||||
rigidbodyList.Add (newRigidbody);
|
||||
|
||||
rigidbodyInfo newRigidbodyInfo = new rigidbodyInfo ();
|
||||
|
||||
newRigidbodyInfo.mainGameObject = currentObjectToGrabFound;
|
||||
newRigidbodyInfo.objectLayer = currentObjectToGrabFound.layer;
|
||||
|
||||
rigidbodyInfoList.Add (newRigidbodyInfo);
|
||||
|
||||
newRigidbody.gameObject.layer = LayerMask.NameToLayer (layerToSetOnObjectsFound);
|
||||
}
|
||||
}
|
||||
|
||||
if (useRemoteEvents) {
|
||||
remoteEventSystem currentRemoteEventSystem = currentObjectToGrabFound.GetComponent<remoteEventSystem> ();
|
||||
|
||||
if (currentRemoteEventSystem != null) {
|
||||
for (int i = 0; i < removeEventNameList.Count; i++) {
|
||||
|
||||
currentRemoteEventSystem.callRemoteEvent (removeEventNameList [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rigidbodyList.Count > 0) {
|
||||
currentHoldTransform = mainCameraTransform;
|
||||
|
||||
if (playerCameraManager.is2_5ViewActive ()) {
|
||||
currentHoldTransform = playerCameraManager.getCurrentLookDirection2_5d ();
|
||||
|
||||
holdDistance = 0;
|
||||
}
|
||||
|
||||
if (playerCameraManager.useTopDownView) {
|
||||
currentHoldTransform = playerCameraManager.getCurrentLookDirectionTopDown ();
|
||||
|
||||
holdDistance = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rigidbodyList.Count; i++) {
|
||||
Rigidbody currentRigidbody = rigidbodyList [i];
|
||||
|
||||
if (currentRigidbody != null) {
|
||||
nextObjectHeldPosition = currentHoldTransform.position + mainCameraTransform.forward * holdDistance;
|
||||
|
||||
currentObjectHeldPosition = currentRigidbody.position;
|
||||
|
||||
currentRigidbody.linearVelocity = (nextObjectHeldPosition - currentObjectHeldPosition) * vacuumSpeed;
|
||||
|
||||
if (storeObjectsOnInventory) {
|
||||
if (GKC_Utils.distance (mainCameraTransform.position, currentRigidbody.position) < minDistanceToStoreObjects) {
|
||||
pickUpObject currentPickupObject = currentRigidbody.GetComponent<pickUpObject> ();
|
||||
|
||||
if (currentPickupObject != null) {
|
||||
|
||||
string inventoryObjectName = currentPickupObject.getPickupObjectName ();
|
||||
|
||||
// print ("checking " + inventoryObjectName);
|
||||
|
||||
if (inventoryObjectName != "") {
|
||||
int inventoryObjectAmount = (int)currentPickupObject.getAmountPicked ();
|
||||
|
||||
// print ("checking " + inventoryObjectAmount);
|
||||
|
||||
removeRigidbodyFromList (currentRigidbody);
|
||||
|
||||
if (applyDamage.giveInventoryObjectToCharacter (playerControllerManager.gameObject,
|
||||
inventoryObjectName,
|
||||
inventoryObjectAmount, null,
|
||||
0, 0,
|
||||
ForceMode.Impulse, 0, false, false, false)) {
|
||||
|
||||
Destroy (currentRigidbody.gameObject);
|
||||
}
|
||||
|
||||
checkNullObjects ();
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (destroyAllObjectsOnReachPosition) {
|
||||
Destroy (currentRigidbody.gameObject);
|
||||
|
||||
checkNullObjects ();
|
||||
|
||||
return;
|
||||
} else {
|
||||
removeRigidbodyFromList (currentRigidbody);
|
||||
|
||||
checkNullObjects ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (destroyAllObjectsOnReachPosition) {
|
||||
Destroy (currentRigidbody.gameObject);
|
||||
|
||||
checkNullObjects ();
|
||||
|
||||
return;
|
||||
} else {
|
||||
removeRigidbodyFromList (currentRigidbody);
|
||||
|
||||
checkNullObjects ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (destroyAllObjectsOnReachPosition) {
|
||||
Destroy (currentRigidbody.gameObject);
|
||||
|
||||
checkNullObjects ();
|
||||
|
||||
return;
|
||||
} else {
|
||||
removeRigidbodyFromList (currentRigidbody);
|
||||
|
||||
checkNullObjects ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
removeRigidbodyFromList (currentRigidbody);
|
||||
|
||||
checkNullObjects ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (expelActive) {
|
||||
if (Time.time > lastTimeExpel + expelRate) {
|
||||
if (!mainInventoryManager.isInventoryEmpty ()) {
|
||||
inventoryInfo currentInventoryInfo = mainInventoryManager.getRandomInventoryInfo ();
|
||||
|
||||
if (currentInventoryInfo != null) {
|
||||
bool canExpelObjectResult = true;
|
||||
|
||||
if (!currentInventoryInfo.canBeDropped) {
|
||||
canExpelObjectResult = false;
|
||||
}
|
||||
|
||||
if (canExpelObjectResult) {
|
||||
if (ignoreInventoryObjectListToExpel) {
|
||||
if (ignoreInventoryObjectListToExpelList.Contains (currentInventoryInfo.Name)) {
|
||||
canExpelObjectResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canExpelObjectResult) {
|
||||
if (ignoreInventoryObjectCategoryListToExpel) {
|
||||
if (ignoreInventoryObjectCategoryListToExpelList.Contains (currentInventoryInfo.categoryName)) {
|
||||
canExpelObjectResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canExpelObjectResult) {
|
||||
int amountToDrop = 0;
|
||||
|
||||
if (expelObjectsOneByOne) {
|
||||
amountToDrop = 1;
|
||||
} else {
|
||||
amountToDrop = currentInventoryInfo.amount;
|
||||
}
|
||||
|
||||
mainInventoryManager.dropObjectByName (currentInventoryInfo.Name, amountToDrop, true, false, false);
|
||||
|
||||
GameObject lastObjectDropped = mainInventoryManager.getLastObjectDropped ();
|
||||
|
||||
if (lastObjectDropped != null && previousObjectDropped != lastObjectDropped) {
|
||||
lastObjectDropped.transform.position = expelTransformPosition.position;
|
||||
|
||||
Rigidbody currentObjectRigidbody = lastObjectDropped.GetComponent<Rigidbody> ();
|
||||
|
||||
if (currentObjectRigidbody != null) {
|
||||
currentObjectRigidbody.AddForce (expelTransformPosition.forward * expelForce, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
previousObjectDropped = lastObjectDropped;
|
||||
}
|
||||
|
||||
lastTimeExpel = Time.time;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
enableOrDisableExpel (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useRotor) {
|
||||
rotor.Rotate (0, 0, Time.deltaTime * rotorRotationSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
GameObject previousObjectDropped;
|
||||
|
||||
|
||||
void checkNullObjects ()
|
||||
{
|
||||
for (int i = rigidbodyList.Count - 1; i >= 0; i--) {
|
||||
if (rigidbodyList [i] == null) {
|
||||
rigidbodyList.RemoveAt (i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void removeRigidbodyFromList (Rigidbody currentRigidbody)
|
||||
{
|
||||
if (currentRigidbody == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rigidbodyList.Contains (currentRigidbody)) {
|
||||
rigidbodyList.Remove (currentRigidbody);
|
||||
|
||||
int currentIndex = rigidbodyInfoList.FindIndex (s => s.mainGameObject == currentRigidbody.gameObject);
|
||||
|
||||
if (currentIndex > -1) {
|
||||
rigidbodyInfo newRigidbodyInfo = rigidbodyInfoList [currentIndex];
|
||||
|
||||
if (newRigidbodyInfo.mainGameObject != null) {
|
||||
newRigidbodyInfo.mainGameObject.layer = newRigidbodyInfo.objectLayer;
|
||||
}
|
||||
|
||||
rigidbodyInfoList.RemoveAt (currentIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVacuumEnabledState (bool state)
|
||||
{
|
||||
if (!state) {
|
||||
if (vacuumActive) {
|
||||
enableOrDisableVacuum (false);
|
||||
}
|
||||
}
|
||||
|
||||
vacuumEnabled = state;
|
||||
}
|
||||
|
||||
public void enableVacuum ()
|
||||
{
|
||||
enableOrDisableVacuum (true);
|
||||
}
|
||||
|
||||
public void disableVacuum ()
|
||||
{
|
||||
enableOrDisableVacuum (false);
|
||||
}
|
||||
|
||||
public void enableOrDisableVacuum (bool state)
|
||||
{
|
||||
if (!vacuumEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
vacuumActive = state;
|
||||
|
||||
mainInventoryManager.setEquipWeaponsWhenPickedPausedState (state);
|
||||
|
||||
if (state) {
|
||||
initializeComponents ();
|
||||
|
||||
holdDistance = orignalHoldDistance;
|
||||
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
|
||||
expelActive = false;
|
||||
} else {
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
currentObjectToGrabFound = null;
|
||||
|
||||
rigidbodyList.Clear ();
|
||||
|
||||
for (int i = 0; i < rigidbodyInfoList.Count; i++) {
|
||||
rigidbodyInfo newRigidbodyInfo = rigidbodyInfoList [i];
|
||||
|
||||
if (newRigidbodyInfo.mainGameObject != null) {
|
||||
|
||||
newRigidbodyInfo.mainGameObject.layer = newRigidbodyInfo.objectLayer;
|
||||
}
|
||||
}
|
||||
|
||||
rigidbodyInfoList.Clear ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setExpelEnabledState (bool state)
|
||||
{
|
||||
if (!state) {
|
||||
if (expelActive) {
|
||||
enableOrDisableExpel (false);
|
||||
}
|
||||
}
|
||||
|
||||
expelEnabled = state;
|
||||
}
|
||||
|
||||
public void enableOrDisableExpel (bool state)
|
||||
{
|
||||
if (!expelEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
expelActive = state;
|
||||
|
||||
previousObjectDropped = null;
|
||||
|
||||
lastTimeExpel = Time.time;
|
||||
|
||||
if (state) {
|
||||
initializeComponents ();
|
||||
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
|
||||
if (vacuumActive) {
|
||||
mainInventoryManager.setEquipWeaponsWhenPickedPausedState (false);
|
||||
|
||||
vacuumActive = false;
|
||||
}
|
||||
} else {
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void initializeComponents ()
|
||||
{
|
||||
if (componentsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainPlayerWeaponSystem != null) {
|
||||
GameObject playerControllerGameObject = mainPlayerWeaponSystem.getPlayerWeaponsManger ().gameObject;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = playerControllerGameObject.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
playerControllerManager = mainPlayerComponentsManager.getPlayerController ();
|
||||
|
||||
playerCameraManager = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
|
||||
mainCameraTransform = playerCameraManager.getCameraTransform ();
|
||||
}
|
||||
}
|
||||
|
||||
orignalHoldDistance = holdDistance;
|
||||
|
||||
componentsInitialized = true;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class rigidbodyInfo
|
||||
{
|
||||
public GameObject mainGameObject;
|
||||
public int objectLayer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbd2c141967e2f242ac26019a57a7652
|
||||
timeCreated: 1696540501
|
||||
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/Weapons/New Weapon Behaviors/vacuumGun.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,456 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
|
||||
public class weaponLaser : laser
|
||||
{
|
||||
[Space]
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool weaponLaserEnabled;
|
||||
public float laserDamage = 0.3f;
|
||||
public LayerMask layer;
|
||||
|
||||
public laserDevice.laserType lasertype;
|
||||
public int reflactionLimit = 10;
|
||||
|
||||
public float useEnergyRate;
|
||||
public int amountEnergyUsed;
|
||||
|
||||
public bool useMinTimeToUseLaserDamageRate;
|
||||
public float minTimeToUseLaserDamageRate;
|
||||
public float laserDamageRate;
|
||||
|
||||
[Space]
|
||||
[Header ("Sound Settings")]
|
||||
[Space]
|
||||
|
||||
public AudioClip laserEffect;
|
||||
public AudioElement laserEffectAudioElement;
|
||||
public float playSoundRate;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool reloading;
|
||||
|
||||
public GameObject currentLaser;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerWeaponSystem weaponManager;
|
||||
|
||||
public Transform mainCameraTransform;
|
||||
|
||||
public AudioSource mainAudioSource;
|
||||
public GameObject hitSmoke;
|
||||
public GameObject hitSparks;
|
||||
public GameObject laserLight;
|
||||
public GameObject player;
|
||||
|
||||
float lastTimeLaserActive;
|
||||
bool laserActivePreviously;
|
||||
|
||||
float lastTimeLaserDamage;
|
||||
Vector3 inDirection;
|
||||
Vector3 laserHitPosition;
|
||||
RaycastHit hit;
|
||||
Ray ray;
|
||||
int nPoints;
|
||||
Renderer currentLaserRenderer;
|
||||
|
||||
float lastTimeUsed;
|
||||
float lastTimeSoundPlayed;
|
||||
bool canDamage;
|
||||
int propertyNameID;
|
||||
|
||||
private void InitializeAudioElements ()
|
||||
{
|
||||
if (laserEffect != null) {
|
||||
laserEffectAudioElement.clip = laserEffect;
|
||||
}
|
||||
|
||||
if (mainAudioSource != null) {
|
||||
laserEffectAudioElement.audioSource = mainAudioSource;
|
||||
}
|
||||
}
|
||||
|
||||
void Start ()
|
||||
{
|
||||
InitializeAudioElements ();
|
||||
|
||||
propertyNameID = Shader.PropertyToID ("_TintColor");
|
||||
|
||||
StartCoroutine (laserAnimation ());
|
||||
|
||||
reflactionLimit++;
|
||||
|
||||
lRenderer.positionCount = 0;
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (reloading) {
|
||||
if (weaponManager.remainAmmoInClip () && weaponManager.carryingWeapon () && !weaponManager.isWeaponReloading ()) {
|
||||
reloading = false;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!weaponLaserEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Time.time > lastTimeUsed + useEnergyRate) {
|
||||
if (weaponManager.remainAmmoInClip () && !weaponManager.isWeaponReloading ()) {
|
||||
lastTimeUsed = Time.time;
|
||||
|
||||
weaponManager.useAmmo (amountEnergyUsed);
|
||||
|
||||
weaponManager.checkToUpdateInventoryWeaponAmmoTextFromWeaponSystem ();
|
||||
}
|
||||
|
||||
if (!weaponManager.remainAmmoInClip () || weaponManager.isWeaponReloading ()) {
|
||||
setWeaponLaserState (false);
|
||||
|
||||
reloading = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Time.time > lastTimeSoundPlayed + playSoundRate) {
|
||||
lastTimeSoundPlayed = Time.time;
|
||||
playWeaponSoundEffect ();
|
||||
}
|
||||
|
||||
//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;
|
||||
|
||||
if (hit.collider.gameObject != player) {
|
||||
damageTarget (hit.collider.gameObject, -ray.direction, hit.point);
|
||||
}
|
||||
|
||||
} 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;
|
||||
|
||||
hitSmoke.SetActive (false);
|
||||
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
|
||||
hitSparks.SetActive (true);
|
||||
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) {
|
||||
damageTarget (hit.collider.gameObject, -ray.direction, hit.point);
|
||||
}
|
||||
|
||||
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) {
|
||||
damageTarget (hit.collider.gameObject, -ray.direction, hit.point);
|
||||
}
|
||||
|
||||
//get the hit position to set the particles of smoke and sparks
|
||||
laserDistance = hit.distance;
|
||||
|
||||
hitSparks.SetActive (true);
|
||||
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;
|
||||
|
||||
hitSmoke.SetActive (false);
|
||||
hitSparks.SetActive (false);
|
||||
|
||||
laserDistance = 1000;
|
||||
lRenderer.positionCount = 2;
|
||||
lRenderer.SetPosition (0, transform.position);
|
||||
lRenderer.SetPosition (1, (laserDistance * transform.forward));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void damageTarget (GameObject objectToDamage, Vector3 laserDirection, Vector3 hitPoint)
|
||||
{
|
||||
canDamage = false;
|
||||
|
||||
if (useMinTimeToUseLaserDamageRate) {
|
||||
if (Time.time > lastTimeLaserActive + minTimeToUseLaserDamageRate &&
|
||||
Time.time > lastTimeLaserDamage + laserDamageRate) {
|
||||
lastTimeLaserDamage = Time.time;
|
||||
canDamage = true;
|
||||
}
|
||||
} else {
|
||||
canDamage = true;
|
||||
}
|
||||
|
||||
if (canDamage) {
|
||||
applyDamage.checkHealth (gameObject, objectToDamage, laserDamage, -laserDirection, hitPoint, player, true, true,
|
||||
weaponManager.weaponSettings.ignoreShield, false, weaponManager.weaponSettings.damageCanBeBlocked, false, -1,
|
||||
weaponManager.weaponSettings.damageTypeID);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
gameObject.SetActive (false);
|
||||
|
||||
//deflect the laser and enable the laser connector
|
||||
GameObject baseLaserConnector = currentLaser.GetComponent<laserDevice> ().laserConnector;
|
||||
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 ()) {
|
||||
baseLaserConnector.GetComponent<laserConnector> ().setCubeRefractionLaser (hitObject);
|
||||
|
||||
currentRefractionCube.cubeLaserDeviceGameObject.transform.rotation = baseLaserConnector.transform.rotation;
|
||||
|
||||
currentRefractionCube.setRefractingLaserState (true);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
public void enableWeaponLaser ()
|
||||
{
|
||||
setWeaponLaserState (true);
|
||||
}
|
||||
|
||||
public void disableWeaponLaser ()
|
||||
{
|
||||
setWeaponLaserState (false);
|
||||
}
|
||||
|
||||
public void setWeaponLaserState (bool state)
|
||||
{
|
||||
if (reloading) {
|
||||
weaponLaserEnabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
initializeComponents ();
|
||||
|
||||
weaponLaserEnabled = state;
|
||||
|
||||
if (laserActivePreviously != weaponLaserEnabled) {
|
||||
if (weaponLaserEnabled) {
|
||||
lastTimeLaserActive = Time.time;
|
||||
}
|
||||
laserActivePreviously = weaponLaserEnabled;
|
||||
}
|
||||
|
||||
laserLight.SetActive (weaponLaserEnabled);
|
||||
|
||||
if (weaponLaserEnabled) {
|
||||
hitSmoke.transform.SetParent (null);
|
||||
} else {
|
||||
lRenderer.positionCount = 0;
|
||||
hitSparks.SetActive (false);
|
||||
hitSmoke.SetActive (false);
|
||||
|
||||
hitSmoke.transform.SetParent (transform);
|
||||
}
|
||||
}
|
||||
|
||||
void playWeaponSoundEffect ()
|
||||
{
|
||||
if (laserEffectAudioElement != null) {
|
||||
AudioPlayer.PlayOneShot (laserEffectAudioElement, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool componentsInitialized;
|
||||
|
||||
void initializeComponents ()
|
||||
{
|
||||
if (componentsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (weaponManager != null) {
|
||||
GameObject playerControllerGameObject = weaponManager.getPlayerWeaponsManger ().gameObject;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = playerControllerGameObject.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
player = mainPlayerComponentsManager.getPlayerController ().gameObject;
|
||||
|
||||
mainCameraTransform = mainPlayerComponentsManager.getPlayerCamera ().getCameraTransform ();
|
||||
}
|
||||
}
|
||||
|
||||
componentsInitialized = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9f43eec15676c945a3c3c4b20725ec4
|
||||
timeCreated: 1537381416
|
||||
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/Weapons/New Weapon Behaviors/weaponLaser.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6809807a137a7054985f9c6cd993a6be
|
||||
folderAsset: yes
|
||||
timeCreated: 1522205631
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,304 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class arrowProjectile : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool rotateArrowWithGravity = true;
|
||||
public float gravityForceRotationSpeed = 5;
|
||||
public float extraRotationAmount;
|
||||
|
||||
public string movingObjectsTag = "moving";
|
||||
|
||||
public bool useGravityOnArrow = true;
|
||||
|
||||
public float gravityForceDownAmount = 5;
|
||||
|
||||
[Space]
|
||||
[Header ("Adjust On Surface Settings")]
|
||||
[Space]
|
||||
|
||||
public float adjustToSurfaceSpeed = 4;
|
||||
|
||||
public float offsetOnCharacterBodyParent = 0.15f;
|
||||
|
||||
public float attachProjectileToSurfaceOffset = 0.5f;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventOnArrowImpact;
|
||||
public UnityEvent eventOnArrowImpact;
|
||||
|
||||
public UnityEvent eventToDropArrowPickupOnBounce;
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public projectileSystem mainProjectileSystem;
|
||||
public Rigidbody mainRigidbody;
|
||||
public spawnObject mainSpawnObject;
|
||||
|
||||
Quaternion targetRotation;
|
||||
|
||||
bool applyArrowForces = true;
|
||||
|
||||
bool checkSurfaceTypeDetected;
|
||||
|
||||
List<bowSystem.arrowSurfaceTypeInfo> arrowSurfaceTypeInfoList = new List<bowSystem.arrowSurfaceTypeInfo> ();
|
||||
|
||||
Coroutine adjustArrowCoroutine;
|
||||
|
||||
float currentArrowDownForce = 1;
|
||||
|
||||
|
||||
void OnEnable ()
|
||||
{
|
||||
resetProjectile ();
|
||||
}
|
||||
|
||||
void FixedUpdate ()
|
||||
{
|
||||
if (!mainProjectileSystem.isProjectileUsed ()) {
|
||||
if (showDebugPrint) {
|
||||
print ("searching");
|
||||
}
|
||||
|
||||
if (applyArrowForces) {
|
||||
if (mainProjectileSystem.currentProjectileInfo.isSeeker || mainProjectileSystem.currentProjectileInfo.isHommingProjectile) {
|
||||
applyArrowForces = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (applyArrowForces) {
|
||||
if (!useGravityOnArrow && gravityForceDownAmount > 0) {
|
||||
mainRigidbody.AddForce (-Vector3.up * (gravityForceDownAmount * currentArrowDownForce * mainRigidbody.mass));
|
||||
}
|
||||
|
||||
if (rotateArrowWithGravity) {
|
||||
if (gravityForceRotationSpeed > 0) {
|
||||
if (!mainRigidbody.isKinematic) {
|
||||
targetRotation = Quaternion.LookRotation (mainRigidbody.linearVelocity - Vector3.up * extraRotationAmount);
|
||||
|
||||
transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, Time.deltaTime * gravityForceRotationSpeed * currentArrowDownForce);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mainProjectileSystem.disableProjectileMeshOnImpact) {
|
||||
mainProjectileSystem.disableProjectileMeshOnImpact = false;
|
||||
}
|
||||
}
|
||||
|
||||
//when the bullet touchs a surface, then
|
||||
public void checkObjectDetected (GameObject objectToDamage)
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("detected " + objectToDamage.name);
|
||||
}
|
||||
|
||||
mainProjectileSystem.setProjectileUsedState (true);
|
||||
|
||||
mainProjectileSystem.enableOrDisableMainTrailRenderer (false);
|
||||
|
||||
mainProjectileSystem.projectilePaused = true;
|
||||
|
||||
//set the bullet kinematic
|
||||
|
||||
mainRigidbody.isKinematic = true;
|
||||
|
||||
Rigidbody objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
|
||||
|
||||
bool isAttachedToCharacter = false;
|
||||
|
||||
bool surfaceDetectedIsDead = false;
|
||||
|
||||
if (applyDamage.objectCanBeDamaged (objectToDamage)) {
|
||||
Vector3 projectilePosition = Vector3.zero;
|
||||
|
||||
if (attachProjectileToSurfaceOffset != 0) {
|
||||
projectilePosition = transform.position + transform.forward * attachProjectileToSurfaceOffset;
|
||||
}
|
||||
|
||||
isAttachedToCharacter = applyDamage.attachObjectToSurfaceFound (objectToDamage.transform, transform,
|
||||
transform.position, true, projectilePosition);
|
||||
|
||||
surfaceDetectedIsDead = applyDamage.checkIfDead (objectToDamage);
|
||||
}
|
||||
|
||||
mainRigidbody.useGravity = false;
|
||||
mainRigidbody.isKinematic = true;
|
||||
|
||||
if (!surfaceDetectedIsDead && !isAttachedToCharacter && (objectToDamage.CompareTag (movingObjectsTag) || objectToDamageRigidbody != null)) {
|
||||
applyDamage.checkParentToAssign (transform, objectToDamage.transform);
|
||||
}
|
||||
|
||||
mainProjectileSystem.setIgnoreParentDestroyedState (true);
|
||||
|
||||
mainProjectileSystem.checkProjectilesParent ();
|
||||
|
||||
if (useEventOnArrowImpact) {
|
||||
eventOnArrowImpact.Invoke ();
|
||||
}
|
||||
|
||||
if (checkSurfaceTypeDetected) {
|
||||
meleeAttackSurfaceInfo currentMeleeAttackSurfaceInfo = objectToDamage.GetComponent<meleeAttackSurfaceInfo> ();
|
||||
|
||||
if (currentMeleeAttackSurfaceInfo != null) {
|
||||
bool surfaceLocated = false;
|
||||
|
||||
string surfaceName = currentMeleeAttackSurfaceInfo.getSurfaceName ();
|
||||
|
||||
for (int i = 0; i < arrowSurfaceTypeInfoList.Count; i++) {
|
||||
if (!surfaceLocated && arrowSurfaceTypeInfoList [i].Name.Equals (surfaceName)) {
|
||||
surfaceLocated = true;
|
||||
|
||||
if (arrowSurfaceTypeInfoList [i].isObstacle) {
|
||||
if (arrowSurfaceTypeInfoList [i].arrowBounceOnSurface) {
|
||||
if (arrowSurfaceTypeInfoList [i].dropArrowPickupOnBounce) {
|
||||
gameObject.SetActive (false);
|
||||
|
||||
eventToDropArrowPickupOnBounce.Invoke ();
|
||||
|
||||
if (arrowSurfaceTypeInfoList [i].addExtraForceOnBounce) {
|
||||
GameObject arrowPickup = mainSpawnObject.getLastObjectSpawned ();
|
||||
|
||||
if (arrowPickup != null) {
|
||||
Rigidbody mainArrowRigidbody = arrowPickup.GetComponent<Rigidbody> ();
|
||||
|
||||
if (mainArrowRigidbody != null) {
|
||||
mainArrowRigidbody.AddForce (-mainArrowRigidbody.transform.forward * arrowSurfaceTypeInfoList [i].extraForceOnBounce, ForceMode.Impulse);
|
||||
|
||||
float randomRightDirection = Random.Range (0, 1);
|
||||
|
||||
if (randomRightDirection == 0) {
|
||||
randomRightDirection = -1;
|
||||
}
|
||||
|
||||
mainArrowRigidbody.AddTorque (mainRigidbody.transform.right * 10 * randomRightDirection, ForceMode.Impulse);
|
||||
|
||||
mainArrowRigidbody.AddTorque (mainRigidbody.transform.up * 5 * (-1 * randomRightDirection), ForceMode.Impulse);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mainRigidbody.useGravity = true;
|
||||
mainRigidbody.isKinematic = false;
|
||||
|
||||
mainProjectileSystem.enableOrDisableSecondaryMeshCollider (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = objectToDamage.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
projectilesOnCharacterBodyManager mainProjectilesOnCharacterBodyManager = mainPlayerComponentsManager.getProjectilesOnCharacterBodyManager ();
|
||||
|
||||
if (mainProjectilesOnCharacterBodyManager != null) {
|
||||
mainProjectilesOnCharacterBodyManager.addProjectileToCharacterBody (gameObject);
|
||||
}
|
||||
} else {
|
||||
projectilesOnCharacterBodyManager mainProjectilesOnCharacterBodyManager = objectToDamage.GetComponent<projectilesOnCharacterBodyManager> ();
|
||||
|
||||
if (mainProjectilesOnCharacterBodyManager != null) {
|
||||
mainProjectilesOnCharacterBodyManager.addProjectileToCharacterBody (gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
if (isAttachedToCharacter) {
|
||||
stopAdjustArrowToSurfaceDetectedCoroutine ();
|
||||
|
||||
adjustArrowCoroutine = StartCoroutine (adjustArrowToSurfaceDetectedCoroutine ());
|
||||
}
|
||||
|
||||
mainProjectileSystem.currentProjectileInfo.isSeeker = false;
|
||||
mainProjectileSystem.currentProjectileInfo.isHommingProjectile = false;
|
||||
}
|
||||
|
||||
public void resetProjectile ()
|
||||
{
|
||||
applyArrowForces = true;
|
||||
|
||||
stopAdjustArrowToSurfaceDetectedCoroutine ();
|
||||
|
||||
transform.SetParent (null);
|
||||
|
||||
currentArrowDownForce = 1;
|
||||
}
|
||||
|
||||
public void setNewArrowDownForce (float newValue)
|
||||
{
|
||||
currentArrowDownForce = newValue;
|
||||
}
|
||||
|
||||
public void setArrowSurfaceTypeInfoList (List<bowSystem.arrowSurfaceTypeInfo> newArrowSurfaceTypeInfoList)
|
||||
{
|
||||
arrowSurfaceTypeInfoList = newArrowSurfaceTypeInfoList;
|
||||
|
||||
checkSurfaceTypeDetected = true;
|
||||
}
|
||||
|
||||
public void disableCheckSurfaceTypeDetected ()
|
||||
{
|
||||
checkSurfaceTypeDetected = false;
|
||||
}
|
||||
|
||||
void stopAdjustArrowToSurfaceDetectedCoroutine ()
|
||||
{
|
||||
if (adjustArrowCoroutine != null) {
|
||||
StopCoroutine (adjustArrowCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator adjustArrowToSurfaceDetectedCoroutine ()
|
||||
{
|
||||
bool targetReached = false;
|
||||
|
||||
float t = 0;
|
||||
|
||||
float positionDifference = 0;
|
||||
|
||||
float movementTimer = 0;
|
||||
|
||||
Vector3 targetPosition = transform.position + transform.forward * offsetOnCharacterBodyParent;
|
||||
|
||||
Transform currentParent = transform.parent;
|
||||
|
||||
targetPosition = currentParent.InverseTransformPoint (targetPosition);
|
||||
|
||||
while (!targetReached) {
|
||||
t += Time.deltaTime / adjustToSurfaceSpeed;
|
||||
|
||||
transform.localPosition = Vector3.Lerp (transform.localPosition, targetPosition, t);
|
||||
|
||||
positionDifference = GKC_Utils.distance (transform.localPosition, targetPosition);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
if (positionDifference < 0.01f || movementTimer > 3) {
|
||||
targetReached = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("target reached " + targetPosition);
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1bf914b954ba094399cc9e2f60e1293
|
||||
timeCreated: 1606481786
|
||||
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/Weapons/Projectiles/arrowProjectile.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,145 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine;
|
||||
|
||||
public class audioClipBip : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public float playTime;
|
||||
public float playRate;
|
||||
public float increasePitchSpeed;
|
||||
public float increasePlayRateSpeed;
|
||||
|
||||
public bool playBipAtStart = true;
|
||||
|
||||
public bool playBipOnEnable;
|
||||
|
||||
public AudioClip soundClip;
|
||||
public AudioElement soundClipAudioElement;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public float lastTimePlayed;
|
||||
public float totalTimePlayed;
|
||||
public bool audioPlayed;
|
||||
|
||||
public bool bipActivated;
|
||||
public float originalPlayRate;
|
||||
|
||||
AudioSource mainAudioSource;
|
||||
|
||||
bool initialized;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (playBipAtStart) {
|
||||
intializeBip ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable ()
|
||||
{
|
||||
if (playBipOnEnable) {
|
||||
intializeBip ();
|
||||
}
|
||||
}
|
||||
|
||||
void intializeBip ()
|
||||
{
|
||||
if (mainAudioSource == null) {
|
||||
mainAudioSource = GetComponent<AudioSource> ();
|
||||
}
|
||||
|
||||
if (mainAudioSource)
|
||||
soundClipAudioElement.audioSource = mainAudioSource;
|
||||
|
||||
if (soundClip)
|
||||
soundClipAudioElement.clip = soundClip;
|
||||
|
||||
if (originalPlayRate == 0) {
|
||||
originalPlayRate = playRate;
|
||||
}
|
||||
|
||||
totalTimePlayed = Time.time;
|
||||
|
||||
resetBip ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Initialize bip");
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
void FixedUpdate ()
|
||||
{
|
||||
if (!audioPlayed && (bipActivated || playBipAtStart || playBipOnEnable)) {
|
||||
if (Time.time > lastTimePlayed + playRate) {
|
||||
|
||||
mainAudioSource.pitch += increasePitchSpeed;
|
||||
AudioPlayer.PlayOneShot (soundClipAudioElement, gameObject);
|
||||
|
||||
lastTimePlayed = Time.time;
|
||||
playRate -= increasePlayRateSpeed;
|
||||
|
||||
if (playRate <= 0) {
|
||||
playRate = 0.1f;
|
||||
}
|
||||
|
||||
if (Time.time > (totalTimePlayed + playTime)) {
|
||||
audioPlayed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void increasePlayTime (float extraTime)
|
||||
{
|
||||
if (!initialized || !playBipOnEnable) {
|
||||
intializeBip ();
|
||||
}
|
||||
|
||||
totalTimePlayed = Time.time;
|
||||
|
||||
playTime = extraTime;
|
||||
|
||||
bipActivated = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Activate bip");
|
||||
}
|
||||
}
|
||||
|
||||
public void disableBip ()
|
||||
{
|
||||
bipActivated = false;
|
||||
|
||||
mainAudioSource.pitch = 1;
|
||||
|
||||
lastTimePlayed = 0;
|
||||
|
||||
playRate = originalPlayRate;
|
||||
}
|
||||
|
||||
void resetBip ()
|
||||
{
|
||||
lastTimePlayed = 0;
|
||||
|
||||
playRate = originalPlayRate;
|
||||
|
||||
totalTimePlayed = Time.time;
|
||||
|
||||
audioPlayed = false;
|
||||
bipActivated = false;
|
||||
|
||||
if (mainAudioSource != null) {
|
||||
mainAudioSource.pitch = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64f52c0afd5c0a241a915adb71d77b1d
|
||||
timeCreated: 1519432620
|
||||
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/Weapons/Projectiles/audioClipBip.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,168 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
|
||||
public class dissolveProjectile : projectileSystem
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public LayerMask layer;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useLayerMaskToIgnore;
|
||||
|
||||
public LayerMask layerMaskToIgnore;
|
||||
|
||||
[Space]
|
||||
|
||||
public float timeToDestroyObject = 0.9f;
|
||||
|
||||
public float dissolveSpeed = 1;
|
||||
|
||||
[Space]
|
||||
[Header ("Shader Settings")]
|
||||
[Space]
|
||||
|
||||
public Shader shaderToApply;
|
||||
public Texture dissolveTexture;
|
||||
public Color dissolveColor;
|
||||
public float dissolveColorAlpha;
|
||||
|
||||
public string dissolveShaderFieldName = "_Amount";
|
||||
public string dissolveShaderTextureFieldName = "_DissolveTexture";
|
||||
public string dissolveShaderColorFieldName = "_DissolveColor";
|
||||
public string dissolveShaderAlphaColorFieldName = "_DissolveColorAlpha";
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool objectToDissolveFound;
|
||||
|
||||
public float currentFadeValue = 1;
|
||||
|
||||
dissolveObject currentDissolveObject;
|
||||
|
||||
GameObject objectToDissolve;
|
||||
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (objectToDissolveFound) {
|
||||
currentFadeValue = currentDissolveObject.currentFadeValue;
|
||||
|
||||
if (currentFadeValue >= 1 || currentFadeValue > timeToDestroyObject) {
|
||||
destroyObject ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dissolveObject (GameObject objectToDissolve)
|
||||
{
|
||||
checkObjectDetected (objectToDissolve.GetComponent<Collider> ());
|
||||
}
|
||||
|
||||
//when the bullet touchs a surface, then
|
||||
public void checkObjectDetected (Collider col)
|
||||
{
|
||||
if (canActivateEffect (col)) {
|
||||
if (currentProjectileInfo.impactAudioElement != null) {
|
||||
currentProjectileInfo.impactAudioElement.audioSource = GetComponent<AudioSource> ();
|
||||
AudioPlayer.PlayOneShot (currentProjectileInfo.impactAudioElement, gameObject);
|
||||
}
|
||||
|
||||
setProjectileUsedState (true);
|
||||
|
||||
//set the bullet kinematic
|
||||
objectToDamage = col.GetComponent<Collider> ().gameObject;
|
||||
|
||||
mainRigidbody.isKinematic = true;
|
||||
|
||||
if ((1 << col.gameObject.layer & layer.value) == 1 << col.gameObject.layer) {
|
||||
|
||||
if (objectToDamage.GetComponent<Rigidbody> ()) {
|
||||
|
||||
objectToDissolve = objectToDamage;
|
||||
|
||||
objectToDissolveFound = true;
|
||||
}
|
||||
|
||||
if (useLayerMaskToIgnore) {
|
||||
if ((1 << col.gameObject.layer & layerMaskToIgnore.value) == 1 << col.gameObject.layer) {
|
||||
objectToDissolveFound = false;
|
||||
|
||||
setProjectileUsedState (false);
|
||||
|
||||
setIgnoreProjectileWithAbilityState (true);
|
||||
|
||||
checkSurface (col);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool isCharacter = applyDamage.isCharacter (objectToDamage);
|
||||
|
||||
if (isCharacter) {
|
||||
objectToDissolve = applyDamage.getCharacter (objectToDamage);
|
||||
|
||||
objectToDissolveFound = true;
|
||||
} else {
|
||||
bool isVehicle = applyDamage.isVehicle (objectToDamage);
|
||||
|
||||
if (isVehicle) {
|
||||
objectToDissolve = applyDamage.getVehicle (objectToDamage);
|
||||
|
||||
objectToDissolveFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (objectToDissolveFound) {
|
||||
currentDissolveObject = objectToDissolve.GetComponent<dissolveObject> ();
|
||||
|
||||
if (currentDissolveObject != null) {
|
||||
destroyObject ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentDissolveObject == null) {
|
||||
currentDissolveObject = objectToDissolve.AddComponent<dissolveObject> ();
|
||||
}
|
||||
|
||||
if (currentDissolveObject != null) {
|
||||
currentDissolveObject.shaderToApply = shaderToApply;
|
||||
currentDissolveObject.dissolveTexture = dissolveTexture;
|
||||
currentDissolveObject.dissolveColor = dissolveColor;
|
||||
currentDissolveObject.dissolveColorAlpha = dissolveColorAlpha;
|
||||
currentDissolveObject.timeToDestroyObject = timeToDestroyObject;
|
||||
currentDissolveObject.dissolveSpeed = dissolveSpeed;
|
||||
|
||||
currentDissolveObject.activateDissolve (objectToDissolve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkProjectilesParent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyObject ()
|
||||
{
|
||||
destroyProjectile ();
|
||||
}
|
||||
|
||||
public override void resetProjectile ()
|
||||
{
|
||||
base.resetProjectile ();
|
||||
|
||||
objectToDissolveFound = false;
|
||||
|
||||
currentDissolveObject = null;
|
||||
|
||||
objectToDissolve = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54c8cb24b623ea1408d528e8fc6c8bb7
|
||||
timeCreated: 1552203785
|
||||
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/Weapons/Projectiles/dissolveProjectile.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine;
|
||||
|
||||
public class laserMine : projectileSystem
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public GameObject laserBeam;
|
||||
public bool disableByTime;
|
||||
public float timeToDisable;
|
||||
public bool infiniteEnergy;
|
||||
public int numberOfContactsToDisable;
|
||||
|
||||
int currentNumberOfContacts;
|
||||
|
||||
public void increaseNumberOfContacts ()
|
||||
{
|
||||
if (!infiniteEnergy) {
|
||||
currentNumberOfContacts++;
|
||||
|
||||
if (currentNumberOfContacts >= numberOfContactsToDisable) {
|
||||
disableBullet (0);
|
||||
|
||||
projectilePaused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkObjectDetected (Collider col)
|
||||
{
|
||||
if (canActivateEffect (col)) {
|
||||
if (currentProjectileInfo.impactAudioElement != null) {
|
||||
currentProjectileInfo.impactAudioElement.audioSource = GetComponent<AudioSource> ();
|
||||
AudioPlayer.PlayOneShot (currentProjectileInfo.impactAudioElement, gameObject);
|
||||
}
|
||||
|
||||
setProjectileUsedState (true);
|
||||
|
||||
//set the bullet kinematic
|
||||
objectToDamage = col.GetComponent<Collider> ().gameObject;
|
||||
Vector3 previousVelocity = mainRigidbody.linearVelocity;
|
||||
|
||||
//print (objectToDamage.name);
|
||||
mainRigidbody.isKinematic = true;
|
||||
|
||||
if (currentProjectileInfo.adhereToSurface) {
|
||||
attachProjectileToSurface ();
|
||||
}
|
||||
|
||||
if (disableByTime) {
|
||||
disableBullet (timeToDisable);
|
||||
} else {
|
||||
projectilePaused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void resetProjectile ()
|
||||
{
|
||||
base.resetProjectile ();
|
||||
|
||||
currentNumberOfContacts = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae8723c6ee3f65e4ab6d0edce6607237
|
||||
timeCreated: 1519069213
|
||||
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/Weapons/Projectiles/laserMine.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,697 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine;
|
||||
|
||||
public class plasmaCutterProjectile : projectileSystem
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public Material defaultSliceMaterial;
|
||||
|
||||
public float forceToApplyToCutPart;
|
||||
public ForceMode forceMode;
|
||||
public float forceRadius;
|
||||
|
||||
public bool cutMultipleTimesActive;
|
||||
|
||||
public bool useCutLimit;
|
||||
public int cutLimit;
|
||||
|
||||
public bool activateRigidbodiesOnNewObjects = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Shatter Object Settings")]
|
||||
[Space]
|
||||
|
||||
public bool shatterObjectActive;
|
||||
public int shatterAmount;
|
||||
|
||||
public bool applyForceOnShatter;
|
||||
|
||||
public bool addSliceComponentToPieces = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Damage Settings")]
|
||||
[Space]
|
||||
|
||||
public bool activateDamageOnSlice;
|
||||
public float damageAmountToApplyOnSlice;
|
||||
public bool ignoreShieldOnDamage = true;
|
||||
public bool canActivateReactionSystemTemporally;
|
||||
public int damageReactionID = -1;
|
||||
|
||||
public int damageTypeID = -1;
|
||||
|
||||
[Space]
|
||||
[Header ("Physics Settings")]
|
||||
[Space]
|
||||
|
||||
public bool updateLastObjectSpeed;
|
||||
|
||||
public bool applyForcesOnObjectsDetected;
|
||||
public float addForceMultiplier;
|
||||
public bool applyImpactForceToVehicles;
|
||||
public float impactForceToVehiclesMultiplier;
|
||||
|
||||
public bool checkObjectLayerAndTagToApplyForces;
|
||||
|
||||
public LayerMask targetToApplyForceLayer;
|
||||
public List<string> tagetToApplyForceTagList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public float minDelayToSliceSameObject = 0.01f;
|
||||
|
||||
public Transform cutPositionTransform;
|
||||
|
||||
public Vector3 cutOverlapBoxSize = new Vector3 (5, 0.1f, 5);
|
||||
|
||||
public bool addRigidbodyToBothSlicedObjects;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public List<GameObject> objectsDetected = new List<GameObject> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Gizmo Settings")]
|
||||
[Space]
|
||||
|
||||
public bool showGizmo;
|
||||
public Color gizmoColor = Color.red;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Transform cutDirectionTransform;
|
||||
public Transform planeDefiner1;
|
||||
public Transform planeDefiner2;
|
||||
public Transform planeDefiner3;
|
||||
|
||||
surfaceToSlice currentSurfaceToSlice;
|
||||
|
||||
int currentNumberOfCuts;
|
||||
|
||||
List<GameObject> objectsToShatter;
|
||||
bool objectShattered = false;
|
||||
|
||||
public void checkObjectDetected (Collider col)
|
||||
{
|
||||
if (canActivateEffect (col)) {
|
||||
|
||||
objectShattered = false;
|
||||
|
||||
if (currentProjectileInfo.impactAudioElement != null) {
|
||||
currentProjectileInfo.impactAudioElement.audioSource = GetComponent<AudioSource> ();
|
||||
AudioPlayer.PlayOneShot (currentProjectileInfo.impactAudioElement, gameObject);
|
||||
}
|
||||
|
||||
Collider objectCollider = col.GetComponent<Collider> ();
|
||||
|
||||
objectToDamage = objectCollider.gameObject;
|
||||
|
||||
processObject (objectToDamage, objectCollider, cutPositionTransform.position);
|
||||
|
||||
if (!cutMultipleTimesActive || currentNumberOfCuts >= cutLimit) {
|
||||
setProjectileUsedState (true);
|
||||
|
||||
mainRigidbody.isKinematic = true;
|
||||
|
||||
projectilePaused = true;
|
||||
|
||||
destroyProjectile ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void processObject (GameObject objectToCheck, Collider objectCollider, Vector3 slicePosition)
|
||||
{
|
||||
if (cutMultipleTimesActive) {
|
||||
if (objectsDetected.Contains (objectToCheck)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
currentSurfaceToSlice = objectToCheck.GetComponent<surfaceToSlice> ();
|
||||
|
||||
if (currentSurfaceToSlice == null) {
|
||||
currentSurfaceToSlice = sliceSystemUtils.getSurfaceToSlice (objectToCheck);
|
||||
}
|
||||
|
||||
bool isVehicle = applyDamage.isVehicle (objectToCheck);
|
||||
|
||||
if (isVehicle) {
|
||||
GameObject currentVehicle = applyDamage.getVehicle (objectToCheck);
|
||||
|
||||
if (currentVehicle != null) {
|
||||
currentSurfaceToSlice = currentVehicle.GetComponent<surfaceToSlice> ();
|
||||
|
||||
if (currentSurfaceToSlice != null) {
|
||||
objectToCheck = currentVehicle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool objectIsSliceSurfaceDisabled = false;
|
||||
|
||||
bool objectCanBeSliced = false;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("processing object " + objectToCheck.name);
|
||||
}
|
||||
|
||||
bool ignoreRegularDamageIfCutSurfaceNotEnabled = false;
|
||||
|
||||
bool isIgnoreDamageIfSliceNotActivatedActive = false;
|
||||
|
||||
if (currentSurfaceToSlice != null) {
|
||||
bool isCutSurfaceEnabled = currentSurfaceToSlice.isCutSurfaceEnabled ();
|
||||
|
||||
bool sliceCanBeActivated = currentSurfaceToSlice.sliceCanBeActivated (minDelayToSliceSameObject);
|
||||
|
||||
bool checkSliceDirectionResult = currentSurfaceToSlice.checkSliceDirectionResult (cutPositionTransform.right, cutPositionTransform.up);
|
||||
|
||||
isIgnoreDamageIfSliceNotActivatedActive = currentSurfaceToSlice.isIgnoreDamageIfSliceNotActivatedActive ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Surface cut enabled state " + isCutSurfaceEnabled +
|
||||
" can activate slice " + sliceCanBeActivated);
|
||||
}
|
||||
|
||||
if (isCutSurfaceEnabled && sliceCanBeActivated && checkSliceDirectionResult) {
|
||||
Material crossSectionMaterial = currentSurfaceToSlice.getCrossSectionMaterial ();
|
||||
|
||||
if (crossSectionMaterial == null) {
|
||||
crossSectionMaterial = defaultSliceMaterial;
|
||||
}
|
||||
|
||||
sliceCurrentObject (objectToCheck, objectCollider, crossSectionMaterial, slicePosition);
|
||||
|
||||
objectCanBeSliced = true;
|
||||
} else {
|
||||
if (isVehicle && isCutSurfaceEnabled) {
|
||||
objectCanBeSliced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isCutSurfaceEnabled) {
|
||||
objectIsSliceSurfaceDisabled = true;
|
||||
|
||||
ignoreRegularDamageIfCutSurfaceNotEnabled = currentSurfaceToSlice.isIgnoreRegularDamageIfCutSurfaceNotEnabled ();
|
||||
}
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("Surface to slice not found on " + objectToCheck.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!objectCanBeSliced && !ignoreRegularDamageIfCutSurfaceNotEnabled) {
|
||||
if (activateDamageOnSlice && !isIgnoreDamageIfSliceNotActivatedActive) {
|
||||
Vector3 damagePosition = cutPositionTransform.position;
|
||||
|
||||
if (applyDamage.checkIfDead (objectToCheck)) {
|
||||
damagePosition = objectToCheck.transform.position;
|
||||
}
|
||||
|
||||
applyDamage.checkCanBeDamaged (gameObject, objectToCheck, damageAmountToApplyOnSlice, -cutPositionTransform.forward, damagePosition,
|
||||
currentProjectileInfo.owner, true, true, ignoreShieldOnDamage, false, true, canActivateReactionSystemTemporally,
|
||||
damageReactionID, damageTypeID);
|
||||
}
|
||||
|
||||
if (applyForcesOnObjectsDetected && !objectIsSliceSurfaceDisabled) {
|
||||
if (!checkObjectLayerAndTagToApplyForces ||
|
||||
((1 << objectToCheck.layer & targetToApplyForceLayer.value) == 1 << objectToCheck.layer && tagetToApplyForceTagList.Contains (objectToCheck.tag))) {
|
||||
checkForceToApplyOnObject (objectToCheck);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sliceCurrentObject (GameObject objectToCheck, Collider objectCollider, Material crossSectionMaterial, Vector3 slicePosition)
|
||||
{
|
||||
if (useCutLimit) {
|
||||
currentNumberOfCuts++;
|
||||
}
|
||||
|
||||
// slice the provided object using the transforms of this object
|
||||
if (currentSurfaceToSlice.isObjectCharacter ()) {
|
||||
// print ("character found " + objectToCheck.name + " is dead " + applyDamage.checkIfDead (objectToCheck));
|
||||
|
||||
if (applyDamage.getCharacterOrVehicle (objectToCheck) != null && !applyDamage.checkIfDead (objectToCheck)) {
|
||||
processCharacter (objectToCheck);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Rigidbody mainObject = objectToCheck.GetComponent<Rigidbody> ();
|
||||
|
||||
bool mainObjectHasRigidbody = mainObject != null;
|
||||
|
||||
Vector3 lastSpeed = Vector3.zero;
|
||||
|
||||
if (mainObjectHasRigidbody) {
|
||||
lastSpeed = mainObject.linearVelocity;
|
||||
}
|
||||
|
||||
currentSurfaceToSlice.checkEventBeforeSlice ();
|
||||
|
||||
currentSurfaceToSlice.getMainSimpleSliceSystem ().activateSlice (objectCollider, positionInWorldSpace,
|
||||
normalInWorldSpace, slicePosition, updateLastObjectSpeed, lastSpeed);
|
||||
|
||||
currentSurfaceToSlice.checkEventOnCut ();
|
||||
|
||||
currentSurfaceToSlice.checkTimeBulletOnCut ();
|
||||
} else {
|
||||
if (shatterObjectActive) {
|
||||
shatterObject (objectToCheck, crossSectionMaterial);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// slice the provided object using the transforms of this object
|
||||
bool objectSliced = false;
|
||||
|
||||
GameObject object1 = null;
|
||||
GameObject object2 = null;
|
||||
|
||||
currentSurfaceToSlice.checkEventBeforeSlice ();
|
||||
|
||||
objectToCheck = currentSurfaceToSlice.getMainSurfaceToSlice ();
|
||||
|
||||
// slice the provided objectToCheck ect using the transforms of this object
|
||||
sliceSystemUtils.sliceObject (transform.position, objectToCheck, cutDirectionTransform.up, crossSectionMaterial, ref objectSliced, ref object1, ref object2);
|
||||
|
||||
Vector3 objectPosition = objectToCheck.transform.position;
|
||||
Quaternion objectRotation = objectToCheck.transform.rotation;
|
||||
|
||||
Transform objectParent = objectToCheck.transform.parent;
|
||||
|
||||
if (objectSliced) {
|
||||
if (currentSurfaceToSlice.useParticlesOnSlice) {
|
||||
Quaternion particlesRotation = Quaternion.LookRotation (positionInWorldSpace);
|
||||
|
||||
Instantiate (currentSurfaceToSlice.particlesOnSlicePrefab, slicePosition, particlesRotation);
|
||||
}
|
||||
|
||||
currentSurfaceToSlice.checkEventOnCut ();
|
||||
|
||||
currentSurfaceToSlice.checkTimeBulletOnCut ();
|
||||
|
||||
Rigidbody mainObject = objectToCheck.GetComponent<Rigidbody> ();
|
||||
bool mainObjectHasRigidbody = mainObject != null;
|
||||
|
||||
object1.transform.position = objectPosition;
|
||||
object1.transform.rotation = objectRotation;
|
||||
|
||||
object2.transform.position = objectPosition;
|
||||
object2.transform.rotation = objectRotation;
|
||||
|
||||
if (objectParent != null) {
|
||||
object1.transform.SetParent (objectParent);
|
||||
object2.transform.SetParent (objectParent);
|
||||
}
|
||||
|
||||
surfaceToSlice newSurfaceToSlice1 = object1.AddComponent<surfaceToSlice> ();
|
||||
surfaceToSlice newSurfaceToSlice2 = object2.AddComponent<surfaceToSlice> ();
|
||||
|
||||
currentSurfaceToSlice.copySurfaceInfo (newSurfaceToSlice1);
|
||||
currentSurfaceToSlice.copySurfaceInfo (newSurfaceToSlice2);
|
||||
|
||||
newSurfaceToSlice1.checkDestroySlicedPartsAfterDelay ();
|
||||
newSurfaceToSlice2.checkDestroySlicedPartsAfterDelay ();
|
||||
|
||||
float currentForceToApply = forceToApplyToCutPart;
|
||||
|
||||
ForceMode currentForceMode = forceMode;
|
||||
|
||||
if (currentSurfaceToSlice.useCustomForceMode) {
|
||||
currentForceMode = currentSurfaceToSlice.customForceMode;
|
||||
}
|
||||
|
||||
if (mainObjectHasRigidbody || activateRigidbodiesOnNewObjects) {
|
||||
|
||||
if (currentSurfaceToSlice.useCustomForceAmount) {
|
||||
currentForceToApply = currentSurfaceToSlice.customForceAmount;
|
||||
}
|
||||
|
||||
Rigidbody object1Rigidbody = object1.AddComponent<Rigidbody> ();
|
||||
|
||||
Rigidbody object2Rigidbody = object2.AddComponent<Rigidbody> ();
|
||||
|
||||
object2Rigidbody.AddExplosionForce (currentForceToApply, transform.position, 10, 1, currentForceMode);
|
||||
|
||||
object1Rigidbody.AddExplosionForce (currentForceToApply, transform.position, 10, 1, currentForceMode);
|
||||
} else {
|
||||
if (currentSurfaceToSlice.useCustomForceAmount) {
|
||||
currentForceToApply = currentSurfaceToSlice.customForceAmount;
|
||||
}
|
||||
|
||||
bool addRigidbodyToObject1 = false;
|
||||
bool addRigidbodyToObject2 = false;
|
||||
|
||||
if (addRigidbodyToBothSlicedObjects) {
|
||||
addRigidbodyToObject1 = true;
|
||||
addRigidbodyToObject2 = true;
|
||||
} else {
|
||||
float distance1 = GKC_Utils.distance (objectToCheck.transform.position, object1.transform.position);
|
||||
float distance2 = GKC_Utils.distance (objectToCheck.transform.position, object2.transform.position);
|
||||
|
||||
if (distance1 < distance2) {
|
||||
addRigidbodyToObject1 = true;
|
||||
} else {
|
||||
addRigidbodyToObject2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (addRigidbodyToObject1) {
|
||||
Rigidbody object2Rigidbody = object2.AddComponent<Rigidbody> ();
|
||||
|
||||
object2Rigidbody.AddExplosionForce (currentForceToApply, transform.position, 10, 1, currentForceMode);
|
||||
}
|
||||
|
||||
if (addRigidbodyToObject2) {
|
||||
Rigidbody object1Rigidbody = object1.AddComponent<Rigidbody> ();
|
||||
|
||||
object1Rigidbody.AddExplosionForce (currentForceToApply, transform.position, 10, 1, currentForceMode);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSurfaceToSlice.useBoxCollider) {
|
||||
object1.AddComponent<BoxCollider> ();
|
||||
object2.AddComponent<BoxCollider> ();
|
||||
} else {
|
||||
MeshCollider object1Collider = object1.AddComponent<MeshCollider> ();
|
||||
MeshCollider object2Collider = object2.AddComponent<MeshCollider> ();
|
||||
|
||||
object1Collider.convex = true;
|
||||
object2Collider.convex = true;
|
||||
}
|
||||
|
||||
if (currentSurfaceToSlice.setNewLayerOnCut) {
|
||||
object1.layer = LayerMask.NameToLayer (currentSurfaceToSlice.newLayerOnCut);
|
||||
object2.layer = LayerMask.NameToLayer (currentSurfaceToSlice.newLayerOnCut);
|
||||
}
|
||||
|
||||
if (currentSurfaceToSlice.setNewTagOnCut) {
|
||||
object1.tag = currentSurfaceToSlice.newTagOnCut;
|
||||
object2.tag = currentSurfaceToSlice.newTagOnCut;
|
||||
}
|
||||
|
||||
if (cutMultipleTimesActive) {
|
||||
if (!objectsDetected.Contains (object1)) {
|
||||
objectsDetected.Add (object1);
|
||||
}
|
||||
|
||||
if (!objectsDetected.Contains (object2)) {
|
||||
objectsDetected.Add (object2);
|
||||
}
|
||||
}
|
||||
|
||||
objectToCheck.SetActive (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void processCharacter (GameObject currentCharacter)
|
||||
{
|
||||
StartCoroutine (processCharacterCoroutine (currentCharacter));
|
||||
}
|
||||
|
||||
List<Collider> colliders = new List<Collider> ();
|
||||
|
||||
IEnumerator processCharacterCoroutine (GameObject currentCharacter)
|
||||
{
|
||||
applyDamage.pushCharacterWithoutForceAndPauseGetUp (currentCharacter);
|
||||
|
||||
Vector3 slicePosition = cutPositionTransform.position;
|
||||
|
||||
Collider [] temporalHits = Physics.OverlapBox (slicePosition, cutOverlapBoxSize, cutDirectionTransform.rotation, currentProjectileInfo.targetToDamageLayer);
|
||||
|
||||
bool bodyPartFound = false;
|
||||
|
||||
if (temporalHits.Length > 0) {
|
||||
bool ragdollCollidersFoundOnCharacter = false;
|
||||
|
||||
colliders = null;
|
||||
|
||||
ragdollActivator currentRagdollActivator = currentCharacter.GetComponent<ragdollActivator> ();
|
||||
|
||||
if (currentRagdollActivator != null) {
|
||||
colliders = currentRagdollActivator.getBodyColliderList ();
|
||||
|
||||
if (colliders != null && colliders.Count > 0) {
|
||||
ragdollCollidersFoundOnCharacter = true;
|
||||
}
|
||||
}
|
||||
|
||||
Collider colliderToCheck = null;
|
||||
|
||||
float minDistance = 1000;
|
||||
|
||||
for (int i = 0; i < temporalHits.Length; i++) {
|
||||
Collider currentCollider = temporalHits [i];
|
||||
|
||||
bool canActivateSliceResult = false;
|
||||
|
||||
if (ragdollCollidersFoundOnCharacter) {
|
||||
if (showDebugPrint) {
|
||||
print ("ragoll detected");
|
||||
}
|
||||
|
||||
if (colliders.Contains (currentCollider)) {
|
||||
canActivateSliceResult = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("ragdoll part found");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
canActivateSliceResult = true;
|
||||
}
|
||||
|
||||
if (canActivateSliceResult) {
|
||||
|
||||
if (applyDamage.isCharacter (currentCollider.gameObject)) {
|
||||
bodyPartFound = true;
|
||||
|
||||
float currentDistance = GKC_Utils.distance (slicePosition, currentCollider.transform.position);
|
||||
|
||||
if (currentDistance < minDistance) {
|
||||
minDistance = currentDistance;
|
||||
|
||||
colliderToCheck = currentCollider;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bodyPartFound) {
|
||||
if (currentCharacter != null) {
|
||||
applyDamage.killCharacter (currentCharacter);
|
||||
}
|
||||
|
||||
processObject (colliderToCheck.gameObject, colliderToCheck, slicePosition);
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
private Vector3 positionInWorldSpace
|
||||
{
|
||||
get
|
||||
{
|
||||
return (planeDefiner1.position + planeDefiner2.position + planeDefiner3.position) / 3f;
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 normalInWorldSpace
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 t0 = planeDefiner1.position;
|
||||
Vector3 t1 = planeDefiner2.position;
|
||||
Vector3 t2 = planeDefiner3.position;
|
||||
|
||||
Vector3 vectorValue;
|
||||
|
||||
vectorValue.x = t0.y * (t1.z - t2.z) + t1.y * (t2.z - t0.z) + t2.y * (t0.z - t1.z);
|
||||
vectorValue.y = t0.z * (t1.x - t2.x) + t1.z * (t2.x - t0.x) + t2.z * (t0.x - t1.x);
|
||||
vectorValue.z = t0.x * (t1.y - t2.y) + t1.x * (t2.y - t0.y) + t2.x * (t0.y - t1.y);
|
||||
|
||||
return vectorValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void checkForceToApplyOnObject (GameObject objectToDamage)
|
||||
{
|
||||
Rigidbody objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
|
||||
|
||||
Vector3 forceDirection = cutDirectionTransform.forward;
|
||||
|
||||
float forceAmount = addForceMultiplier;
|
||||
|
||||
float forceToVehiclesMultiplier = impactForceToVehiclesMultiplier;
|
||||
|
||||
if (applyImpactForceToVehicles) {
|
||||
Rigidbody objectToDamageMainRigidbody = applyDamage.applyForce (objectToDamage);
|
||||
|
||||
if (objectToDamageMainRigidbody != null) {
|
||||
Vector3 force = forceAmount * forceDirection;
|
||||
|
||||
bool isVehicle = applyDamage.isVehicle (objectToDamage);
|
||||
|
||||
if (isVehicle) {
|
||||
force *= forceToVehiclesMultiplier;
|
||||
}
|
||||
|
||||
objectToDamageMainRigidbody.AddForce (objectToDamageMainRigidbody.mass * force, forceMode);
|
||||
}
|
||||
} else {
|
||||
if (applyDamage.canApplyForce (objectToDamage)) {
|
||||
//print (objectToDamage.name);
|
||||
Vector3 force = forceAmount * forceDirection;
|
||||
|
||||
if (objectToDamageRigidbody == null) {
|
||||
objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
|
||||
}
|
||||
|
||||
objectToDamageRigidbody.AddForce (objectToDamageRigidbody.mass * force, forceMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void setProjectileSpecialActionActiveState (bool state)
|
||||
{
|
||||
setShatterObjectActiveState (state);
|
||||
}
|
||||
|
||||
//SHATTER FUNCTIONS
|
||||
public void setShatterObjectActiveState (bool state)
|
||||
{
|
||||
shatterObjectActive = state;
|
||||
}
|
||||
|
||||
public void shatterObject (GameObject objectToCheck, Material crossSectionMaterial)
|
||||
{
|
||||
if (objectShattered) {
|
||||
return;
|
||||
}
|
||||
|
||||
objectsToShatter = new List<GameObject> ();
|
||||
|
||||
if (objectToCheck.transform.parent != null) {
|
||||
objectToCheck.transform.SetParent (null);
|
||||
}
|
||||
|
||||
objectsToShatter.Add (objectToCheck);
|
||||
|
||||
for (int i = 0; i < shatterAmount; i++) {
|
||||
randomShatter (crossSectionMaterial);
|
||||
}
|
||||
|
||||
objectShattered = true;
|
||||
}
|
||||
|
||||
public void randomShatter (Material crossSectionMaterial)
|
||||
{
|
||||
List<GameObject> adders = new List<GameObject> ();
|
||||
List<GameObject> removals = new List<GameObject> ();
|
||||
|
||||
foreach (GameObject objectToShatter in objectsToShatter) {
|
||||
GameObject [] shatters = randomShatterSingle (objectToShatter, crossSectionMaterial);
|
||||
|
||||
if (shatters != null) {
|
||||
foreach (GameObject add in shatters) {
|
||||
adders.Add (add);
|
||||
}
|
||||
|
||||
removals.Add (objectToShatter);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GameObject rem in removals) {
|
||||
objectsToShatter.Remove (rem);
|
||||
}
|
||||
|
||||
foreach (GameObject add in adders) {
|
||||
objectsToShatter.Add (add);
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject [] randomShatterSingle (GameObject objectToShatter, Material crossSectionMaterial)
|
||||
{
|
||||
Vector3 shatterPosition = objectToShatter.transform.position;
|
||||
|
||||
GameObject [] shatters = sliceSystemUtils.shatterObject (objectToShatter, shatterPosition, crossSectionMaterial);
|
||||
|
||||
if (shatters != null && shatters.Length > 0) {
|
||||
objectToShatter.SetActive (false);
|
||||
|
||||
Vector3 cutPosition = objectToShatter.transform.position;
|
||||
|
||||
// add rigidbodies and colliders
|
||||
foreach (GameObject shatteredObject in shatters) {
|
||||
shatteredObject.AddComponent<MeshCollider> ().convex = true;
|
||||
|
||||
if (applyForceOnShatter) {
|
||||
Rigidbody currentObjectRigidbody = shatteredObject.AddComponent<Rigidbody> ();
|
||||
|
||||
currentObjectRigidbody.AddExplosionForce (forceToApplyToCutPart, cutPosition, 10, 1, forceMode);
|
||||
} else {
|
||||
shatteredObject.AddComponent<Rigidbody> ();
|
||||
}
|
||||
|
||||
if (addSliceComponentToPieces) {
|
||||
surfaceToSlice newSurfaceToSlice = shatteredObject.AddComponent<surfaceToSlice> ();
|
||||
|
||||
newSurfaceToSlice.setCrossSectionMaterial (crossSectionMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return shatters;
|
||||
}
|
||||
|
||||
public override void resetProjectile ()
|
||||
{
|
||||
base.resetProjectile ();
|
||||
|
||||
currentNumberOfCuts = 0;
|
||||
|
||||
objectsDetected.Clear ();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void OnDrawGizmos ()
|
||||
{
|
||||
if (!showGizmo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
|
||||
DrawGizmos ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected ()
|
||||
{
|
||||
DrawGizmos ();
|
||||
}
|
||||
|
||||
void DrawGizmos ()
|
||||
{
|
||||
if (showGizmo) {
|
||||
GKC_Utils.drawRectangleGizmo (cutPositionTransform.position, cutPositionTransform.rotation, Vector3.zero, cutOverlapBoxSize, gizmoColor);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16de5b5c61147a543bde1ca381cbec6d
|
||||
timeCreated: 1576820159
|
||||
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/Weapons/Projectiles/plasmaCutterProjectile.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,333 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using GameKitController.Audio;
|
||||
|
||||
[System.Serializable]
|
||||
public class projectileInfo
|
||||
{
|
||||
public bool isHommingProjectile;
|
||||
public bool isSeeker;
|
||||
public bool targetOnScreenForSeeker = true;
|
||||
public float waitTimeToSearchTarget;
|
||||
|
||||
public bool useRaycastCheckingOnRigidbody;
|
||||
|
||||
public float customRaycastCheckingRate;
|
||||
|
||||
public float customRaycastCheckingDistance = 0.1f;
|
||||
|
||||
public bool useRayCastShoot;
|
||||
|
||||
public bool useRaycastShootDelay;
|
||||
public float raycastShootDelay;
|
||||
public bool getDelayWithDistance;
|
||||
public float delayWithDistanceSpeed;
|
||||
public float maxDelayWithDistance;
|
||||
|
||||
public bool useFakeProjectileTrails;
|
||||
|
||||
public float projectileDamage;
|
||||
public float projectileSpeed;
|
||||
public float impactForceApplied;
|
||||
public ForceMode forceMode;
|
||||
public bool applyImpactForceToVehicles;
|
||||
public float impactForceToVehiclesMultiplier;
|
||||
|
||||
public bool checkObjectsWithMultipleDamageReceiversEnabled = true;
|
||||
|
||||
public float forceMassMultiplier = 1;
|
||||
|
||||
public bool projectileWithAbility;
|
||||
public AudioClip impactSoundEffect;
|
||||
public AudioElement impactAudioElement;
|
||||
public GameObject scorch;
|
||||
public GameObject owner;
|
||||
public GameObject projectileParticles;
|
||||
public GameObject impactParticles;
|
||||
|
||||
public bool isExplosive;
|
||||
public bool isImplosive;
|
||||
public float explosionForce;
|
||||
public float explosionRadius;
|
||||
public bool useExplosionDelay;
|
||||
public float explosionDelay;
|
||||
public float explosionDamage;
|
||||
public bool pushCharacters;
|
||||
public bool canDamageProjectileOwner;
|
||||
public bool applyExplosionForceToVehicles;
|
||||
public float explosionForceToVehiclesMultiplier;
|
||||
|
||||
public bool searchClosestWeakSpot;
|
||||
|
||||
public bool killInOneShot;
|
||||
|
||||
public bool useDisableTimer;
|
||||
public float noImpactDisableTimer;
|
||||
public float impactDisableTimer;
|
||||
|
||||
public bool useCustomIgnoreTags;
|
||||
public List<string> customTagsToIgnoreList = new List<string> ();
|
||||
|
||||
public LayerMask targetToDamageLayer;
|
||||
|
||||
public LayerMask targetForScorchLayer;
|
||||
|
||||
public float scorchRayCastDistance;
|
||||
|
||||
public int impactDecalIndex;
|
||||
|
||||
public bool launchProjectile;
|
||||
|
||||
public bool adhereToSurface;
|
||||
public bool adhereToLimbs;
|
||||
|
||||
public bool ignoreSetProjectilePositionOnImpact;
|
||||
|
||||
public bool useGravityOnLaunch;
|
||||
public bool useGraivtyOnImpact;
|
||||
|
||||
public bool breakThroughObjects;
|
||||
|
||||
public bool canBreakThroughArmorSurface;
|
||||
|
||||
public int breakThroughArmorSurfacePriorityValue = -1;
|
||||
|
||||
public bool infiniteNumberOfImpacts;
|
||||
public int numberOfImpacts;
|
||||
public bool canDamageSameObjectMultipleTimes;
|
||||
public Vector3 forwardDirection;
|
||||
public bool ignoreNewRotationOnProjectileImpact;
|
||||
|
||||
public bool stopBreakThroughObjectsOnLayer;
|
||||
public LayerMask layerToStopBreahtThroughObjects;
|
||||
|
||||
public bool damageTargetOverTime;
|
||||
public float damageOverTimeDelay;
|
||||
public float damageOverTimeDuration;
|
||||
public float damageOverTimeAmount;
|
||||
public float damageOverTimeRate;
|
||||
public bool damageOverTimeToDeath;
|
||||
|
||||
public bool removeDamageOverTimeState;
|
||||
|
||||
public bool sedateCharacters;
|
||||
public float sedateDelay;
|
||||
public bool useWeakSpotToReduceDelay;
|
||||
public bool sedateUntilReceiveDamage;
|
||||
public float sedateDuration;
|
||||
|
||||
public bool pushCharacter;
|
||||
public float pushCharacterForce;
|
||||
public float pushCharacterRagdollForce;
|
||||
|
||||
public bool setProjectileMeshRotationToFireRotation;
|
||||
|
||||
public bool useRemoteEventOnObjectsFound;
|
||||
public List<string> remoteEventNameList = new List<string> ();
|
||||
|
||||
public bool useRemoteEventOnObjectsFoundOnExplosion;
|
||||
public string remoteEventNameOnExplosion;
|
||||
|
||||
public bool ignoreShield;
|
||||
|
||||
public bool canActivateReactionSystemTemporally;
|
||||
|
||||
public int damageReactionID = -1;
|
||||
|
||||
public int damageTypeID = -1;
|
||||
|
||||
public bool damageCanBeBlocked = true;
|
||||
|
||||
public bool projectilesPoolEnabled;
|
||||
|
||||
public int maxAmountOfPoolElementsOnWeapon;
|
||||
|
||||
public bool allowDamageForProjectileOwner;
|
||||
|
||||
public bool projectileCanBeDeflected = true;
|
||||
|
||||
|
||||
public bool sliceObjectsDetected;
|
||||
public LayerMask layerToSlice;
|
||||
public bool useBodyPartsSliceList;
|
||||
public List<string> bodyPartsSliceList = new List<string> ();
|
||||
public float maxDistanceToBodyPart;
|
||||
public bool randomSliceDirection;
|
||||
public bool showSliceGizmo;
|
||||
|
||||
public bool activateRigidbodiesOnNewObjects = true;
|
||||
|
||||
public bool useGeneralProbabilitySliceObjects;
|
||||
[Range (0, 100)] public float generalProbabilitySliceObjects;
|
||||
|
||||
|
||||
public void InitializeAudioElements ()
|
||||
{
|
||||
if (impactSoundEffect != null) {
|
||||
impactAudioElement.clip = impactSoundEffect;
|
||||
}
|
||||
}
|
||||
|
||||
public projectileInfo ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public projectileInfo (projectileInfo newInfo)
|
||||
{
|
||||
isHommingProjectile = newInfo.isHommingProjectile;
|
||||
isSeeker = newInfo.isSeeker;
|
||||
targetOnScreenForSeeker = newInfo.targetOnScreenForSeeker;
|
||||
waitTimeToSearchTarget = newInfo.waitTimeToSearchTarget;
|
||||
|
||||
useRaycastCheckingOnRigidbody = newInfo.useRaycastCheckingOnRigidbody;
|
||||
|
||||
customRaycastCheckingRate = newInfo.customRaycastCheckingRate;
|
||||
|
||||
customRaycastCheckingDistance = newInfo.customRaycastCheckingDistance;
|
||||
|
||||
useRayCastShoot = newInfo.useRayCastShoot;
|
||||
|
||||
useRaycastShootDelay = newInfo.useRaycastShootDelay;
|
||||
raycastShootDelay = newInfo.raycastShootDelay;
|
||||
getDelayWithDistance = newInfo.getDelayWithDistance;
|
||||
delayWithDistanceSpeed = newInfo.delayWithDistanceSpeed;
|
||||
maxDelayWithDistance = newInfo.maxDelayWithDistance;
|
||||
|
||||
useFakeProjectileTrails = newInfo.useFakeProjectileTrails;
|
||||
|
||||
projectileDamage = newInfo.projectileDamage;
|
||||
projectileSpeed = newInfo.projectileSpeed;
|
||||
impactForceApplied = newInfo.impactForceApplied;
|
||||
forceMode = newInfo.forceMode;
|
||||
applyImpactForceToVehicles = newInfo.applyImpactForceToVehicles;
|
||||
impactForceToVehiclesMultiplier = newInfo.impactForceToVehiclesMultiplier;
|
||||
|
||||
forceMassMultiplier = newInfo.forceMassMultiplier;
|
||||
|
||||
checkObjectsWithMultipleDamageReceiversEnabled = newInfo.checkObjectsWithMultipleDamageReceiversEnabled;
|
||||
|
||||
projectileWithAbility = newInfo.projectileWithAbility;
|
||||
impactSoundEffect = newInfo.impactSoundEffect;
|
||||
impactAudioElement = newInfo.impactAudioElement;
|
||||
scorch = newInfo.scorch;
|
||||
owner = newInfo.owner;
|
||||
projectileParticles = newInfo.projectileParticles;
|
||||
impactParticles = newInfo.impactParticles;
|
||||
|
||||
isExplosive = newInfo.isExplosive;
|
||||
isImplosive = newInfo.isImplosive;
|
||||
explosionForce = newInfo.explosionForce;
|
||||
explosionRadius = newInfo.explosionRadius;
|
||||
useExplosionDelay = newInfo.useExplosionDelay;
|
||||
explosionDelay = newInfo.explosionDelay;
|
||||
explosionDamage = newInfo.explosionDamage;
|
||||
pushCharacters = newInfo.pushCharacters;
|
||||
canDamageProjectileOwner = newInfo.canDamageProjectileOwner;
|
||||
applyExplosionForceToVehicles = newInfo.applyExplosionForceToVehicles;
|
||||
explosionForceToVehiclesMultiplier = newInfo.explosionForceToVehiclesMultiplier;
|
||||
|
||||
searchClosestWeakSpot = newInfo.searchClosestWeakSpot;
|
||||
|
||||
killInOneShot = newInfo.killInOneShot;
|
||||
|
||||
useDisableTimer = newInfo.useDisableTimer;
|
||||
noImpactDisableTimer = newInfo.noImpactDisableTimer;
|
||||
impactDisableTimer = newInfo.impactDisableTimer;
|
||||
|
||||
useCustomIgnoreTags = newInfo.useCustomIgnoreTags;
|
||||
customTagsToIgnoreList = newInfo.customTagsToIgnoreList;
|
||||
|
||||
targetToDamageLayer = newInfo.targetToDamageLayer;
|
||||
|
||||
targetForScorchLayer = newInfo.targetForScorchLayer;
|
||||
|
||||
scorchRayCastDistance = newInfo.scorchRayCastDistance;
|
||||
|
||||
impactDecalIndex = newInfo.impactDecalIndex;
|
||||
|
||||
launchProjectile = newInfo.launchProjectile;
|
||||
|
||||
adhereToSurface = newInfo.adhereToSurface;
|
||||
adhereToLimbs = newInfo.adhereToLimbs;
|
||||
|
||||
ignoreSetProjectilePositionOnImpact = newInfo.ignoreSetProjectilePositionOnImpact;
|
||||
|
||||
useGravityOnLaunch = newInfo.useGravityOnLaunch;
|
||||
useGraivtyOnImpact = newInfo.useGraivtyOnImpact;
|
||||
|
||||
breakThroughObjects = newInfo.breakThroughObjects;
|
||||
|
||||
canBreakThroughArmorSurface = newInfo.canBreakThroughArmorSurface;
|
||||
|
||||
breakThroughArmorSurfacePriorityValue = newInfo.breakThroughArmorSurfacePriorityValue;
|
||||
|
||||
infiniteNumberOfImpacts = newInfo.infiniteNumberOfImpacts;
|
||||
numberOfImpacts = newInfo.numberOfImpacts;
|
||||
canDamageSameObjectMultipleTimes = newInfo.canDamageSameObjectMultipleTimes;
|
||||
forwardDirection = newInfo.forwardDirection;
|
||||
ignoreNewRotationOnProjectileImpact = newInfo.ignoreNewRotationOnProjectileImpact;
|
||||
|
||||
stopBreakThroughObjectsOnLayer = newInfo.stopBreakThroughObjectsOnLayer;
|
||||
layerToStopBreahtThroughObjects = newInfo.layerToStopBreahtThroughObjects;
|
||||
|
||||
damageTargetOverTime = newInfo.damageTargetOverTime;
|
||||
damageOverTimeDelay = newInfo.damageOverTimeDelay;
|
||||
damageOverTimeDuration = newInfo.damageOverTimeDuration;
|
||||
damageOverTimeAmount = newInfo.damageOverTimeAmount;
|
||||
damageOverTimeRate = newInfo.damageOverTimeRate;
|
||||
damageOverTimeToDeath = newInfo.damageOverTimeToDeath;
|
||||
|
||||
removeDamageOverTimeState = newInfo.removeDamageOverTimeState;
|
||||
|
||||
sedateCharacters = newInfo.sedateCharacters;
|
||||
sedateDelay = newInfo.sedateDelay;
|
||||
useWeakSpotToReduceDelay = newInfo.useWeakSpotToReduceDelay;
|
||||
sedateUntilReceiveDamage = newInfo.sedateUntilReceiveDamage;
|
||||
sedateDuration = newInfo.sedateDuration;
|
||||
|
||||
pushCharacter = newInfo.pushCharacter;
|
||||
pushCharacterForce = newInfo.pushCharacterForce;
|
||||
pushCharacterRagdollForce = newInfo.pushCharacterRagdollForce;
|
||||
|
||||
setProjectileMeshRotationToFireRotation = newInfo.setProjectileMeshRotationToFireRotation;
|
||||
|
||||
useRemoteEventOnObjectsFound = newInfo.useRemoteEventOnObjectsFound;
|
||||
remoteEventNameList = newInfo.remoteEventNameList;
|
||||
|
||||
useRemoteEventOnObjectsFoundOnExplosion = newInfo.useRemoteEventOnObjectsFoundOnExplosion;
|
||||
remoteEventNameOnExplosion = newInfo.remoteEventNameOnExplosion;
|
||||
|
||||
ignoreShield = newInfo.ignoreShield;
|
||||
|
||||
canActivateReactionSystemTemporally = newInfo.canActivateReactionSystemTemporally;
|
||||
|
||||
damageReactionID = newInfo.damageReactionID;
|
||||
|
||||
damageTypeID = newInfo.damageTypeID;
|
||||
|
||||
damageCanBeBlocked = newInfo.damageCanBeBlocked;
|
||||
|
||||
projectilesPoolEnabled = newInfo.projectilesPoolEnabled;
|
||||
|
||||
maxAmountOfPoolElementsOnWeapon = newInfo.maxAmountOfPoolElementsOnWeapon;
|
||||
|
||||
allowDamageForProjectileOwner = newInfo.allowDamageForProjectileOwner;
|
||||
|
||||
projectileCanBeDeflected = newInfo.projectileCanBeDeflected;
|
||||
|
||||
sliceObjectsDetected = newInfo.sliceObjectsDetected;
|
||||
layerToSlice = newInfo.layerToSlice;
|
||||
useBodyPartsSliceList = newInfo.useBodyPartsSliceList;
|
||||
bodyPartsSliceList = newInfo.bodyPartsSliceList;
|
||||
maxDistanceToBodyPart = newInfo.maxDistanceToBodyPart;
|
||||
randomSliceDirection = newInfo.randomSliceDirection;
|
||||
showSliceGizmo = newInfo.showSliceGizmo;
|
||||
|
||||
activateRigidbodiesOnNewObjects = newInfo.activateRigidbodiesOnNewObjects;
|
||||
|
||||
useGeneralProbabilitySliceObjects = newInfo.useGeneralProbabilitySliceObjects;
|
||||
generalProbabilitySliceObjects = newInfo.generalProbabilitySliceObjects;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f50ab08e8bd7c8346bc7fd2e361612a9
|
||||
timeCreated: 1514499113
|
||||
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/Weapons/Projectiles/projectileInfo.cs
|
||||
uploadId: 814740
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e76cc7e3fc942aa4a9eb5a14bf1b3e4f
|
||||
timeCreated: 1514586393
|
||||
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/Weapons/Projectiles/projectileSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,305 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
|
||||
public class spearProjectile : projectileSystem
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public LayerMask layer;
|
||||
|
||||
public float rayDistance = 1;
|
||||
public float carryingRagdollSpeedMultiplier = 3;
|
||||
public float maxProjectileSpeedClamp = 30;
|
||||
public float capsuleCastRadius = 2;
|
||||
|
||||
public float delayToDropSpearIfNotSurfaceFound = 10;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useGeneralProbabilityToKillTargets;
|
||||
[Range (0, 100)] public float generalProbabilityToKillTargets;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool surfaceFound;
|
||||
public bool carryingRagdoll;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Transform raycastPositionTransform;
|
||||
|
||||
ragdollActivator currentRagdoll;
|
||||
|
||||
Vector3 previousVelocity;
|
||||
Transform currentRagdollRootMotion;
|
||||
bool firstSurfaceDetected;
|
||||
Vector3 surfacePoint;
|
||||
float extraDistanceRaycast = 5;
|
||||
Collider[] hitColliders;
|
||||
|
||||
float lastTimeSpearCarryingRagdoll;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
if (carryingRagdoll) {
|
||||
if (surfaceFound) {
|
||||
stopUpdateCoroutine ();
|
||||
} else {
|
||||
if (!firstSurfaceDetected) {
|
||||
if (Physics.Linecast (currentRagdollRootMotion.position, currentRagdollRootMotion.position + transform.forward * extraDistanceRaycast, out hit, layer)) {
|
||||
if (!hit.collider.GetComponent<Rigidbody> ()) {
|
||||
firstSurfaceDetected = true;
|
||||
surfacePoint = hit.point;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (firstSurfaceDetected) {
|
||||
float currentDistance = GKC_Utils.distance (currentRagdollRootMotion.position, surfacePoint);
|
||||
|
||||
if (currentDistance < rayDistance) {
|
||||
surfaceFound = true;
|
||||
}
|
||||
|
||||
if (currentDistance < extraDistanceRaycast) {
|
||||
if (carryingRagdollSpeedMultiplier > 1) {
|
||||
carryingRagdollSpeedMultiplier = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Physics.Linecast (currentRagdollRootMotion.position, currentRagdollRootMotion.position + transform.forward * rayDistance, out hit, layer)) {
|
||||
if (!hit.collider.GetComponent<Rigidbody> ()) {
|
||||
surfaceFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 movementValue = transform.InverseTransformDirection (transform.forward) * (Mathf.Abs (previousVelocity.magnitude) * carryingRagdollSpeedMultiplier * Time.deltaTime);
|
||||
|
||||
if (maxProjectileSpeedClamp != 0) {
|
||||
if (Mathf.Abs (movementValue.magnitude) > maxProjectileSpeedClamp) {
|
||||
movementValue = Vector3.ClampMagnitude (movementValue, maxProjectileSpeedClamp);
|
||||
}
|
||||
}
|
||||
|
||||
transform.Translate (movementValue);
|
||||
|
||||
if (Time.time > lastTimeSpearCarryingRagdoll + delayToDropSpearIfNotSurfaceFound) {
|
||||
surfaceFound = true;
|
||||
|
||||
mainRigidbody.isKinematic = false;
|
||||
|
||||
mainRigidbody.useGravity = true;
|
||||
|
||||
mainRigidbody.AddForce (transform.forward * Mathf.Abs (previousVelocity.magnitude) * carryingRagdollSpeedMultiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//when the bullet touchs a surface, then
|
||||
public void checkObjectDetected (Collider col)
|
||||
{
|
||||
if (canActivateEffect (col)) {
|
||||
setProjectileUsedState (true);
|
||||
|
||||
enableOrDisableMainTrailRenderer (false);
|
||||
|
||||
//set the bullet kinematic
|
||||
objectToDamage = col.GetComponent<Collider> ().gameObject;
|
||||
|
||||
setProjectileScorch ();
|
||||
|
||||
previousVelocity = mainRigidbody.linearVelocity;
|
||||
|
||||
mainRigidbody.isKinematic = true;
|
||||
|
||||
if (carryingRagdoll) {
|
||||
return;
|
||||
}
|
||||
|
||||
Rigidbody objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
|
||||
|
||||
Transform currentCharacter = null;
|
||||
|
||||
GameObject currentCharacterGameObject = applyDamage.getCharacterOrVehicle (objectToDamage);
|
||||
|
||||
if (currentCharacterGameObject != null) {
|
||||
currentCharacter = currentCharacterGameObject.transform;
|
||||
}
|
||||
|
||||
bool bodyPartOnRagdollDetected = false;
|
||||
|
||||
bool isCharacter = applyDamage.isCharacter (objectToDamage);
|
||||
|
||||
if (objectToDamageRigidbody != null) {
|
||||
currentRagdoll = objectToDamage.GetComponent<ragdollActivator> ();
|
||||
|
||||
if (currentRagdoll == null) {
|
||||
if (currentCharacter != null) {
|
||||
currentRagdoll = currentCharacter.GetComponent<ragdollActivator> ();
|
||||
|
||||
bodyPartOnRagdollDetected = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRagdoll != null) {
|
||||
Vector3 currentPosition = transform.position;
|
||||
|
||||
List<ragdollActivator.bodyPart> bones = currentRagdoll.getBodyPartsList ();
|
||||
|
||||
float distance = Mathf.Infinity;
|
||||
|
||||
int index = -1;
|
||||
|
||||
for (int i = 0; i < bones.Count; i++) {
|
||||
float currentDistance = GKC_Utils.distance (bones [i].transform.position, currentPosition);
|
||||
|
||||
if (currentDistance < distance) {
|
||||
distance = currentDistance;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1) {
|
||||
if (applyDamage.checkIfDead (objectToDamage)) {
|
||||
if (bodyPartOnRagdollDetected) {
|
||||
transform.SetParent (objectToDamage.transform);
|
||||
} else {
|
||||
mainRigidbody.isKinematic = false;
|
||||
|
||||
mainRigidbody.linearVelocity = previousVelocity;
|
||||
|
||||
setProjectileUsedState (false);
|
||||
|
||||
currentRagdoll.setRagdollOnExternalParent (transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (currentCharacter != null) {
|
||||
isCharacter = false;
|
||||
|
||||
transform.SetParent (currentCharacter);
|
||||
} else if (objectToDamage != null) {
|
||||
transform.SetParent (objectToDamage.transform);
|
||||
}
|
||||
} else if (currentCharacter != null) {
|
||||
transform.SetParent (currentCharacter);
|
||||
|
||||
isCharacter = false;
|
||||
}
|
||||
|
||||
if (isCharacter) {
|
||||
setIgnoreParentDestroyedState (true);
|
||||
}
|
||||
|
||||
checkProjectilesParent ();
|
||||
|
||||
|
||||
bool activateSliceResult = true;
|
||||
|
||||
if (!currentProjectileInfo.killInOneShot) {
|
||||
activateSliceResult = false;
|
||||
} else {
|
||||
if (useGeneralProbabilityToKillTargets) {
|
||||
float randomProbability = UnityEngine.Random.Range (0, 101);
|
||||
|
||||
if (randomProbability > generalProbabilityToKillTargets) {
|
||||
activateSliceResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//add velocity if the touched object has rigidbody
|
||||
if (activateSliceResult) {
|
||||
applyDamage.killCharacter (gameObject, objectToDamage, -transform.forward, transform.position, currentProjectileInfo.owner, false);
|
||||
|
||||
if (!bodyPartOnRagdollDetected) {
|
||||
if (currentRagdoll != null) {
|
||||
projectilePaused = true;
|
||||
|
||||
transform.SetParent (null);
|
||||
|
||||
currentRagdollRootMotion = currentRagdoll.getRootMotion ();
|
||||
|
||||
currentRagdollRootMotion.SetParent (transform);
|
||||
|
||||
currentRagdollRootMotion.GetComponent<Rigidbody> ().isKinematic = true;
|
||||
|
||||
currentRagdoll.setRagdollOnExternalParent (transform);
|
||||
|
||||
setProjectileUsedState (false);
|
||||
|
||||
lastTimeSpearCarryingRagdoll = Time.time;
|
||||
|
||||
carryingRagdoll = true;
|
||||
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
applyDamage.checkHealth (gameObject, objectToDamage, currentProjectileInfo.projectileDamage, -transform.forward,
|
||||
transform.position, currentProjectileInfo.owner, false, true, currentProjectileInfo.ignoreShield, false, currentProjectileInfo.damageCanBeBlocked,
|
||||
currentProjectileInfo.canActivateReactionSystemTemporally, currentProjectileInfo.damageReactionID, currentProjectileInfo.damageTypeID);
|
||||
}
|
||||
|
||||
if (currentProjectileInfo.applyImpactForceToVehicles) {
|
||||
Rigidbody objectToDamageMainRigidbody = applyDamage.applyForce (objectToDamage);
|
||||
|
||||
if (objectToDamageMainRigidbody != null) {
|
||||
Vector3 force = transform.forward * currentProjectileInfo.impactForceApplied;
|
||||
|
||||
objectToDamageMainRigidbody.AddForce (force * objectToDamageMainRigidbody.mass, currentProjectileInfo.forceMode);
|
||||
}
|
||||
} else {
|
||||
if (applyDamage.canApplyForce (objectToDamage)) {
|
||||
Vector3 force = transform.forward * currentProjectileInfo.impactForceApplied;
|
||||
|
||||
objectToDamageRigidbody.AddForce (force * objectToDamageRigidbody.mass, currentProjectileInfo.forceMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void resetProjectile ()
|
||||
{
|
||||
base.resetProjectile ();
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
surfaceFound = false;
|
||||
carryingRagdoll = false;
|
||||
firstSurfaceDetected = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f92c34106991c94e9089e4c191130a8
|
||||
timeCreated: 1523733459
|
||||
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/Weapons/Projectiles/spearProjectile.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,96 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
|
||||
public class taserProjectile : projectileSystem
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public LayerMask layer;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useLayerMaskToIgnore;
|
||||
|
||||
public LayerMask layerMaskToIgnore;
|
||||
|
||||
[Space]
|
||||
[Header ("Ragdoll Settings")]
|
||||
[Space]
|
||||
|
||||
public float sedateDelay;
|
||||
public bool useWeakSpotToReduceDelay;
|
||||
public bool sedateUntilReceiveDamage;
|
||||
public float sedateDuration;
|
||||
|
||||
public bool useActionSystemOnImpact;
|
||||
public string actionSystemOnImpactName;
|
||||
|
||||
|
||||
//when the bullet touchs a surface, then
|
||||
public void checkObjectDetected (Collider col)
|
||||
{
|
||||
if (canActivateEffect (col)) {
|
||||
if (currentProjectileInfo.impactAudioElement != null) {
|
||||
currentProjectileInfo.impactAudioElement.audioSource = GetComponent<AudioSource> ();
|
||||
AudioPlayer.PlayOneShot (currentProjectileInfo.impactAudioElement, gameObject);
|
||||
}
|
||||
|
||||
setProjectileUsedState (true);
|
||||
|
||||
//set the bullet kinematic
|
||||
objectToDamage = col.GetComponent<Collider> ().gameObject;
|
||||
|
||||
mainRigidbody.isKinematic = true;
|
||||
|
||||
if ((1 << col.gameObject.layer & layer.value) == 1 << col.gameObject.layer) {
|
||||
|
||||
if (useLayerMaskToIgnore) {
|
||||
if ((1 << col.gameObject.layer & layerMaskToIgnore.value) == 1 << col.gameObject.layer) {
|
||||
|
||||
setProjectileUsedState (false);
|
||||
|
||||
setIgnoreProjectileWithAbilityState (true);
|
||||
|
||||
checkSurface (col);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool isCharacter = applyDamage.isCharacter (objectToDamage);
|
||||
|
||||
if (isCharacter) {
|
||||
objectToDamage = applyDamage.getCharacter (objectToDamage);
|
||||
|
||||
applyDamage.sedateCharacter (objectToDamage, transform.position, sedateDelay, useWeakSpotToReduceDelay,
|
||||
sedateUntilReceiveDamage, sedateDuration);
|
||||
|
||||
if (useActionSystemOnImpact) {
|
||||
playerController currentPlayerController = objectToDamage.GetComponent<playerController> ();
|
||||
|
||||
if (currentPlayerController != null) {
|
||||
currentPlayerController.activateCustomAction (actionSystemOnImpactName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkProjectilesParent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyObject ()
|
||||
{
|
||||
destroyProjectile ();
|
||||
}
|
||||
|
||||
public override void resetProjectile ()
|
||||
{
|
||||
base.resetProjectile ();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d84ddf5dfc85edf47b076d5ebff6fa0b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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/Weapons/Projectiles/taserProjectile.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6483e51481fe3394cae7661d5a8e4078
|
||||
folderAsset: yes
|
||||
timeCreated: 1573356735
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu (fileName = "Object Transform Data", menuName = "GKC/Create Object Transform Data", order = 51)]
|
||||
public class objectTransformData : ScriptableObject
|
||||
{
|
||||
public List<objectTransformInfo> objectTransformInfoList = new List<objectTransformInfo> ();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27819fcd07cb63f45b19f46d1abbe163
|
||||
timeCreated: 1571533154
|
||||
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/Weapons/Scriptable Objects/objectTransformData.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class objectTransformInfo
|
||||
{
|
||||
public Vector3 objectPosition;
|
||||
public Quaternion objectRotation;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class objectsTransformInfo
|
||||
{
|
||||
public string Name;
|
||||
public List<objectTransformInfo> objectTransformInfoList = new List<objectTransformInfo> ();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd4e4fb2d3b0f19418c50f45c8515f84
|
||||
timeCreated: 1571532990
|
||||
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/Weapons/Scriptable Objects/objectTransformInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,143 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class addGrenadeToThrowAwayFromCharacter : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool checkGrenadeOnCharacterEnabled = true;
|
||||
|
||||
public string throwGrenadeAbilityName = "Throw Grenade";
|
||||
|
||||
public string messagePanelName = "Return Grenade";
|
||||
|
||||
public bool setThrowGrenadeAbilityAutomatically = true;
|
||||
|
||||
public projectileSystem mainProjectileSystem;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public GameObject currentPlayer;
|
||||
|
||||
public bool confirmThrowGrenadeActive;
|
||||
|
||||
|
||||
public void addGrenadeToCharacterSystem (GameObject playerToCheck)
|
||||
{
|
||||
if (!checkGrenadeOnCharacterEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentPlayer = playerToCheck;
|
||||
|
||||
if (currentPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkPlayer (true);
|
||||
}
|
||||
|
||||
public void removeGrenadeToCharacterSystem ()
|
||||
{
|
||||
if (!checkGrenadeOnCharacterEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkPlayer (false);
|
||||
}
|
||||
|
||||
void checkPlayer (bool addingGrenade)
|
||||
{
|
||||
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
|
||||
playerAbilitiesSystem currentPlayerAbilitiesSystem = currentPlayerComponentsManager.getPlayerAbilitiesSystem ();
|
||||
|
||||
if (currentPlayerAbilitiesSystem != null) {
|
||||
abilityInfo throwGrenadeAbility = currentPlayerAbilitiesSystem.getAbilityByName (throwGrenadeAbilityName);
|
||||
|
||||
if (throwGrenadeAbility != null) {
|
||||
getObjectFromInventorySystem currentGetObjectFromInventorySystem = throwGrenadeAbility.GetComponentInChildren<getObjectFromInventorySystem> ();
|
||||
|
||||
if (currentGetObjectFromInventorySystem != null) {
|
||||
if (addingGrenade) {
|
||||
currentGetObjectFromInventorySystem.addExtraInventoryObjectAmount (1);
|
||||
|
||||
if (setThrowGrenadeAbilityAutomatically) {
|
||||
playerAbilitiesUISystem currentPlayerAbilitiesUISystem = currentPlayerAbilitiesSystem.GetComponent<playerAbilitiesUISystem> ();
|
||||
|
||||
if (currentPlayerAbilitiesUISystem != null) {
|
||||
currentPlayerAbilitiesUISystem.selectAbilityByName (throwGrenadeAbilityName);
|
||||
}
|
||||
}
|
||||
|
||||
simpleWeaponSystem currentSimpleWeaponSystem = throwGrenadeAbility.GetComponentInChildren<simpleWeaponSystem> ();
|
||||
|
||||
if (currentSimpleWeaponSystem != null) {
|
||||
currentSimpleWeaponSystem.addExternalProjectileToFire (mainProjectileSystem.gameObject);
|
||||
}
|
||||
|
||||
showMessageOnHUDSystem currentShowMessageOnHUDSystem = throwGrenadeAbility.GetComponentInChildren<showMessageOnHUDSystem> ();
|
||||
|
||||
if (currentShowMessageOnHUDSystem != null) {
|
||||
currentShowMessageOnHUDSystem.showMessagePanel (messagePanelName);
|
||||
}
|
||||
} else {
|
||||
showMessageOnHUDSystem currentShowMessageOnHUDSystem = throwGrenadeAbility.GetComponentInChildren<showMessageOnHUDSystem> ();
|
||||
|
||||
if (currentShowMessageOnHUDSystem != null) {
|
||||
currentShowMessageOnHUDSystem.hideMessagePanel (messagePanelName);
|
||||
}
|
||||
|
||||
currentGetObjectFromInventorySystem.addExtraInventoryObjectAmount (-1);
|
||||
|
||||
simpleWeaponSystem currentSimpleWeaponSystem = throwGrenadeAbility.GetComponentInChildren<simpleWeaponSystem> ();
|
||||
|
||||
if (currentSimpleWeaponSystem != null) {
|
||||
currentSimpleWeaponSystem.removeExternalProjectileToFire (mainProjectileSystem.gameObject);
|
||||
}
|
||||
|
||||
currentPlayer = null;
|
||||
|
||||
if (!confirmThrowGrenadeActive) {
|
||||
currentPlayerAbilitiesSystem.cancelPressAbility ();
|
||||
}
|
||||
|
||||
confirmThrowGrenadeActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void confirmThrowAwayGrenade ()
|
||||
{
|
||||
confirmThrowGrenadeActive = true;
|
||||
|
||||
mainProjectileSystem.projectileInitialized = false;
|
||||
|
||||
mainProjectileSystem.setProjectileUsedState (false);
|
||||
|
||||
if (mainProjectileSystem.currentProjectileInfo != null) {
|
||||
GameObject previousOwner = mainProjectileSystem.currentProjectileInfo.owner;
|
||||
|
||||
if (previousOwner != null) {
|
||||
Collider previousOwnerCollider = previousOwner.GetComponent<Collider> ();
|
||||
|
||||
if (previousOwnerCollider != null) {
|
||||
Physics.IgnoreCollision (mainProjectileSystem.mainCollider, previousOwnerCollider, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77580b15b9f958545a5b8b62d7b55828
|
||||
timeCreated: 1648057578
|
||||
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/Weapons/addGrenadeToThrowAwayFromCharacter.cs
|
||||
uploadId: 814740
|
||||
310
Assets/Game Kit Controller/Scripts/Weapons/armorSurfaceSystem.cs
Normal file
310
Assets/Game Kit Controller/Scripts/Weapons/armorSurfaceSystem.cs
Normal file
@@ -0,0 +1,310 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class armorSurfaceSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool armorActive = true;
|
||||
public GameObject armorOwner;
|
||||
|
||||
public bool useMinAngleToReturnProjectileToOwner;
|
||||
public float minAngleToReturnProjectileToOwner;
|
||||
|
||||
[Space]
|
||||
[Header ("Armor Health Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useArmorHealthAmount;
|
||||
public float armorHealthAmount;
|
||||
public float maxArmorHealthAmount;
|
||||
|
||||
public bool disableArmorOnEmptyHealth;
|
||||
|
||||
[Space]
|
||||
[Header ("Break Through Armor Surface Settings")]
|
||||
[Space]
|
||||
|
||||
public bool blockProjectilesFromBreakingThroughSurfaceEnabled;
|
||||
|
||||
public int armorSurfacePriorityValue = -1;
|
||||
|
||||
[Space]
|
||||
[Header ("Return Projectiles Settings")]
|
||||
[Space]
|
||||
|
||||
public bool throwProjectilesToPreviousOwnerEnabled = true;
|
||||
|
||||
public bool useNewDamageLayerOnReturnProjectiles;
|
||||
public LayerMask newDamageLayerOnReturnProjectiles;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setUseCustomIgnoreTagsOnReturnProjectilesState;
|
||||
public bool useCustomIgnoreTagsOnReturnProjectilesState;
|
||||
public List<string> customTagsToIgnoreOnReturnProjectilesList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public List<projectileSystem> projectilesStored = new List<projectileSystem> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public bool returnProjectilesOnContact;
|
||||
|
||||
public UnityEvent eventToReturnProjectilesOnContact;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventOnDeflectProjectilesActivated;
|
||||
|
||||
public UnityEvent eventOnDeflectProjectilesActivated;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventOnArmorHealthEmpty;
|
||||
public UnityEvent eventOnArmorHealthEmpty;
|
||||
|
||||
public bool useEventOnArmorHealthDamaged;
|
||||
public UnityEvent eventOnArmorHealthDamaged;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public BoxCollider mainCollider;
|
||||
|
||||
Coroutine armorSurfaceStateChangeCoroutine;
|
||||
|
||||
bool changeArmorActiveStateCoroutineActive;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (armorOwner == null) {
|
||||
armorOwner = gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
public void addProjectile (projectileSystem newProjectile)
|
||||
{
|
||||
if (!projectilesStored.Contains (newProjectile)) {
|
||||
projectilesStored.Add (newProjectile);
|
||||
|
||||
if (returnProjectilesOnContact) {
|
||||
eventToReturnProjectilesOnContact.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void throwProjectilesStored (Vector3 throwDirection)
|
||||
{
|
||||
bool ignoreProjectileOwner = !throwProjectilesToPreviousOwnerEnabled;
|
||||
|
||||
for (int i = 0; i < projectilesStored.Count; i++) {
|
||||
if (projectilesStored [i] != null) {
|
||||
|
||||
projectilesStored [i].returnBullet (throwDirection, armorOwner, ignoreProjectileOwner);
|
||||
}
|
||||
}
|
||||
|
||||
projectilesStored.Clear ();
|
||||
}
|
||||
|
||||
public void throwProjectilesStoredCheckingDirection (Transform playerTransform, Transform mainCameraTransform)
|
||||
{
|
||||
if (projectilesStored.Count > 0) {
|
||||
if (useEventOnDeflectProjectilesActivated) {
|
||||
eventOnDeflectProjectilesActivated.Invoke ();
|
||||
}
|
||||
|
||||
for (int i = 0; i < projectilesStored.Count; i++) {
|
||||
if (projectilesStored [i] != null) {
|
||||
|
||||
Vector3 projectileDirection = playerTransform.position - projectilesStored [i].transform.position;
|
||||
|
||||
projectileDirection = projectileDirection / projectileDirection.magnitude;
|
||||
|
||||
float angleForward = Vector3.SignedAngle (playerTransform.forward, projectileDirection, playerTransform.up);
|
||||
|
||||
bool returnProjectileToOwner = true;
|
||||
|
||||
if (useMinAngleToReturnProjectileToOwner) {
|
||||
if (Mathf.Abs (angleForward) > minAngleToReturnProjectileToOwner) {
|
||||
returnProjectileToOwner = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ignoreProjectileOwner = false;
|
||||
|
||||
if (!returnProjectileToOwner) {
|
||||
ignoreProjectileOwner = true;
|
||||
}
|
||||
|
||||
Debug.DrawRay (projectilesStored [i].transform.position, projectileDirection * 5, Color.red, 5);
|
||||
|
||||
Vector3 targetPositionToLook = playerTransform.position + playerTransform.up + playerTransform.forward;
|
||||
|
||||
if (useNewDamageLayerOnReturnProjectiles) {
|
||||
projectilesStored [i].setTargetToDamageLayer (newDamageLayerOnReturnProjectiles);
|
||||
}
|
||||
|
||||
if (setUseCustomIgnoreTagsOnReturnProjectilesState) {
|
||||
projectilesStored [i].setUseCustomIgnoreTags (useCustomIgnoreTagsOnReturnProjectilesState, customTagsToIgnoreOnReturnProjectilesList);
|
||||
}
|
||||
|
||||
projectilesStored [i].returnBullet (targetPositionToLook, armorOwner, ignoreProjectileOwner);
|
||||
}
|
||||
}
|
||||
|
||||
projectilesStored.Clear ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool thereAreProjectilesStored ()
|
||||
{
|
||||
return projectilesStored.Count > 0;
|
||||
}
|
||||
|
||||
public void destroyProjetilesOnShield ()
|
||||
{
|
||||
if (projectilesStored.Count < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < projectilesStored.Count; i++) {
|
||||
if (projectilesStored [i] != null) {
|
||||
|
||||
projectilesStored [i].destroyProjectile ();
|
||||
}
|
||||
}
|
||||
|
||||
projectilesStored.Clear ();
|
||||
}
|
||||
|
||||
public bool isArmorEnabled ()
|
||||
{
|
||||
return armorActive;
|
||||
}
|
||||
|
||||
public bool isBlockProjectilesFromBreakingThroughSurfaceEnabled ()
|
||||
{
|
||||
return blockProjectilesFromBreakingThroughSurfaceEnabled;
|
||||
}
|
||||
|
||||
public int getArmorSurfacePriorityValue ()
|
||||
{
|
||||
return armorSurfacePriorityValue;
|
||||
}
|
||||
|
||||
public void setNewArmorOwner (GameObject newObject)
|
||||
{
|
||||
armorOwner = newObject;
|
||||
}
|
||||
|
||||
public GameObject getArmorOwner ()
|
||||
{
|
||||
return armorOwner;
|
||||
}
|
||||
|
||||
public void setArmorActiveState (bool state)
|
||||
{
|
||||
armorActive = state;
|
||||
|
||||
if (changeArmorActiveStateCoroutineActive) {
|
||||
stopSetArmorSurfaceStateAfterDelayCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTriggerScaleValues (Vector3 newCenterValues, Vector3 newSizeValues)
|
||||
{
|
||||
if (mainCollider != null) {
|
||||
mainCollider.center = newCenterValues;
|
||||
|
||||
mainCollider.size = newSizeValues;
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnableArmorSurfaceStateWithDuration (float delayDuration, bool stateBeforeDelay, bool stateAfterDelay)
|
||||
{
|
||||
stopSetArmorSurfaceStateAfterDelayCoroutine ();
|
||||
|
||||
if (gameObject.activeSelf && gameObject.activeInHierarchy) {
|
||||
armorSurfaceStateChangeCoroutine = StartCoroutine (setArmorSurfaceStateAfterDelayCoroutine (delayDuration, stateBeforeDelay, stateAfterDelay));
|
||||
}
|
||||
}
|
||||
|
||||
public void stopSetArmorSurfaceStateAfterDelayCoroutine ()
|
||||
{
|
||||
if (armorSurfaceStateChangeCoroutine != null) {
|
||||
StopCoroutine (armorSurfaceStateChangeCoroutine);
|
||||
}
|
||||
|
||||
changeArmorActiveStateCoroutineActive = false;
|
||||
}
|
||||
|
||||
IEnumerator setArmorSurfaceStateAfterDelayCoroutine (float delayDuration, bool stateBeforeDelay, bool stateAfterDelay)
|
||||
{
|
||||
changeArmorActiveStateCoroutineActive = true;
|
||||
|
||||
armorActive = stateBeforeDelay;
|
||||
|
||||
yield return new WaitForSeconds (delayDuration);
|
||||
|
||||
armorActive = stateAfterDelay;
|
||||
|
||||
changeArmorActiveStateCoroutineActive = false;
|
||||
}
|
||||
|
||||
public void setArmorDamage (float damageAmount)
|
||||
{
|
||||
if (!useArmorHealthAmount) {
|
||||
return;
|
||||
}
|
||||
|
||||
armorHealthAmount -= damageAmount;
|
||||
|
||||
if (armorHealthAmount <= 0) {
|
||||
armorHealthAmount = 0;
|
||||
|
||||
if (disableArmorOnEmptyHealth) {
|
||||
armorActive = false;
|
||||
}
|
||||
|
||||
if (useEventOnArmorHealthEmpty) {
|
||||
eventOnArmorHealthEmpty.Invoke ();
|
||||
}
|
||||
} else {
|
||||
if (useEventOnArmorHealthDamaged) {
|
||||
eventOnArmorHealthDamaged.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void addArmorHealth (float healthAmount)
|
||||
{
|
||||
if (!useArmorHealthAmount) {
|
||||
return;
|
||||
}
|
||||
|
||||
armorHealthAmount += healthAmount;
|
||||
|
||||
armorHealthAmount = Mathf.Clamp (armorHealthAmount, 0, maxArmorHealthAmount);
|
||||
|
||||
if (armorHealthAmount > 0) {
|
||||
armorActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isUseArmorHealthAmountEnabled ()
|
||||
{
|
||||
return useArmorHealthAmount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d4d62ad346d1104ea78b4645c42abc1
|
||||
timeCreated: 1550340087
|
||||
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/Weapons/armorSurfaceSystem.cs
|
||||
uploadId: 814740
|
||||
136
Assets/Game Kit Controller/Scripts/Weapons/arrowManager.cs
Normal file
136
Assets/Game Kit Controller/Scripts/Weapons/arrowManager.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class arrowManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useArrowsEnabled = true;
|
||||
|
||||
public string currentArrowInventoryObjectName = "Regular Arrow";
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnArrowsFoundOnInventory;
|
||||
|
||||
public UnityEvent eventOnArrowsNotFoundOnInventory;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public GameObject arrowInfoPanel;
|
||||
|
||||
public Text arrowAmountText;
|
||||
|
||||
public RawImage arrowTypeIcon;
|
||||
|
||||
public GameObject infiniteArrowsIcon;
|
||||
|
||||
public inventoryManager mainInventoryManager;
|
||||
|
||||
int currentArrowAmount;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (useArrowsEnabled) {
|
||||
updateArrowAmountText ();
|
||||
} else {
|
||||
enableOrDisableArrowInfoPanel (false);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableOrDisableArrowInfoPanel (bool state)
|
||||
{
|
||||
if (useArrowsEnabled) {
|
||||
if (arrowInfoPanel != null) {
|
||||
if (arrowInfoPanel.activeSelf != state) {
|
||||
arrowInfoPanel.SetActive (state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfArrowsFoundOnInventory ()
|
||||
{
|
||||
if (!useArrowsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentArrowAmount = mainInventoryManager.getInventoryObjectAmountByName (currentArrowInventoryObjectName);
|
||||
|
||||
if (currentArrowAmount > 0) {
|
||||
|
||||
eventOnArrowsFoundOnInventory.Invoke ();
|
||||
} else {
|
||||
eventOnArrowsNotFoundOnInventory.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void useArrowFromInventory (int amountToUse)
|
||||
{
|
||||
checkIfArrowsFoundOnInventory ();
|
||||
|
||||
if (currentArrowAmount > 0) {
|
||||
mainInventoryManager.removeObjectAmountFromInventoryByName (currentArrowInventoryObjectName, amountToUse);
|
||||
}
|
||||
|
||||
updateArrowAmountText ();
|
||||
}
|
||||
|
||||
public void updateArrowAmountText ()
|
||||
{
|
||||
if (!useArrowsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentArrowAmount = mainInventoryManager.getInventoryObjectAmountByName (currentArrowInventoryObjectName);
|
||||
|
||||
if (arrowAmountText != null) {
|
||||
if (currentArrowAmount < 0) {
|
||||
currentArrowAmount = 0;
|
||||
}
|
||||
|
||||
arrowAmountText.text = currentArrowAmount.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentArrowInventoryObjectName (string newName)
|
||||
{
|
||||
currentArrowInventoryObjectName = newName;
|
||||
}
|
||||
|
||||
public void setArrowTypeIcon (Texture newIcon, bool useInfiniteArrows)
|
||||
{
|
||||
if (!useArrowsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arrowTypeIcon != null) {
|
||||
if (newIcon == null) {
|
||||
arrowTypeIcon.enabled = false;
|
||||
} else {
|
||||
arrowTypeIcon.enabled = true;
|
||||
|
||||
arrowTypeIcon.texture = newIcon;
|
||||
}
|
||||
|
||||
if (infiniteArrowsIcon != null) {
|
||||
if (infiniteArrowsIcon.activeSelf != useInfiniteArrows) {
|
||||
infiniteArrowsIcon.SetActive (useInfiniteArrows);
|
||||
}
|
||||
}
|
||||
|
||||
if (arrowAmountText.gameObject.activeSelf != !useInfiniteArrows) {
|
||||
arrowAmountText.gameObject.SetActive (!useInfiniteArrows);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 549e0f95715e03f4799e533045ca921c
|
||||
timeCreated: 1615618861
|
||||
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/Weapons/arrowManager.cs
|
||||
uploadId: 814740
|
||||
115
Assets/Game Kit Controller/Scripts/Weapons/bowHolderSystem.cs
Normal file
115
Assets/Game Kit Controller/Scripts/Weapons/bowHolderSystem.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class bowHolderSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public int bowWeaponID;
|
||||
|
||||
public bool canUseMultipleArrowType;
|
||||
|
||||
public List<int> bowWeaponIDList = new List<int> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnLoadArrow;
|
||||
|
||||
public UnityEvent eventOnFireArrow;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnStartAim;
|
||||
|
||||
public UnityEvent eventOnEndAim;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnCancelBowAction;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnMaxPullBowMultiplierStart;
|
||||
|
||||
public UnityEvent eventOnMaxPullBowMultiplierEnd;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug Settings")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
|
||||
public void checkEventOnLoadArrow ()
|
||||
{
|
||||
eventOnLoadArrow.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Event On Load Arrow");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnFireArrow ()
|
||||
{
|
||||
eventOnFireArrow.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Event On Fire Arrow");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnStartAim ()
|
||||
{
|
||||
eventOnStartAim.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Event On Start Aim");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnEndAim ()
|
||||
{
|
||||
eventOnEndAim.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Event On End Aim");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnCancelBowAction ()
|
||||
{
|
||||
eventOnCancelBowAction.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Event On Cancel Bow Action");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnMaxPullBowMultiplierStart ()
|
||||
{
|
||||
eventOnMaxPullBowMultiplierStart.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Event On Max Pull Bow Multiplier Start");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnMaxPullBowMultiplierEnd ()
|
||||
{
|
||||
eventOnMaxPullBowMultiplierEnd.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Event On Max Pull Bow Multiplier End");
|
||||
}
|
||||
}
|
||||
|
||||
public int getBowWeaponID ()
|
||||
{
|
||||
return bowWeaponID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d3ff1a8d8ace934681ede127b227b7a
|
||||
timeCreated: 1606154622
|
||||
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/Weapons/bowHolderSystem.cs
|
||||
uploadId: 814740
|
||||
1656
Assets/Game Kit Controller/Scripts/Weapons/bowSystem.cs
Normal file
1656
Assets/Game Kit Controller/Scripts/Weapons/bowSystem.cs
Normal file
File diff suppressed because it is too large
Load Diff
19
Assets/Game Kit Controller/Scripts/Weapons/bowSystem.cs.meta
Normal file
19
Assets/Game Kit Controller/Scripts/Weapons/bowSystem.cs.meta
Normal file
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 816f9b231e7ef9943961f5ed2e941f5e
|
||||
timeCreated: 1606148657
|
||||
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/Weapons/bowSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,289 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class dynamicReticleSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool dynamicReticleEnbled = true;
|
||||
|
||||
public bool useDelayToResetReticleSize;
|
||||
public float delayToResetReticleSize;
|
||||
|
||||
[Space]
|
||||
[Header ("Reticle List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<dynamicReticleInfo> dynamicReticleInfoList = new List<dynamicReticleInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public bool reticleActive;
|
||||
|
||||
public Vector2 currentReticleSizeDelta;
|
||||
|
||||
public string currentReticleName;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerController mainPlayerController;
|
||||
public playerCamera mainPlayerCamera;
|
||||
public playerWeaponsManager mainPlayerWeaponsManager;
|
||||
|
||||
|
||||
dynamicReticleInfo currentDynamicReticleInfo;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
RectTransform currentReticleRectTransform;
|
||||
|
||||
float lastTimeIncreaseReticleActive;
|
||||
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
bool increaseReticleResult = false;
|
||||
|
||||
currentReticleSizeDelta = currentDynamicReticleInfo.reticleMinDeltaSize;
|
||||
|
||||
if (currentDynamicReticleInfo.addExtraDeltaSizeOnWalking) {
|
||||
if (mainPlayerController.isPlayerMoving (0.1f) && mainPlayerController.getRawAxisValues () != Vector2.zero) {
|
||||
currentReticleSizeDelta += currentDynamicReticleInfo.deltaSizeOnWalking;
|
||||
|
||||
increaseReticleResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentDynamicReticleInfo.addExtraDeltaSizeOnRunning) {
|
||||
if (mainPlayerController.isPlayerRunning ()) {
|
||||
currentReticleSizeDelta += currentDynamicReticleInfo.deltaSizeOnRunning;
|
||||
|
||||
increaseReticleResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentDynamicReticleInfo.addExtraDeltaSizeOnLooking) {
|
||||
if (mainPlayerCamera.isCameraRotating () && mainPlayerCamera.checkIfCameraRotatingWithTolerance (0.5f)) {
|
||||
currentReticleSizeDelta += currentDynamicReticleInfo.deltaSizeOnLooking;
|
||||
|
||||
increaseReticleResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentDynamicReticleInfo.addExtraDeltaSizeOnAir) {
|
||||
if (!mainPlayerController.isPlayerOnGround ()) {
|
||||
currentReticleSizeDelta += currentDynamicReticleInfo.extraDeltaSizeOnAir;
|
||||
|
||||
increaseReticleResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentDynamicReticleInfo.addExtraDeltaSizeOnShooting) {
|
||||
if (mainPlayerWeaponsManager.isCharacterShooting ()) {
|
||||
currentReticleSizeDelta += currentDynamicReticleInfo.extraDeltaSizeOnShooting;
|
||||
|
||||
currentReticleRectTransform.sizeDelta += currentDynamicReticleInfo.extraDeltaSizeOnShooting;
|
||||
|
||||
increaseReticleResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (useDelayToResetReticleSize) {
|
||||
if (!increaseReticleResult) {
|
||||
if (lastTimeIncreaseReticleActive != 0) {
|
||||
if (Time.time < delayToResetReticleSize + lastTimeIncreaseReticleActive) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (increaseReticleResult) {
|
||||
lastTimeIncreaseReticleActive = Time.time;
|
||||
|
||||
if (currentDynamicReticleInfo.addSpreadToWeapon) {
|
||||
float sizeDeltaValue = (currentReticleRectTransform.sizeDelta.x - currentDynamicReticleInfo.reticleMinDeltaSize.x) /
|
||||
(currentDynamicReticleInfo.reticleMaxDeltaSize.x - currentDynamicReticleInfo.reticleMinDeltaSize.x);
|
||||
|
||||
float spreadAmount = currentDynamicReticleInfo.spreadToWeapon * sizeDeltaValue;
|
||||
|
||||
spreadAmount = Mathf.Clamp (spreadAmount, currentDynamicReticleInfo.minSpreadToWeapon, currentDynamicReticleInfo.maxSpreadToWeapon);
|
||||
|
||||
mainPlayerWeaponsManager.setExternalSpreadMultiplier (spreadAmount);
|
||||
}
|
||||
} else {
|
||||
if (currentDynamicReticleInfo.addSpreadToWeapon) {
|
||||
mainPlayerWeaponsManager.setExternalSpreadMultiplier (0);
|
||||
}
|
||||
}
|
||||
|
||||
currentReticleRectTransform.sizeDelta = Vector2.Lerp (currentReticleRectTransform.sizeDelta,
|
||||
currentReticleSizeDelta, Time.fixedDeltaTime * currentDynamicReticleInfo.reticleScaleSpeed);
|
||||
|
||||
Vector2 currentSizeDelta = currentReticleRectTransform.sizeDelta;
|
||||
|
||||
currentSizeDelta.x = Mathf.Clamp (currentSizeDelta.x,
|
||||
currentDynamicReticleInfo.reticleMinDeltaSize.x, currentDynamicReticleInfo.reticleMaxDeltaSize.x);
|
||||
currentSizeDelta.y = Mathf.Clamp (currentSizeDelta.y,
|
||||
currentDynamicReticleInfo.reticleMinDeltaSize.y, currentDynamicReticleInfo.reticleMaxDeltaSize.y);
|
||||
|
||||
currentReticleRectTransform.sizeDelta = currentSizeDelta;
|
||||
}
|
||||
|
||||
public void enableOrDisableReticleByName (string reticleName, bool state)
|
||||
{
|
||||
if (!dynamicReticleEnbled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("reticle state " + state + " " + reticleName);
|
||||
}
|
||||
|
||||
if (state) {
|
||||
if (!reticleName.Equals ("") && reticleName.Equals (currentReticleName)) {
|
||||
if (reticleActive) {
|
||||
if (showDebugPrint) {
|
||||
print ("trying to set the reticle which is already active, cancelling");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (reticleActive) {
|
||||
if (currentDynamicReticleInfo.reticleGameObject.activeSelf) {
|
||||
currentDynamicReticleInfo.reticleGameObject.SetActive (false);
|
||||
}
|
||||
|
||||
if (currentDynamicReticleInfo.addSpreadToWeapon) {
|
||||
mainPlayerWeaponsManager.setExternalSpreadMultiplier (0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!state) {
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
reticleActive = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int currentIndex = dynamicReticleInfoList.FindIndex (s => s.Name.Equals (reticleName));
|
||||
|
||||
if (currentIndex > -1) {
|
||||
currentDynamicReticleInfo = dynamicReticleInfoList [currentIndex];
|
||||
|
||||
if (currentDynamicReticleInfo.reticleEnabled) {
|
||||
reticleActive = state;
|
||||
|
||||
if (currentDynamicReticleInfo.reticleGameObject.activeSelf != reticleActive) {
|
||||
currentDynamicReticleInfo.reticleGameObject.SetActive (reticleActive);
|
||||
}
|
||||
|
||||
currentReticleRectTransform = currentDynamicReticleInfo.reticleRectTransform;
|
||||
|
||||
currentReticleSizeDelta = currentDynamicReticleInfo.reticleMinDeltaSize;
|
||||
|
||||
currentReticleRectTransform.sizeDelta = currentReticleSizeDelta;
|
||||
|
||||
currentReticleName = currentDynamicReticleInfo.Name;
|
||||
|
||||
lastTimeIncreaseReticleActive = 0;
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
if (reticleActive) {
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool isReticleActive ()
|
||||
{
|
||||
return reticleActive;
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class dynamicReticleInfo
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public string Name;
|
||||
|
||||
public bool reticleEnabled = true;
|
||||
|
||||
public Vector2 reticleMinDeltaSize;
|
||||
public Vector2 reticleMaxDeltaSize;
|
||||
|
||||
public float reticleScaleSpeed;
|
||||
|
||||
[Space]
|
||||
[Header ("Size Settings")]
|
||||
[Space]
|
||||
|
||||
public bool addExtraDeltaSizeOnWalking;
|
||||
public Vector2 deltaSizeOnWalking;
|
||||
|
||||
public bool addExtraDeltaSizeOnRunning;
|
||||
public Vector2 deltaSizeOnRunning;
|
||||
|
||||
public bool addExtraDeltaSizeOnLooking;
|
||||
public Vector2 deltaSizeOnLooking;
|
||||
|
||||
public bool addExtraDeltaSizeOnShooting;
|
||||
public Vector2 extraDeltaSizeOnShooting;
|
||||
|
||||
public bool addExtraDeltaSizeOnAir;
|
||||
public Vector2 extraDeltaSizeOnAir;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public bool addSpreadToWeapon;
|
||||
public float spreadToWeapon;
|
||||
|
||||
public float minSpreadToWeapon;
|
||||
public float maxSpreadToWeapon;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public RectTransform reticleRectTransform;
|
||||
|
||||
public GameObject reticleGameObject;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a71fc961a1bbc5a49baab48b9d7fde49
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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/Weapons/dynamicReticleSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,151 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class fakeProjectileTrailSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool trailEnabled = true;
|
||||
|
||||
public float reduceTrailTimeSpeed = 4;
|
||||
public bool movementActive = true;
|
||||
|
||||
public bool disableInsteadOfDestroyActive;
|
||||
|
||||
public float speedMultiplier;
|
||||
|
||||
public float maxSpawnTime = 5;
|
||||
|
||||
public bool destroyTrailAfterTime;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool trailActive;
|
||||
public Vector3 targetPosition;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public TrailRenderer mainTrail;
|
||||
|
||||
float timerSpeed;
|
||||
|
||||
Vector3 originalPosition;
|
||||
|
||||
float lastTimeInstantiated;
|
||||
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (trailActive) {
|
||||
if (movementActive) {
|
||||
|
||||
timerSpeed += Time.deltaTime / speedMultiplier;
|
||||
transform.position = Vector3.Lerp (originalPosition, targetPosition, timerSpeed);
|
||||
|
||||
} else {
|
||||
mainTrail.time -= Time.deltaTime * reduceTrailTimeSpeed;
|
||||
|
||||
if (mainTrail.time <= 0) {
|
||||
if (disableInsteadOfDestroyActive) {
|
||||
setActiveState (false);
|
||||
|
||||
resetFakeProjectileTrail ();
|
||||
} else {
|
||||
Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (destroyTrailAfterTime) {
|
||||
if (Time.time > lastTimeInstantiated + maxSpawnTime) {
|
||||
if (disableInsteadOfDestroyActive) {
|
||||
setActiveState (false);
|
||||
|
||||
resetFakeProjectileTrail ();
|
||||
} else {
|
||||
Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void instantiateFakeProjectileTrail (Vector3 newTargetPosition)
|
||||
{
|
||||
if (trailEnabled) {
|
||||
setActiveState (true);
|
||||
|
||||
originalPosition = transform.position;
|
||||
|
||||
transform.SetParent (null);
|
||||
|
||||
mainTrail.Clear ();
|
||||
|
||||
mainTrail.time = 0;
|
||||
|
||||
trailActive = true;
|
||||
|
||||
Vector3 newTargetDirection = newTargetPosition - transform.position;
|
||||
|
||||
transform.rotation = Quaternion.LookRotation (newTargetDirection);
|
||||
|
||||
targetPosition = newTargetPosition;
|
||||
|
||||
lastTimeInstantiated = Time.time;
|
||||
} else {
|
||||
setActiveState (false);
|
||||
}
|
||||
}
|
||||
|
||||
void setActiveState (bool state)
|
||||
{
|
||||
if (gameObject.activeSelf != state) {
|
||||
gameObject.SetActive (state);
|
||||
|
||||
// print ("ACTIVE STATE " + state);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSpeedMultiplier (float newValue)
|
||||
{
|
||||
speedMultiplier = newValue;
|
||||
}
|
||||
|
||||
public void stopTrailMovement ()
|
||||
{
|
||||
movementActive = false;
|
||||
}
|
||||
|
||||
public void setDestroyTrailAfterTimeState (bool state)
|
||||
{
|
||||
destroyTrailAfterTime = state;
|
||||
}
|
||||
|
||||
public void changeDestroyForSetActiveFunction (bool state)
|
||||
{
|
||||
disableInsteadOfDestroyActive = state;
|
||||
}
|
||||
|
||||
public void resetFakeProjectileTrail ()
|
||||
{
|
||||
if (trailActive) {
|
||||
trailActive = false;
|
||||
|
||||
mainTrail.time = 1;
|
||||
|
||||
timerSpeed = 0;
|
||||
|
||||
movementActive = true;
|
||||
|
||||
destroyTrailAfterTime = false;
|
||||
|
||||
mainTrail.Clear ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55237c14ad765064a99ebbea45a7ba9c
|
||||
timeCreated: 1560831358
|
||||
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/Weapons/fakeProjectileTrailSystem.cs
|
||||
uploadId: 814740
|
||||
3838
Assets/Game Kit Controller/Scripts/Weapons/playerWeaponSystem.cs
Normal file
3838
Assets/Game Kit Controller/Scripts/Weapons/playerWeaponSystem.cs
Normal file
File diff suppressed because it is too large
Load Diff
3201
Assets/Game Kit Controller/Scripts/Weapons/playerWeaponSystem.cs.bak
Normal file
3201
Assets/Game Kit Controller/Scripts/Weapons/playerWeaponSystem.cs.bak
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31496ae75d28efb418fbf636937447f6
|
||||
timeCreated: 1690847404
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
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/Weapons/playerWeaponSystem.cs.bak
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00d563bf0f5a0264e85efdb72f3f9ca7
|
||||
timeCreated: 1586132781
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 3bb029879d63f16449b4297a89074ae3, type: 3}
|
||||
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/Weapons/playerWeaponSystem.cs
|
||||
uploadId: 814740
|
||||
11787
Assets/Game Kit Controller/Scripts/Weapons/playerWeaponsManager.cs
Normal file
11787
Assets/Game Kit Controller/Scripts/Weapons/playerWeaponsManager.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7d01051531b50046bd36239328f37be
|
||||
timeCreated: 1580456581
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 3bb029879d63f16449b4297a89074ae3, type: 3}
|
||||
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/Weapons/playerWeaponsManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine;
|
||||
|
||||
public class projectileImpactSystem : MonoBehaviour
|
||||
{
|
||||
public AudioSource mainAudioSource;
|
||||
public destroyGameObject mainDestroyGameObject;
|
||||
|
||||
public void activateImpactElements (Vector3 newPosition, AudioElement impactSoundEffect)
|
||||
{
|
||||
// print ("----Activate impact elements " + gameObject.activeSelf + " " + mainDestroyGameObject.destroyCoroutineActive);
|
||||
|
||||
transform.position = newPosition;
|
||||
|
||||
if (mainAudioSource != null) {
|
||||
impactSoundEffect.audioSource = mainAudioSource;
|
||||
}
|
||||
// print (impactSoundEffect.length);
|
||||
|
||||
if (impactSoundEffect.clip != null) {
|
||||
mainDestroyGameObject.setTimer (impactSoundEffect.clip.length + 0.2f);
|
||||
}
|
||||
|
||||
if (gameObject.activeSelf) {
|
||||
|
||||
mainDestroyGameObject.checkToDestroyObjectInTime (false);
|
||||
} else {
|
||||
gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
GKC_Utils.checkAudioSourcePitch (mainAudioSource);
|
||||
AudioPlayer.Play (impactSoundEffect, gameObject);
|
||||
|
||||
decalManager.setImpactSoundParent (transform);
|
||||
}
|
||||
|
||||
public void changeDestroyForSetActiveFunction (bool state)
|
||||
{
|
||||
mainDestroyGameObject.changeDestroyForSetActiveFunction (state);
|
||||
}
|
||||
|
||||
public void setSendObjectToPoolSystemToDisableState (bool state)
|
||||
{
|
||||
mainDestroyGameObject.setSendObjectToPoolSystemToDisableState (state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69cdf25f184f52543ba34fb7bb7fde6f
|
||||
timeCreated: 1608482729
|
||||
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/Weapons/projectileImpactSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class projectilesOnCharacterBodyManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool removeProjectilesEnabled = true;
|
||||
|
||||
public float timeToRemoveProjectiles = 5;
|
||||
|
||||
public float waitTimeBetweenProjectileRemoving = 2;
|
||||
|
||||
|
||||
List<GameObject> projectilesGameObjectList = new List<GameObject> ();
|
||||
|
||||
Coroutine removeCoroutine;
|
||||
|
||||
float currentRemoveProjectileWaitTime;
|
||||
|
||||
|
||||
public void addProjectileToCharacterBody (GameObject newProjectileObject)
|
||||
{
|
||||
if (!removeProjectilesEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!projectilesGameObjectList.Contains (newProjectileObject)) {
|
||||
projectilesGameObjectList.Add (newProjectileObject);
|
||||
}
|
||||
|
||||
currentRemoveProjectileWaitTime = timeToRemoveProjectiles;
|
||||
|
||||
activateProjectileRemove ();
|
||||
}
|
||||
|
||||
void activateProjectileRemove ()
|
||||
{
|
||||
stopRemoveProjectilesCoroutine ();
|
||||
|
||||
removeCoroutine = StartCoroutine (removeProjectilesCoroutine ());
|
||||
}
|
||||
|
||||
public void stopRemoveProjectilesCoroutine ()
|
||||
{
|
||||
if (removeCoroutine != null) {
|
||||
StopCoroutine (removeCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator removeProjectilesCoroutine ()
|
||||
{
|
||||
yield return new WaitForSeconds (currentRemoveProjectileWaitTime);
|
||||
|
||||
int projectileIndex = projectilesGameObjectList.Count - 1;
|
||||
|
||||
if (projectilesGameObjectList [projectileIndex] != null) {
|
||||
Destroy (projectilesGameObjectList [projectileIndex]);
|
||||
}
|
||||
|
||||
projectilesGameObjectList.RemoveAt (projectileIndex);
|
||||
|
||||
if (projectilesGameObjectList.Count > 0) {
|
||||
|
||||
currentRemoveProjectileWaitTime = waitTimeBetweenProjectileRemoving;
|
||||
|
||||
activateProjectileRemove ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da7eebfba45e5bc41b67b8dd9bc2f3b8
|
||||
timeCreated: 1619162266
|
||||
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/Weapons/projectilesOnCharacterBodyManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,273 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class simpleSniperSightSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool sniperSightThirdPersonEnabled = true;
|
||||
public bool sniperSightFirstPersonEnabled = true;
|
||||
|
||||
public bool sniperSightThirdPersonWithoutAimEnabled;
|
||||
|
||||
[Space]
|
||||
|
||||
public string sniperCameraThirdPersonStateName = "Sniper Camera View Third Person";
|
||||
public string sniperCameraFirstPersonStateName = "Sniper Camera View First Person";
|
||||
|
||||
public string sniperCameraFBAStateName = "Sniper Camera View FBA";
|
||||
|
||||
[Space]
|
||||
|
||||
public string sniperCameraThirdPersonCrouchStateName = "Sniper Camera View Third Person Crouch";
|
||||
public string sniperCameraFirstPersonCrouchStateName = "Sniper Camera View First Person Crouch";
|
||||
|
||||
public string sniperCameraFBACrouchStateName = "Sniper Camera View FBA Crouch";
|
||||
|
||||
[Space]
|
||||
|
||||
public float newCameraFovValueThirdPerson = 20;
|
||||
|
||||
public float newCameraFovValueFirstPerson = 15;
|
||||
|
||||
public bool changeFovSmoothly;
|
||||
public float changeFovSpeed;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool sniperSightActive;
|
||||
|
||||
public string previuousCameraState;
|
||||
|
||||
public bool sniperSightActivePreviously;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public GameObject sniperSightPanelGameObject;
|
||||
public playerCamera mainPlayerCamera;
|
||||
public playerController mainPlayerController;
|
||||
public playerWeaponsManager mainPlayerWeaponsManager;
|
||||
public Camera weaponsCamera;
|
||||
|
||||
Coroutine sniperSightCoroutine;
|
||||
|
||||
public void enableOrDisableSniperSight (bool state)
|
||||
{
|
||||
bool isFirstPersonActive = mainPlayerCamera.isFirstPersonActive ();
|
||||
|
||||
if (isFirstPersonActive || mainPlayerCamera.isFullBodyAwarenessActive ()) {
|
||||
if (!sniperSightFirstPersonEnabled) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!sniperSightThirdPersonEnabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mainPlayerCamera.isCameraTypeFree ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainPlayerCamera.isFullBodyAwarenessActive ()) {
|
||||
if (mainPlayerWeaponsManager != null) {
|
||||
bool setSniperSightResult = true;
|
||||
|
||||
if (state) {
|
||||
if (!mainPlayerWeaponsManager.isAimModeInputPressed ()) {
|
||||
setSniperSightResult = false;
|
||||
}
|
||||
} else {
|
||||
if (!sniperSightActive) {
|
||||
setSniperSightResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!setSniperSightResult) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mainPlayerWeaponsManager != null) {
|
||||
bool setSniperSightResult = true;
|
||||
|
||||
if (!sniperSightThirdPersonWithoutAimEnabled) {
|
||||
if (state) {
|
||||
if (!mainPlayerWeaponsManager.isAimModeInputPressed ()) {
|
||||
setSniperSightResult = false;
|
||||
}
|
||||
} else {
|
||||
if (!sniperSightActive) {
|
||||
setSniperSightResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!setSniperSightResult) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setSniperSightState (state, isFirstPersonActive);
|
||||
}
|
||||
|
||||
void setSniperSightState (bool state, bool isFirstPersonActive)
|
||||
{
|
||||
sniperSightActive = state;
|
||||
|
||||
if (sniperSightPanelGameObject.activeSelf != sniperSightActive) {
|
||||
sniperSightPanelGameObject.SetActive (sniperSightActive);
|
||||
}
|
||||
|
||||
if (sniperSightActive) {
|
||||
previuousCameraState = mainPlayerCamera.getCurrentStateName ();
|
||||
|
||||
if (sniperSightCoroutine != null) {
|
||||
StopCoroutine (sniperSightCoroutine);
|
||||
}
|
||||
|
||||
sniperSightCoroutine = StartCoroutine (enableSniperSightCoroutine ());
|
||||
|
||||
} else {
|
||||
if (previuousCameraState != "") {
|
||||
mainPlayerCamera.setCameraStateExternally (previuousCameraState);
|
||||
|
||||
setCameraStateValues ();
|
||||
|
||||
if (isFirstPersonActive) {
|
||||
weaponsCamera.enabled = true;
|
||||
}
|
||||
|
||||
setUseCustomCameraStateActiveState (false);
|
||||
}
|
||||
|
||||
previuousCameraState = "";
|
||||
}
|
||||
|
||||
sniperSightActivePreviously = false;
|
||||
|
||||
mainPlayerCamera.setPauseChangeCameraFovActiveState (sniperSightActive);
|
||||
|
||||
mainPlayerCamera.setIgnoreMainCameraFovOnSetCameraState (sniperSightActive);
|
||||
}
|
||||
|
||||
public void disableSniperSight ()
|
||||
{
|
||||
setSniperSightState (false, mainPlayerCamera.isFirstPersonActive ());
|
||||
}
|
||||
|
||||
public void disableSniperSightIfActive ()
|
||||
{
|
||||
if (sniperSightActive) {
|
||||
disableSniperSight ();
|
||||
|
||||
sniperSightActivePreviously = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void enableSniperSightIfActivePreviously ()
|
||||
{
|
||||
if (sniperSightActivePreviously) {
|
||||
if (mainPlayerController.isPlayerAiming ()) {
|
||||
enableOrDisableSniperSight (true);
|
||||
}
|
||||
}
|
||||
|
||||
sniperSightActivePreviously = false;
|
||||
}
|
||||
|
||||
|
||||
IEnumerator enableSniperSightCoroutine ()
|
||||
{
|
||||
yield return new WaitForSeconds (0.001f);
|
||||
|
||||
bool isFirstPersonActive = mainPlayerCamera.isFirstPersonActive ();
|
||||
|
||||
if (isFirstPersonActive) {
|
||||
mainPlayerCamera.setCameraStateExternally (sniperCameraFirstPersonStateName);
|
||||
|
||||
weaponsCamera.enabled = false;
|
||||
} else {
|
||||
if (mainPlayerCamera.isFullBodyAwarenessActive ()) {
|
||||
if (mainPlayerController.isCrouching ()) {
|
||||
mainPlayerCamera.setCameraState (sniperCameraFBACrouchStateName);
|
||||
} else {
|
||||
mainPlayerCamera.setCameraState (sniperCameraFBAStateName);
|
||||
}
|
||||
} else {
|
||||
if (mainPlayerController.isCrouching ()) {
|
||||
mainPlayerCamera.setCameraStateExternally (sniperCameraThirdPersonCrouchStateName);
|
||||
} else {
|
||||
mainPlayerCamera.setCameraStateExternally (sniperCameraThirdPersonStateName);
|
||||
}
|
||||
}
|
||||
|
||||
setUseCustomCameraStateActiveState (true);
|
||||
}
|
||||
|
||||
setCameraStateValues ();
|
||||
|
||||
mainPlayerCamera.stopFovChangeCoroutine ();
|
||||
|
||||
mainPlayerCamera.stopCameraFovStartAndEndCoroutine ();
|
||||
|
||||
float currentCameraFoValue = newCameraFovValueThirdPerson;
|
||||
|
||||
if (mainPlayerCamera.isFullBodyAwarenessActive () || mainPlayerCamera.isFirstPersonActive ()) {
|
||||
currentCameraFoValue = newCameraFovValueFirstPerson;
|
||||
}
|
||||
|
||||
if (changeFovSmoothly) {
|
||||
mainPlayerCamera.setMainCameraFov (currentCameraFoValue, changeFovSpeed);
|
||||
} else {
|
||||
mainPlayerCamera.quickChangeFovValue (currentCameraFoValue);
|
||||
}
|
||||
}
|
||||
|
||||
void setCameraStateValues ()
|
||||
{
|
||||
mainPlayerCamera.resetCurrentCameraStateAtOnce ();
|
||||
|
||||
mainPlayerCamera.configureCameraAndPivotPositionAtOnce ();
|
||||
|
||||
mainPlayerCamera.quickChangeFovValue (mainPlayerCamera.getOriginalCameraFov ());
|
||||
}
|
||||
|
||||
void setUseCustomCameraStateActiveState (bool state)
|
||||
{
|
||||
if (!state) {
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimActivePausedState (false);
|
||||
}
|
||||
|
||||
if (mainPlayerCamera.isFullBodyAwarenessActive ()) {
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimActiveState (state,
|
||||
sniperCameraFBAStateName,
|
||||
sniperCameraFBAStateName);
|
||||
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimCrouchActiveState (state,
|
||||
sniperCameraFBACrouchStateName,
|
||||
sniperCameraFBACrouchStateName);
|
||||
} else {
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimActiveState (state,
|
||||
sniperCameraThirdPersonStateName,
|
||||
sniperCameraThirdPersonStateName);
|
||||
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimCrouchActiveState (state,
|
||||
sniperCameraThirdPersonCrouchStateName,
|
||||
sniperCameraThirdPersonCrouchStateName);
|
||||
}
|
||||
|
||||
mainPlayerCamera.setCheckUseCustomFBAAimActiveState (state);
|
||||
|
||||
if (state) {
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimActivePausedState (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2550f2e4672ed164ab90f69d93717a25
|
||||
timeCreated: 1605497596
|
||||
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/Weapons/simpleSniperSightSystem.cs
|
||||
uploadId: 814740
|
||||
1468
Assets/Game Kit Controller/Scripts/Weapons/simpleWeaponSystem.cs
Normal file
1468
Assets/Game Kit Controller/Scripts/Weapons/simpleWeaponSystem.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2964276276ff5464ead228e6debbe5be
|
||||
timeCreated: 1581554422
|
||||
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/Weapons/simpleWeaponSystem.cs
|
||||
uploadId: 814740
|
||||
138
Assets/Game Kit Controller/Scripts/Weapons/throwGrenadeSystem.cs
Normal file
138
Assets/Game Kit Controller/Scripts/Weapons/throwGrenadeSystem.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class throwGrenadeSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool throwGrenadeEnabled = true;
|
||||
|
||||
public string grenadeInventoryObjectName = "Grenade";
|
||||
|
||||
public bool checkInventoryInfo = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnStartThrowGrenade;
|
||||
|
||||
public UnityEvent eventOnConfirmThrowGrenade;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public GameObject grenadeInfoPanel;
|
||||
|
||||
public Text grenadeAmountText;
|
||||
|
||||
public inventoryManager mainInventoryManager;
|
||||
|
||||
|
||||
bool canConfirmThrowGrenade;
|
||||
|
||||
int currentGrenadeAmount;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
checkGrenadesInfo ();
|
||||
}
|
||||
|
||||
public void checkGrenadesInfo ()
|
||||
{
|
||||
if (throwGrenadeEnabled) {
|
||||
updateGrenadeAmountText ();
|
||||
} else {
|
||||
if (grenadeInfoPanel != null) {
|
||||
if (grenadeInfoPanel.activeSelf != false) {
|
||||
grenadeInfoPanel.SetActive (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputStartThrowGrenade ()
|
||||
{
|
||||
if (!throwGrenadeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
canConfirmThrowGrenade = false;
|
||||
|
||||
if (checkInventoryInfo) {
|
||||
currentGrenadeAmount = mainInventoryManager.getInventoryObjectAmountByName (grenadeInventoryObjectName);
|
||||
|
||||
if (currentGrenadeAmount < 0) {
|
||||
currentGrenadeAmount = 0;
|
||||
}
|
||||
} else {
|
||||
currentGrenadeAmount = 1;
|
||||
}
|
||||
|
||||
if (currentGrenadeAmount > 0) {
|
||||
|
||||
canConfirmThrowGrenade = true;
|
||||
|
||||
eventOnStartThrowGrenade.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Amount found higher than 0");
|
||||
}
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("Amount found is 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputConfirmThrowGrenade ()
|
||||
{
|
||||
if (!throwGrenadeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (canConfirmThrowGrenade) {
|
||||
eventOnConfirmThrowGrenade.Invoke ();
|
||||
|
||||
updateGrenadeAmountText ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Confirm to throw grenade");
|
||||
}
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("Can't confirm to throw grenade");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateGrenadeAmountText ()
|
||||
{
|
||||
if (!throwGrenadeEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (grenadeAmountText != null) {
|
||||
|
||||
currentGrenadeAmount = mainInventoryManager.getInventoryObjectAmountByName (grenadeInventoryObjectName);
|
||||
|
||||
if (currentGrenadeAmount < 0) {
|
||||
currentGrenadeAmount = 0;
|
||||
}
|
||||
|
||||
grenadeAmountText.text = currentGrenadeAmount.ToString ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 568c99d9cf19e704e9fbfe2e99c971e2
|
||||
timeCreated: 1607985580
|
||||
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/Weapons/throwGrenadeSystem.cs
|
||||
uploadId: 814740
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user