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

View File

@@ -0,0 +1,304 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class arrowProjectile : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool rotateArrowWithGravity = true;
public float gravityForceRotationSpeed = 5;
public float extraRotationAmount;
public string movingObjectsTag = "moving";
public bool useGravityOnArrow = true;
public float gravityForceDownAmount = 5;
[Space]
[Header ("Adjust On Surface Settings")]
[Space]
public float adjustToSurfaceSpeed = 4;
public float offsetOnCharacterBodyParent = 0.15f;
public float attachProjectileToSurfaceOffset = 0.5f;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnArrowImpact;
public UnityEvent eventOnArrowImpact;
public UnityEvent eventToDropArrowPickupOnBounce;
public bool showDebugPrint;
[Space]
[Header ("Components")]
[Space]
public projectileSystem mainProjectileSystem;
public Rigidbody mainRigidbody;
public spawnObject mainSpawnObject;
Quaternion targetRotation;
bool applyArrowForces = true;
bool checkSurfaceTypeDetected;
List<bowSystem.arrowSurfaceTypeInfo> arrowSurfaceTypeInfoList = new List<bowSystem.arrowSurfaceTypeInfo> ();
Coroutine adjustArrowCoroutine;
float currentArrowDownForce = 1;
void OnEnable ()
{
resetProjectile ();
}
void FixedUpdate ()
{
if (!mainProjectileSystem.isProjectileUsed ()) {
if (showDebugPrint) {
print ("searching");
}
if (applyArrowForces) {
if (mainProjectileSystem.currentProjectileInfo.isSeeker || mainProjectileSystem.currentProjectileInfo.isHommingProjectile) {
applyArrowForces = false;
}
}
if (applyArrowForces) {
if (!useGravityOnArrow && gravityForceDownAmount > 0) {
mainRigidbody.AddForce (-Vector3.up * (gravityForceDownAmount * currentArrowDownForce * mainRigidbody.mass));
}
if (rotateArrowWithGravity) {
if (gravityForceRotationSpeed > 0) {
if (!mainRigidbody.isKinematic) {
targetRotation = Quaternion.LookRotation (mainRigidbody.linearVelocity - Vector3.up * extraRotationAmount);
transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, Time.deltaTime * gravityForceRotationSpeed * currentArrowDownForce);
}
}
}
}
}
if (mainProjectileSystem.disableProjectileMeshOnImpact) {
mainProjectileSystem.disableProjectileMeshOnImpact = false;
}
}
//when the bullet touchs a surface, then
public void checkObjectDetected (GameObject objectToDamage)
{
if (showDebugPrint) {
print ("detected " + objectToDamage.name);
}
mainProjectileSystem.setProjectileUsedState (true);
mainProjectileSystem.enableOrDisableMainTrailRenderer (false);
mainProjectileSystem.projectilePaused = true;
//set the bullet kinematic
mainRigidbody.isKinematic = true;
Rigidbody objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
bool isAttachedToCharacter = false;
bool surfaceDetectedIsDead = false;
if (applyDamage.objectCanBeDamaged (objectToDamage)) {
Vector3 projectilePosition = Vector3.zero;
if (attachProjectileToSurfaceOffset != 0) {
projectilePosition = transform.position + transform.forward * attachProjectileToSurfaceOffset;
}
isAttachedToCharacter = applyDamage.attachObjectToSurfaceFound (objectToDamage.transform, transform,
transform.position, true, projectilePosition);
surfaceDetectedIsDead = applyDamage.checkIfDead (objectToDamage);
}
mainRigidbody.useGravity = false;
mainRigidbody.isKinematic = true;
if (!surfaceDetectedIsDead && !isAttachedToCharacter && (objectToDamage.CompareTag (movingObjectsTag) || objectToDamageRigidbody != null)) {
applyDamage.checkParentToAssign (transform, objectToDamage.transform);
}
mainProjectileSystem.setIgnoreParentDestroyedState (true);
mainProjectileSystem.checkProjectilesParent ();
if (useEventOnArrowImpact) {
eventOnArrowImpact.Invoke ();
}
if (checkSurfaceTypeDetected) {
meleeAttackSurfaceInfo currentMeleeAttackSurfaceInfo = objectToDamage.GetComponent<meleeAttackSurfaceInfo> ();
if (currentMeleeAttackSurfaceInfo != null) {
bool surfaceLocated = false;
string surfaceName = currentMeleeAttackSurfaceInfo.getSurfaceName ();
for (int i = 0; i < arrowSurfaceTypeInfoList.Count; i++) {
if (!surfaceLocated && arrowSurfaceTypeInfoList [i].Name.Equals (surfaceName)) {
surfaceLocated = true;
if (arrowSurfaceTypeInfoList [i].isObstacle) {
if (arrowSurfaceTypeInfoList [i].arrowBounceOnSurface) {
if (arrowSurfaceTypeInfoList [i].dropArrowPickupOnBounce) {
gameObject.SetActive (false);
eventToDropArrowPickupOnBounce.Invoke ();
if (arrowSurfaceTypeInfoList [i].addExtraForceOnBounce) {
GameObject arrowPickup = mainSpawnObject.getLastObjectSpawned ();
if (arrowPickup != null) {
Rigidbody mainArrowRigidbody = arrowPickup.GetComponent<Rigidbody> ();
if (mainArrowRigidbody != null) {
mainArrowRigidbody.AddForce (-mainArrowRigidbody.transform.forward * arrowSurfaceTypeInfoList [i].extraForceOnBounce, ForceMode.Impulse);
float randomRightDirection = Random.Range (0, 1);
if (randomRightDirection == 0) {
randomRightDirection = -1;
}
mainArrowRigidbody.AddTorque (mainRigidbody.transform.right * 10 * randomRightDirection, ForceMode.Impulse);
mainArrowRigidbody.AddTorque (mainRigidbody.transform.up * 5 * (-1 * randomRightDirection), ForceMode.Impulse);
}
}
}
} else {
mainRigidbody.useGravity = true;
mainRigidbody.isKinematic = false;
mainProjectileSystem.enableOrDisableSecondaryMeshCollider (true);
}
}
}
}
}
}
}
playerComponentsManager mainPlayerComponentsManager = objectToDamage.GetComponent<playerComponentsManager> ();
if (mainPlayerComponentsManager != null) {
projectilesOnCharacterBodyManager mainProjectilesOnCharacterBodyManager = mainPlayerComponentsManager.getProjectilesOnCharacterBodyManager ();
if (mainProjectilesOnCharacterBodyManager != null) {
mainProjectilesOnCharacterBodyManager.addProjectileToCharacterBody (gameObject);
}
} else {
projectilesOnCharacterBodyManager mainProjectilesOnCharacterBodyManager = objectToDamage.GetComponent<projectilesOnCharacterBodyManager> ();
if (mainProjectilesOnCharacterBodyManager != null) {
mainProjectilesOnCharacterBodyManager.addProjectileToCharacterBody (gameObject);
}
}
if (isAttachedToCharacter) {
stopAdjustArrowToSurfaceDetectedCoroutine ();
adjustArrowCoroutine = StartCoroutine (adjustArrowToSurfaceDetectedCoroutine ());
}
mainProjectileSystem.currentProjectileInfo.isSeeker = false;
mainProjectileSystem.currentProjectileInfo.isHommingProjectile = false;
}
public void resetProjectile ()
{
applyArrowForces = true;
stopAdjustArrowToSurfaceDetectedCoroutine ();
transform.SetParent (null);
currentArrowDownForce = 1;
}
public void setNewArrowDownForce (float newValue)
{
currentArrowDownForce = newValue;
}
public void setArrowSurfaceTypeInfoList (List<bowSystem.arrowSurfaceTypeInfo> newArrowSurfaceTypeInfoList)
{
arrowSurfaceTypeInfoList = newArrowSurfaceTypeInfoList;
checkSurfaceTypeDetected = true;
}
public void disableCheckSurfaceTypeDetected ()
{
checkSurfaceTypeDetected = false;
}
void stopAdjustArrowToSurfaceDetectedCoroutine ()
{
if (adjustArrowCoroutine != null) {
StopCoroutine (adjustArrowCoroutine);
}
}
IEnumerator adjustArrowToSurfaceDetectedCoroutine ()
{
bool targetReached = false;
float t = 0;
float positionDifference = 0;
float movementTimer = 0;
Vector3 targetPosition = transform.position + transform.forward * offsetOnCharacterBodyParent;
Transform currentParent = transform.parent;
targetPosition = currentParent.InverseTransformPoint (targetPosition);
while (!targetReached) {
t += Time.deltaTime / adjustToSurfaceSpeed;
transform.localPosition = Vector3.Lerp (transform.localPosition, targetPosition, t);
positionDifference = GKC_Utils.distance (transform.localPosition, targetPosition);
movementTimer += Time.deltaTime;
if (positionDifference < 0.01f || movementTimer > 3) {
targetReached = true;
if (showDebugPrint) {
print ("target reached " + targetPosition);
}
}
yield return null;
}
}
}

