plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent 195b696771
commit 779f2c8b20
14443 changed files with 23840465 additions and 452 deletions

View File

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

View File

@@ -0,0 +1,416 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class cuttingModeSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public float cuttingPanelRotationSpeed = 5;
public float cuttingSpeed = 10;
public bool playerCanMoveOnCuttingModeActive = true;
public bool useCameraStateOnCuttingMode;
public string cameraStateNameOnCuttingMode;
public bool setBulletTime;
public float bulletTimeScale;
public float delayToSetBulletTime;
public bool canToggleCameraRotation;
public bool pauseCameraRotationAtStartOnCutModeActive = true;
[Space]
[Header ("Animation Settings")]
[Space]
public int cuttingModeStateID = 50000;
public string cuttingModeActionActiveName = "Action Active Upper Body";
public string cuttingModeActionIDName = "Action ID";
public string horizontalAnimatorName = "Horizontal Action";
public string verticalAnimatorName = "Vertical Action";
[Space]
[Header ("Stamina Settings")]
[Space]
public bool useStaminaOnSliceEnabled = true;
public string sliceStaminaState = "Slice Object";
public float staminaToUseOnSlice = 10;
public float customRefillStaminaDelayAfterSlice;
public float generalStaminaUseMultiplier = 1;
[Space]
[Header ("Other")]
[Space]
public float headTrackBodyWeightOnAim = 1;
public string customAimReticleName = "Reticle 1";
[Space]
[Header ("Debug")]
[Space]
public bool cuttingModeActive;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnCuttingModeStart;
public UnityEvent eventOnCuttingModeEnd;
public UnityEvent eventOnCutting;
[Space]
[Header ("Components")]
[Space]
public Transform cutParticlesParent;
public GameObject cuttingPanelGameObject;
public Transform cuttingPanelTransform;
public Transform cuttingPanelTransformReference;
public Transform cuttingPanelFirstReferenceTransform;
public Transform cuttingPanelSecondReferenceTransform;
public Transform cuttingDirectionTransform;
public playerController mainPlayerController;
public playerCamera mainPlayerCamera;
public playerInputManager mainPlayerInputManager;
public timeBullet timeBulletManager;
public staminaSystem mainStaminaSystem;
public Animator mainAnimator;
public headTrack mainHeadTrack;
string previousCameraStateName;
Vector2 axisValues;
int horizontalAnimatorID;
int verticalAnimatorID;
float horizontalRotationValue;
float verticalRotationValue;
float cutDirection = 1;
Coroutine moveReferencePanelOnCutCoroutine;
Coroutine bulletTimeCoroutine;
bool cutPanelRotationActive = true;
bool sliceInputPausedForStamina;
float horizontalOffset = 0.3f;
float verticalOffset = 0.18f;
Vector2 rotationValues;
bool isPlayerMovingOn3dWorld;
bool isCameraTypeFree;
bool checkBodyAimStateActive;
void Update ()
{
if (cuttingModeActive) {
if (mainPlayerCamera.cameraCanBeUsedActive ()) {
if (cutPanelRotationActive) {
axisValues = mainPlayerInputManager.getPlayerMouseAxis ();
} else {
axisValues = Vector2.zero;
}
cuttingPanelTransform.localEulerAngles += new Vector3 (0, 0, -axisValues.x * cuttingPanelRotationSpeed);
cuttingPanelTransformReference.localEulerAngles = cuttingPanelTransform.localEulerAngles;
cuttingPanelSecondReferenceTransform.position = cuttingPanelFirstReferenceTransform.position;
horizontalRotationValue = Mathf.Clamp (cuttingPanelSecondReferenceTransform.localPosition.x + horizontalOffset, -1, 1);
verticalRotationValue = Mathf.Clamp (cuttingPanelSecondReferenceTransform.localPosition.y + verticalOffset, -1, 1);
rotationValues = new Vector2 (horizontalRotationValue, verticalRotationValue);
rotationValues = Vector2.ClampMagnitude (rotationValues, 1);
mainAnimator.SetFloat (horizontalAnimatorID, rotationValues.x);
mainAnimator.SetFloat (verticalAnimatorID, rotationValues.y);
}
}
}
public void setSliceInputPausedForStaminaState (bool state)
{
sliceInputPausedForStamina = state;
}
public void inputToggleCameraRotation ()
{
if (cuttingModeActive) {
if (canToggleCameraRotation) {
cutPanelRotationActive = !cutPanelRotationActive;
mainPlayerCamera.changeCameraRotationState (!cutPanelRotationActive);
}
}
}
public void inputActivateCut ()
{
if (cuttingModeActive) {
// stopActivateCutCoroutine ();
if (sliceInputPausedForStamina) {
// print ("Not enough stamina");
return;
}
if (cuttingInProcess) {
return;
}
if (useStaminaOnSliceEnabled) {
mainStaminaSystem.activeStaminaStateWithCustomAmount (sliceStaminaState, staminaToUseOnSlice * generalStaminaUseMultiplier, customRefillStaminaDelayAfterSlice);
}
moveReferencePanelOnCutCoroutine = StartCoroutine (activateCutCoroutine ());
cutParticlesParent.localEulerAngles += Vector3.forward * 180;
cuttingDirectionTransform.localEulerAngles += Vector3.up * 180;
eventOnCutting.Invoke ();
}
}
public void setCuttingModeActiveState (bool state)
{
cuttingModeActive = state;
if (cuttingModeActive) {
horizontalAnimatorID = Animator.StringToHash (horizontalAnimatorName);
verticalAnimatorID = Animator.StringToHash (verticalAnimatorName);
cuttingPanelTransform.localEulerAngles = Vector3.zero;
cuttingPanelTransformReference.localEulerAngles = cuttingPanelTransform.localEulerAngles;
stopActivateCutCoroutine ();
cutDirection = 1;
cuttingPanelFirstReferenceTransform.localPosition = Vector3.right * cutDirection * 1.3f;
cutParticlesParent.localEulerAngles = Vector3.zero;
cuttingDirectionTransform.localEulerAngles = Vector3.zero;
cutPanelRotationActive = true;
}
cuttingPanelGameObject.SetActive (cuttingModeActive);
if (useCameraStateOnCuttingMode) {
if (cuttingModeActive) {
previousCameraStateName = mainPlayerCamera.getCurrentStateName ();
mainPlayerCamera.setCameraStateExternally (cameraStateNameOnCuttingMode);
} else {
mainPlayerCamera.setCameraStateExternally (previousCameraStateName);
previousCameraStateName = "";
}
}
if (cuttingModeActive) {
mainAnimator.SetInteger (cuttingModeActionIDName, cuttingModeStateID);
} else {
mainAnimator.SetInteger (cuttingModeActionIDName, 0);
}
mainAnimator.SetBool (cuttingModeActionActiveName, cuttingModeActive);
if (pauseCameraRotationAtStartOnCutModeActive) {
mainPlayerCamera.changeCameraRotationState (!cuttingModeActive);
}
if (!playerCanMoveOnCuttingModeActive) {
if (cuttingModeActive) {
mainPlayerController.smoothChangeScriptState (false);
mainPlayerController.setCanMoveState (false);
mainPlayerController.resetPlayerControllerInput ();
mainPlayerController.resetOtherInputFields ();
} else {
mainPlayerController.setCanMoveState (true);
}
}
checkSetBulletTime ();
if (cuttingModeActive) {
eventOnCuttingModeStart.Invoke ();
} else {
eventOnCuttingModeEnd.Invoke ();
}
isPlayerMovingOn3dWorld = mainPlayerController.isPlayerMovingOn3dWorld ();
isCameraTypeFree = mainPlayerCamera.isCameraTypeFree ();
if (!isPlayerMovingOn3dWorld || !isCameraTypeFree) {
checkBodyAimState (state);
}
}
public void checkSetBulletTime ()
{
if (setBulletTime) {
stopCheckSetBulletTimeCoroutine ();
if (cuttingModeActive) {
bulletTimeCoroutine = StartCoroutine (checkSetBulletTimeCoroutine ());
} else {
timeBulletManager.setBulletTimeState (false, 1);
}
}
}
public void stopCheckSetBulletTimeCoroutine ()
{
if (bulletTimeCoroutine != null) {
StopCoroutine (bulletTimeCoroutine);
}
}
IEnumerator checkSetBulletTimeCoroutine ()
{
yield return new WaitForSeconds (delayToSetBulletTime);
timeBulletManager.setBulletTimeState (true, bulletTimeScale);
}
bool cuttingInProcess;
public void stopActivateCutCoroutine ()
{
if (moveReferencePanelOnCutCoroutine != null) {
StopCoroutine (moveReferencePanelOnCutCoroutine);
}
}
IEnumerator activateCutCoroutine ()
{
cuttingInProcess = true;
float movementSpeed = cuttingSpeed;
bool targetReached = false;
float positionDifference = 0;
cutDirection *= (-1);
Vector3 targetPosition = Vector3.right * (cutDirection * 1.3f);
float dist = GKC_Utils.distance (cuttingPanelFirstReferenceTransform.localPosition, targetPosition);
float duration = dist / movementSpeed;
float t = 0;
float movementTimer = 0;
while (!targetReached) {
t += Time.deltaTime / duration;
cuttingPanelFirstReferenceTransform.localPosition =
Vector3.Lerp (cuttingPanelFirstReferenceTransform.localPosition, targetPosition, t);
positionDifference = GKC_Utils.distance (cuttingPanelFirstReferenceTransform.localPosition, targetPosition);
movementTimer += Time.deltaTime;
if (positionDifference < 0.01f || movementTimer > (duration + 1)) {
targetReached = true;
}
yield return null;
}
cuttingInProcess = false;
}
public void setGeneralStaminaUseMultiplierValue (float newValue)
{
generalStaminaUseMultiplier = newValue;
}
public void setUseStaminaOnSliceEnabledState (bool state)
{
useStaminaOnSliceEnabled = state;
}
void checkBodyAimState (bool state)
{
if (mainHeadTrack == null) {
mainHeadTrack = GKC_Utils.getCharacterHeadTrack (mainPlayerController.gameObject);
}
if (mainHeadTrack == null) {
return;
}
if (checkBodyAimStateActive == state) {
return;
}
checkBodyAimStateActive = state;
if (state) {
mainHeadTrack.setCameraBodyWeightValue (headTrackBodyWeightOnAim);
} else {
mainHeadTrack.setOriginalCameraBodyWeightValue ();
}
mainHeadTrack.setHeadTrackActiveWhileAimingState (state);
mainHeadTrack.setCanUseHeadTrackOnLockedCameraActiveState (state);
mainPlayerController.enableOrDisableAiminig (state);
mainPlayerCamera.setManualAimStateOnLockedCamera (state);
if (state) {
mainPlayerCamera.enableCustomReticle (customAimReticleName);
} else {
mainPlayerCamera.disableAllCustomReticle ();
}
if (state) {
if (canToggleCameraRotation) {
cutPanelRotationActive = false;
mainPlayerCamera.changeCameraRotationState (!cutPanelRotationActive);
}
}
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 5bff1467ec1ae8f418e1948a0080b3ca
timeCreated: 1594982617
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/Combat System/Melee Combat System/Slice
System/cuttingModeSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,175 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class runtimeShatterRecursive : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool shatterEnabled = true;
public Material crossSectionMaterial;
public int numberOfShatters;
public bool addSliceComponentToPieces;
[Space]
[Header ("Objects To Shatter List Settings")]
[Space]
public List<GameObject> objectsToShatter;
public bool useCustomShatterPosition;
public Transform customShatterPosition;
[Space]
[Header ("Tag and Layer Settings")]
[Space]
public bool setNewTagOnCut;
public string newTagOnCut;
public bool setNewLayerOnCut;
public string newLayerOnCut;
[Space]
[Header ("Physics Settings")]
[Space]
public bool applyForceOnShatter;
public ForceMode forceMode;
public float forceToApplyToCutPart;
[Space]
[Header ("Others Settings")]
[Space]
public bool activateShatterAtStart;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnShatter;
public UnityEvent eventOnShatter;
void Start ()
{
if (activateShatterAtStart) {
activateShatterOnObject ();
}
}
public void activateShatterOnObject ()
{
if (!shatterEnabled) {
return;
}
for (int i = 0; i < objectsToShatter.Count; i++) {
if (objectsToShatter [i] != null) {
if (objectsToShatter [i].transform.parent != null) {
objectsToShatter [i].transform.SetParent (null);
}
}
}
for (int i = 0; i < numberOfShatters; i++) {
randomShatter ();
}
checkEventOnShatter ();
if (showDebugPrint) {
print ("activate shatter on object " + gameObject.name);
}
}
public void randomShatter ()
{
List<GameObject> adders = new List<GameObject> ();
List<GameObject> removals = new List<GameObject> ();
foreach (GameObject objectToShatter in objectsToShatter) {
GameObject [] shatters = randomShatterSingle (objectToShatter);
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)
{
Vector3 shatterPosition = objectToShatter.transform.position;
if (useCustomShatterPosition) {
shatterPosition = customShatterPosition.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);
}
if (setNewLayerOnCut) {
shatteredObject.layer = LayerMask.NameToLayer (newLayerOnCut);
}
if (setNewTagOnCut) {
shatteredObject.tag = newTagOnCut;
}
}
}
return shatters;
}
public void checkEventOnShatter ()
{
if (useEventOnShatter) {
eventOnShatter.Invoke ();
}
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 7c2ab5e2b6f547043ab73b6932dd3da6
timeCreated: 1650697508
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/Combat System/Melee Combat System/Slice
System/runtimeShatterRecursive.cs
uploadId: 814740

View File

@@ -0,0 +1,245 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class simpleSliceSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool sliceEnabled = true;
public GameObject objectToSlice;
public GameObject alternatePrefab;
public Material infillMaterial;
public surfaceToSlice mainSurfaceToSlice;
public Transform[] severables = new Transform[0];
[Space]
[Header ("Slice Ragdoll Settings")]
[Space]
public string prefabsPath = "";
public Material sliceMaterial;
public bool setTagOnSkeletonRigidbodies = true;
public string tagOnSkeletonRigidbodies = "box";
[Space]
[Header ("Physics Settings")]
[Space]
public bool ignoreUpdateLastObjectSpeed;
[Space]
[Header ("Other Settings")]
[Space]
public bool ignoreDestroyOriginalObject;
public UnityEvent eventsOnIgnoreDestroyOriginalObject;
[Space]
public bool setCustomIDOnSliceSpieces;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool sliceInitialized;
const string glyphs = "abcdefghijklmnopqrstuvwxyz0123456789";
string randomString = "";
public string getRandomString ()
{
return randomString;
}
public void setRandomString (string newValue)
{
if (randomString.Equals ("")) {
randomString = newValue;
}
}
public void setRandomString ()
{
if (setCustomIDOnSliceSpieces) {
if (randomString.Equals ("")) {
int charAmount = UnityEngine.Random.Range (10, 20); //set those to the minimum and maximum length of your string
for (int i = 0; i < charAmount; i++) {
randomString += glyphs [UnityEngine.Random.Range (0, glyphs.Length)];
}
}
}
}
public void destroyAllSlicedPiecesByRandomString ()
{
if (setCustomIDOnSliceSpieces && randomString != "") {
sliceSystemUtils.destroyAllSlicedPiecesByRandomString (randomString, gameObject);
}
}
void Awake ()
{
if (sliceEnabled) {
initializeValuesOnHackableComponent ();
}
}
public void initializeValuesOnHackableComponent ()
{
if (sliceInitialized) {
return;
}
sliceSystemUtils.initializeValuesOnHackableComponent (gameObject, this);
sliceInitialized = true;
}
public void setDestructionPending (bool state)
{
sliceSystemUtils.setDestructionPending (gameObject, state);
}
public void activateSlice (Collider objectCollider, Vector3 newNormalInWorldSpaceValue,
Vector3 positionInWorldSpace, Vector3 slicePosition, bool updateLastObjectSpeed, Vector3 lastSpeed)
{
if (!sliceEnabled) {
return;
}
Vector3 point = objectCollider.ClosestPointOnBounds (positionInWorldSpace);
if (mainSurfaceToSlice.useParticlesOnSlice) {
Quaternion particlesRotation = Quaternion.LookRotation (newNormalInWorldSpaceValue);
Instantiate (mainSurfaceToSlice.particlesOnSlicePrefab, slicePosition, particlesRotation);
}
sliceSystemUtils.sliceCharacter (objectToSlice, point, newNormalInWorldSpaceValue, updateLastObjectSpeed, lastSpeed);
if (showDebugPrint) {
print ("Activate Slice on Character " + objectToSlice.name);
}
}
public void searchBodyParts ()
{
if (objectToSlice == null) {
objectToSlice = gameObject;
}
List<GameObject> bodyPartsList = new List<GameObject> ();
Component[] childrens = objectToSlice.GetComponentsInChildren (typeof(Rigidbody));
int childrensLength = childrens.Length;
for (int i = 0; i < childrensLength; i++) {
Rigidbody child = childrens [i] as Rigidbody;
Collider currentCollider = child.GetComponent<Collider> ();
if (currentCollider != null && !currentCollider.isTrigger) {
bodyPartsList.Add (child.gameObject);
}
}
severables = new Transform[bodyPartsList.Count];
for (int i = 0; i < bodyPartsList.Count; i++) {
severables [i] = bodyPartsList [i].transform;
}
if (!Application.isPlaying) {
updateComponent ();
}
}
public void setTagOnBodyParts (string newTag)
{
for (int i = 0; i < severables.Length; i++) {
if (severables [i] != null) {
severables [i].tag = newTag;
}
}
}
public GameObject getMainAlternatePrefab ()
{
return alternatePrefab;
}
public Transform[] getSeverables ()
{
return severables;
}
public void setNewSeverablesList (GameObject newObject)
{
if (newObject != null) {
genericRagdollBuilder currentGenericRagdollBuilder = newObject.GetComponent<genericRagdollBuilder> ();
if (currentGenericRagdollBuilder != null) {
int bonesCount = currentGenericRagdollBuilder.bones.Count;
severables = new Transform[bonesCount];
for (int i = 0; i < bonesCount; i++) {
severables [i] = currentGenericRagdollBuilder.bones [i].anchor;
}
}
}
}
public void createRagdollPrefab ()
{
if (alternatePrefab == null) {
prefabsPath = pathInfoValues.getSliceObjectsPrefabsPath ();
alternatePrefab = GKC_Utils.createSliceRagdollPrefab (objectToSlice, prefabsPath, sliceMaterial, setTagOnSkeletonRigidbodies, tagOnSkeletonRigidbodies);
}
}
public void setSliceEnabledState (bool state)
{
sliceEnabled = state;
if (sliceEnabled) {
initializeValuesOnHackableComponent ();
}
}
public void setSliceEnabledStateFromEditor (bool state)
{
sliceEnabled = state;
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Simple Slice System " + gameObject.name, gameObject);
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: c9863965be858744cb7a238ad41d989d
timeCreated: 1596432143
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/Combat System/Melee Combat System/Slice
System/simpleSliceSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,789 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class sliceSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public Vector3 cutOverlapBoxSize = new Vector3 (5, 0.1f, 5);
public bool activateRigidbodiesOnNewObjects;
public float minDelayToSliceSameObject = 0.3f;
[Space]
[Header ("Objects To Affect Settings")]
[Space]
public LayerMask targetToDamageLayer;
public bool useObjectsToIgnoreList;
public List<GameObject> objectsToIgnoreList = new List<GameObject> ();
[Space]
[Header ("Force Settings")]
[Space]
public float forceToApplyToCutPart;
public ForceMode forceMode;
public float forceRadius;
public float forceUp;
[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 ("Slice Transform Values Settings")]
[Space]
public List<sliceTransformValuesInfo> sliceTransformValuesInfoList = new List<sliceTransformValuesInfo> ();
[Space]
[Header ("Bullet Time Settings")]
[Space]
public bool ignoreTimeBulletOnRegularSlice;
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
public Color gizmoColor = Color.red;
public bool showDebugPrint;
[Space]
[Header ("Components")]
[Space]
public GameObject playerGameObject;
public Material defaultSliceMaterial;
public Transform cutPositionTransform;
public Transform cutDirectionTransform;
public Transform planeDefiner1;
public Transform planeDefiner2;
public Transform planeDefiner3;
bool usingCustomCutValues;
surfaceToSlice currentSurfaceToSlice;
Collider [] hits;
List<GameObject> hitsGameObjectList = new List<GameObject> ();
bool collidersListSent;
Vector3 currentCutPosition;
Quaternion currentCutRotation;
Vector3 currentCutUp;
Vector3 currentCutForward;
Vector3 currentCutDirection;
Vector3 currentPlaneDefiner1;
Vector3 currentPlaneDefiner2;
Vector3 currentPlaneDefiner3;
Vector3 currentCutOverlapBoxSize;
bool objectsDetectedOnLastSlice;
float lastTimeSliceActivated;
public void setCustomSliceTransformValues (string sliceInfoName)
{
int sliceIndex = sliceTransformValuesInfoList.FindIndex (a => a.Name == sliceInfoName);
if (sliceIndex > -1) {
sliceTransformValuesInfo currentSliceTransformValuesInfo = sliceTransformValuesInfoList [sliceIndex];
if (currentSliceTransformValuesInfo.sliceInfoEnabled) {
setCustomCutTransformValues (currentSliceTransformValuesInfo.cutOverlapBoxSize,
currentSliceTransformValuesInfo.cutPositionTransform,
currentSliceTransformValuesInfo.cutDirectionTransform,
currentSliceTransformValuesInfo.planeDefiner1,
currentSliceTransformValuesInfo.planeDefiner2,
currentSliceTransformValuesInfo.planeDefiner3);
activateCut ();
}
}
}
public void setCustomCutTransformValues (Vector3 newCutOverlapBoxSize,
Transform newcutPositionTransform,
Transform newCutDirectionTransform,
Transform newPlaneDefiner1,
Transform newPlaneDefiner2,
Transform newPlaneDefiner3)
{
usingCustomCutValues = true;
currentCutPosition = newcutPositionTransform.position;
currentCutRotation = newcutPositionTransform.rotation;
currentCutUp = newcutPositionTransform.up;
currentCutForward = newcutPositionTransform.forward;
currentCutDirection = newCutDirectionTransform.right;
currentPlaneDefiner1 = newPlaneDefiner1.position;
currentPlaneDefiner2 = newPlaneDefiner2.position;
currentPlaneDefiner3 = newPlaneDefiner3.position;
currentCutOverlapBoxSize = newCutOverlapBoxSize;
}
void setCurrentCutTransformValues ()
{
if (usingCustomCutValues) {
usingCustomCutValues = false;
return;
}
currentCutPosition = cutPositionTransform.position;
currentCutRotation = cutPositionTransform.rotation;
currentCutUp = cutPositionTransform.up;
currentCutForward = cutPositionTransform.forward;
currentCutDirection = cutDirectionTransform.right;
currentPlaneDefiner1 = planeDefiner1.position;
currentPlaneDefiner2 = planeDefiner2.position;
currentPlaneDefiner3 = planeDefiner3.position;
currentCutOverlapBoxSize = cutOverlapBoxSize;
}
bool currentSliceActivatedExternally;
public void activateCutExternally ()
{
currentSliceActivatedExternally = true;
activateCut ();
}
public void activateCut ()
{
if (lastTimeSliceActivated > 0) {
if (Time.time > lastTimeSliceActivated + 0.7f) {
currentSliceActivatedExternally = false;
lastTimeSliceActivated = 0;
}
}
objectsDetectedOnLastSlice = false;
setCurrentCutTransformValues ();
hits = Physics.OverlapBox (currentCutPosition, currentCutOverlapBoxSize, currentCutRotation, targetToDamageLayer);
if (hits.Length > 0) {
for (int i = 0; i < hits.Length; i++) {
Collider currentCollider = hits [i];
processObject (currentCollider.gameObject, currentCollider, hits [i].ClosestPointOnBounds (currentCutPosition));
}
}
collidersListSent = false;
lastTimeSliceActivated = Time.time;
}
public List<GameObject> getLastCollidersListDetected ()
{
hitsGameObjectList.Clear ();
if (!collidersListSent) {
if (hits.Length > 0) {
for (int i = 0; i < hits.Length; i++) {
hitsGameObjectList.Add (hits [i].gameObject);
}
}
}
collidersListSent = true;
return hitsGameObjectList;
}
public void processObject (GameObject obj, Collider objectCollider, Vector3 slicePosition)
{
if (useObjectsToIgnoreList) {
if (objectsToIgnoreList.Contains (obj)) {
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 +
"check Slice Direction Result " + checkSliceDirectionResult);
}
if (isCutSurfaceEnabled && sliceCanBeActivated && checkSliceDirectionResult) {
Material crossSectionMaterial = currentSurfaceToSlice.getCrossSectionMaterial ();
if (crossSectionMaterial == null) {
crossSectionMaterial = defaultSliceMaterial;
}
sliceCurrentObject (obj, objectCollider, crossSectionMaterial, slicePosition);
objectsDetectedOnLastSlice = true;
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 (!objectCanBeSliced && !ignoreRegularDamageIfCutSurfaceNotEnabled) {
if (activateDamageOnSlice && !isIgnoreDamageIfSliceNotActivatedActive) {
Vector3 damagePosition = currentCutPosition;
if (applyDamage.checkIfDead (obj)) {
damagePosition = obj.transform.position;
}
applyDamage.checkCanBeDamaged (gameObject, obj, damageAmountToApplyOnSlice, -currentCutForward, damagePosition,
playerGameObject, 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);
}
}
}
}
public void sliceCurrentObject (GameObject obj, Collider objectCollider, Material crossSectionMaterial, Vector3 slicePosition)
{
if (showDebugPrint) {
print ("\n\n");
print ("CHECKING IF OBJECT IS CHARACTER " + currentSurfaceToSlice.isObjectCharacter ());
}
// slice the provided object using the transforms of this object
if (currentSurfaceToSlice.isObjectCharacter ()) {
bool isCharacterOrVehicle = applyDamage.getCharacterOrVehicle (obj) != null;
bool objectIsDead = applyDamage.checkIfDead (obj);
if (isCharacterOrVehicle && !objectIsDead) {
if (showDebugPrint) {
print ("CONFIRMED " + obj.name + " can be sliced and is not dead, PROCESSING CHARACTER");
}
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 (!currentSliceActivatedExternally) {
if (ignoreTimeBulletOnRegularSlice) {
canCheckTimeBulletResult = false;
}
}
if (canCheckTimeBulletResult) {
currentSurfaceToSlice.checkTimeBulletOnCut ();
}
} else {
bool objectSliced = false;
GameObject object1 = null;
GameObject object2 = null;
currentSurfaceToSlice.checkEventBeforeSlice ();
obj = currentSurfaceToSlice.getMainSurfaceToSlice ();
sliceSystemUtils.sliceObject (currentCutPosition, 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 ();
bool canCheckTimeBulletResult = true;
if (!currentSliceActivatedExternally) {
if (ignoreTimeBulletOnRegularSlice) {
canCheckTimeBulletResult = false;
}
}
if (canCheckTimeBulletResult) {
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;
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> ();
object1Rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
object2Rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
object2Rigidbody.AddExplosionForce (currentForceToApply, currentCutPosition, forceRadius, forceUp, currentForceMode);
object1Rigidbody.AddExplosionForce (currentForceToApply, currentCutPosition, forceRadius, forceUp, currentForceMode);
} else {
if (currentSurfaceToSlice.useCustomForceAmount) {
currentForceToApply = currentSurfaceToSlice.customForceAmount;
}
if (distance1 < distance2) {
Rigidbody object2Rigidbody = object2.AddComponent<Rigidbody> ();
object2Rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
object2Rigidbody.AddExplosionForce (currentForceToApply, currentCutPosition, forceRadius, forceUp, currentForceMode);
} else {
Rigidbody object1Rigidbody = object1.AddComponent<Rigidbody> ();
object1Rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
object1Rigidbody.AddExplosionForce (currentForceToApply, currentCutPosition, 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;
}
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;
}
obj.SetActive (false);
}
}
}
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);
if (showDebugPrint) {
print ("ragdoll " + currentCharacter.name);
}
yield return new WaitForEndOfFrame ();
List<Collider> temporalHitsList = new List<Collider> ();
if (hits.Length > 0) {
for (int i = 0; i < hits.Length; i++) {
temporalHitsList.Add (hits [i]);
}
}
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;
}
}
Collider colliderToCheck = null;
float minDistance = 1000;
for (int i = 0; i < temporalHits.Length; i++) {
Collider currentCollider = temporalHits [i];
if (showDebugPrint) {
print ("checking " + currentCollider.name);
}
if (!temporalHitsList.Contains (currentCollider)) {
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 (showDebugPrint) {
print (currentCollider.name + " body part when killing");
}
if (applyDamage.isCharacter (currentCollider.gameObject)) {
bodyPartFound = true;
float currentDistance = GKC_Utils.distance (currentCutPosition, currentCollider.transform.position);
if (currentDistance < minDistance) {
minDistance = currentDistance;
colliderToCheck = currentCollider;
}
}
}
} else {
if (showDebugPrint) {
print (currentCollider.name + " already on temporal hist list");
}
}
}
if (bodyPartFound) {
if (currentCharacter != null) {
applyDamage.killCharacter (currentCharacter);
}
processObject (colliderToCheck.gameObject, colliderToCheck, currentCutPosition);
}
}
if (showDebugPrint) {
print (temporalHits.Length + " " + bodyPartFound);
}
}
public bool anyObjectDetectedOnLastSlice ()
{
return objectsDetectedOnLastSlice;
}
#if UNITY_EDITOR
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
if (usingCustomCutValues) {
GKC_Utils.drawRectangleGizmo (currentCutPosition, currentCutRotation,
Vector3.zero, currentCutOverlapBoxSize, gizmoColor);
} else {
GKC_Utils.drawRectangleGizmo (cutPositionTransform.position, cutPositionTransform.rotation,
Vector3.zero, cutOverlapBoxSize, gizmoColor);
}
}
}
#endif
[System.Serializable]
public class sliceTransformValuesInfo
{
public string Name;
public bool sliceInfoEnabled;
public Vector3 cutOverlapBoxSize = new Vector3 (5, 0.1f, 5);
public Transform cutPositionTransform;
public Transform cutDirectionTransform;
public Transform planeDefiner1;
public Transform planeDefiner2;
public Transform planeDefiner3;
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 6f57840be6508904eb0570cc3ca3289b
timeCreated: 1594988061
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/Combat System/Melee Combat System/Slice
System/sliceSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,434 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//using EzySlice;
//using NobleMuffins.LimbHacker.Guts;
//using NobleMuffins.LimbHacker;
public class sliceSystemUtils : MonoBehaviour
{
public static void sliceObject (Vector3 slicePosition, GameObject objectToSlice, Vector3 cutDirection, Material crossSectionMaterial, ref bool objectSliced, ref GameObject object1, ref GameObject object2)
{
//SlicedHull hull = objectToSlice.SliceObject (slicePosition, cutDirection, crossSectionMaterial);
//if (hull != null) {
// objectSliced = true;
// object1 = hull.CreateLowerHull (objectToSlice, crossSectionMaterial);
// object2 = hull.CreateUpperHull (objectToSlice, crossSectionMaterial);
//}
}
public static surfaceToSlice getSurfaceToSlice (GameObject currentSurface)
{
//ChildOfHackable currentChildOfHackable = currentSurface.GetComponent<ChildOfHackable> ();
//if (currentChildOfHackable != null) {
// return currentChildOfHackable.parentHackable.mainSurfaceToSlice;
//}
return null;
}
public static void initializeValuesOnHackableComponent (GameObject objectToUse, simpleSliceSystem currentSimpleSliceSystem)
{
//Hackable currentHackable = objectToUse.GetComponent<Hackable> ();
//if (currentHackable == null) {
// currentHackable = objectToUse.AddComponent<Hackable> ();
//}
//currentHackable.mainSurfaceToSlice = currentSimpleSliceSystem.mainSurfaceToSlice;
//currentHackable.alternatePrefab = currentSimpleSliceSystem.getMainAlternatePrefab ();
//currentHackable.objectToSlice = currentSimpleSliceSystem.objectToSlice;
//currentHackable.infillMaterial = currentSimpleSliceSystem.infillMaterial;
//currentHackable.severables = currentSimpleSliceSystem.getSeverables ();
//currentHackable.ignoreUpdateLastObjectSpeed = currentSimpleSliceSystem.ignoreUpdateLastObjectSpeed;
//currentHackable.ignoreDestroyOriginalObject = currentSimpleSliceSystem.ignoreDestroyOriginalObject;
//currentHackable.eventsOnIgnoreDestroyOriginalObject = currentSimpleSliceSystem.eventsOnIgnoreDestroyOriginalObject;
//currentHackable.setCustomIDOnSliceSpieces = currentSimpleSliceSystem.setCustomIDOnSliceSpieces;
//if (currentSimpleSliceSystem.setCustomIDOnSliceSpieces) {
// currentSimpleSliceSystem.setRandomString ();
// currentHackable.setRandomString (currentSimpleSliceSystem.getRandomString ());
//}
//currentHackable.initializeValues ();
}
public static void setDestructionPending (GameObject objectToUse, bool state)
{
//Hackable currentHackable = objectToUse.GetComponent<Hackable> ();
//if (currentHackable == null) {
// currentHackable = objectToUse.AddComponent<Hackable> ();
//}
//if (currentHackable != null) {
// currentHackable.setDestructionPending (state);
//}
}
public static void sliceCharacter (GameObject objectToSlice, Vector3 point, Vector3 newNormalInWorldSpaceValue,
bool updateLastObjectSpeed, Vector3 lastSpeed)
{
if (objectToSlice == null) {
return;
}
//Hackable currentHackable = objectToSlice.GetComponent<Hackable> ();
//if (currentHackable != null) {
// currentHackable.activateSlice (objectToSlice, point, newNormalInWorldSpaceValue, updateLastObjectSpeed, lastSpeed);
//}
}
public static GameObject[] shatterObject (GameObject obj, Vector3 shatterPosition, Material crossSectionMaterial = null, bool shaterActive = true)
{
//if (shaterActive) {
// return obj.SliceInstantiate (getRandomPlane (shatterPosition, obj.transform.localScale),
// new TextureRegion (0.0f, 0.0f, 1.0f, 1.0f),
// crossSectionMaterial);
//}
return null;
}
//public static EzySlice.Plane getRandomPlane (Vector3 positionOffset, Vector3 scaleOffset)
//{
// Vector3 randomPosition = Random.insideUnitSphere;
// Vector3 randomDirection = Random.insideUnitSphere.normalized;
// return new EzySlice.Plane (randomPosition, randomDirection);
//}
public static void destroyAllSlicedPiecesByRandomString (string stringValue, GameObject mainObjectToIgnore)
{
//Hackable[] HackableList = FindObjectsOfType<Hackable> ();
//int HackableListLength = HackableList.Length;
//for (int i = 0; i < HackableListLength; i++) {
// Hackable currentHackable = HackableList [i] as Hackable;
// if (mainObjectToIgnore != currentHackable.gameObject && currentHackable.getRandomString ().Equals (stringValue)) {
// Destroy (currentHackable.gameObject);
// }
//}
}
public static void processObjectToSlice (GameObject objectToCheck, Collider objectCollider,
Vector3 slicePosition, Quaternion sliceRotation,
float minDelayToSliceSameObject, Vector3 sliceUpDirection,
Vector3 sliceRightDirection, Vector3 sliceForwardDirection,
float forceToApplyToCutPart, LayerMask targetToDamageLayer,
bool randomSliceDirection, bool showSliceGizmo,
bool activateRigidbodiesOnNewObjects)
{
surfaceToSlice currentSurfaceToSlice = objectToCheck.GetComponent<surfaceToSlice> ();
if (currentSurfaceToSlice == null) {
currentSurfaceToSlice = sliceSystemUtils.getSurfaceToSlice (objectToCheck);
}
if (currentSurfaceToSlice != null) {
bool isCutSurfaceEnabled = currentSurfaceToSlice.isCutSurfaceEnabled ();
if (isCutSurfaceEnabled && currentSurfaceToSlice.sliceCanBeActivated (minDelayToSliceSameObject)) {
sliceCurrentObject (currentSurfaceToSlice, objectToCheck, objectCollider,
currentSurfaceToSlice.getCrossSectionMaterial (),
slicePosition, sliceRotation, sliceUpDirection, sliceRightDirection,
sliceForwardDirection, forceToApplyToCutPart, minDelayToSliceSameObject,
targetToDamageLayer, randomSliceDirection, showSliceGizmo, activateRigidbodiesOnNewObjects);
}
}
}
public static void sliceCurrentObject (surfaceToSlice currentSurfaceToSlice, GameObject objectToCheck,
Collider objectCollider, Material crossSectionMaterial,
Vector3 slicePosition, Quaternion sliceRotation,
Vector3 sliceUpDirection, Vector3 sliceRightDirection, Vector3 sliceForwardDirection,
float forceToApplyToCutPart, float minDelayToSliceSameObject,
LayerMask targetToDamageLayer, bool randomSliceDirection, bool showSliceGizmo,
bool activateRigidbodiesOnNewObjects)
{
if (currentSurfaceToSlice.isObjectCharacter ()) {
if (applyDamage.getCharacterOrVehicle (objectToCheck) != null && !applyDamage.checkIfDead (objectToCheck)) {
processCharacter (objectToCheck, slicePosition, sliceRotation,
minDelayToSliceSameObject, sliceUpDirection,
sliceRightDirection, sliceForwardDirection, forceToApplyToCutPart,
targetToDamageLayer, randomSliceDirection, showSliceGizmo, activateRigidbodiesOnNewObjects);
return;
}
Rigidbody mainObject = objectToCheck.GetComponent<Rigidbody> ();
bool mainObjectHasRigidbody = mainObject != null;
Vector3 lastSpeed = Vector3.zero;
if (mainObjectHasRigidbody) {
lastSpeed = mainObject.linearVelocity;
}
Vector3 planeDefiner1 = slicePosition - 0.2f * sliceForwardDirection;
Vector3 planeDefiner2 = slicePosition + 0.2f * sliceRightDirection;
Vector3 planeDefiner3 = slicePosition - 0.2f * sliceRightDirection;
Vector3 positionInWorldSpace = (planeDefiner1 + planeDefiner2 + planeDefiner3) / 3f;
Vector3 normalInWorldSpace = Vector3.zero;
Vector3 t0 = planeDefiner1;
Vector3 t1 = planeDefiner2;
Vector3 t2 = planeDefiner3;
normalInWorldSpace.x = t0.y * (t1.z - t2.z) + t1.y * (t2.z - t0.z) + t2.y * (t0.z - t1.z);
normalInWorldSpace.y = t0.z * (t1.x - t2.x) + t1.z * (t2.x - t0.x) + t2.z * (t0.x - t1.x);
normalInWorldSpace.z = t0.x * (t1.y - t2.y) + t1.x * (t2.y - t0.y) + t2.x * (t0.y - t1.y);
if (showSliceGizmo) {
Vector3 rayDirection1 = slicePosition;
Vector3 rayDirection2 = sliceForwardDirection;
Debug.DrawRay (rayDirection1, rayDirection2, Color.blue, 5);
rayDirection1 = slicePosition + sliceForwardDirection + sliceRightDirection;
rayDirection2 = sliceRightDirection;
Debug.DrawRay (rayDirection1, rayDirection2, Color.blue, 5);
rayDirection1 = slicePosition - sliceForwardDirection + sliceRightDirection;
rayDirection2 = sliceRightDirection;
Debug.DrawRay (rayDirection1, rayDirection2, Color.blue, 5);
}
currentSurfaceToSlice.checkEventBeforeSlice ();
currentSurfaceToSlice.getMainSimpleSliceSystem ().activateSlice (objectCollider, positionInWorldSpace,
normalInWorldSpace, slicePosition, true, lastSpeed);
currentSurfaceToSlice.checkEventOnCut ();
currentSurfaceToSlice.checkTimeBulletOnCut ();
} else {
bool objectSliced = false;
GameObject object1 = null;
GameObject object2 = null;
Vector3 sliceDirection = sliceUpDirection;
if (randomSliceDirection) {
sliceDirection = Quaternion.Euler (Random.Range (0, 361) * sliceForwardDirection) * sliceDirection;
}
currentSurfaceToSlice.checkEventBeforeSlice ();
objectToCheck = currentSurfaceToSlice.getMainSurfaceToSlice ();
sliceSystemUtils.sliceObject (slicePosition, objectToCheck, sliceDirection, 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) {
Vector3 planeDefiner1 = slicePosition - 0.2f * sliceForwardDirection;
Vector3 planeDefiner2 = slicePosition + 0.2f * sliceRightDirection;
Vector3 planeDefiner3 = slicePosition - 0.2f * sliceRightDirection;
Vector3 positionInWorldSpace = (planeDefiner1 + planeDefiner2 + planeDefiner3) / 3f;
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.Impulse;
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, slicePosition, 10, 1, currentForceMode);
object1Rigidbody.AddExplosionForce (currentForceToApply, slicePosition, 10, 1, currentForceMode);
} else {
if (currentSurfaceToSlice.useCustomForceAmount) {
currentForceToApply = currentSurfaceToSlice.customForceAmount;
}
Rigidbody object2Rigidbody = object2.AddComponent<Rigidbody> ();
object2Rigidbody.AddExplosionForce (currentForceToApply, slicePosition, 10, 1, currentForceMode);
Rigidbody object1Rigidbody = object1.AddComponent<Rigidbody> ();
object1Rigidbody.AddExplosionForce (currentForceToApply, slicePosition, 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;
}
objectToCheck.SetActive (false);
}
}
}
public static void processCharacter (GameObject currentCharacter, Vector3 slicePosition, Quaternion sliceRotation,
float minDelayToSliceSameObject, Vector3 sliceUpDirection,
Vector3 sliceRightDirection, Vector3 sliceForwardDirection,
float forceToApplyToCutPart, LayerMask targetToDamageLayer,
bool randomSliceDirection, bool showSliceGizmo,
bool activateRigidbodiesOnNewObjects)
{
applyDamage.pushCharacterWithoutForceAndPauseGetUp (currentCharacter);
Collider[] temporalHits = Physics.OverlapBox (slicePosition, new Vector3 (0.2f, 0.2f, 0.2f), sliceRotation,
targetToDamageLayer);
if (showSliceGizmo) {
Vector3 rayDirection1 = slicePosition;
Vector3 rayDirection2 = sliceForwardDirection;
Debug.DrawRay (rayDirection1, rayDirection2, Color.blue, 5);
rayDirection1 = slicePosition + sliceForwardDirection + sliceRightDirection;
rayDirection2 = sliceRightDirection;
Debug.DrawRay (rayDirection1, rayDirection2, Color.blue, 5);
rayDirection1 = slicePosition - sliceForwardDirection + sliceRightDirection;
rayDirection2 = sliceRightDirection;
Debug.DrawRay (rayDirection1, rayDirection2, Color.blue, 5);
}
bool bodyPartFound = false;
if (temporalHits.Length > 0) {
if (showSliceGizmo) {
print ("objects detected amount " + temporalHits.Length);
for (int i = 0; i < temporalHits.Length; i++) {
print (temporalHits [i].name);
}
}
Collider colliderToCheck = null;
float minDistance = 1000;
for (int i = 0; i < temporalHits.Length; i++) {
Collider currentCollider = temporalHits [i];
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);
}
if (showSliceGizmo) {
print ("body part detected " + colliderToCheck.name);
}
processObjectToSlice (colliderToCheck.gameObject, colliderToCheck,
slicePosition, sliceRotation,
minDelayToSliceSameObject, sliceUpDirection,
sliceRightDirection, sliceForwardDirection,
forceToApplyToCutPart, targetToDamageLayer, randomSliceDirection, showSliceGizmo,
activateRigidbodiesOnNewObjects);
}
}
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 30cb00ac6203f75449414e05cf26c702
timeCreated: 1603579394
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/Combat System/Melee Combat System/Slice
System/sliceSystemUtils.cs
uploadId: 814740