View File

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

View File

@@ -0,0 +1,145 @@
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
using UnityEngine;
public class audioClipBip : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public float playTime;
public float playRate;
public float increasePitchSpeed;
public float increasePlayRateSpeed;
public bool playBipAtStart = true;
public bool playBipOnEnable;
public AudioClip soundClip;
public AudioElement soundClipAudioElement;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public float lastTimePlayed;
public float totalTimePlayed;
public bool audioPlayed;
public bool bipActivated;
public float originalPlayRate;
AudioSource mainAudioSource;
bool initialized;
void Start ()
{
if (playBipAtStart) {
intializeBip ();
}
}
void OnEnable ()
{
if (playBipOnEnable) {
intializeBip ();
}
}
void intializeBip ()
{
if (mainAudioSource == null) {
mainAudioSource = GetComponent<AudioSource> ();
}
if (mainAudioSource)
soundClipAudioElement.audioSource = mainAudioSource;
if (soundClip)
soundClipAudioElement.clip = soundClip;
if (originalPlayRate == 0) {
originalPlayRate = playRate;
}
totalTimePlayed = Time.time;
resetBip ();
if (showDebugPrint) {
print ("Initialize bip");
}
initialized = true;
}
void FixedUpdate ()
{
if (!audioPlayed && (bipActivated || playBipAtStart || playBipOnEnable)) {
if (Time.time > lastTimePlayed + playRate) {
mainAudioSource.pitch += increasePitchSpeed;
AudioPlayer.PlayOneShot (soundClipAudioElement, gameObject);
lastTimePlayed = Time.time;
playRate -= increasePlayRateSpeed;
if (playRate <= 0) {
playRate = 0.1f;
}
if (Time.time > (totalTimePlayed + playTime)) {
audioPlayed = true;
}
}
}
}
public void increasePlayTime (float extraTime)
{
if (!initialized || !playBipOnEnable) {
intializeBip ();
}
totalTimePlayed = Time.time;
playTime = extraTime;
bipActivated = true;
if (showDebugPrint) {
print ("Activate bip");
}
}
public void disableBip ()
{
bipActivated = false;
mainAudioSource.pitch = 1;
lastTimePlayed = 0;
playRate = originalPlayRate;
}
void resetBip ()
{
lastTimePlayed = 0;
playRate = originalPlayRate;
totalTimePlayed = Time.time;
audioPlayed = false;
bipActivated = false;
if (mainAudioSource != null) {
mainAudioSource.pitch = 1;
}
}
}

View File

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

View File

@@ -0,0 +1,168 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
public class dissolveProjectile : projectileSystem
{
[Header ("Main Settings")]
[Space]
public LayerMask layer;
[Space]
public bool useLayerMaskToIgnore;
public LayerMask layerMaskToIgnore;
[Space]
public float timeToDestroyObject = 0.9f;
public float dissolveSpeed = 1;
[Space]
[Header ("Shader Settings")]
[Space]
public Shader shaderToApply;
public Texture dissolveTexture;
public Color dissolveColor;
public float dissolveColorAlpha;
public string dissolveShaderFieldName = "_Amount";
public string dissolveShaderTextureFieldName = "_DissolveTexture";
public string dissolveShaderColorFieldName = "_DissolveColor";
public string dissolveShaderAlphaColorFieldName = "_DissolveColorAlpha";
[Space]
[Header ("Debug")]
[Space]
public bool objectToDissolveFound;
public float currentFadeValue = 1;
dissolveObject currentDissolveObject;
GameObject objectToDissolve;
void Update ()
{
if (objectToDissolveFound) {
currentFadeValue = currentDissolveObject.currentFadeValue;
if (currentFadeValue >= 1 || currentFadeValue > timeToDestroyObject) {
destroyObject ();
}
}
}
public void dissolveObject (GameObject objectToDissolve)
{
checkObjectDetected (objectToDissolve.GetComponent<Collider> ());
}
//when the bullet touchs a surface, then
public void checkObjectDetected (Collider col)
{
if (canActivateEffect (col)) {
if (currentProjectileInfo.impactAudioElement != null) {
currentProjectileInfo.impactAudioElement.audioSource = GetComponent<AudioSource> ();
AudioPlayer.PlayOneShot (currentProjectileInfo.impactAudioElement, gameObject);
}
setProjectileUsedState (true);
//set the bullet kinematic
objectToDamage = col.GetComponent<Collider> ().gameObject;
mainRigidbody.isKinematic = true;
if ((1 << col.gameObject.layer & layer.value) == 1 << col.gameObject.layer) {
if (objectToDamage.GetComponent<Rigidbody> ()) {
objectToDissolve = objectToDamage;
objectToDissolveFound = true;
}
if (useLayerMaskToIgnore) {
if ((1 << col.gameObject.layer & layerMaskToIgnore.value) == 1 << col.gameObject.layer) {
objectToDissolveFound = false;
setProjectileUsedState (false);
setIgnoreProjectileWithAbilityState (true);
checkSurface (col);
return;
}
}
bool isCharacter = applyDamage.isCharacter (objectToDamage);
if (isCharacter) {
objectToDissolve = applyDamage.getCharacter (objectToDamage);
objectToDissolveFound = true;
} else {
bool isVehicle = applyDamage.isVehicle (objectToDamage);
if (isVehicle) {
objectToDissolve = applyDamage.getVehicle (objectToDamage);
objectToDissolveFound = true;
}
}
if (objectToDissolveFound) {
currentDissolveObject = objectToDissolve.GetComponent<dissolveObject> ();
if (currentDissolveObject != null) {
destroyObject ();
return;
}
if (currentDissolveObject == null) {
currentDissolveObject = objectToDissolve.AddComponent<dissolveObject> ();
}
if (currentDissolveObject != null) {
currentDissolveObject.shaderToApply = shaderToApply;
currentDissolveObject.dissolveTexture = dissolveTexture;
currentDissolveObject.dissolveColor = dissolveColor;
currentDissolveObject.dissolveColorAlpha = dissolveColorAlpha;
currentDissolveObject.timeToDestroyObject = timeToDestroyObject;
currentDissolveObject.dissolveSpeed = dissolveSpeed;
currentDissolveObject.activateDissolve (objectToDissolve);
}
}
}
checkProjectilesParent ();
}
}
public void destroyObject ()
{
destroyProjectile ();
}
public override void resetProjectile ()
{
base.resetProjectile ();
objectToDissolveFound = false;
currentDissolveObject = null;
objectToDissolve = null;
}
}

View File

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

View File

@@ -0,0 +1,67 @@
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
using UnityEngine;
public class laserMine : projectileSystem
{
[Header ("Main Settings")]
[Space]
public GameObject laserBeam;
public bool disableByTime;
public float timeToDisable;
public bool infiniteEnergy;
public int numberOfContactsToDisable;
int currentNumberOfContacts;
public void increaseNumberOfContacts ()
{
if (!infiniteEnergy) {
currentNumberOfContacts++;
if (currentNumberOfContacts >= numberOfContactsToDisable) {
disableBullet (0);
projectilePaused = false;
}
}
}
public void checkObjectDetected (Collider col)
{
if (canActivateEffect (col)) {
if (currentProjectileInfo.impactAudioElement != null) {
currentProjectileInfo.impactAudioElement.audioSource = GetComponent<AudioSource> ();
AudioPlayer.PlayOneShot (currentProjectileInfo.impactAudioElement, gameObject);
}
setProjectileUsedState (true);
//set the bullet kinematic
objectToDamage = col.GetComponent<Collider> ().gameObject;
Vector3 previousVelocity = mainRigidbody.linearVelocity;
//print (objectToDamage.name);
mainRigidbody.isKinematic = true;
if (currentProjectileInfo.adhereToSurface) {
attachProjectileToSurface ();
}
if (disableByTime) {
disableBullet (timeToDisable);
} else {
projectilePaused = true;
}
}
}
public override void resetProjectile ()
{
base.resetProjectile ();
currentNumberOfContacts = 0;
}
}

View File

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

View File