View File

@@ -0,0 +1,85 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class airAttackToLandSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public float downForceAmount = 5;
public LayerMask raycastLayermask;
public float minDistanceToDetectGround;
public bool attackLandingInProcess;
[Space]
[Header ("Event Settings")]
[Space]
public UnityEvent eventOnStartAttack;
public UnityEvent eventOnEndAttack;
[Space]
[Header ("Components")]
[Space]
public playerController mainPlayerController;
public Transform playerTransform;
Coroutine attackCoroutine;
public void activateAirAttackToLand ()
{
stopActivateAirAttackToLandCoroutine ();
attackCoroutine = StartCoroutine (activateAirAttackToLandCoroutine ());
}
void stopActivateAirAttackToLandCoroutine ()
{
if (attackCoroutine != null) {
StopCoroutine (attackCoroutine);
}
attackLandingInProcess = false;
}
IEnumerator activateAirAttackToLandCoroutine ()
{
attackLandingInProcess = true;
eventOnStartAttack.Invoke ();
bool targetReached = false;
while (!targetReached) {
Vector3 raycastPosition = playerTransform.position + playerTransform.up * 0.2f;
if (Physics.Raycast (raycastPosition, -playerTransform.up, minDistanceToDetectGround, raycastLayermask)) {
targetReached = true;
} else {
mainPlayerController.addExternalForce (-playerTransform.up * downForceAmount);
}
yield return null;
}
eventOnEndAttack.Invoke ();
attackLandingInProcess = false;
if (mainPlayerController.getCurrentSurfaceBelowPlayer () != null || mainPlayerController.checkIfPlayerOnGroundWithRaycast ()) {
mainPlayerController.setPlayerOnGroundState (true);
mainPlayerController.setOnGroundAnimatorIDValue (true);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6d3e9faaaf3133042a11c16cb3195121
timeCreated: 1621661280
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/Combat System/Melee Combat System/airAttackToLandSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,144 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dualWieldMeleeWeaponObjectSystem : MonoBehaviour
{
[Space]
[Header ("Components")]
[Space]
public hitCombat mainHitCombat;
public grabbedObjectMeleeAttackSystem currentGrabbedObjectMeleeAttackSystem;
public Transform meleeWeaponObject;
public Transform meleeWeaponParent;
public Transform meleeWeaponHandTransformReference;
public Transform meleeWeaponTransformReference;
public Transform raycastCheckTransfrom;
public Transform mainDamagePositionTransform;
[Space]
[Header ("Cutting Mode Settings")]
[Space]
public Transform cutPositionTransform;
public Transform cutDirectionTransform;
public Transform planeDefiner1;
public Transform planeDefiner2;
public Transform planeDefiner3;
[Space]
[Header ("Damage Detection Settings")]
[Space]
public List<Transform> raycastCheckTransfromList = new List<Transform> ();
Vector3 originalHitCombatColliderSize;
BoxCollider currentHitCombatBoxCollider;
Vector3 originalHitCombatColliderCenter;
Transform leftHandMountPoint;
public void enableDualWieldMeleeweapobObject (grabbedObjectMeleeAttackSystem newGrabbedObjectMeleeAttackSystem, bool useEventsOnDamageDetected)
{
currentGrabbedObjectMeleeAttackSystem = newGrabbedObjectMeleeAttackSystem;
if (currentGrabbedObjectMeleeAttackSystem.useCustomLayerToDetectSurfaces) {
mainHitCombat.setCustomLayerMask (currentGrabbedObjectMeleeAttackSystem.customLayerToDetectSurfaces);
}
if (currentGrabbedObjectMeleeAttackSystem.useCustomIgnoreTags) {
mainHitCombat.setCustomTagsToIgnore (currentGrabbedObjectMeleeAttackSystem.customTagsToIgnoreList);
} else {
mainHitCombat.setCustomTagsToIgnore (null);
}
mainHitCombat.setCustomDamageCanBeBlockedState (true);
currentHitCombatBoxCollider = mainHitCombat.getMainCollider ().GetComponent<BoxCollider> ();
originalHitCombatColliderCenter = currentHitCombatBoxCollider.center;
originalHitCombatColliderSize = currentHitCombatBoxCollider.size;
mainHitCombat.getOwner (currentGrabbedObjectMeleeAttackSystem.playerControllerGameObject);
mainHitCombat.setMainColliderEnabledState (true);
mainHitCombat.setSendMessageOnDamageDetectedState (useEventsOnDamageDetected);
if (useEventsOnDamageDetected) {
mainHitCombat.setCustomObjectToSendMessage (currentGrabbedObjectMeleeAttackSystem.gameObject);
}
leftHandMountPoint = currentGrabbedObjectMeleeAttackSystem.getLeftHandMountPoint ();
meleeWeaponObject.SetParent (leftHandMountPoint);
Vector3 localPosition = meleeWeaponHandTransformReference.localPosition;
Quaternion localRotation = meleeWeaponHandTransformReference.localRotation;
meleeWeaponObject.localPosition = localPosition;
meleeWeaponObject.localRotation = localRotation;
enableOrDisableDualWieldMeleeWeaponObject (true);
}
public void enableOrDisableDualWieldMeleeWeaponObject (bool state)
{
if (meleeWeaponObject.gameObject.activeSelf != state) {
meleeWeaponObject.gameObject.SetActive (state);
}
}
public void disableDualWieldMeleeweapobObject ()
{
mainHitCombat.setMainColliderEnabledState (false);
enableOrDisableDualWieldMeleeWeaponObject (true);
meleeWeaponObject.SetParent (meleeWeaponParent);
Vector3 localPosition = meleeWeaponTransformReference.localPosition;
Quaternion localRotation = meleeWeaponTransformReference.localRotation;
meleeWeaponObject.localPosition = localPosition;
meleeWeaponObject.localRotation = localRotation;
}
public void setHitCombatScale (Vector3 newScale)
{
if (currentHitCombatBoxCollider != null) {
currentHitCombatBoxCollider.size = newScale;
}
}
public void setHitCombatOffset (Vector3 newValue)
{
if (currentHitCombatBoxCollider != null) {
currentHitCombatBoxCollider.center = newValue;
}
}
public void setOriginalHitCombatScale ()
{
setHitCombatScale (originalHitCombatColliderSize);
}
public void setOriginalHitCombatOffset ()
{
setHitCombatOffset (originalHitCombatColliderCenter);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: cf1c383d49e63bc46a02dbbec4d5cf78
timeCreated: 1642357594
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/Combat System/Melee Combat System/dualWieldMeleeWeaponObjectSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class hiddenMeleeSurface : MonoBehaviour
{
public bool hiddenSurfaceEnabled = true;
public meleeAttackSurfaceInfo mainMeleeAttackSurfaceInfo;
public bool isSurfaceEnabled ()
{
return hiddenSurfaceEnabled;
}
public void setHiddenSurfaceEnabledState (bool state)
{
hiddenSurfaceEnabled = state;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 57defb32edebac94a8cd4e554450d5a0
timeCreated: 1651982306
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/Combat System/Melee Combat System/hiddenMeleeSurface.cs
uploadId: 814740

View File

@@ -0,0 +1,157 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class meleeAttackSurfaceInfo : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool surfaceEnabled = true;
public string surfaceName;
[Space]
[Header ("Weapon Throw Settings")]
[Space]
public bool useOffsetTransformOnWeaponThrow;
public Transform offsetTransformOnWeaponThrow;
public bool useOffsetDistanceOnWeaponThrow;
public float offsetDistanceOnWeaponThrow;
public bool disableInstaTeleportOnThisSurface;
[Space]
[Header ("Attach To Surface On Throw Settings")]
[Space]
public bool setAttachMeleeWeaponOnSurfaceValue;
public bool attachMeleeWeaponOnSurfaceValue;
[Space]
[Header ("Durability Settings")]
[Space]
public bool ignoreDurability;
public float extraDurabilityMultiplier;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnSurfaceDetected;
public UnityEvent eventOnSurfaceDeteceted;
[Space]
[Header ("Events On Throw/Return Weapon Settings")]
[Space]
public bool useEventOnThrowWeapon;
public UnityEvent eventOnThrowWeapon;
public bool useEventOnReturnWeapon;
public UnityEvent eventOnReturnWeapon;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEvent;
public List<string> remoteEventNameList = new List<string> ();
[Space]
public bool useRemoteEventOnWeapon;
public List<string> remoteEventOnWeaponNameList = new List<string> ();
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool ignoreSurfaceActive;
string originalSurfaceName;
void Start ()
{
originalSurfaceName = surfaceName;
}
public string getSurfaceName ()
{
return surfaceName;
}
public bool isSurfaceEnabled ()
{
return surfaceEnabled && !ignoreSurfaceActive;
}
public void setNewSurfaceName (string newSurfaceName)
{
surfaceName = newSurfaceName;
if (showDebugPrint) {
print ("setting new surface name " + surfaceName);
}
}
public void setOriginalSurfaceName ()
{
setNewSurfaceName (originalSurfaceName);
}
public void setIgnoreSurfaceActiveState (bool state)
{
ignoreSurfaceActive = state;
if (showDebugPrint) {
print ("ignore surface active " + state);
}
}
public void setUseRemoteEventState (bool state)
{
useRemoteEvent = state;
}
public void setUseRemoteEventOnWeaponState (bool state)
{
useRemoteEventOnWeapon = state;
}
public void checkEventOnSurfaceDetected ()
{
if (useEventOnSurfaceDetected) {
eventOnSurfaceDeteceted.Invoke ();
}
}
public void checkEventOnThrowWeapon ()
{
if (useEventOnThrowWeapon) {
eventOnThrowWeapon.Invoke ();
if (showDebugPrint) {
print ("event on throw weapon activated " + gameObject.name);
}
}
}
public void checkEventOnReturnWeapon ()
{
if (useEventOnReturnWeapon) {
eventOnReturnWeapon.Invoke ();
if (showDebugPrint) {
print ("event on return weapon activated " + gameObject.name);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a5a11e568ae95e9449816e370b95ba7c
timeCreated: 1596490101
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/Combat System/Melee Combat System/meleeAttackSurfaceInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class meleeCombatAttackStartState : MonoBehaviour
{
public bool attackResetEnabled = true;
public grabbedObjectMeleeAttackSystem mainGrabbedObjectMeleeAttackSystem;
public void resetActivateDamageTriggerCoroutine ()
{
if (attackResetEnabled) {
mainGrabbedObjectMeleeAttackSystem.resetActivateDamageTriggerCoroutine ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6faa74483dbcfef4c80c151637975fdd
timeCreated: 1616387778
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/Combat System/Melee Combat System/meleeCombatAttackStartState.cs
uploadId: 814740

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 0e19d4d0605725e4faa0a14f27d2d9c6
timeCreated: 1657204400
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/Combat System/Melee Combat System/meleeCombatThrowReturnWeaponSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,163 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class meleeShieldObjectSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public float blockDamageProtectionAmount = 1;
public float reducedBlockDamageProtectionAmount = 0.1f;
public bool useMaxBlockRangeAngle = true;
public float maxBlockRangeAngle = 180;
[Space]
public bool shieldCarriedOnRightArm;
public bool hideWeaponMeshWhenNotUsed;
[Space]
[Header ("Durability Settings")]
[Space]
public bool useObjectDurabilityOnBlock;
public float durabilityUsedOnBlock = 1;
[Space]
[Header ("Debug")]
[Space]
public GameObject currentCharacter;
[Space]
[Header ("Components")]
[Space]
public durabilityInfo mainDurabilityInfo;
public void setCurrentCharacter (GameObject newObject)
{
currentCharacter = newObject;
}
public GameObject getCurrentCharacter ()
{
return currentCharacter;
}
public bool checkDurabilityOnBlockWithShield (float extraMultiplier)
{
if (useObjectDurabilityOnBlock) {
mainDurabilityInfo.addOrRemoveDurabilityAmountToObjectByName (-durabilityUsedOnBlock * extraMultiplier, false);
if (mainDurabilityInfo.durabilityAmount <= 0) {
return true;
}
}
return false;
}
public void updateDurabilityAmountState ()
{
if (useObjectDurabilityOnBlock) {
mainDurabilityInfo.updateDurabilityAmountState ();
}
}
public float getDurabilityAmount ()
{
if (useObjectDurabilityOnBlock) {
return mainDurabilityInfo.getDurabilityAmount ();
}
return -1;
}
public void initializeDurabilityValue (float newAmount, int currentObjectIndex)
{
if (useObjectDurabilityOnBlock) {
mainDurabilityInfo.initializeDurabilityValue (newAmount);
mainDurabilityInfo.setInventoryObjectIndex (currentObjectIndex);
}
}
public void setInventoryObjectIndex (int currentObjectIndex)
{
if (useObjectDurabilityOnBlock) {
mainDurabilityInfo.setInventoryObjectIndex (currentObjectIndex);
}
}
public void repairObjectFully ()
{
if (useObjectDurabilityOnBlock) {
mainDurabilityInfo.repairObjectFully ();
}
}
public void breakFullDurabilityOnCurrentWeapon ()
{
if (useObjectDurabilityOnBlock) {
mainDurabilityInfo.breakFullDurability ();
}
}
public void setUseObjectDurabilityOnBlockValue (bool newValue)
{
useObjectDurabilityOnBlock = newValue;
}
public void setDurabilityUsedOnBlockValue (float newValue)
{
durabilityUsedOnBlock = newValue;
}
public void setUseObjectDurabilityOnBlockValueFromEditor (bool newValue)
{
setUseObjectDurabilityOnBlockValue (newValue);
updateComponent ();
}
public void setDurabilityUsedOnBlockValueFromEditor (float newValue)
{
setDurabilityUsedOnBlockValue (newValue);
updateComponent ();
}
public void setObjectNameFromEditor (string newName)
{
if (useObjectDurabilityOnBlock) {
mainDurabilityInfo.setObjectNameFromEditor (newName);
}
}
public void setDurabilityAmountFromEditor (float newValue)
{
if (useObjectDurabilityOnBlock) {
mainDurabilityInfo.setDurabilityAmountFromEditor (newValue);
}
}
public void setMaxDurabilityAmountFromEditor (float newValue)
{
if (useObjectDurabilityOnBlock) {
mainDurabilityInfo.setMaxDurabilityAmountFromEditor (newValue);
}
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Updating melee shield object info" + gameObject.name, gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c75b6bcfae23b8a4e833e71f74c9484b
timeCreated: 1680657574
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/Combat System/Melee Combat System/meleeShieldObjectSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,85 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class meleeUISystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool meleeUIEnabled = true;
[Space]
[Header ("Debug")]
[Space]
public bool meleeUIActive;
public string currentMeleeWeaponName;
[Space]
[Header ("UI Components")]
[Space]
public Text meleeWeaponText;
public RawImage meleeWeaponImage;
public GameObject meleePanelGameObject;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventsOnMeleePanelStateChange;
public UnityEvent eventOnEnableMeleePanel;
public UnityEvent eventOnDisableMeleePanel;
public void setCurrentMeleeWeaponName (string newName)
{
currentMeleeWeaponName = newName;
meleeWeaponText.text = GKC_Utils.getInteractionObjectsLocalizationManagerLocalizedText (currentMeleeWeaponName);
}
public void setCurrrentMeleeWeaponIcon (Texture newIcon)
{
meleeWeaponImage.texture = newIcon;
}
public void enableOrDisableMeleeUI (bool state)
{
if (!meleeUIEnabled) {
return;
}
if (meleeUIActive == state) {
return;
}
meleeUIActive = state;
if (meleeUIActive) {
} else {
}
if (meleePanelGameObject.activeSelf != meleeUIActive) {
meleePanelGameObject.SetActive (meleeUIActive);
}
checkEventsOnMeleePanelStateChange (meleeUIActive);
}
void checkEventsOnMeleePanelStateChange (bool state)
{
if (useEventsOnMeleePanelStateChange) {
if (state) {
eventOnEnableMeleePanel.Invoke ();
} else {
eventOnDisableMeleePanel.Invoke ();
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6814a4084794b2e4fab94bd7a48ffde4
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/Combat System/Melee Combat System/meleeUISystem.cs
uploadId: 814740

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu (fileName = "Melee Weapon Attack Info Template", menuName = "GKC/Create Melee Weapon Attack Info Template", order = 51)]
public class meleeWeaponAttackInfo : ScriptableObject
{
public string Name;
public int ID = 0;
public meleeWeaponInfo mainMeleeWeaponInfo;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ff400eece7fb7cb4e93d51d69e12b589
timeCreated: 1637477241
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/Combat System/Melee Combat System/meleeWeaponAttackInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class meleeWeaponAttackListInfoSocket : MonoBehaviour
{
public meleeWeaponAttackInfo mainMeleeWeaponAttackInfo;
public grabPhysicalObjectMeleeAttackSystem mainGrabPhysicalObjectMeleeAttackSystem;
public void copyWeaponInfoToTemplate (bool settingInfoOnEditorTime)
{
if (mainGrabPhysicalObjectMeleeAttackSystem != null) {
mainGrabPhysicalObjectMeleeAttackSystem.setNewMeleeWeaponAttackInfoTemplate (mainMeleeWeaponAttackInfo, settingInfoOnEditorTime);
mainGrabPhysicalObjectMeleeAttackSystem.copyWeaponInfoToTemplate (settingInfoOnEditorTime);
}
}
public void copyTemplateToWeaponAttackInfo (bool settingInfoOnEditorTime)
{
if (mainGrabPhysicalObjectMeleeAttackSystem != null) {
mainGrabPhysicalObjectMeleeAttackSystem.setNewMeleeWeaponAttackInfoTemplate (mainMeleeWeaponAttackInfo, settingInfoOnEditorTime);
mainGrabPhysicalObjectMeleeAttackSystem.copyTemplateToWeaponAttackInfo (settingInfoOnEditorTime);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: f94282928ce08ef4fa01911eff78de56
timeCreated: 1637903618
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/Combat System/Melee Combat System/meleeWeaponAttackListInfoSocket.cs
uploadId: 814740

View File

@@ -0,0 +1,43 @@
using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
[CustomEditor (typeof(meleeWeaponAttackListInfoSocket))]
public class meleeWeaponAttackListInfoSocketEditor : Editor
{
meleeWeaponAttackListInfoSocket manager;
Vector3 curretPositionHandle;
Quaternion currentRotationHandle;
void OnEnable ()
{
manager = (meleeWeaponAttackListInfoSocket)target;
}
public override void OnInspectorGUI ()
{
DrawDefaultInspector ();
EditorGUILayout.Space ();
GUILayout.Label ("EDITOR BUTTONS", EditorStyles.boldLabel);
EditorGUILayout.Space ();
if (GUILayout.Button ("Copy Weapon Info To Template")) {
manager.copyWeaponInfoToTemplate (true);
}
EditorGUILayout.Space ();
if (GUILayout.Button ("Copy Template To Weapon Attack Info")) {
manager.copyTemplateToWeaponAttackInfo (true);
}
EditorGUILayout.Space ();
}
}
#endif

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 64d247d60f48cda41b4e0f0b03bd4e8f
timeCreated: 1637903781
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/Combat System/Melee Combat System/meleeWeaponAttackListInfoSocketEditor.cs
uploadId: 814740

View File

@@ -0,0 +1,47 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class meleeWeaponInfo
{
[Space]
[Header ("Movements Settings")]
[Space]
public bool setNewMovementValues;
[Space]
[Space]
public bool setNewIdleID;
public int idleIDUsed;
public bool useStrafeMode;
public int strafeIDUsed;
public bool activateStrafeModeOnLockOnTargetActive;
[Space]
public bool toggleStrafeModeIfRunningActive;
public bool setSprintEnabledStateWithWeapon;
public bool sprintEnabledStateWithWeapon;
[Space]
public bool setNewCrouchID;
public int crouchIDUsed;
[Space]
public bool setNewMovementID;
public int movementIDUsed;
[Space]
[Header ("Attack Settings")]
[Space]
public List<grabPhysicalObjectMeleeAttackSystem.attackInfo> mainAttackInfoList = new List<grabPhysicalObjectMeleeAttackSystem.attackInfo> ();
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 4216cb94094d1a44ba12237ded4f798e
timeCreated: 1638261338
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/Combat System/Melee Combat System/meleeWeaponInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,379 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class meleeWeaponRangeAttacksManager : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool rangeAttacksActive;
public float aimingActiveBodyWeight = 0.5f;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public int currentRangeWeaponID;
public int currentRangeWeaponInfo;
public bool aimingActive;
[Space]
[Header ("Range Weapon Types List")]
[Space]
public List<rangeWeaponSystemInfo> rangeWeaponSystemInfoList = new List<rangeWeaponSystemInfo> ();
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventsOnAim;
public UnityEvent eventOnStartAiming;
public UnityEvent eventOnStopAiming;
public bool callEventsOnDisableRangeAttacksState;
[Space]
[Header ("Components")]
[Space]
public grabbedObjectMeleeAttackSystem mainGrabbedObjectMeleeAttackSystem;
public playerCamera mainPlayerCamera;
public playerController mainPlayerController;
public headTrack mainHeadTrack;
meleeWeaponRangeAttacksSystem currentMeleeWeaponRangeAttacksSystem;
rangeWeaponSystemInfo currentRangeWeaponSystemInfo;
simpleWeaponSystem currentSimpleWeaponSystem;
bool currentSimpleWeaponSystemAssigned;
bool firingCurrentSimpleWeaponSystem;
public void setMeleeWeaponRangeAttackManagerActiveState (bool state)
{
if (rangeAttacksActive == state) {
return;
}
rangeAttacksActive = state;
if (rangeAttacksActive) {
Transform currentGrabbedObjectTransform = mainGrabbedObjectMeleeAttackSystem.getCurrentGrabbedObjectTransform ();
if (currentGrabbedObjectTransform == null) {
return;
}
currentMeleeWeaponRangeAttacksSystem = currentGrabbedObjectTransform.GetComponent<meleeWeaponRangeAttacksSystem> ();
currentRangeWeaponInfo = 0;
currentRangeWeaponID = currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [currentRangeWeaponInfo].rangeWeaponID;
setCurrentRangeWeaponSystemByID (currentRangeWeaponID);
currentSimpleWeaponSystem.setCustomprojectilePosition (currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [currentRangeWeaponInfo].projectilePosition);
} else {
if (aimingActive || firingCurrentSimpleWeaponSystem) {
forceStopFireCurrentRangeWeapon ();
}
if (currentSimpleWeaponSystem != null) {
currentSimpleWeaponSystem.enabled = false;
}
aimingActive = false;
if (callEventsOnDisableRangeAttacksState) {
checkEventsOnStateChange (false);
}
}
}
public void setCurrentRangeWeaponSystemByID (int rangeWeaponID)
{
for (int i = 0; i < rangeWeaponSystemInfoList.Count; i++) {
if (rangeWeaponSystemInfoList [i].rangeWeaponID == rangeWeaponID) {
currentRangeWeaponSystemInfo = rangeWeaponSystemInfoList [i];
currentRangeWeaponSystemInfo.isCurrentWeapon = true;
currentSimpleWeaponSystem = currentRangeWeaponSystemInfo.mainSimpleWeaponSystem;
currentSimpleWeaponSystem.enabled = true;
currentSimpleWeaponSystemAssigned = true;
} else {
if (rangeWeaponSystemInfoList [i].isCurrentWeapon) {
rangeWeaponSystemInfoList [i].mainSimpleWeaponSystem.enabled = false;
}
rangeWeaponSystemInfoList [i].isCurrentWeapon = false;
}
}
}
public void fireCurrentRangeWeapon ()
{
if (rangeAttacksActive) {
if (currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [currentRangeWeaponInfo].useEventOnRangeWeapon) {
currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [currentRangeWeaponInfo].eventOnRangeWeapon.Invoke ();
}
currentSimpleWeaponSystem.inputShootWeaponOnPressDown ();
currentSimpleWeaponSystem.inputShootWeaponOnPressUp ();
}
}
public void fireCurrentRangeWeaponByAttackRangeID (int newRangeID)
{
if (rangeAttacksActive) {
setCurrentRangeWeaponSystemByID (newRangeID);
int rangeWeaponInfoListCount = currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList.Count;
for (int i = 0; i < rangeWeaponInfoListCount; i++) {
if (currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [i].rangeWeaponID == newRangeID) {
currentRangeWeaponInfo = newRangeID;
currentSimpleWeaponSystem.setCustomprojectilePosition (currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [i].projectilePosition);
fireCurrentRangeWeapon ();
return;
}
}
}
}
public void startFireCurrentRangeWeapon ()
{
if (rangeAttacksActive) {
if (currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [currentRangeWeaponInfo].useEventOnRangeWeapon) {
currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [currentRangeWeaponInfo].eventOnRangeWeapon.Invoke ();
}
currentSimpleWeaponSystem.inputHoldOrReleaseShootWeapon (true);
firingCurrentSimpleWeaponSystem = true;
if (showDebugPrint) {
print ("Star fire current range weapon");
}
if (currentRangeWeaponSystemInfo.useStrafeMode) {
if (currentRangeWeaponSystemInfo.previousStrafeID == -1) {
currentRangeWeaponSystemInfo.previousStrafeMode = mainGrabbedObjectMeleeAttackSystem.isStrafeModeActive ();
currentRangeWeaponSystemInfo.previousStrafeID = mainGrabbedObjectMeleeAttackSystem.getCurrentStrafeID ();
mainGrabbedObjectMeleeAttackSystem.setStrafeModeState (true, currentRangeWeaponSystemInfo.strafeIDUsed);
}
}
if (currentRangeWeaponSystemInfo.setNewCrouchID) {
if (currentRangeWeaponSystemInfo.previousCrouchID == -1) {
currentRangeWeaponSystemInfo.previousCrouchID = mainGrabbedObjectMeleeAttackSystem.getCurrentCrouchID ();
mainGrabbedObjectMeleeAttackSystem.setCurrentCrouchIDValue (currentRangeWeaponSystemInfo.crouchIDUsed);
}
}
mainPlayerController.enableOrDisableAiminig (true);
mainHeadTrack.setHeadTrackActiveWhileAimingState (true);
if (aimingActiveBodyWeight != 0) {
mainHeadTrack.setCameraBodyWeightValue (aimingActiveBodyWeight);
}
}
}
public void stopFireCurrentRangeWeapon ()
{
if (rangeAttacksActive) {
forceStopFireCurrentRangeWeapon ();
}
}
void forceStopFireCurrentRangeWeapon ()
{
if (currentSimpleWeaponSystemAssigned && firingCurrentSimpleWeaponSystem) {
currentSimpleWeaponSystem.inputHoldOrReleaseShootWeapon (false);
firingCurrentSimpleWeaponSystem = false;
if (showDebugPrint) {
print ("Stop fire current range weapon");
}
if (currentRangeWeaponSystemInfo.useStrafeMode) {
if (currentRangeWeaponSystemInfo.previousStrafeID != -1) {
mainGrabbedObjectMeleeAttackSystem.setStrafeModeState (currentRangeWeaponSystemInfo.previousStrafeMode, currentRangeWeaponSystemInfo.previousStrafeID);
} else {
mainGrabbedObjectMeleeAttackSystem.setStrafeModeState (false, 0);
}
currentRangeWeaponSystemInfo.previousStrafeMode = false;
currentRangeWeaponSystemInfo.previousStrafeID = -1;
}
if (currentRangeWeaponSystemInfo.setNewCrouchID) {
if (currentRangeWeaponSystemInfo.previousCrouchID != -1) {
mainGrabbedObjectMeleeAttackSystem.setCurrentCrouchIDValue (currentRangeWeaponSystemInfo.previousCrouchID);
} else {
mainGrabbedObjectMeleeAttackSystem.setCurrentCrouchIDValue (0);
}
currentRangeWeaponSystemInfo.previousCrouchID = -1;
}
mainPlayerController.enableOrDisableAiminig (false);
mainHeadTrack.setHeadTrackActiveWhileAimingState (false);
if (aimingActiveBodyWeight != 0) {
mainHeadTrack.setOriginalCameraBodyWeightValue ();
}
}
}
public void startFireCurrentRangeWeaponByAttackRangeID (int newRangeID)
{
if (rangeAttacksActive) {
setCurrentRangeWeaponSystemByID (newRangeID);
if (showDebugPrint) {
print ("Start Fire Current Range Weapon By Attack Range ID " + newRangeID);
}
for (int i = 0; i < rangeWeaponSystemInfoList.Count; i++) {
if (currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [i].rangeWeaponID == newRangeID) {
currentRangeWeaponInfo = newRangeID;
currentSimpleWeaponSystem.setCustomprojectilePosition (currentMeleeWeaponRangeAttacksSystem.rangeWeaponInfoList [i].projectilePosition);
if (showDebugPrint) {
print ("Range ID detected " + newRangeID);
}
startFireCurrentRangeWeapon ();
return;
}
}
}
}
public void enableCustomReticle (string reticleName)
{
if (mainPlayerCamera != null) {
mainPlayerCamera.enableOrDisableCustomReticle (true, reticleName);
}
}
public void disableCustomReticle (string reticleName)
{
if (mainPlayerCamera != null) {
mainPlayerCamera.enableOrDisableCustomReticle (false, reticleName);
}
}
public void disableAllCustomReticle ()
{
if (mainPlayerCamera != null) {
mainPlayerCamera.disableAllCustomReticle ();
}
}
public void inputSetAimState (bool state)
{
if (!rangeAttacksActive) {
return;
}
setAimState (state);
}
public void inputToggleAimState ()
{
if (!rangeAttacksActive) {
return;
}
setAimState (!aimingActive);
}
public void setAimState (bool state)
{
if (aimingActive == state) {
return;
}
aimingActive = state;
checkEventsOnStateChange (aimingActive);
}
void checkEventsOnStateChange (bool state)
{
if (useEventsOnAim) {
if (state) {
eventOnStartAiming.Invoke ();
} else {
eventOnStopAiming.Invoke ();
}
}
}
[System.Serializable]
public class rangeWeaponSystemInfo
{
[Header ("Main Settings")]
[Space]
public string Name;
public int rangeWeaponID;
public bool isCurrentWeapon;
[Space]
[Header ("Movement Settings")]
[Space]
public bool useStrafeMode;
public int strafeIDUsed;
public bool previousStrafeMode;
public int previousStrafeID = -1;
[Space]
public bool setNewCrouchID;
public int crouchIDUsed;
public int previousCrouchID = -1;
[Space]
[Header ("Other Settings")]
[Space]
public simpleWeaponSystem mainSimpleWeaponSystem;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 74f243dc0ba44c54e93f1e60c52a17b6
timeCreated: 1624110304
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/Combat System/Melee Combat System/meleeWeaponRangeAttacksManager.cs
uploadId: 814740

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class meleeWeaponRangeAttacksSystem : MonoBehaviour
{
public List<rangeWeaponInfo> rangeWeaponInfoList = new List<rangeWeaponInfo> ();
[System.Serializable]
public class rangeWeaponInfo
{
public string Name;
public int rangeWeaponID;
public List<Transform> projectilePosition = new List<Transform> ();
public bool useEventOnRangeWeapon;
public UnityEvent eventOnRangeWeapon;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 00128f0999e7eab4390908b487b2ca29
timeCreated: 1624095797
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/Combat System/Melee Combat System/meleeWeaponRangeAttacksSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu (fileName = "Melee Weapon Transform Data", menuName = "GKC/Create Melee Weapon Transform Data", order = 51)]
public class meleeWeaponTransformData : ScriptableObject
{
public string meleeWeaponName;
public objectTransformInfo mainObjectTransformInfo;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 3967cee7732269f409e53a756afbced0
timeCreated: 1620069876
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/Combat System/Melee Combat System/meleeWeaponTransformData.cs
uploadId: 814740

View File

@@ -0,0 +1,314 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class meleeWeaponTransformInfoSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool editWeaponTransformValuesIngame;
[Space]
public Vector3 weaponPosition;
public Vector3 weaponRotation;
[Space]
public Transform currentWeaponObjectTransform;
public GameObject currentWeaponMeshGameObject;
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
[Space]
[Header ("Melee Object Data Settings")]
[Space]
public grabbedObjectMeleeAttackSystem mainGrabbedObjectMeleeAttackSystem;
public meleeWeaponsGrabbedManager mainMeleeWeaponsGrabbedManager;
public meleeWeaponTransformData mainMeleeWeaponHandTransformData;
public meleeWeaponTransformData mainMeleeWeaponMeshTransformData;
// Coroutine updateCoroutine;
public void toggleEditWeaponTransformValuesIngameStateState ()
{
if (Application.isPlaying) {
setEditWeaponTransformValuesIngameState (!editWeaponTransformValuesIngame);
}
}
public void setEditWeaponTransformValuesIngameState (bool state)
{
editWeaponTransformValuesIngame = state;
// stopUpdateCoroutine ();
//
// if (editWeaponTransformValuesIngame) {
// updateCoroutine = StartCoroutine (updateSystemCoroutine ());
// }
currentWeaponObjectTransform = null;
currentWeaponMeshGameObject = null;
showGizmo = false;
}
public void selectCurrentWeaponObjectInGame ()
{
if (Application.isPlaying) {
if (mainGrabbedObjectMeleeAttackSystem.carryingObject) {
currentWeaponObjectTransform = mainGrabbedObjectMeleeAttackSystem.getCurrentGrabbedObjectTransform ();
if (currentWeaponObjectTransform != null) {
GKC_Utils.setActiveGameObjectInEditor (currentWeaponObjectTransform.gameObject);
}
} else {
string meleeWeaponName = mainMeleeWeaponsGrabbedManager.getCurrentWeaponActiveName ();
if (meleeWeaponName != "") {
currentWeaponMeshGameObject = mainMeleeWeaponsGrabbedManager.getCurrentWeaponMeshByName (meleeWeaponName);
if (currentWeaponMeshGameObject != null) {
GKC_Utils.setActiveGameObjectInEditor (currentWeaponMeshGameObject);
}
}
}
}
}
// public void stopUpdateCoroutine ()
// {
// if (updateCoroutine != null) {
// StopCoroutine (updateCoroutine);
// }
// }
// IEnumerator updateSystemCoroutine ()
// {
// var waitTime = new WaitForFixedUpdate ();
//
// while (true) {
// updateSystem ();
//
// yield return waitTime;
// }
// }
// void updateSystem ()
// {
void Update ()
{
if (editWeaponTransformValuesIngame) {
if (mainGrabbedObjectMeleeAttackSystem.carryingObject) {
if (currentWeaponObjectTransform != null) {
currentWeaponObjectTransform.localPosition = weaponPosition;
currentWeaponObjectTransform.localEulerAngles = weaponRotation;
} else {
currentWeaponObjectTransform = mainGrabbedObjectMeleeAttackSystem.getCurrentGrabbedObjectTransform ();
weaponPosition = currentWeaponObjectTransform.localPosition;
weaponRotation = currentWeaponObjectTransform.localEulerAngles;
}
} else {
string meleeWeaponName = mainMeleeWeaponsGrabbedManager.getCurrentWeaponActiveName ();
if (meleeWeaponName != "") {
if (currentWeaponMeshGameObject != null) {
currentWeaponObjectTransform.localPosition = weaponPosition;
currentWeaponObjectTransform.localEulerAngles = weaponRotation;
} else {
currentWeaponMeshGameObject = mainMeleeWeaponsGrabbedManager.getCurrentWeaponMeshByName (meleeWeaponName);
currentWeaponObjectTransform = currentWeaponMeshGameObject.transform;
weaponPosition = currentWeaponObjectTransform.localPosition;
weaponRotation = currentWeaponObjectTransform.localEulerAngles;
}
}
}
}
}
public void copyTransformValuesToBuffer ()
{
if (mainGrabbedObjectMeleeAttackSystem.isCarryingObject ()) {
objectTransformInfo newObjectTransformInfo = new objectTransformInfo ();
Transform currentGrabbedObjectTransform = mainGrabbedObjectMeleeAttackSystem.getCurrentGrabbedObjectTransform ();
if (currentGrabbedObjectTransform != null) {
newObjectTransformInfo.objectPosition = currentGrabbedObjectTransform.localPosition;
newObjectTransformInfo.objectRotation = currentGrabbedObjectTransform.localRotation;
mainMeleeWeaponHandTransformData.meleeWeaponName = mainGrabbedObjectMeleeAttackSystem.getCurrentMeleeWeaponTypeName ();
mainMeleeWeaponHandTransformData.mainObjectTransformInfo = newObjectTransformInfo;
print ("Copying melee weapon main positions for " + mainMeleeWeaponHandTransformData.meleeWeaponName);
}
}
string meleeWeaponName = mainMeleeWeaponsGrabbedManager.getCurrentWeaponActiveName ();
if (meleeWeaponName != "") {
currentWeaponMeshGameObject = mainMeleeWeaponsGrabbedManager.getCurrentWeaponMeshByName (meleeWeaponName);
if (currentWeaponMeshGameObject != null) {
Transform currentWeaponMeshTransform = currentWeaponMeshGameObject.transform;
objectTransformInfo newObjectTransformInfo = new objectTransformInfo ();
newObjectTransformInfo.objectPosition = currentWeaponMeshTransform.localPosition;
newObjectTransformInfo.objectRotation = currentWeaponMeshTransform.localRotation;
mainMeleeWeaponMeshTransformData.meleeWeaponName = getMeleeWeaponTypeNameByRegularWeaponName (meleeWeaponName);
mainMeleeWeaponMeshTransformData.mainObjectTransformInfo = newObjectTransformInfo;
print ("Copying melee weapon mesh positions for type " + mainMeleeWeaponMeshTransformData.meleeWeaponName);
}
}
}
public string getMeleeWeaponTypeNameByRegularWeaponName (string weaponName)
{
for (int k = 0; k < mainMeleeWeaponsGrabbedManager.meleeWeaponPrefabInfoList.Count; k++) {
if (mainMeleeWeaponsGrabbedManager.meleeWeaponPrefabInfoList [k].Name.Equals (weaponName)) {
grabPhysicalObjectMeleeAttackSystem currentGrabPhysicalObjectMeleeAttackSystem =
mainMeleeWeaponsGrabbedManager.meleeWeaponPrefabInfoList [k].weaponPrefab.GetComponent<grabPhysicalObjectMeleeAttackSystem> ();
if (currentGrabPhysicalObjectMeleeAttackSystem != null) {
return currentGrabPhysicalObjectMeleeAttackSystem.weaponInfoName;
}
}
}
return "";
}
public void pasteTransformValuesToBuffer ()
{
objectTransformInfo newWeaponHandTransformInfo = mainMeleeWeaponHandTransformData.mainObjectTransformInfo;
objectTransformInfo newWeaponMeshTransformInfo = mainMeleeWeaponMeshTransformData.mainObjectTransformInfo;
for (int i = 0; i < mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList.Count; i++) {
if (mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].Name.Equals (mainMeleeWeaponHandTransformData.meleeWeaponName)) {
if (mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].useGrabbedWeaponReferenceValues) {
mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].grabbedWeaponReferenceValuesPosition = newWeaponHandTransformInfo.objectPosition;
mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].grabbedWeaponReferenceValuesEuler = newWeaponHandTransformInfo.objectRotation.eulerAngles;
} else {
Transform customGrabbedWeaponReferencePosition = mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].customGrabbedWeaponReferencePosition;
if (customGrabbedWeaponReferencePosition != null) {
customGrabbedWeaponReferencePosition.localPosition = newWeaponHandTransformInfo.objectPosition;
customGrabbedWeaponReferencePosition.localRotation = newWeaponHandTransformInfo.objectRotation;
}
}
}
}
for (int i = 0; i < mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList.Count; i++) {
if (mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].Name.Equals (mainMeleeWeaponMeshTransformData.meleeWeaponName)) {
if (mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].useReferenceToKeepObjectMeshValues) {
mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].referenceToKeepObjectMeshValuesPosition = newWeaponMeshTransformInfo.objectPosition;
mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].referenceToKeepObjectMeshValuesEuler = newWeaponMeshTransformInfo.objectRotation.eulerAngles;
} else {
Transform customReferencePositionToKeepObjectMesh = mainGrabbedObjectMeleeAttackSystem.grabbedWeaponInfoList [i].customReferencePositionToKeepObjectMesh;
if (customReferencePositionToKeepObjectMesh != null) {
customReferencePositionToKeepObjectMesh.localPosition = newWeaponMeshTransformInfo.objectPosition;
customReferencePositionToKeepObjectMesh.localRotation = newWeaponMeshTransformInfo.objectRotation;
}
}
}
}
for (int k = 0; k < mainMeleeWeaponsGrabbedManager.meleeWeaponPrefabInfoList.Count; k++) {
if (mainMeleeWeaponsGrabbedManager.meleeWeaponPrefabInfoList [k].Name.Equals (mainMeleeWeaponMeshTransformData.meleeWeaponName)) {
if (mainMeleeWeaponsGrabbedManager.meleeWeaponPrefabInfoList [k].weaponPrefab != null) {
grabPhysicalObjectMeleeAttackSystem currentGrabPhysicalObjectMeleeAttackSystem =
mainMeleeWeaponsGrabbedManager.meleeWeaponPrefabInfoList [k].weaponPrefab.GetComponent<grabPhysicalObjectMeleeAttackSystem> ();
if (currentGrabPhysicalObjectMeleeAttackSystem != null) {
currentGrabPhysicalObjectMeleeAttackSystem.setReferencePositionToKeepObjectMeshPositionFromEditor (
newWeaponMeshTransformInfo.objectPosition, newWeaponMeshTransformInfo.objectRotation);
}
}
}
}
print ("Adjusting melee weapon main positions for " + mainMeleeWeaponHandTransformData.meleeWeaponName);
print ("Adjusting melee weapon mesh positions for type " + mainMeleeWeaponMeshTransformData.meleeWeaponName);
GKC_Utils.updateDirtyScene ("Adjusting melee weapon positions", gameObject);
}
public void cleanPositionsOnScriptable ()
{
objectTransformInfo newObjectTransformInfo = new objectTransformInfo ();
newObjectTransformInfo.objectPosition = Vector3.zero;
newObjectTransformInfo.objectRotation = Quaternion.identity;
mainMeleeWeaponHandTransformData.meleeWeaponName = "";
mainMeleeWeaponHandTransformData.mainObjectTransformInfo = newObjectTransformInfo;
mainMeleeWeaponMeshTransformData.meleeWeaponName = "";
mainMeleeWeaponMeshTransformData.mainObjectTransformInfo = newObjectTransformInfo;
}
public void toggleShowHandleGizmo ()
{
if (Application.isPlaying) {
editWeaponTransformValuesIngame = false;
// stopUpdateCoroutine ();
showGizmo = !showGizmo;
if (showGizmo) {
if (mainGrabbedObjectMeleeAttackSystem.carryingObject) {
currentWeaponObjectTransform = mainGrabbedObjectMeleeAttackSystem.getCurrentGrabbedObjectTransform ();
} else {
string meleeWeaponName = mainMeleeWeaponsGrabbedManager.getCurrentWeaponActiveName ();
if (meleeWeaponName != "") {
currentWeaponMeshGameObject = mainMeleeWeaponsGrabbedManager.getCurrentWeaponMeshByName (meleeWeaponName);
}
}
} else {
currentWeaponObjectTransform = null;
currentWeaponMeshGameObject = null;
}
}
}
public void updateGrabbedWeaponReferenceValuesOnAllWeaponInfoList ()
{
mainGrabbedObjectMeleeAttackSystem.updateGrabbedWeaponReferenceValuesOnAllWeaponInfoList ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 1f8ede88c14c0bb4b9bba5d7f22c3fdf
timeCreated: 1620069743
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/Combat System/Melee Combat System/meleeWeaponTransformInfoSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 78175cf36d067834088e5017c616f21f
timeCreated: 1598872264
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/Combat System/Melee Combat System/meleeWeaponsGrabbedManager.cs
uploadId: 814740

View File

@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class objectToFollowOnThrowMeleeWeapon : MonoBehaviour
{
public Transform mainObjectToFollow;
public bool componentedAddedTemporaly;
public Transform getMainObjectToFollow ()
{
if (mainObjectToFollow == null) {
mainObjectToFollow = transform;
}
return mainObjectToFollow;
}
public void setComponentedAddedTemporalyState (bool state)
{
componentedAddedTemporaly = state;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 513842cf9d0f301439a77bb53a3c3033
timeCreated: 1597116223
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/Combat System/Melee Combat System/objectToFollowOnThrowMeleeWeapon.cs
uploadId: 814740

View File

@@ -0,0 +1,270 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class searchMeleeSurfaceSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool searchSurfaceEnabled = true;
public LayerMask layerToCheck;
public float raycastDistance = 2;
public Transform playerTransform;
public string surfaceInfoOnMeleeAttackNameForSwingOnAir = "Swing On Air";
public float maxDistanceToHiddenSurfaces = 3;
[Space]
[Header ("Extraction Settings")]
[Space]
public bool checkForMaterialsZoneToExtract;
public float maxDetectionDistanceToExtract = 10;
public bool useMaxMaterialZonesToExtractAtSameTime;
public int maxMaterialZonesToExtractAtSameTime;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public GameObject lastSurfaceDetected;
[Space]
[Header ("Components")]
[Space]
public grabbedObjectMeleeAttackSystem mainGrabbedObjectMeleeAttackSystem;
RaycastHit hit;
Vector3 attackPosition;
Vector3 attackNormal;
List<materialsZoneSystem> materialsZoneSystemLocatedList = new List<materialsZoneSystem> ();
public void checkSurfaceDown ()
{
checkSurfaceType (true);
}
public void checkHiddenSurfacesDown ()
{
checkSurfaceType (false);
}
void checkSurfaceType (bool checkByRaycast)
{
lastSurfaceDetected = null;
attackPosition = Vector3.zero;
attackNormal = Vector3.zero;
if (checkByRaycast) {
Vector3 raycastPosition = playerTransform.position + playerTransform.up;
Vector3 raycastDirection = -playerTransform.up;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, layerToCheck)) {
if (hit.collider.transform == playerTransform) {
raycastPosition = hit.point;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, layerToCheck)) {
lastSurfaceDetected = hit.collider.gameObject;
attackPosition = hit.point;
attackNormal = hit.normal;
}
} else {
lastSurfaceDetected = hit.collider.gameObject;
attackPosition = hit.point;
attackNormal = hit.normal;
}
}
checkSurface ();
} else {
hiddenMeleeSurface[] hiddenMeleeSurfaceList = FindObjectsOfType<hiddenMeleeSurface> ();
foreach (hiddenMeleeSurface currentHiddenMeleeSurface in hiddenMeleeSurfaceList) {
if (currentHiddenMeleeSurface.isSurfaceEnabled ()) {
float currentDistance = GKC_Utils.distance (playerTransform.position, currentHiddenMeleeSurface.transform.position);
if (currentDistance < maxDistanceToHiddenSurfaces) {
lastSurfaceDetected = currentHiddenMeleeSurface.gameObject;
Vector3 raycastPosition = playerTransform.position + playerTransform.up;
Vector3 heading = lastSurfaceDetected.transform.position - raycastPosition;
float distance = heading.magnitude;
Vector3 raycastDirection = heading / distance;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, layerToCheck)) {
attackPosition = hit.point;
attackNormal = hit.normal;
checkSurface ();
}
}
}
}
}
if (checkForMaterialsZoneToExtract) {
materialsZoneSystemLocatedList.Clear ();
materialsZoneSystem[] temporalMaterialsZoneSystem = FindObjectsOfType<materialsZoneSystem> ();
foreach (materialsZoneSystem currentMaterialsZoneSystem in temporalMaterialsZoneSystem) {
if (currentMaterialsZoneSystem.isMaterialsZoneEnabled ()) {
bool addZoneResult = false;
float currentDistance = GKC_Utils.distance (playerTransform.position, currentMaterialsZoneSystem.transform.position);
if (currentDistance < maxDetectionDistanceToExtract) {
addZoneResult = true;
}
if (useMaxMaterialZonesToExtractAtSameTime) {
if (materialsZoneSystemLocatedList.Count >= maxMaterialZonesToExtractAtSameTime) {
addZoneResult = false;
}
}
if (addZoneResult) {
materialsZoneSystemLocatedList.Add (currentMaterialsZoneSystem);
}
}
}
if (materialsZoneSystemLocatedList.Count > 0) {
for (int i = 0; i < materialsZoneSystemLocatedList.Count; i++) {
if (materialsZoneSystemLocatedList [i].isCanBeExtractedByExternalElementsEnabled () &&
!materialsZoneSystemLocatedList [i].isMaterialsZoneEmpty ()) {
materialsZoneSystemLocatedList [i].checkMaterialZoneToExtractExternally ();
materialsZoneSystemLocatedList [i].setMaterialsZoneFullState (false);
}
}
}
}
}
public void checkSurface ()
{
if (!searchSurfaceEnabled) {
return;
}
if (!mainGrabbedObjectMeleeAttackSystem.grabbedObjectMeleeAttackActive) {
return;
}
string surfaceName = surfaceInfoOnMeleeAttackNameForSwingOnAir;
bool surfaceLocated = true;
if (lastSurfaceDetected != null) {
if (showDebugPrint) {
print ("checking surface " + lastSurfaceDetected.name);
}
meleeAttackSurfaceInfo currentMeleeAttackSurfaceInfo = lastSurfaceDetected.GetComponent<meleeAttackSurfaceInfo> ();
if (currentMeleeAttackSurfaceInfo != null) {
if (!currentMeleeAttackSurfaceInfo.isSurfaceEnabled ()) {
surfaceLocated = false;
} else {
surfaceName = currentMeleeAttackSurfaceInfo.getSurfaceName ();
grabPhysicalObjectMeleeAttackSystem currentGrabPhysicalObjectMeleeAttackSystem = mainGrabbedObjectMeleeAttackSystem.getCurrentGrabPhysicalObjectMeleeAttackSystem ();
if (currentMeleeAttackSurfaceInfo.useRemoteEventOnWeapon) {
remoteEventSystem currentRemoteEventSystem = currentGrabPhysicalObjectMeleeAttackSystem.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
if (showDebugPrint) {
print ("remote event on weapon detected");
}
for (int j = 0; j < currentMeleeAttackSurfaceInfo.remoteEventOnWeaponNameList.Count; j++) {
currentRemoteEventSystem.callRemoteEvent (currentMeleeAttackSurfaceInfo.remoteEventOnWeaponNameList [j]);
}
}
}
if (currentGrabPhysicalObjectMeleeAttackSystem.useRemoteEventOnSurfacesDetected) {
if (currentMeleeAttackSurfaceInfo.useRemoteEvent) {
remoteEventSystem currentRemoteEventSystem = lastSurfaceDetected.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
if (showDebugPrint) {
print ("remote event on object detected");
}
for (int j = 0; j < currentMeleeAttackSurfaceInfo.remoteEventNameList.Count; j++) {
string currentRemoteEventName = currentMeleeAttackSurfaceInfo.remoteEventNameList [j];
if (currentGrabPhysicalObjectMeleeAttackSystem.isRemoteEventIncluded (currentRemoteEventName)) {
currentRemoteEventSystem.callRemoteEvent (currentRemoteEventName);
}
}
}
}
}
currentMeleeAttackSurfaceInfo.checkEventOnSurfaceDetected ();
}
} else {
GameObject currentCharacter = applyDamage.getCharacterOrVehicle (lastSurfaceDetected);
if (currentCharacter != null) {
currentMeleeAttackSurfaceInfo = currentCharacter.GetComponent<meleeAttackSurfaceInfo> ();
if (currentMeleeAttackSurfaceInfo != null) {
if (!currentMeleeAttackSurfaceInfo.isSurfaceEnabled ()) {
surfaceLocated = false;
} else {
surfaceName = currentMeleeAttackSurfaceInfo.getSurfaceName ();
currentMeleeAttackSurfaceInfo.checkEventOnSurfaceDetected ();
}
}
} else {
surfaceLocated = false;
}
if (!surfaceLocated) {
return;
}
}
} else {
if (showDebugPrint) {
print ("SURFACE NOT FOUND BY TRIGGER!!!!!!!!!!");
}
}
bool ignoreBounceEvent = false;
bool ignoreSoundOnSurface = false;
mainGrabbedObjectMeleeAttackSystem.checkSurfaceFoundOnAttackToProcess (surfaceName, surfaceLocated, attackPosition, attackNormal, ignoreBounceEvent, ignoreSoundOnSurface);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6b99495366dbab04d953ab4380a5619e
timeCreated: 1651980044
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/Combat System/Melee Combat System/searchMeleeSurfaceSystem.cs
uploadId: 814740