@@ -0,0 +1,697 @@
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
using UnityEngine;
public class plasmaCutterProjectile : projectileSystem
{
[Header ("Main Settings")]
[Space]
public Material defaultSliceMaterial;
public float forceToApplyToCutPart;
public ForceMode forceMode;
public float forceRadius;
public bool cutMultipleTimesActive;
public bool useCutLimit;
public int cutLimit;
public bool activateRigidbodiesOnNewObjects = true;
[Space]
[Header ("Shatter Object Settings")]
[Space]
public bool shatterObjectActive;
public int shatterAmount;
public bool applyForceOnShatter;
public bool addSliceComponentToPieces = true;
[Space]
[Header ("Damage Settings")]
[Space]
public bool activateDamageOnSlice;
public float damageAmountToApplyOnSlice;
public bool ignoreShieldOnDamage = true;
public bool canActivateReactionSystemTemporally;
public int damageReactionID = -1;
public int damageTypeID = -1;
[Space]
[Header ("Physics Settings")]
[Space]
public bool updateLastObjectSpeed;
public bool applyForcesOnObjectsDetected;
public float addForceMultiplier;
public bool applyImpactForceToVehicles;
public float impactForceToVehiclesMultiplier;
public bool checkObjectLayerAndTagToApplyForces;
public LayerMask targetToApplyForceLayer;
public List<string> tagetToApplyForceTagList = new List<string> ();
[Space]
[Header ("Other Settings")]
[Space]
public float minDelayToSliceSameObject = 0.01f;
public Transform cutPositionTransform;
public Vector3 cutOverlapBoxSize = new Vector3 (5, 0.1f, 5);
public bool addRigidbodyToBothSlicedObjects;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public List<GameObject> objectsDetected = new List<GameObject> ();
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
public Color gizmoColor = Color.red;
[Space]
[Header ("Components")]
[Space]
public Transform cutDirectionTransform;
public Transform planeDefiner1;
public Transform planeDefiner2;
public Transform planeDefiner3;
surfaceToSlice currentSurfaceToSlice;
int currentNumberOfCuts;
List<GameObject> objectsToShatter;
bool objectShattered = false;
public void checkObjectDetected (Collider col)
{
if (canActivateEffect (col)) {
objectShattered = false;
if (currentProjectileInfo.impactAudioElement != null) {
currentProjectileInfo.impactAudioElement.audioSource = GetComponent<AudioSource> ();
AudioPlayer.PlayOneShot (currentProjectileInfo.impactAudioElement, gameObject);
}
Collider objectCollider = col.GetComponent<Collider> ();
objectToDamage = objectCollider.gameObject;
processObject (objectToDamage, objectCollider, cutPositionTransform.position);
if (!cutMultipleTimesActive || currentNumberOfCuts >= cutLimit) {
setProjectileUsedState (true);
mainRigidbody.isKinematic = true;
projectilePaused = true;
destroyProjectile ();
}
}
}
public void processObject (GameObject objectToCheck, Collider objectCollider, Vector3 slicePosition)
{
if (cutMultipleTimesActive) {
if (objectsDetected.Contains (objectToCheck)) {
return;
}
}
currentSurfaceToSlice = objectToCheck.GetComponent<surfaceToSlice> ();
if (currentSurfaceToSlice == null) {
currentSurfaceToSlice = sliceSystemUtils.getSurfaceToSlice (objectToCheck);
}
bool isVehicle = applyDamage.isVehicle (objectToCheck);
if (isVehicle) {
GameObject currentVehicle = applyDamage.getVehicle (objectToCheck);
if (currentVehicle != null) {
currentSurfaceToSlice = currentVehicle.GetComponent<surfaceToSlice> ();
if (currentSurfaceToSlice != null) {
objectToCheck = currentVehicle;
}
}
}
bool objectIsSliceSurfaceDisabled = false;
bool objectCanBeSliced = false;
if (showDebugPrint) {
print ("processing object " + objectToCheck.name);
}
bool ignoreRegularDamageIfCutSurfaceNotEnabled = false;
bool isIgnoreDamageIfSliceNotActivatedActive = false;
if (currentSurfaceToSlice != null) {
bool isCutSurfaceEnabled = currentSurfaceToSlice.isCutSurfaceEnabled ();
bool sliceCanBeActivated = currentSurfaceToSlice.sliceCanBeActivated (minDelayToSliceSameObject);
bool checkSliceDirectionResult = currentSurfaceToSlice.checkSliceDirectionResult (cutPositionTransform.right, cutPositionTransform.up);
isIgnoreDamageIfSliceNotActivatedActive = currentSurfaceToSlice.isIgnoreDamageIfSliceNotActivatedActive ();
if (showDebugPrint) {
print ("Surface cut enabled state " + isCutSurfaceEnabled +
" can activate slice " + sliceCanBeActivated);
}
if (isCutSurfaceEnabled && sliceCanBeActivated && checkSliceDirectionResult) {
Material crossSectionMaterial = currentSurfaceToSlice.getCrossSectionMaterial ();
if (crossSectionMaterial == null) {
crossSectionMaterial = defaultSliceMaterial;
}
sliceCurrentObject (objectToCheck, objectCollider, crossSectionMaterial, slicePosition);
objectCanBeSliced = true;
} else {
if (isVehicle && isCutSurfaceEnabled) {
objectCanBeSliced = true;
}
}
if (!isCutSurfaceEnabled) {
objectIsSliceSurfaceDisabled = true;
ignoreRegularDamageIfCutSurfaceNotEnabled = currentSurfaceToSlice.isIgnoreRegularDamageIfCutSurfaceNotEnabled ();
}
} else {
if (showDebugPrint) {
print ("Surface to slice not found on " + objectToCheck.name);
}
}
if (!objectCanBeSliced && !ignoreRegularDamageIfCutSurfaceNotEnabled) {
if (activateDamageOnSlice && !isIgnoreDamageIfSliceNotActivatedActive) {
Vector3 damagePosition = cutPositionTransform.position;
if (applyDamage.checkIfDead (objectToCheck)) {
damagePosition = objectToCheck.transform.position;
}
applyDamage.checkCanBeDamaged (gameObject, objectToCheck, damageAmountToApplyOnSlice, -cutPositionTransform.forward, damagePosition,
currentProjectileInfo.owner, true, true, ignoreShieldOnDamage, false, true, canActivateReactionSystemTemporally,
damageReactionID, damageTypeID);
}
if (applyForcesOnObjectsDetected && !objectIsSliceSurfaceDisabled) {
if (!checkObjectLayerAndTagToApplyForces ||
((1 << objectToCheck.layer & targetToApplyForceLayer.value) == 1 << objectToCheck.layer && tagetToApplyForceTagList.Contains (objectToCheck.tag))) {
checkForceToApplyOnObject (objectToCheck);
}
}
}
}
public void sliceCurrentObject (GameObject objectToCheck, Collider objectCollider, Material crossSectionMaterial, Vector3 slicePosition)
{
if (useCutLimit) {
currentNumberOfCuts++;
}
// slice the provided object using the transforms of this object
if (currentSurfaceToSlice.isObjectCharacter ()) {
// print ("character found " + objectToCheck.name + " is dead " + applyDamage.checkIfDead (objectToCheck));
if (applyDamage.getCharacterOrVehicle (objectToCheck) != null && !applyDamage.checkIfDead (objectToCheck)) {
processCharacter (objectToCheck);
return;
}
Rigidbody mainObject = objectToCheck.GetComponent<Rigidbody> ();
bool mainObjectHasRigidbody = mainObject != null;
Vector3 lastSpeed = Vector3.zero;
if (mainObjectHasRigidbody) {
lastSpeed = mainObject.linearVelocity;
}
currentSurfaceToSlice.checkEventBeforeSlice ();
currentSurfaceToSlice.getMainSimpleSliceSystem ().activateSlice (objectCollider, positionInWorldSpace,
normalInWorldSpace, slicePosition, updateLastObjectSpeed, lastSpeed);
currentSurfaceToSlice.checkEventOnCut ();
currentSurfaceToSlice.checkTimeBulletOnCut ();
} else {
if (shatterObjectActive) {
shatterObject (objectToCheck, crossSectionMaterial);
return;
}
// slice the provided object using the transforms of this object
bool objectSliced = false;
GameObject object1 = null;
GameObject object2 = null;
currentSurfaceToSlice.checkEventBeforeSlice ();
objectToCheck = currentSurfaceToSlice.getMainSurfaceToSlice ();
// slice the provided objectToCheck ect using the transforms of this object
sliceSystemUtils.sliceObject (transform.position, objectToCheck, cutDirectionTransform.up, crossSectionMaterial, ref objectSliced, ref object1, ref object2);
Vector3 objectPosition = objectToCheck.transform.position;
Quaternion objectRotation = objectToCheck.transform.rotation;
Transform objectParent = objectToCheck.transform.parent;
if (objectSliced) {
if (currentSurfaceToSlice.useParticlesOnSlice) {
Quaternion particlesRotation = Quaternion.LookRotation (positionInWorldSpace);
Instantiate (currentSurfaceToSlice.particlesOnSlicePrefab, slicePosition, particlesRotation);
}
currentSurfaceToSlice.checkEventOnCut ();
currentSurfaceToSlice.checkTimeBulletOnCut ();
Rigidbody mainObject = objectToCheck.GetComponent<Rigidbody> ();
bool mainObjectHasRigidbody = mainObject != null;
object1.transform.position = objectPosition;
object1.transform.rotation = objectRotation;
object2.transform.position = objectPosition;
object2.transform.rotation = objectRotation;
if (objectParent != null) {
object1.transform.SetParent (objectParent);
object2.transform.SetParent (objectParent);
}
surfaceToSlice newSurfaceToSlice1 = object1.AddComponent<surfaceToSlice> ();
surfaceToSlice newSurfaceToSlice2 = object2.AddComponent<surfaceToSlice> ();
currentSurfaceToSlice.copySurfaceInfo (newSurfaceToSlice1);
currentSurfaceToSlice.copySurfaceInfo (newSurfaceToSlice2);
newSurfaceToSlice1.checkDestroySlicedPartsAfterDelay ();
newSurfaceToSlice2.checkDestroySlicedPartsAfterDelay ();
float currentForceToApply = forceToApplyToCutPart;
ForceMode currentForceMode = forceMode;
if (currentSurfaceToSlice.useCustomForceMode) {
currentForceMode = currentSurfaceToSlice.customForceMode;
}
if (mainObjectHasRigidbody || activateRigidbodiesOnNewObjects) {
if (currentSurfaceToSlice.useCustomForceAmount) {
currentForceToApply = currentSurfaceToSlice.customForceAmount;
}
Rigidbody object1Rigidbody = object1.AddComponent<Rigidbody> ();
Rigidbody object2Rigidbody = object2.AddComponent<Rigidbody> ();
object2Rigidbody.AddExplosionForce (currentForceToApply, transform.position, 10, 1, currentForceMode);
object1Rigidbody.AddExplosionForce (currentForceToApply, transform.position, 10, 1, currentForceMode);
} else {
if (currentSurfaceToSlice.useCustomForceAmount) {
currentForceToApply = currentSurfaceToSlice.customForceAmount;
}
bool addRigidbodyToObject1 = false;
bool addRigidbodyToObject2 = false;
if (addRigidbodyToBothSlicedObjects) {
addRigidbodyToObject1 = true;
addRigidbodyToObject2 = true;
} else {
float distance1 = GKC_Utils.distance (objectToCheck.transform.position, object1.transform.position);
float distance2 = GKC_Utils.distance (objectToCheck.transform.position, object2.transform.position);
if (distance1 < distance2) {
addRigidbodyToObject1 = true;
} else {
addRigidbodyToObject2 = true;
}
}
if (addRigidbodyToObject1) {
Rigidbody object2Rigidbody = object2.AddComponent<Rigidbody> ();
object2Rigidbody.AddExplosionForce (currentForceToApply, transform.position, 10, 1, currentForceMode);
}
if (addRigidbodyToObject2) {
Rigidbody object1Rigidbody = object1.AddComponent<Rigidbody> ();
object1Rigidbody.AddExplosionForce (currentForceToApply, transform.position, 10, 1, currentForceMode);
}
}
if (currentSurfaceToSlice.useBoxCollider) {
object1.AddComponent<BoxCollider> ();
object2.AddComponent<BoxCollider> ();
} else {
MeshCollider object1Collider = object1.AddComponent<MeshCollider> ();
MeshCollider object2Collider = object2.AddComponent<MeshCollider> ();
object1Collider.convex = true;
object2Collider.convex = true;
}
if (currentSurfaceToSlice.setNewLayerOnCut) {
object1.layer = LayerMask.NameToLayer (currentSurfaceToSlice.newLayerOnCut);
object2.layer = LayerMask.NameToLayer (currentSurfaceToSlice.newLayerOnCut);
}
if (currentSurfaceToSlice.setNewTagOnCut) {
object1.tag = currentSurfaceToSlice.newTagOnCut;
object2.tag = currentSurfaceToSlice.newTagOnCut;
}
if (cutMultipleTimesActive) {
if (!objectsDetected.Contains (object1)) {
objectsDetected.Add (object1);
}
if (!objectsDetected.Contains (object2)) {
objectsDetected.Add (object2);
}
}
objectToCheck.SetActive (false);
}
}
}
void processCharacter (GameObject currentCharacter)
{
StartCoroutine (processCharacterCoroutine (currentCharacter));
}
List<Collider> colliders = new List<Collider> ();
IEnumerator processCharacterCoroutine (GameObject currentCharacter)
{
applyDamage.pushCharacterWithoutForceAndPauseGetUp (currentCharacter);
Vector3 slicePosition = cutPositionTransform.position;
Collider [] temporalHits = Physics.OverlapBox (slicePosition, cutOverlapBoxSize, cutDirectionTransform.rotation, currentProjectileInfo.targetToDamageLayer);
bool bodyPartFound = false;
if (temporalHits.Length > 0) {
bool ragdollCollidersFoundOnCharacter = false;
colliders = null;
ragdollActivator currentRagdollActivator = currentCharacter.GetComponent<ragdollActivator> ();
if (currentRagdollActivator != null) {
colliders = currentRagdollActivator.getBodyColliderList ();
if (colliders != null && colliders.Count > 0) {
ragdollCollidersFoundOnCharacter = true;
}
}
Collider colliderToCheck = null;
float minDistance = 1000;
for (int i = 0; i < temporalHits.Length; i++) {
Collider currentCollider = temporalHits [i];
bool canActivateSliceResult = false;
if (ragdollCollidersFoundOnCharacter) {
if (showDebugPrint) {
print ("ragoll detected");
}
if (colliders.Contains (currentCollider)) {
canActivateSliceResult = true;
if (showDebugPrint) {
print ("ragdoll part found");
}
}
} else {
canActivateSliceResult = true;
}
if (canActivateSliceResult) {
if (applyDamage.isCharacter (currentCollider.gameObject)) {
bodyPartFound = true;
float currentDistance = GKC_Utils.distance (slicePosition, currentCollider.transform.position);
if (currentDistance < minDistance) {
minDistance = currentDistance;
colliderToCheck = currentCollider;
}
}
}
}
if (bodyPartFound) {
if (currentCharacter != null) {
applyDamage.killCharacter (currentCharacter);
}
processObject (colliderToCheck.gameObject, colliderToCheck, slicePosition);
}
}
yield return null;
}
private Vector3 positionInWorldSpace
{
get
{
return (planeDefiner1.position + planeDefiner2.position + planeDefiner3.position) / 3f;
}
}
private Vector3 normalInWorldSpace
{
get
{
Vector3 t0 = planeDefiner1.position;
Vector3 t1 = planeDefiner2.position;
Vector3 t2 = planeDefiner3.position;
Vector3 vectorValue;
vectorValue.x = t0.y * (t1.z - t2.z) + t1.y * (t2.z - t0.z) + t2.y * (t0.z - t1.z);
vectorValue.y = t0.z * (t1.x - t2.x) + t1.z * (t2.x - t0.x) + t2.z * (t0.x - t1.x);
vectorValue.z = t0.x * (t1.y - t2.y) + t1.x * (t2.y - t0.y) + t2.x * (t0.y - t1.y);
return vectorValue;
}
}
public void checkForceToApplyOnObject (GameObject objectToDamage)
{
Rigidbody objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
Vector3 forceDirection = cutDirectionTransform.forward;
float forceAmount = addForceMultiplier;
float forceToVehiclesMultiplier = impactForceToVehiclesMultiplier;
if (applyImpactForceToVehicles) {
Rigidbody objectToDamageMainRigidbody = applyDamage.applyForce (objectToDamage);
if (objectToDamageMainRigidbody != null) {
Vector3 force = forceAmount * forceDirection;
bool isVehicle = applyDamage.isVehicle (objectToDamage);
if (isVehicle) {
force *= forceToVehiclesMultiplier;
}
objectToDamageMainRigidbody.AddForce (objectToDamageMainRigidbody.mass * force, forceMode);
}
} else {
if (applyDamage.canApplyForce (objectToDamage)) {
//print (objectToDamage.name);
Vector3 force = forceAmount * forceDirection;
if (objectToDamageRigidbody == null) {
objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
}
objectToDamageRigidbody.AddForce (objectToDamageRigidbody.mass * force, forceMode);
}
}
}
public override void setProjectileSpecialActionActiveState (bool state)
{
setShatterObjectActiveState (state);
}
//SHATTER FUNCTIONS
public void setShatterObjectActiveState (bool state)
{
shatterObjectActive = state;
}
public void shatterObject (GameObject objectToCheck, Material crossSectionMaterial)
{
if (objectShattered) {
return;
}
objectsToShatter = new List<GameObject> ();
if (objectToCheck.transform.parent != null) {
objectToCheck.transform.SetParent (null);
}
objectsToShatter.Add (objectToCheck);
for (int i = 0; i < shatterAmount; i++) {
randomShatter (crossSectionMaterial);
}
objectShattered = true;
}
public void randomShatter (Material crossSectionMaterial)
{
List<GameObject> adders = new List<GameObject> ();
List<GameObject> removals = new List<GameObject> ();
foreach (GameObject objectToShatter in objectsToShatter) {
GameObject [] shatters = randomShatterSingle (objectToShatter, crossSectionMaterial);
if (shatters != null) {
foreach (GameObject add in shatters) {
adders.Add (add);
}
removals.Add (objectToShatter);
}
}
foreach (GameObject rem in removals) {
objectsToShatter.Remove (rem);
}
foreach (GameObject add in adders) {
objectsToShatter.Add (add);
}
}
public GameObject [] randomShatterSingle (GameObject objectToShatter, Material crossSectionMaterial)
{
Vector3 shatterPosition = objectToShatter.transform.position;
GameObject [] shatters = sliceSystemUtils.shatterObject (objectToShatter, shatterPosition, crossSectionMaterial);
if (shatters != null && shatters.Length > 0) {
objectToShatter.SetActive (false);
Vector3 cutPosition = objectToShatter.transform.position;
// add rigidbodies and colliders
foreach (GameObject shatteredObject in shatters) {
shatteredObject.AddComponent<MeshCollider> ().convex = true;
if (applyForceOnShatter) {
Rigidbody currentObjectRigidbody = shatteredObject.AddComponent<Rigidbody> ();
currentObjectRigidbody.AddExplosionForce (forceToApplyToCutPart, cutPosition, 10, 1, forceMode);
} else {
shatteredObject.AddComponent<Rigidbody> ();
}
if (addSliceComponentToPieces) {
surfaceToSlice newSurfaceToSlice = shatteredObject.AddComponent<surfaceToSlice> ();
newSurfaceToSlice.setCrossSectionMaterial (crossSectionMaterial);
}
}
}
return shatters;
}
public override void resetProjectile ()
{
base.resetProjectile ();
currentNumberOfCuts = 0;
objectsDetected.Clear ();
}
#if UNITY_EDITOR
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
GKC_Utils.drawRectangleGizmo (cutPositionTransform.position, cutPositionTransform.rotation, Vector3.zero, cutOverlapBoxSize, gizmoColor);
}
}
#endif
}

View File

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

View File

@@ -0,0 +1,333 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using GameKitController.Audio;
[System.Serializable]
public class projectileInfo
{
public bool isHommingProjectile;
public bool isSeeker;
public bool targetOnScreenForSeeker = true;
public float waitTimeToSearchTarget;
public bool useRaycastCheckingOnRigidbody;
public float customRaycastCheckingRate;
public float customRaycastCheckingDistance = 0.1f;
public bool useRayCastShoot;
public bool useRaycastShootDelay;
public float raycastShootDelay;
public bool getDelayWithDistance;
public float delayWithDistanceSpeed;
public float maxDelayWithDistance;
public bool useFakeProjectileTrails;
public float projectileDamage;
public float projectileSpeed;
public float impactForceApplied;
public ForceMode forceMode;
public bool applyImpactForceToVehicles;
public float impactForceToVehiclesMultiplier;
public bool checkObjectsWithMultipleDamageReceiversEnabled = true;
public float forceMassMultiplier = 1;
public bool projectileWithAbility;
public AudioClip impactSoundEffect;
public AudioElement impactAudioElement;
public GameObject scorch;
public GameObject owner;
public GameObject projectileParticles;
public GameObject impactParticles;
public bool isExplosive;
public bool isImplosive;
public float explosionForce;
public float explosionRadius;
public bool useExplosionDelay;
public float explosionDelay;
public float explosionDamage;
public bool pushCharacters;
public bool canDamageProjectileOwner;
public bool applyExplosionForceToVehicles;
public float explosionForceToVehiclesMultiplier;
public bool searchClosestWeakSpot;
public bool killInOneShot;
public bool useDisableTimer;
public float noImpactDisableTimer;
public float impactDisableTimer;
public bool useCustomIgnoreTags;
public List<string> customTagsToIgnoreList = new List<string> ();
public LayerMask targetToDamageLayer;
public LayerMask targetForScorchLayer;
public float scorchRayCastDistance;
public int impactDecalIndex;
public bool launchProjectile;
public bool adhereToSurface;
public bool adhereToLimbs;
public bool ignoreSetProjectilePositionOnImpact;
public bool useGravityOnLaunch;
public bool useGraivtyOnImpact;
public bool breakThroughObjects;
public bool canBreakThroughArmorSurface;
public int breakThroughArmorSurfacePriorityValue = -1;
public bool infiniteNumberOfImpacts;
public int numberOfImpacts;
public bool canDamageSameObjectMultipleTimes;
public Vector3 forwardDirection;
public bool ignoreNewRotationOnProjectileImpact;
public bool stopBreakThroughObjectsOnLayer;
public LayerMask layerToStopBreahtThroughObjects;
public bool damageTargetOverTime;
public float damageOverTimeDelay;
public float damageOverTimeDuration;
public float damageOverTimeAmount;
public float damageOverTimeRate;
public bool damageOverTimeToDeath;
public bool removeDamageOverTimeState;
public bool sedateCharacters;
public float sedateDelay;
public bool useWeakSpotToReduceDelay;
public bool sedateUntilReceiveDamage;
public float sedateDuration;
public bool pushCharacter;
public float pushCharacterForce;
public float pushCharacterRagdollForce;
public bool setProjectileMeshRotationToFireRotation;
public bool useRemoteEventOnObjectsFound;
public List<string> remoteEventNameList = new List<string> ();
public bool useRemoteEventOnObjectsFoundOnExplosion;
public string remoteEventNameOnExplosion;
public bool ignoreShield;
public bool canActivateReactionSystemTemporally;
public int damageReactionID = -1;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
public bool projectilesPoolEnabled;
public int maxAmountOfPoolElementsOnWeapon;
public bool allowDamageForProjectileOwner;
public bool projectileCanBeDeflected = true;
public bool sliceObjectsDetected;
public LayerMask layerToSlice;
public bool useBodyPartsSliceList;
public List<string> bodyPartsSliceList = new List<string> ();
public float maxDistanceToBodyPart;
public bool randomSliceDirection;
public bool showSliceGizmo;
public bool activateRigidbodiesOnNewObjects = true;
public bool useGeneralProbabilitySliceObjects;
[Range (0, 100)] public float generalProbabilitySliceObjects;
public void InitializeAudioElements ()
{
if (impactSoundEffect != null) {
impactAudioElement.clip = impactSoundEffect;
}
}
public projectileInfo ()
{
}
public projectileInfo (projectileInfo newInfo)
{
isHommingProjectile = newInfo.isHommingProjectile;
isSeeker = newInfo.isSeeker;
targetOnScreenForSeeker = newInfo.targetOnScreenForSeeker;
waitTimeToSearchTarget = newInfo.waitTimeToSearchTarget;
useRaycastCheckingOnRigidbody = newInfo.useRaycastCheckingOnRigidbody;
customRaycastCheckingRate = newInfo.customRaycastCheckingRate;
customRaycastCheckingDistance = newInfo.customRaycastCheckingDistance;
useRayCastShoot = newInfo.useRayCastShoot;
useRaycastShootDelay = newInfo.useRaycastShootDelay;
raycastShootDelay = newInfo.raycastShootDelay;
getDelayWithDistance = newInfo.getDelayWithDistance;
delayWithDistanceSpeed = newInfo.delayWithDistanceSpeed;
maxDelayWithDistance = newInfo.maxDelayWithDistance;
useFakeProjectileTrails = newInfo.useFakeProjectileTrails;
projectileDamage = newInfo.projectileDamage;
projectileSpeed = newInfo.projectileSpeed;
impactForceApplied = newInfo.impactForceApplied;
forceMode = newInfo.forceMode;
applyImpactForceToVehicles = newInfo.applyImpactForceToVehicles;
impactForceToVehiclesMultiplier = newInfo.impactForceToVehiclesMultiplier;
forceMassMultiplier = newInfo.forceMassMultiplier;
checkObjectsWithMultipleDamageReceiversEnabled = newInfo.checkObjectsWithMultipleDamageReceiversEnabled;
projectileWithAbility = newInfo.projectileWithAbility;
impactSoundEffect = newInfo.impactSoundEffect;
impactAudioElement = newInfo.impactAudioElement;
scorch = newInfo.scorch;
owner = newInfo.owner;
projectileParticles = newInfo.projectileParticles;
impactParticles = newInfo.impactParticles;
isExplosive = newInfo.isExplosive;
isImplosive = newInfo.isImplosive;
explosionForce = newInfo.explosionForce;
explosionRadius = newInfo.explosionRadius;
useExplosionDelay = newInfo.useExplosionDelay;
explosionDelay = newInfo.explosionDelay;
explosionDamage = newInfo.explosionDamage;
pushCharacters = newInfo.pushCharacters;
canDamageProjectileOwner = newInfo.canDamageProjectileOwner;
applyExplosionForceToVehicles = newInfo.applyExplosionForceToVehicles;
explosionForceToVehiclesMultiplier = newInfo.explosionForceToVehiclesMultiplier;
searchClosestWeakSpot = newInfo.searchClosestWeakSpot;
killInOneShot = newInfo.killInOneShot;
useDisableTimer = newInfo.useDisableTimer;
noImpactDisableTimer = newInfo.noImpactDisableTimer;
impactDisableTimer = newInfo.impactDisableTimer;
useCustomIgnoreTags = newInfo.useCustomIgnoreTags;
customTagsToIgnoreList = newInfo.customTagsToIgnoreList;
targetToDamageLayer = newInfo.targetToDamageLayer;
targetForScorchLayer = newInfo.targetForScorchLayer;
scorchRayCastDistance = newInfo.scorchRayCastDistance;
impactDecalIndex = newInfo.impactDecalIndex;
launchProjectile = newInfo.launchProjectile;
adhereToSurface = newInfo.adhereToSurface;
adhereToLimbs = newInfo.adhereToLimbs;
ignoreSetProjectilePositionOnImpact = newInfo.ignoreSetProjectilePositionOnImpact;
useGravityOnLaunch = newInfo.useGravityOnLaunch;
useGraivtyOnImpact = newInfo.useGraivtyOnImpact;
breakThroughObjects = newInfo.breakThroughObjects;
canBreakThroughArmorSurface = newInfo.canBreakThroughArmorSurface;
breakThroughArmorSurfacePriorityValue = newInfo.breakThroughArmorSurfacePriorityValue;
infiniteNumberOfImpacts = newInfo.infiniteNumberOfImpacts;
numberOfImpacts = newInfo.numberOfImpacts;
canDamageSameObjectMultipleTimes = newInfo.canDamageSameObjectMultipleTimes;
forwardDirection = newInfo.forwardDirection;
ignoreNewRotationOnProjectileImpact = newInfo.ignoreNewRotationOnProjectileImpact;
stopBreakThroughObjectsOnLayer = newInfo.stopBreakThroughObjectsOnLayer;
layerToStopBreahtThroughObjects = newInfo.layerToStopBreahtThroughObjects;
damageTargetOverTime = newInfo.damageTargetOverTime;
damageOverTimeDelay = newInfo.damageOverTimeDelay;
damageOverTimeDuration = newInfo.damageOverTimeDuration;
damageOverTimeAmount = newInfo.damageOverTimeAmount;
damageOverTimeRate = newInfo.damageOverTimeRate;
damageOverTimeToDeath = newInfo.damageOverTimeToDeath;
removeDamageOverTimeState = newInfo.removeDamageOverTimeState;
sedateCharacters = newInfo.sedateCharacters;
sedateDelay = newInfo.sedateDelay;
useWeakSpotToReduceDelay = newInfo.useWeakSpotToReduceDelay;
sedateUntilReceiveDamage = newInfo.sedateUntilReceiveDamage;
sedateDuration = newInfo.sedateDuration;
pushCharacter = newInfo.pushCharacter;
pushCharacterForce = newInfo.pushCharacterForce;
pushCharacterRagdollForce = newInfo.pushCharacterRagdollForce;
setProjectileMeshRotationToFireRotation = newInfo.setProjectileMeshRotationToFireRotation;
useRemoteEventOnObjectsFound = newInfo.useRemoteEventOnObjectsFound;
remoteEventNameList = newInfo.remoteEventNameList;
useRemoteEventOnObjectsFoundOnExplosion = newInfo.useRemoteEventOnObjectsFoundOnExplosion;
remoteEventNameOnExplosion = newInfo.remoteEventNameOnExplosion;
ignoreShield = newInfo.ignoreShield;
canActivateReactionSystemTemporally = newInfo.canActivateReactionSystemTemporally;
damageReactionID = newInfo.damageReactionID;
damageTypeID = newInfo.damageTypeID;
damageCanBeBlocked = newInfo.damageCanBeBlocked;
projectilesPoolEnabled = newInfo.projectilesPoolEnabled;
maxAmountOfPoolElementsOnWeapon = newInfo.maxAmountOfPoolElementsOnWeapon;
allowDamageForProjectileOwner = newInfo.allowDamageForProjectileOwner;
projectileCanBeDeflected = newInfo.projectileCanBeDeflected;
sliceObjectsDetected = newInfo.sliceObjectsDetected;
layerToSlice = newInfo.layerToSlice;
useBodyPartsSliceList = newInfo.useBodyPartsSliceList;
bodyPartsSliceList = newInfo.bodyPartsSliceList;
maxDistanceToBodyPart = newInfo.maxDistanceToBodyPart;
randomSliceDirection = newInfo.randomSliceDirection;
showSliceGizmo = newInfo.showSliceGizmo;
activateRigidbodiesOnNewObjects = newInfo.activateRigidbodiesOnNewObjects;
useGeneralProbabilitySliceObjects = newInfo.useGeneralProbabilitySliceObjects;
generalProbabilitySliceObjects = newInfo.generalProbabilitySliceObjects;
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -0,0 +1,305 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
public class spearProjectile : projectileSystem
{
[Header ("Main Settings")]
[Space]
public LayerMask layer;
public float rayDistance = 1;
public float carryingRagdollSpeedMultiplier = 3;
public float maxProjectileSpeedClamp = 30;
public float capsuleCastRadius = 2;
public float delayToDropSpearIfNotSurfaceFound = 10;
[Space]
[Header ("Other Settings")]
[Space]
public bool useGeneralProbabilityToKillTargets;
[Range (0, 100)] public float generalProbabilityToKillTargets;
[Space]
[Header ("Debug")]
[Space]
public bool surfaceFound;
public bool carryingRagdoll;
[Space]
[Header ("Components")]
[Space]
public Transform raycastPositionTransform;
ragdollActivator currentRagdoll;
Vector3 previousVelocity;
Transform currentRagdollRootMotion;
bool firstSurfaceDetected;
Vector3 surfacePoint;
float extraDistanceRaycast = 5;
Collider[] hitColliders;
float lastTimeSpearCarryingRagdoll;
Coroutine updateCoroutine;
public void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
if (carryingRagdoll) {
if (surfaceFound) {
stopUpdateCoroutine ();
} else {
if (!firstSurfaceDetected) {
if (Physics.Linecast (currentRagdollRootMotion.position, currentRagdollRootMotion.position + transform.forward * extraDistanceRaycast, out hit, layer)) {
if (!hit.collider.GetComponent<Rigidbody> ()) {
firstSurfaceDetected = true;
surfacePoint = hit.point;
}
}
}
if (firstSurfaceDetected) {
float currentDistance = GKC_Utils.distance (currentRagdollRootMotion.position, surfacePoint);
if (currentDistance < rayDistance) {
surfaceFound = true;
}
if (currentDistance < extraDistanceRaycast) {
if (carryingRagdollSpeedMultiplier > 1) {
carryingRagdollSpeedMultiplier = 1;
}
}
}
if (Physics.Linecast (currentRagdollRootMotion.position, currentRagdollRootMotion.position + transform.forward * rayDistance, out hit, layer)) {
if (!hit.collider.GetComponent<Rigidbody> ()) {
surfaceFound = true;
}
}
Vector3 movementValue = transform.InverseTransformDirection (transform.forward) * (Mathf.Abs (previousVelocity.magnitude) * carryingRagdollSpeedMultiplier * Time.deltaTime);
if (maxProjectileSpeedClamp != 0) {
if (Mathf.Abs (movementValue.magnitude) > maxProjectileSpeedClamp) {
movementValue = Vector3.ClampMagnitude (movementValue, maxProjectileSpeedClamp);
}
}
transform.Translate (movementValue);
if (Time.time > lastTimeSpearCarryingRagdoll + delayToDropSpearIfNotSurfaceFound) {
surfaceFound = true;
mainRigidbody.isKinematic = false;
mainRigidbody.useGravity = true;
mainRigidbody.AddForce (transform.forward * Mathf.Abs (previousVelocity.magnitude) * carryingRagdollSpeedMultiplier);
}
}
}
}
//when the bullet touchs a surface, then
public void checkObjectDetected (Collider col)
{
if (canActivateEffect (col)) {
setProjectileUsedState (true);
enableOrDisableMainTrailRenderer (false);
//set the bullet kinematic
objectToDamage = col.GetComponent<Collider> ().gameObject;
setProjectileScorch ();
previousVelocity = mainRigidbody.linearVelocity;
mainRigidbody.isKinematic = true;
if (carryingRagdoll) {
return;
}
Rigidbody objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
Transform currentCharacter = null;
GameObject currentCharacterGameObject = applyDamage.getCharacterOrVehicle (objectToDamage);
if (currentCharacterGameObject != null) {
currentCharacter = currentCharacterGameObject.transform;
}
bool bodyPartOnRagdollDetected = false;
bool isCharacter = applyDamage.isCharacter (objectToDamage);
if (objectToDamageRigidbody != null) {
currentRagdoll = objectToDamage.GetComponent<ragdollActivator> ();
if (currentRagdoll == null) {
if (currentCharacter != null) {
currentRagdoll = currentCharacter.GetComponent<ragdollActivator> ();
bodyPartOnRagdollDetected = true;
}
}
if (currentRagdoll != null) {
Vector3 currentPosition = transform.position;
List<ragdollActivator.bodyPart> bones = currentRagdoll.getBodyPartsList ();
float distance = Mathf.Infinity;
int index = -1;
for (int i = 0; i < bones.Count; i++) {
float currentDistance = GKC_Utils.distance (bones [i].transform.position, currentPosition);
if (currentDistance < distance) {
distance = currentDistance;
index = i;
}
}
if (index != -1) {
if (applyDamage.checkIfDead (objectToDamage)) {
if (bodyPartOnRagdollDetected) {
transform.SetParent (objectToDamage.transform);
} else {
mainRigidbody.isKinematic = false;
mainRigidbody.linearVelocity = previousVelocity;
setProjectileUsedState (false);
currentRagdoll.setRagdollOnExternalParent (transform);
}
}
}
} else if (currentCharacter != null) {
isCharacter = false;
transform.SetParent (currentCharacter);
} else if (objectToDamage != null) {
transform.SetParent (objectToDamage.transform);
}
} else if (currentCharacter != null) {
transform.SetParent (currentCharacter);
isCharacter = false;
}
if (isCharacter) {
setIgnoreParentDestroyedState (true);
}
checkProjectilesParent ();
bool activateSliceResult = true;
if (!currentProjectileInfo.killInOneShot) {
activateSliceResult = false;
} else {
if (useGeneralProbabilityToKillTargets) {
float randomProbability = UnityEngine.Random.Range (0, 101);
if (randomProbability > generalProbabilityToKillTargets) {
activateSliceResult = false;
}
}
}
//add velocity if the touched object has rigidbody
if (activateSliceResult) {
applyDamage.killCharacter (gameObject, objectToDamage, -transform.forward, transform.position, currentProjectileInfo.owner, false);
if (!bodyPartOnRagdollDetected) {
if (currentRagdoll != null) {
projectilePaused = true;
transform.SetParent (null);
currentRagdollRootMotion = currentRagdoll.getRootMotion ();
currentRagdollRootMotion.SetParent (transform);
currentRagdollRootMotion.GetComponent<Rigidbody> ().isKinematic = true;
currentRagdoll.setRagdollOnExternalParent (transform);
setProjectileUsedState (false);
lastTimeSpearCarryingRagdoll = Time.time;
carryingRagdoll = true;
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
}
}
} else {
applyDamage.checkHealth (gameObject, objectToDamage, currentProjectileInfo.projectileDamage, -transform.forward,
transform.position, currentProjectileInfo.owner, false, true, currentProjectileInfo.ignoreShield, false, currentProjectileInfo.damageCanBeBlocked,
currentProjectileInfo.canActivateReactionSystemTemporally, currentProjectileInfo.damageReactionID, currentProjectileInfo.damageTypeID);
}
if (currentProjectileInfo.applyImpactForceToVehicles) {
Rigidbody objectToDamageMainRigidbody = applyDamage.applyForce (objectToDamage);
if (objectToDamageMainRigidbody != null) {
Vector3 force = transform.forward * currentProjectileInfo.impactForceApplied;
objectToDamageMainRigidbody.AddForce (force * objectToDamageMainRigidbody.mass, currentProjectileInfo.forceMode);
}
} else {
if (applyDamage.canApplyForce (objectToDamage)) {
Vector3 force = transform.forward * currentProjectileInfo.impactForceApplied;
objectToDamageRigidbody.AddForce (force * objectToDamageRigidbody.mass, currentProjectileInfo.forceMode);
}
}
}
}
public override void resetProjectile ()
{
base.resetProjectile ();
stopUpdateCoroutine ();
surfaceFound = false;
carryingRagdoll = false;
firstSurfaceDetected = false;
}
}

View File

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

View File

@@ -0,0 +1,96 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
public class taserProjectile : projectileSystem
{
[Header ("Main Settings")]
[Space]
public LayerMask layer;
[Space]
public bool useLayerMaskToIgnore;
public LayerMask layerMaskToIgnore;
[Space]
[Header ("Ragdoll Settings")]
[Space]
public float sedateDelay;
public bool useWeakSpotToReduceDelay;
public bool sedateUntilReceiveDamage;
public float sedateDuration;
public bool useActionSystemOnImpact;
public string actionSystemOnImpactName;
//when the bullet touchs a surface, then
public void checkObjectDetected (Collider col)
{
if (canActivateEffect (col)) {
if (currentProjectileInfo.impactAudioElement != null) {
currentProjectileInfo.impactAudioElement.audioSource = GetComponent<AudioSource> ();
AudioPlayer.PlayOneShot (currentProjectileInfo.impactAudioElement, gameObject);
}
setProjectileUsedState (true);
//set the bullet kinematic
objectToDamage = col.GetComponent<Collider> ().gameObject;
mainRigidbody.isKinematic = true;
if ((1 << col.gameObject.layer & layer.value) == 1 << col.gameObject.layer) {
if (useLayerMaskToIgnore) {
if ((1 << col.gameObject.layer & layerMaskToIgnore.value) == 1 << col.gameObject.layer) {
setProjectileUsedState (false);
setIgnoreProjectileWithAbilityState (true);
checkSurface (col);
return;
}
}
bool isCharacter = applyDamage.isCharacter (objectToDamage);
if (isCharacter) {
objectToDamage = applyDamage.getCharacter (objectToDamage);
applyDamage.sedateCharacter (objectToDamage, transform.position, sedateDelay, useWeakSpotToReduceDelay,
sedateUntilReceiveDamage, sedateDuration);
if (useActionSystemOnImpact) {
playerController currentPlayerController = objectToDamage.GetComponent<playerController> ();
if (currentPlayerController != null) {
currentPlayerController.activateCustomAction (actionSystemOnImpactName);
}
}
}
}
checkProjectilesParent ();
}
}
public void destroyObject ()
{
destroyProjectile ();
}
public override void resetProjectile ()
{
base.resetProjectile ();
}
}

View File

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