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

View File

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

View File

@@ -0,0 +1,104 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class changeGlobalGravityPower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled = true;
public LayerMask layer;
public bool changeGlobalGravityOnSecondaryPowerActive;
public bool changeGravityOnVehicles;
public bool changeGravityOnCharacter;
public bool pushNPCS;
[Space]
public string messageNameToSend = "pushCharacter";
public List<string> ignoreTagList = new List<string> ();
[Space]
[Header ("Components")]
[Space]
public otherPowers powersManager;
public Transform mainCameraTransform;
public gravitySystem gravityManager;
List<vehicleGravityControl> vehicleGravityControlList = new List<vehicleGravityControl> ();
RaycastHit hit;
public void activatePower ()
{
if (!powerEnabled) {
return;
}
//change level's gravity
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, Mathf.Infinity, layer)) {
if (!hit.collider.isTrigger && hit.collider.gameObject.GetComponent<Rigidbody> () == null) {
powersManager.createShootParticles ();
Physics.gravity = -hit.normal * 9.8f;
}
}
}
public void activateSecondaryPower ()
{
if (!powerEnabled) {
return;
}
//change level's gravity
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, Mathf.Infinity, layer)) {
if (!hit.collider.isTrigger && hit.collider.gameObject.GetComponent<Rigidbody> () == null) {
powersManager.createShootParticles ();
if (changeGlobalGravityOnSecondaryPowerActive) {
Physics.gravity = -hit.normal * 9.8f;
}
if (changeGravityOnCharacter) {
gravityManager.changeGravityDirectionDirectly (hit.normal, true);
}
if (changeGravityOnVehicles) {
vehicleGravityControl[] vehicleGravityControlListFound = FindObjectsOfType (typeof(vehicleGravityControl)) as vehicleGravityControl[];
for (int i = 0; i < vehicleGravityControlListFound.Length; i++) {
vehicleGravityControlList.Add (vehicleGravityControlListFound [i]);
}
for (int i = 0; i < vehicleGravityControlList.Count; i++) {
vehicleGravityControlList [i].rotateVehicleToLandSurface (hit.normal);
}
}
if (pushNPCS) {
playerController[] playerControllerListFound = FindObjectsOfType (typeof(playerController)) as playerController[];
for (int i = 0; i < playerControllerListFound.Length; i++) {
GameObject objectToPush = playerControllerListFound [i].gameObject;
if (!ignoreTagList.Contains (objectToPush.tag)) {
objectToPush.SendMessage (messageNameToSend, hit.normal, SendMessageOptions.DontRequireReceiver);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a937352593fe11446834cbb4010b0981
timeCreated: 1537152207
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/Powers/New Powers Behaviors/changeGlobalGravityPower.cs
uploadId: 814740

View File

@@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class changeObjectsPositionPower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled = true;
public LayerMask layer;
public LayerMask groundLayer;
[Space]
[Header ("Components")]
[Space]
public otherPowers powersManager;
public Transform mainCameraTransform;
public Transform playerTransform;
public Transform playerCameraTransform;
public gravitySystem gravityManager;
RaycastHit hit;
public void activatePower ()
{
if (!powerEnabled) {
return;
}
//this power changes the player's position with the object located with a ray when the player fires
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, Mathf.Infinity, layer)) {
if (!hit.collider.isTrigger) {
powersManager.createShootParticles ();
GameObject objectToMove = hit.collider.gameObject;
GameObject characterDetected = applyDamage.getCharacterOrVehicle (objectToMove);
if (characterDetected != null) {
objectToMove = characterDetected;
} else if (objectToMove.GetComponent<Rigidbody> () == null) {
return;
}
Vector3 newPlayerPosition = objectToMove.transform.position;
Vector3 newObjectPosition = playerTransform.position;
objectToMove.transform.position = Vector3.one * 100;
playerTransform.position = Vector3.zero;
if (Physics.Raycast (newPlayerPosition, -gravityManager.getCurrentNormal (), out hit, Mathf.Infinity, groundLayer)) {
newPlayerPosition = hit.point;
}
if (Physics.Raycast (newObjectPosition + playerTransform.up, -gravityManager.getCurrentNormal (), out hit, Mathf.Infinity, groundLayer)) {
newObjectPosition = hit.point + playerTransform.up;
}
objectToMove.transform.position = newObjectPosition;
playerTransform.position = newPlayerPosition;
playerCameraTransform.position = newPlayerPosition;
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 82139cad13caca347a23175270fa10a6
timeCreated: 1537152537
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/Powers/New Powers Behaviors/changeObjectsPositionPower.cs
uploadId: 814740

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class deviceToControlAtDistance : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool deviceToControlEnabled = true;
public GameObject deviceToControlGameObject;
public bool isDeviceToControlEnabled ()
{
return deviceToControlEnabled;
}
public GameObject getDeviceToControlGameObject ()
{
if (deviceToControlGameObject == null) {
deviceToControlGameObject = gameObject;
}
return deviceToControlGameObject;
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 672f04d04ccc59a4fb9c352b18cca641
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/Powers/New Powers Behaviors/deviceToControlAtDistance.cs
uploadId: 814740

View File

@@ -0,0 +1,345 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class joinObjectsPower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled = true;
public float joinObjectsForce = 40;
public float timeToRemoveJoin = 5;
public float extraForceOnVehicles = 1;
public bool useForceMode;
public ForceMode forceModeObject1;
public ForceMode forceModeObject2;
[Space]
[Header ("Debug")]
[Space]
public bool joinObjects;
public Transform joinObject1;
public Transform joinObject2;
public bool joinKinematic1;
public bool joinKinematic2;
[Space]
[Header ("Components")]
[Space]
public otherPowers powersManager;
public LayerMask layer;
public Transform mainCameraTransform;
public GameObject impactParticles;
public GameObject playerGameObject;
GameObject joinParticles1;
GameObject joinParticles2;
Vector3 joinDirection1;
Vector3 joinDirection2;
Vector3 joinPosition1;
Vector3 joinPosition2;
RaycastHit hit;
checkCollisionType currentCheckCollisionType1;
checkCollisionType currentCheckCollisionType2;
public Rigidbody currentRigidbody1;
public Rigidbody currentRigidbody2;
Vector3 heading1;
Vector3 heading2;
ParticleSystem particles1;
ParticleSystem particles2;
bool currentRigidbody1IsVehicle;
bool currentRigidbody2IsVehicle;
float lastTimeJoined;
Coroutine updateCoroutine;
public void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
//two objects are going to be attracted each other
if (joinObjects) {
if (Time.time > lastTimeJoined + timeToRemoveJoin) {
removeObjectsjoin ();
return;
}
//when both objects are stored, then it is checked if any of them have a rigidbody, to add force to them or not
//to this, it is used checkCollisionType, a script that allows to check any type of collision with collider or triggers and enter or exit
//and also can be configurated if the player want to check if the collision is with a particular object, in this case to both join object
//the collision to check is the opposite object
//once the script is added to every object, then the direction of the force to applied is calculated, and checking to which object can be applied
if (currentCheckCollisionType1 && currentCheckCollisionType2) {
//check if the player has not rigidbody, so the position to follow is the hit point
if (joinKinematic1) {
joinParticles2.transform.transform.LookAt (joinPosition1);
heading1 = joinObject2.position - joinPosition1;
} else {
//else, the position of the direction is the position of the object
//also a couple of particles are added
joinParticles2.transform.transform.LookAt (joinObject1.position);
heading1 = joinObject2.position - joinObject1.position;
}
joinDirection1 = heading1 / heading1.magnitude;
if (joinKinematic2) {
joinParticles1.transform.transform.LookAt (joinPosition2);
heading2 = joinObject1.position - joinPosition2;
} else {
joinParticles1.transform.transform.LookAt (joinObject2.position);
heading2 = joinObject1.position - joinObject2.position;
}
joinDirection2 = heading2 / heading2.magnitude;
if (!particles1) {
particles1 = joinParticles1.GetComponent<ParticleSystem> ();
}
if (particles1) {
var particles1Main = particles1.main;
particles1Main.startSpeed = GKC_Utils.distance (joinParticles1.transform.position, joinObject2.position) / 2;
}
if (!particles2) {
particles2 = joinParticles2.GetComponent<ParticleSystem> ();
}
if (particles2) {
var particles2Main = particles2.main;
particles2Main.startSpeed = GKC_Utils.distance (joinParticles2.transform.position, joinObject1.position) / 2;
}
//add force to the object, according to the direction of the other object
if (currentRigidbody1 && currentRigidbody2) {
addForce (-joinDirection2 * (joinObjectsForce * currentRigidbody1.mass), currentRigidbody1, forceModeObject1, currentRigidbody1IsVehicle);
addForce (-joinDirection1 * (joinObjectsForce * currentRigidbody2.mass), currentRigidbody2, forceModeObject2, currentRigidbody2IsVehicle);
} else if (currentRigidbody1 && !currentRigidbody2) {
addForce (-joinDirection2 * (joinObjectsForce * currentRigidbody1.mass), currentRigidbody1, forceModeObject1, currentRigidbody1IsVehicle);
} else if (!currentRigidbody1 && currentRigidbody2) {
addForce (-joinDirection1 * (joinObjectsForce * currentRigidbody2.mass), currentRigidbody2, forceModeObject2, currentRigidbody2IsVehicle);
} else {
//if both objects have not rigidbodies, then cancel the join
removeObjectsjoin ();
return;
}
//if the collision happens, the scripts are removed, and every object return to their normal situation
if (currentCheckCollisionType1.active || currentCheckCollisionType2.active) {
removeObjectsjoin ();
}
}
}
}
public void addForce (Vector3 direction, Rigidbody rigidbodyAffected, ForceMode forceModeToUsse, bool isVehicle)
{
if (isVehicle) {
direction *= extraForceOnVehicles;
}
if (useForceMode) {
rigidbodyAffected.AddForce (direction, forceModeToUsse);
} else {
rigidbodyAffected.AddForce (direction);
}
}
public void activatePower ()
{
if (!powerEnabled) {
return;
}
//this power allows the player to join two objects, and add force to both in the position of the other, checking if any of the objects
//has rigidbody or not, and when both objects collide, the join is disabled
if (joinObject1 == null || joinObject2 == null) {
powersManager.createShootParticles ();
//get every object using a raycast
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.forward, out hit, Mathf.Infinity, layer)) {
if (joinObject1 == null) {
joinObject1 = hit.collider.transform;
GameObject characterDetected = applyDamage.getCharacterOrVehicle (joinObject1.gameObject);
if (characterDetected != null) {
currentRigidbody1IsVehicle = applyDamage.isVehicle (characterDetected);
joinObject1 = characterDetected.transform;
}
if (!applyDamage.canApplyForce (joinObject1.gameObject)) {
joinKinematic1 = true;
joinPosition1 = hit.point;
}
joinParticles1 = (GameObject)Instantiate (impactParticles, hit.point, Quaternion.LookRotation (hit.normal));
joinParticles1.transform.SetParent (joinObject1);
joinParticles1.SetActive (true);
return;
}
if (joinObject2 == null && joinObject1 != hit.collider.transform && !hit.collider.transform.IsChildOf (joinObject1)) {
joinObject2 = hit.collider.transform;
GameObject characterDetected = applyDamage.getCharacterOrVehicle (joinObject2.gameObject);
if (characterDetected != null) {
currentRigidbody2IsVehicle = applyDamage.isVehicle (characterDetected);
joinObject2 = characterDetected.transform;
}
if (!applyDamage.canApplyForce (joinObject2.gameObject)) {
joinKinematic2 = true;
joinPosition2 = hit.point;
}
joinParticles2 = (GameObject)Instantiate (impactParticles, hit.point, Quaternion.LookRotation (hit.normal));
joinParticles2.transform.SetParent (joinObject2);
joinParticles2.SetActive (true);
}
}
}
if (joinObject1 != null && joinObject2 != null) {
lastTimeJoined = Time.time;
joinObjects = true;
currentCheckCollisionType1 = joinObject1.GetComponent<checkCollisionType> ();
currentCheckCollisionType2 = joinObject2.GetComponent<checkCollisionType> ();
currentRigidbody1 = applyDamage.applyForce (joinObject1.gameObject);
currentRigidbody2 = applyDamage.applyForce (joinObject2.gameObject);
if (currentCheckCollisionType1 == null && currentCheckCollisionType2 == null) {
joinObject1.gameObject.AddComponent<checkCollisionType> ();
joinObject2.gameObject.AddComponent<checkCollisionType> ();
currentCheckCollisionType1 = joinObject1.GetComponent<checkCollisionType> ();
currentCheckCollisionType2 = joinObject2.GetComponent<checkCollisionType> ();
currentCheckCollisionType1.onCollisionEnter = true;
currentCheckCollisionType2.onCollisionEnter = true;
currentCheckCollisionType1.objectToCollide = joinObject2.gameObject;
currentCheckCollisionType2.objectToCollide = joinObject1.gameObject;
if (currentRigidbody1 != null) {
currentRigidbody1.useGravity = false;
}
if (currentRigidbody2 != null) {
currentRigidbody2.useGravity = false;
}
//a join object can be used to be launched to an enemy, hurting him, to check this, it is used launchedObjects
if (!joinKinematic1) {
joinObject1.gameObject.AddComponent<launchedObjects> ().setCurrentPlayer (playerGameObject);
}
if (!joinKinematic2) {
joinObject2.gameObject.AddComponent<launchedObjects> ().setCurrentPlayer (playerGameObject);
}
}
stopUpdateCoroutine ();
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
}
}
//if none of the objects join have rigidbody, the join is cancelled
public void removeObjectsjoin ()
{
if (currentCheckCollisionType1 != null) {
Destroy (currentCheckCollisionType1);
}
if (currentCheckCollisionType2 != null) {
Destroy (currentCheckCollisionType2);
}
launchedObjects currentLaunchedObjects1 = joinObject1.GetComponent<launchedObjects> ();
if (currentLaunchedObjects1 != null) {
Destroy (currentLaunchedObjects1);
}
launchedObjects currentLaunchedObjects2 = joinObject2.GetComponent<launchedObjects> ();
if (currentLaunchedObjects2 != null) {
Destroy (currentLaunchedObjects2);
}
if (currentRigidbody1 != null) {
currentRigidbody1.useGravity = true;
currentRigidbody1 = null;
}
if (currentRigidbody2 != null) {
currentRigidbody2.useGravity = true;
currentRigidbody2 = null;
}
stopUpdateCoroutine ();
joinObjects = false;
joinObject1 = null;
joinObject2 = null;
joinKinematic1 = false;
joinKinematic2 = false;
Destroy (joinParticles1);
Destroy (joinParticles2);
particles1 = null;
particles2 = null;
currentRigidbody1IsVehicle = false;
currentRigidbody2IsVehicle = false;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: fb5409083c769c041a0677eae2530713
timeCreated: 1537147373
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/Powers/New Powers Behaviors/joinObjectsPower.cs
uploadId: 814740

View File

@@ -0,0 +1,379 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pushObjectsPower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled = true;
public bool pushObjectsFromCenterPosition;
public bool pushObjectsFromPlayerForwardDirection;
public LayerMask layer;
public List<string> ignoreTagList = new List<string> ();
public bool useMessageToPushCharactersFound = true;
public string messageNameToSend = "pushCharacter";
[Space]
[Header ("Damage Settings")]
[Space]
public bool applyDamageOnFoundObjects;
public float damageToApply;
public bool ignoreShield;
public bool canActivateReactionSystemTemporally;
public int damageReactionID = -1;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
[Space]
[Header ("Force Settings")]
[Space]
public float forceToApply = 4000;
public ForceMode forceMode;
public bool canApplyForceToVehicles = true;
public float applyForceToVehiclesMultiplier = 0.2f;
public bool applyForceToFoundObjectsOnlyOnce;
public bool checkRagdollsDetected;
public float ragdollMultiplierForce = 1;
[Space]
[Header ("Others Settings")]
[Space]
public bool useCustomPushCenterDistance;
public float pushCenterDistance;
public bool searchForObjectsOnUpdate;
public bool checkIfObjectInFrontOfPlayer;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEventOnObjectsFound;
public List<string> remoteEventNameList = new List<string> ();
[Space]
public bool callRemoteEventsBeforeApplyingForce;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool useOfPowerPaused;
[Space]
public List<Rigidbody> vehiclesRigidbodyFoundList = new List<Rigidbody> ();
public List<GameObject> gameObjectsFoundList = new List<GameObject> ();
[Space]
[Header ("Components")]
[Space]
public playerWeaponSystem mainPlayerWeaponSystem;
public GameObject playerGameObject;
public Transform centerPosition;
public otherPowers powersManager;
public Transform pushObjectsCenter;
public Transform mainCameraTransform;
Rigidbody objectToDamageMainRigidbody;
GameObject objectToPush;
Collider [] colliders;
Vector3 currentForceToApply;
float finalExplosionForce;
bool isVehicle;
bool componentsInitialized;
void Start ()
{
if (!useCustomPushCenterDistance) {
//get the distance from the empty object in the player to push objects, close to it
pushCenterDistance = GKC_Utils.distance (playerGameObject.transform.position, pushObjectsCenter.position);
}
if (pushObjectsFromCenterPosition) {
if (centerPosition == null) {
centerPosition = transform;
}
}
}
void Update ()
{
if (searchForObjectsOnUpdate) {
activatePower ();
}
}
public void activatePower ()
{
if (useOfPowerPaused) {
return;
}
if (!powerEnabled) {
return;
}
initializeComponents ();
vehiclesRigidbodyFoundList.Clear ();
if (powersManager != null) {
//the power number 2 is push objects, so any bullet is created
powersManager.createShootParticles ();
}
//if the power selected is push objects, check the objects close to pushObjectsCenter and add force to them in camera forward direction
colliders = Physics.OverlapSphere (pushObjectsCenter.position, pushCenterDistance, layer);
for (int i = 0; i < colliders.Length; i++) {
if (!colliders [i].isTrigger) {
objectToPush = colliders [i].gameObject;
checkObjectToApplyForce (objectToPush);
}
}
}
public void checkObjectToApplyForce (GameObject currentObject)
{
if (applyForceToFoundObjectsOnlyOnce) {
if (!gameObjectsFoundList.Contains (currentObject)) {
gameObjectsFoundList.Add (currentObject);
} else {
return;
}
}
if (!ignoreTagList.Contains (currentObject.tag) && currentObject != playerGameObject) {
if (playerGameObject == null) {
playerGameObject = gameObject;
}
if (checkIfObjectInFrontOfPlayer) {
float dot = Vector3.Dot (playerGameObject.transform.forward, (currentObject.transform.position - playerGameObject.transform.position).normalized);
if (dot < 0) {
return;
}
}
Vector3 pushDirection = Vector3.zero;
if (pushObjectsFromCenterPosition) {
pushDirection = (currentObject.transform.position - centerPosition.position).normalized;
} else {
if (pushObjectsFromPlayerForwardDirection) {
pushDirection = playerGameObject.transform.forward;
} else {
if (mainCameraTransform != null) {
pushDirection = mainCameraTransform.forward;
}
}
}
if (useMessageToPushCharactersFound && messageNameToSend != "") {
currentObject.SendMessage (messageNameToSend, pushDirection, SendMessageOptions.DontRequireReceiver);
}
if (applyDamageOnFoundObjects) {
applyDamage.checkHealth (playerGameObject, currentObject, damageToApply, playerGameObject.transform.forward, transform.position, playerGameObject,
false, true, ignoreShield, false, damageCanBeBlocked, canActivateReactionSystemTemporally, damageReactionID, damageTypeID);
}
objectToDamageMainRigidbody = applyDamage.applyForce (currentObject);
if (showDebugPrint) {
print ("object detected rigidbody result " + currentObject.name + " " + (objectToDamageMainRigidbody != null));
}
bool rigidbodyFound = false;
if (canApplyForceToVehicles) {
if (objectToDamageMainRigidbody != null) {
if (!vehiclesRigidbodyFoundList.Contains (objectToDamageMainRigidbody)) {
if (callRemoteEventsBeforeApplyingForce) {
checkRemoteEvent (objectToDamageMainRigidbody.gameObject);
}
isVehicle = applyDamage.isVehicle (currentObject);
finalExplosionForce = forceToApply;
if (isVehicle) {
finalExplosionForce *= applyForceToVehiclesMultiplier;
}
if (pushObjectsFromCenterPosition) {
currentForceToApply = (objectToDamageMainRigidbody.position - centerPosition.position).normalized * finalExplosionForce;
} else {
if (pushObjectsFromPlayerForwardDirection) {
currentForceToApply = playerGameObject.transform.forward * finalExplosionForce;
} else {
currentForceToApply = mainCameraTransform.TransformDirection (Vector3.forward) * finalExplosionForce;
}
}
if (checkRagdollsDetected) {
if (applyDamage.isRagdollActive (currentObject)) {
// print ("ragdoll found");
currentForceToApply *= ragdollMultiplierForce;
} else {
// print ("Not found");
}
}
if (currentForceToApply != Vector3.zero) {
objectToDamageMainRigidbody.AddForce (currentForceToApply * objectToDamageMainRigidbody.mass, forceMode);
if (showDebugPrint) {
print ("object to apply force " + objectToDamageMainRigidbody.name + " " + currentForceToApply);
}
}
if (isVehicle) {
vehiclesRigidbodyFoundList.Add (objectToDamageMainRigidbody);
}
if (!callRemoteEventsBeforeApplyingForce) {
checkRemoteEvent (objectToDamageMainRigidbody.gameObject);
}
rigidbodyFound = true;
}
}
} else {
if (applyDamage.canApplyForce (currentObject)) {
if (callRemoteEventsBeforeApplyingForce) {
checkRemoteEvent (currentObject);
}
if (pushObjectsFromCenterPosition) {
currentForceToApply = (objectToDamageMainRigidbody.position - centerPosition.position).normalized * forceToApply;
} else {
if (pushObjectsFromPlayerForwardDirection) {
currentForceToApply = playerGameObject.transform.forward * forceToApply;
} else {
currentForceToApply = mainCameraTransform.TransformDirection (Vector3.forward) * forceToApply;
}
}
if (currentForceToApply != Vector3.zero) {
objectToDamageMainRigidbody = currentObject.GetComponent<Rigidbody> ();
objectToDamageMainRigidbody.AddForce (currentForceToApply * objectToDamageMainRigidbody.mass, forceMode);
}
if (!callRemoteEventsBeforeApplyingForce) {
checkRemoteEvent (currentObject);
}
rigidbodyFound = true;
}
}
if (!rigidbodyFound) {
checkRemoteEvent (currentObject);
}
}
}
public void setPowerEnabledState (bool state)
{
powerEnabled = state;
initializeComponents ();
if (powerEnabled) {
gameObjectsFoundList.Clear ();
}
}
public void cleanGameObjectFoundList ()
{
gameObjectsFoundList.Clear ();
}
public void checkRemoteEvent (GameObject objectToCheck)
{
if (useRemoteEventOnObjectsFound) {
remoteEventSystem currentRemoteEventSystem = GKC_Utils.getRemoteEventSystemFromObject (objectToCheck, true);
if (currentRemoteEventSystem != null) {
int remoteEventNameListCount = remoteEventNameList.Count;
for (int i = 0; i < remoteEventNameListCount; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameList [i]);
}
}
}
}
public void setUseRemoteEventOnObjectsFoundState (bool state)
{
useRemoteEventOnObjectsFound = state;
}
public void setUseMessageToPushCharactersFoundState (bool state)
{
useMessageToPushCharactersFound = state;
}
public void setUseOfPowerPausedState (bool state)
{
useOfPowerPaused = state;
}
public void setNewPushCenterDistance (float newValue)
{
pushCenterDistance = newValue;
}
void initializeComponents ()
{
if (componentsInitialized) {
return;
}
if (mainPlayerWeaponSystem != null) {
playerGameObject = mainPlayerWeaponSystem.getPlayerWeaponsManger ().gameObject;
if (playerGameObject != null) {
playerComponentsManager mainPlayerComponentsManager = playerGameObject.GetComponent<playerComponentsManager> ();
if (mainPlayerComponentsManager != null) {
powersManager = mainPlayerComponentsManager.getOtherPowers ();
mainCameraTransform = mainPlayerComponentsManager.getPlayerCamera ().getCameraTransform ();
}
}
}
componentsInitialized = true;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 9dee34cafbc74a44a9f08ac62ebb7d59
timeCreated: 1537152992
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/Powers/New Powers Behaviors/pushObjectsPower.cs
uploadId: 814740

View File

@@ -0,0 +1,97 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class useDevicesAtDistancePower : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool powerEnabled;
public LayerMask layer;
public List<string> tagToCheck = new List<string> ();
public bool useInfiniteRaycastDistance = true;
public float raycastDistance = 100;
public bool ignoreDeviceToControlAtDistanceComponent;
[Space]
[Header ("Components")]
[Space]
public usingDevicesSystem usingDevicesManager;
public Transform mainCameraTransform;
public playerInputManager playerInput;
public Collider playerCollider;
public GameObject player;
RaycastHit hit;
GameObject currentDeviceToUse;
public void activatePower ()
{
if (!powerEnabled) {
return;
}
float currentRaycastDistance = raycastDistance;
if (useInfiniteRaycastDistance) {
currentRaycastDistance = Mathf.Infinity;
}
if (Physics.Raycast (mainCameraTransform.position, mainCameraTransform.TransformDirection (Vector3.forward), out hit, currentRaycastDistance, layer)) {
if (hit.collider.isTrigger && tagToCheck.Contains (hit.collider.tag)) {
currentDeviceToUse = hit.collider.gameObject;
if (!ignoreDeviceToControlAtDistanceComponent) {
deviceToControlAtDistance currentDeviceToControlAtDistance = currentDeviceToUse.GetComponent<deviceToControlAtDistance> ();
if (currentDeviceToControlAtDistance != null) {
if (!currentDeviceToControlAtDistance.isDeviceToControlEnabled ()) {
return;
}
currentDeviceToUse = currentDeviceToControlAtDistance.getDeviceToControlGameObject ();
}
}
electronicDevice currentElectronicDevice = currentDeviceToUse.GetComponent<electronicDevice> ();
if (currentElectronicDevice != null) {
currentElectronicDevice.checkTriggerInfo (playerCollider, true);
usingDevicesManager.useCurrentDevice (currentDeviceToUse);
usingDevicesManager.setObjectToRemoveAferStopUse (currentDeviceToUse);
}
simpleSwitch currentSimpleSwitch = currentDeviceToUse.GetComponent<simpleSwitch> ();
if (currentSimpleSwitch != null) {
usingDevicesManager.useCurrentDevice (currentDeviceToUse);
usingDevicesManager.setObjectToRemoveAferStopUse (currentDeviceToUse);
}
inventoryObject currentInventoryObject = currentDeviceToUse.GetComponent<inventoryObject> ();
if (currentInventoryObject != null) {
pickUpObject currentPickupObject = currentDeviceToUse.GetComponentInParent<pickUpObject> ();
if (currentPickupObject != null) {
currentPickupObject.checkTriggerInfo (playerCollider);
usingDevicesManager.useCurrentDevice (currentDeviceToUse);
usingDevicesManager.setObjectToRemoveAferStopUse (currentDeviceToUse);
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 1324e98dff7d8ad46b269e93cee9941e
timeCreated: 1537317271
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/Powers/New Powers Behaviors/useDevicesAtDistancePower.cs
uploadId: 814740

View File

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

View File

@@ -0,0 +1,70 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
public class brainwashAIProjectile : projectileSystem
{
[Header ("Custom Settings")]
[Space]
public string factionToConfigure = "Friend Soldiers";
public bool setNewName;
public string newName;
public bool AIIsFriend;
public string newTag = "friend";
public bool followPartnerOnTriggerEnabled = true;
public bool setPlayerAsPartner = true;
public bool useRemoteEvents;
//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);
objectToDamage = col.GetComponent<Collider> ().gameObject;
mainRigidbody.isKinematic = true;
Rigidbody objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
Transform currentCharacter = null;
GameObject currentCharacterGameObject = applyDamage.getCharacterOrVehicle (objectToDamage);
if (currentCharacterGameObject != null) {
currentCharacter = currentCharacterGameObject.transform;
}
if (objectToDamageRigidbody != null) {
if (currentCharacter != null) {
GKC_Utils.activateBrainWashOnCharacter (currentCharacter.gameObject, factionToConfigure, newTag, setNewName, newName,
followPartnerOnTriggerEnabled, setPlayerAsPartner, AIIsFriend,
currentProjectileInfo.owner, useRemoteEvents, currentProjectileInfo.remoteEventNameList);
}
}
disableBullet (currentProjectileInfo.impactDisableTimer);
}
}
public override void resetProjectile ()
{
base.resetProjectile ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 3bb53fc348906ac46831436b1831e807
timeCreated: 1614339086
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/Powers/New Projectiles Behaviors/brainwashAIProjectile.cs
uploadId: 814740

View File

@@ -0,0 +1,62 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
public class removeGravityFromCharactersProjectile : projectileSystem
{
[Header ("Custom Settings")]
[Space]
public string remoteEventName = "Remove Gravity From Character";
public applyEffectOnArea mainAreaEffectOnArea;
//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);
mainAreaEffectOnArea.gameObject.SetActive (true);
mainAreaEffectOnArea.setEffectActiveState (true);
mainRigidbody.isKinematic = true;
creatImpactParticles ();
disableBullet (currentProjectileInfo.impactDisableTimer);
}
}
public override void resetProjectile ()
{
base.resetProjectile ();
mainAreaEffectOnArea.gameObject.SetActive (false);
mainAreaEffectOnArea.setEffectActiveState (false);
}
public void applyEffect (GameObject objectToAffect)
{
if (objectToAffect != null) {
playerComponentsManager currentplayerComponentsManager = objectToAffect.GetComponent<playerComponentsManager> ();
if (currentplayerComponentsManager != null) {
remoteEventSystem currentRemoteEventSystem = currentplayerComponentsManager.getRemoteEventSystem ();
if (currentRemoteEventSystem != null) {
currentRemoteEventSystem.callRemoteEvent (remoteEventName);
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 88488d3d7a4d62543998201bd8c6e668
timeCreated: 1614623613
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/Powers/New Projectiles Behaviors/removeGravityFromCharactersProjectile.cs
uploadId: 814740

View File

@@ -0,0 +1,374 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
public class blackHoleProjectile : projectileSystem
{
[Header ("Main Settings")]
[Space]
public float getObjectsRadius = 40;
public float blackHoleAttractionForce = 150;
public GameObject openingBlackHoleParticles;
public GameObject closingBlackHoleParticles;
public List<string> tagToLocate = new List<string> ();
public List<GameObject> elementsToAbsorve = new List<GameObject> ();
public List<Rigidbody> rigidbodiesToAbsorve = new List<Rigidbody> ();
public float minDistanceToStopAttraction = 4;
public float damageRate = 0.5f;
[Space]
[Header ("Black Hole Duration Settings")]
[Space]
public float stopBulletTimer = 1;
public float blackHoleDuration = 10;
public float timeToOpenBlackHoleAfterShoot = 0.5f;
public float timeToActivateOpenParticles = 3.5f;
public float timeToActivateCloseParticles = 4;
public float timeToCloseBlackHole = 0.5f;
public float timeToDestroyParticles = 10;
bool abilityActivated;
bool stopBullet;
bool openingBlackHoleParticlesCreated;
bool closingBlackHoleParticlesCreated;
bool openParticlesActivated;
Vector3 blackHoleDirection;
Vector3 blackHoleScale;
float lastTimeDamage;
bool canDamage;
Vector3 currentPosition;
List<Collider> colliders = new List<Collider> ();
Rigidbody currentRigidbody;
float lastTimeProjectileFired;
float lastTimeBlackHoleActive;
bool objectsStored;
bool blackHoleActivated;
bool blackHoleCloseActivated;
void Update ()
{
if (abilityActivated) {
currentPosition = transform.position;
//black hole
//when the bullet touchs a surface, or the timer reachs the limit, set the bullet kinematic, and activate the black hole
if (blackHoleActivated) {
if (Time.time > lastTimeBlackHoleActive + timeToOpenBlackHoleAfterShoot) {
if (!openingBlackHoleParticlesCreated) {
openingBlackHoleParticles = createParticles (openingBlackHoleParticles, timeToDestroyParticles);
openingBlackHoleParticlesCreated = true;
}
//get all the objects inside a radius
if (!objectsStored) {
if (colliders.Count > 0) {
colliders.Clear ();
}
colliders.AddRange (Physics.OverlapSphere (currentPosition, getObjectsRadius, currentProjectileInfo.targetToDamageLayer));
foreach (Collider hit in colliders) {
if (applyDamage.checkIfCharacterCanBePushedOnExplosions (hit.gameObject)) {
Vector3 explosionDirection = currentPosition - hit.gameObject.transform.position;
explosionDirection = explosionDirection / explosionDirection.magnitude;
applyDamage.pushRagdoll (hit.gameObject, explosionDirection);
}
}
if (colliders.Count > 0) {
objectsStored = true;
}
if (rigidbodiesToAbsorve.Count > 0) {
rigidbodiesToAbsorve.Clear ();
}
if (elementsToAbsorve.Count > 0) {
elementsToAbsorve.Clear ();
}
colliders.Clear ();
colliders.AddRange (Physics.OverlapSphere (currentPosition, getObjectsRadius, currentProjectileInfo.targetToDamageLayer));
foreach (Collider hit in colliders) {
if (hit != null) {
GameObject currentGameObject = hit.gameObject;
bool isCharacterOrVehicle = false;
bool isRigidbody = false;
GameObject target = applyDamage.getCharacterOrVehicle (currentGameObject);
if (target != null) {
currentGameObject = target;
isCharacterOrVehicle = true;
} else {
if (applyDamage.canApplyForce (currentGameObject)) {
isRigidbody = true;
}
}
if (!elementsToAbsorve.Contains (currentGameObject) && tagToLocate.Contains (currentGameObject.tag) && (isCharacterOrVehicle || isRigidbody)) {
currentRigidbody = currentGameObject.GetComponent<Rigidbody> ();
if (currentRigidbody != null) {
currentRigidbody.isKinematic = false;
}
//set the kinematic rigigbody of the enemies to false, to attract them
currentGameObject.SendMessage ("pauseAI", true, SendMessageOptions.DontRequireReceiver);
elementsToAbsorve.Add (currentGameObject);
rigidbodiesToAbsorve.Add (currentRigidbody);
}
}
}
}
if (objectsStored && !blackHoleCloseActivated) {
for (int i = 0; i < rigidbodiesToAbsorve.Count; i++) {
currentRigidbody = rigidbodiesToAbsorve [i];
if (currentRigidbody != null) {
if (GKC_Utils.distance (currentPosition, currentRigidbody.position) < minDistanceToStopAttraction) {
currentRigidbody.linearVelocity = Vector3.zero;
currentRigidbody.useGravity = false;
} else {
blackHoleDirection = currentPosition - currentRigidbody.position;
blackHoleScale = Vector3.Scale (blackHoleDirection.normalized, gameObject.transform.localScale);
currentRigidbody.AddForce (blackHoleScale * (blackHoleAttractionForce * currentRigidbody.mass), currentProjectileInfo.forceMode);
}
if (canDamage) {
applyDamage.checkHealth (gameObject, elementsToAbsorve [i], currentProjectileInfo.projectileDamage, -transform.forward,
currentRigidbody.position, currentProjectileInfo.owner, true, currentProjectileInfo.searchClosestWeakSpot, currentProjectileInfo.ignoreShield, false,
currentProjectileInfo.damageCanBeBlocked, false, -1, currentProjectileInfo.damageTypeID);
}
}
}
if (canDamage) {
canDamage = false;
}
if (Time.time > damageRate + lastTimeDamage) {
lastTimeDamage = Time.time;
canDamage = true;
}
}
}
//activate the particles, they are activated and deactivated according to the timer value
if (Time.time > lastTimeBlackHoleActive + timeToActivateCloseParticles) {
if (!closingBlackHoleParticlesCreated) {
closingBlackHoleParticles = createParticles (closingBlackHoleParticles, timeToDestroyParticles);
closingBlackHoleParticlesCreated = true;
if (openingBlackHoleParticles.activeSelf) {
openingBlackHoleParticles.SetActive (false);
}
}
}
if (!openParticlesActivated) {
if (Time.time > lastTimeBlackHoleActive + timeToActivateOpenParticles && openingBlackHoleParticles) {
if (!openingBlackHoleParticles.activeSelf) {
openingBlackHoleParticles.SetActive (true);
}
openParticlesActivated = true;
}
}
//when the time is finishing, apply an explosion force to all the objects inside the black hole, and make an extra damage to all of them
if (!blackHoleCloseActivated && Time.time > lastTimeBlackHoleActive + timeToCloseBlackHole && blackHoleActivated) {
for (int i = 0; i < rigidbodiesToAbsorve.Count; i++) {
currentRigidbody = rigidbodiesToAbsorve [i];
if (currentRigidbody != null) {
currentRigidbody.useGravity = true;
currentRigidbody.AddExplosionForce (currentProjectileInfo.explosionForce * currentRigidbody.mass, currentPosition, currentProjectileInfo.explosionRadius, 3);
currentRigidbody.SendMessage ("pauseAI", false, SendMessageOptions.DontRequireReceiver);
applyDamage.checkHealth (gameObject, currentRigidbody.gameObject, currentProjectileInfo.projectileDamage * 10, -transform.forward,
currentRigidbody.position, currentProjectileInfo.owner, false, false, currentProjectileInfo.ignoreShield, false,
currentProjectileInfo.damageCanBeBlocked, false, -1, currentProjectileInfo.damageTypeID);
}
}
blackHoleCloseActivated = true;
}
//destroy the black hole bullet
if (Time.time > lastTimeBlackHoleActive + blackHoleDuration) {
Destroy (gameObject);
}
}
//when a black hole bullet is shooted, if it does not touch anything in a certain amount of time, set it kinematic and open the black hole
if (stopBullet) {
if (lastTimeProjectileFired == 0) {
lastTimeProjectileFired = Time.time;
}
if (Time.time > lastTimeProjectileFired + stopBulletTimer) {
mainRigidbody.isKinematic = true;
mainRigidbody.useGravity = false;
stopBullet = false;
lastTimeBlackHoleActive = Time.time;
blackHoleActivated = true;
}
}
}
}
public void dropBlackHoleObjects ()
{
for (int i = 0; i < rigidbodiesToAbsorve.Count; i++) {
currentRigidbody = rigidbodiesToAbsorve [i];
if (currentRigidbody != null) {
if (currentRigidbody != null) {
currentRigidbody.useGravity = true;
currentRigidbody.AddExplosionForce (currentProjectileInfo.explosionForce, transform.position, currentProjectileInfo.explosionRadius, 3);
}
}
}
if (openingBlackHoleParticles) {
openingBlackHoleParticles.SetActive (false);
}
}
GameObject createParticles (GameObject particles, float timeToDestroy)
{
GameObject newParticles = (GameObject)Instantiate (particles, transform.position, transform.rotation);
//newParticles.transform.SetParent (transform.parent);
newParticles.AddComponent<destroyGameObject> ().setTimer (timeToDestroy);
return newParticles;
}
//when the bullet touchs a surface, then
void OnTriggerEnter (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;
if (!objectToDamage.GetComponent<Rigidbody> () && stopBullet) {
mainRigidbody.isKinematic = true;
}
}
}
//set these bools when the bullet is a black hole
public void stopBlackHole ()
{
stopBullet = true;
}
public void activateProjectileAbility ()
{
abilityActivated = true;
//if the bullet type is a black hole, remove any other black hole in the scene and set the parameters in the bullet script
//the bullet with the black hole has activated the option useGravity in its rigidbody
blackHoleProjectile[] blackHoleList = FindObjectsOfType<blackHoleProjectile> ();
foreach (blackHoleProjectile blackHole in blackHoleList) {
if (blackHole.gameObject != gameObject) {
blackHole.dropBlackHoleObjects ();
Destroy (blackHole.gameObject);
}
}
mainRigidbody.useGravity = true;
stopBlackHole ();
GetComponent<SphereCollider> ().radius *= 5;
TrailRenderer currentTrailRenderer = GetComponent<TrailRenderer> ();
currentTrailRenderer.startWidth = 4;
currentTrailRenderer.time = 2;
currentTrailRenderer.endWidth = 3;
}
public override void resetProjectile ()
{
base.resetProjectile ();
abilityActivated = false;
stopBullet = false;
openingBlackHoleParticlesCreated = false;
closingBlackHoleParticlesCreated = false;
openParticlesActivated = false;
lastTimeDamage = 0;
canDamage = false;
lastTimeProjectileFired = 0;
lastTimeBlackHoleActive = 0;
objectsStored = false;
blackHoleActivated = false;
blackHoleCloseActivated = false;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 79129511ac8a3194ea91a9fd2a4feaef
timeCreated: 1503840039
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/Powers/blackHoleProjectile.cs
uploadId: 814740

View File

@@ -0,0 +1,359 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class gravityBootsSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool gravityBootsEnabled;
public float gravityBootsRotationSpeed = 10;
public bool useExtraRaycastDetectionOnGravityBootsEnabled = true;
public bool avoidRigidbodiesOnRaycastEnabled;
public bool rotateToOriginalNormalOnAirEnabled = true;
public bool stopGravityAdherenceWhenStopRun = true;
[Space]
public bool allowCircumnavigationOnAllSurfacesWithIgnoretagList;
public List<string> circumnavigationOnAllSurfacesWithIgnoretagList = new List<string> ();
[Space]
[Header ("Surface Detection Settings")]
[Space]
public LayerMask layer;
public float raycastDistance = 2;
public float groundRaycastDistance = 5;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool gravityBootsActive;
public bool mainCoroutineActive;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnGravityBootsStart;
public bool useEventOnGravityBootsEnd;
[Space]
public UnityEvent eventOnGravityBootsStart;
public UnityEvent eventOnGravityBootsEnd;
[Space]
[Header ("Components")]
[Space]
public playerController mainPlayerController;
public gravitySystem mainGravitySystem;
public Transform playerTransform;
bool resetingSurfaceRotationAfterGravityBootsActive;
float lastTimeResetSurfaceRotationBelow;
RaycastHit hit;
Vector3 originalNormal;
Coroutine mainCoroutine;
bool checkRunGravity;
void Start ()
{
if (gravityBootsEnabled) {
mainCoroutine = StartCoroutine (updateCoroutine ());
mainCoroutineActive = true;
}
}
public void stopUpdateCoroutine ()
{
if (mainCoroutine != null) {
StopCoroutine (mainCoroutine);
}
mainCoroutineActive = false;
}
IEnumerator updateCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
if (!mainPlayerController.playerIsBusy ()) {
checkIfActivateGravityBoots ();
updateGravityBootsState ();
}
yield return waitTime;
}
}
void updateGravityBootsState ()
{
if (gravityBootsActive && gravityBootsEnabled) {
if (resetingSurfaceRotationAfterGravityBootsActive) {
if (mainGravitySystem.isCharacterRotatingToSurface ()) {
return;
} else {
resetingSurfaceRotationAfterGravityBootsActive = false;
lastTimeResetSurfaceRotationBelow = Time.time;
}
}
if (lastTimeResetSurfaceRotationBelow > 0) {
if (Time.time > lastTimeResetSurfaceRotationBelow + 1) {
lastTimeResetSurfaceRotationBelow = 0;
} else {
return;
}
}
if (mainPlayerController.isExternalControlBehaviorForAirTypeActive ()) {
stopGravityBoots ();
}
//check a surface in front of the player, to rotate to it
bool surfaceInFrontDetected = false;
Vector3 playerPosition = playerTransform.position;
Vector3 playerTransformUp = playerTransform.up;
Vector3 playerTransforForward = playerTransform.forward;
Vector3 raycastPosition = playerPosition + playerTransformUp;
Vector3 raycastDirection = playerTransforForward;
bool ignoreSurfaceDetected = false;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, layer)) {
if (avoidRigidbodiesOnRaycastEnabled) {
if (hit.rigidbody != null) {
ignoreSurfaceDetected = true;
}
}
if (!hit.collider.isTrigger && !ignoreSurfaceDetected) {
mainGravitySystem.checkRotateToSurfaceWithoutParent (hit.normal, gravityBootsRotationSpeed);
mainPlayerController.setCurrentNormalCharacter (hit.normal);
surfaceInFrontDetected = true;
if (showDebugPrint) {
print ("surface detected in front");
}
}
}
if (useExtraRaycastDetectionOnGravityBootsEnabled) {
if (!surfaceInFrontDetected && mainPlayerController.isPlayerOnGround () && !mainGravitySystem.isCharacterRotatingToSurface ()) {
Vector3 heading = (playerPosition + playerTransforForward) - raycastPosition;
float distance = heading.magnitude;
raycastDirection = heading / distance;
ignoreSurfaceDetected = false;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, 4, layer)) {
if (avoidRigidbodiesOnRaycastEnabled) {
if (hit.rigidbody != null) {
ignoreSurfaceDetected = true;
}
}
if (!ignoreSurfaceDetected && !hit.collider.isTrigger && mainGravitySystem.getCurrentNormal () != hit.normal) {
mainGravitySystem.checkRotateToSurfaceWithoutParent (hit.normal, gravityBootsRotationSpeed);
mainPlayerController.setCurrentNormalCharacter (hit.normal);
surfaceInFrontDetected = true;
if (showDebugPrint) {
print ("surface detected below 1");
}
}
}
if (!surfaceInFrontDetected) {
raycastPosition = playerPosition + playerTransformUp + playerTransforForward;
raycastDirection = -playerTransformUp;
ignoreSurfaceDetected = false;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, 2, layer)) {
if (avoidRigidbodiesOnRaycastEnabled) {
if (hit.rigidbody != null) {
ignoreSurfaceDetected = true;
}
}
if (!ignoreSurfaceDetected && !hit.collider.isTrigger && mainGravitySystem.getCurrentNormal () != hit.normal) {
mainGravitySystem.checkRotateToSurfaceWithoutParent (hit.normal, gravityBootsRotationSpeed);
mainPlayerController.setCurrentNormalCharacter (hit.normal);
surfaceInFrontDetected = true;
if (showDebugPrint) {
print ("surface detected below 2");
}
}
}
}
}
}
//check if the player is too far from his current ground, to rotate to his previous normal
if (rotateToOriginalNormalOnAirEnabled) {
if (!surfaceInFrontDetected &&
!Physics.Raycast (playerPosition + playerTransformUp, -playerTransformUp, out hit, groundRaycastDistance, layer)) {
if (mainGravitySystem.getCurrentRotatingNormal () != originalNormal && !checkRunGravity) {
checkRunGravity = true;
if (mainGravitySystem.isCharacterRotatingToSurface ()) {
mainGravitySystem.stopRotateToSurfaceWithOutParentCoroutine ();
}
mainGravitySystem.checkRotateToSurface (originalNormal, 2);
mainPlayerController.setCurrentNormalCharacter (originalNormal);
resetingSurfaceRotationAfterGravityBootsActive = true;
}
if (checkRunGravity && mainGravitySystem.getCurrentRotatingNormal () == originalNormal) {
checkRunGravity = false;
}
}
}
}
}
void checkIfActivateGravityBoots ()
{
if (gravityBootsEnabled) {
if (!gravityBootsActive && !mainPlayerController.isWallRunningActive () || mainPlayerController.isExternalControlBehaviorForAirTypeActive ()) {
if (!resetingSurfaceRotationAfterGravityBootsActive || !mainGravitySystem.isCharacterRotatingToSurface ()) {
if (!mainGravitySystem.isCurcumnavigating ()) {
gravityBootsActive = true;
}
}
}
}
}
//when the player stops running, those parameters back to their normal values
public void stopGravityBoots ()
{
if (gravityBootsActive) {
resetingSurfaceRotationAfterGravityBootsActive = false;
if (stopGravityAdherenceWhenStopRun) {
if (mainGravitySystem.getCurrentRotatingNormal () != originalNormal) {
if (mainGravitySystem.isCharacterRotatingToSurface ()) {
mainGravitySystem.stopRotateToSurfaceWithOutParentCoroutine ();
}
mainGravitySystem.checkRotateToSurface (originalNormal, 2);
resetingSurfaceRotationAfterGravityBootsActive = true;
}
mainPlayerController.setCurrentNormalCharacter (originalNormal);
}
mainGravitySystem.setAllowCircumnavigationOnAllSurfacesWithIgnoretagListState (false);
gravityBootsActive = false;
lastTimeResetSurfaceRotationBelow = 0;
}
}
public bool areGravityBootsActive ()
{
return gravityBootsActive;
}
public void setGravityBootsEnabledState (bool state)
{
if (gravityBootsEnabled == state) {
return;
}
gravityBootsEnabled = state;
if (gravityBootsEnabled) {
mainCoroutine = StartCoroutine (updateCoroutine ());
mainCoroutineActive = true;
originalNormal = mainGravitySystem.getCurrentRotatingNormal ();
mainGravitySystem.setAllowCircumnavigationOnAllSurfacesWithIgnoretagListState (allowCircumnavigationOnAllSurfacesWithIgnoretagList);
mainGravitySystem.setCircumnavigationOnAllSurfacesWithIgnoretagList (circumnavigationOnAllSurfacesWithIgnoretagList);
} else {
if (gravityBootsActive) {
stopGravityBoots ();
}
stopUpdateCoroutine ();
}
checkEventsOnGravityBoots (state);
}
public void toggleGravityBootsEnabledState ()
{
setGravityBootsEnabledState (!gravityBootsEnabled);
}
public void disableGravityBootsState ()
{
if (gravityBootsActive) {
stopGravityBoots ();
}
setGravityBootsEnabledState (false);
}
void checkEventsOnGravityBoots (bool state)
{
if (state) {
if (useEventOnGravityBootsStart) {
eventOnGravityBootsStart.Invoke ();
}
} else {
if (useEventOnGravityBootsEnd) {
eventOnGravityBootsEnd.Invoke ();
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: beb6c54141397b54a84b0c30345edd31
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/Powers/gravityBootsSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,714 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class gravityWallRunSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool wallWalkEnabled;
public float wallWalkRotationSpeed = 10;
public bool setAnimSpeedMultiplierOnWallRun = true;
public float animSpeedMultiplierOnWallRun = 2;
public bool useExtraRaycastDetectionOnWallWalkEnabled = true;
public bool stopGravityAdherenceWhenStopRun = true;
public bool avoidRigidbodiesOnRaycastEnabled;
public bool rotateToOriginalNormalOnAirEnabled = true;
[Space]
[Header ("Player Render Setting")]
[Space]
public Material runMat;
public LayerMask layer;
public bool trailsActive = true;
public bool changePlayerMaterialsOnWallRun;
[Space]
[Header ("Player GameObject List")]
[Space]
public List<GameObject> playerGameObjectList = new List<GameObject> ();
public List<GameObject> playerGameObjectWithChildList = new List<GameObject> ();
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool wallWalkActive;
public bool mainCoroutineActive;
public bool forceWalkWallActiveExternally;
[Space]
public List<Renderer> rendererParts = new List<Renderer> ();
public List<Material> materialList = new List<Material> ();
public List<TrailRenderer> trails = new List<TrailRenderer> ();
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnWallWalkStart;
public bool useEventOnWallWalkEnd;
[Space]
public UnityEvent eventOnWallWalkStart;
public UnityEvent eventOnWallWalkEnd;
[Space]
[Header ("Components")]
[Space]
public playerController mainPlayerController;
public gravitySystem mainGravitySystem;
public ragdollActivator mainRagdollActivator;
public GameObject trailsPrefab;
public Transform playerTransform;
float lastTimeRunActivated;
float lastTimeWallWalkActive;
bool resetingSurfaceRotationAfterWallWalkActive;
float lastTimeResetSurfaceRotationBelow;
float trailTimer = -1;
RaycastHit hit;
bool checkRunGravity;
Vector3 originalNormal;
bool materialsStored;
Coroutine mainCoroutine;
float originalAnimSpeedMultiplierOnWallRun;
void Start ()
{
if (wallWalkEnabled) {
mainCoroutine = StartCoroutine (updateCoroutine ());
mainCoroutineActive = true;
}
originalAnimSpeedMultiplierOnWallRun = animSpeedMultiplierOnWallRun;
}
public void stopUpdateCoroutine ()
{
if (mainCoroutine != null) {
StopCoroutine (mainCoroutine);
}
mainCoroutineActive = false;
}
IEnumerator updateCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
if (!mainPlayerController.playerIsBusy ()) {
checkIfActivateWallWalk ();
updateWallWalkState ();
}
//just a configuration to the trails in the player
if (trailsActive) {
if (trailTimer > 0) {
trailTimer -= Time.deltaTime;
for (int j = 0; j < trails.Count; j++) {
if (trails [j] != null) {
trails [j].time -= Time.deltaTime;
}
}
}
if (trailTimer <= 0 && trailTimer > -1) {
for (int j = 0; j < trails.Count; j++) {
if (trails [j] != null) {
trails [j].enabled = false;
}
}
trailTimer = -1;
}
if (trailTimer == -1) {
if (!wallWalkEnabled) {
stopUpdateCoroutine ();
}
}
}
yield return waitTime;
}
}
void updateWallWalkState ()
{
if (wallWalkActive && wallWalkEnabled) {
if (resetingSurfaceRotationAfterWallWalkActive) {
if (mainGravitySystem.isCharacterRotatingToSurface ()) {
return;
} else {
resetingSurfaceRotationAfterWallWalkActive = false;
lastTimeResetSurfaceRotationBelow = Time.time;
}
}
if (lastTimeResetSurfaceRotationBelow > 0) {
if (Time.time > lastTimeResetSurfaceRotationBelow + 1) {
lastTimeResetSurfaceRotationBelow = 0;
} else {
return;
}
}
if (mainPlayerController.isWallRunningActive () || mainPlayerController.isExternalControlBehaviorForAirTypeActive ()) {
stopWallWalk ();
}
//check a surface in front of the player, to rotate to it
bool surfaceInFrontDetected = false;
Vector3 playerPosition = playerTransform.position;
Vector3 playerTransformUp = playerTransform.up;
Vector3 playerTransforForward = playerTransform.forward;
Vector3 raycastPosition = playerPosition + playerTransformUp;
Vector3 raycastDirection = playerTransforForward;
bool ignoreSurfaceDetected = false;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, 2, layer)) {
if (avoidRigidbodiesOnRaycastEnabled) {
if (hit.rigidbody != null) {
ignoreSurfaceDetected = true;
}
}
if (!hit.collider.isTrigger && !ignoreSurfaceDetected) {
mainGravitySystem.checkRotateToSurfaceWithoutParent (hit.normal, wallWalkRotationSpeed);
mainPlayerController.setCurrentNormalCharacter (hit.normal);
surfaceInFrontDetected = true;
}
}
if (useExtraRaycastDetectionOnWallWalkEnabled) {
if (!surfaceInFrontDetected && mainPlayerController.isPlayerOnGround () && !mainGravitySystem.isCharacterRotatingToSurface ()) {
Vector3 heading = (playerPosition + playerTransforForward) - raycastPosition;
float distance = heading.magnitude;
raycastDirection = heading / distance;
ignoreSurfaceDetected = false;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, 4, layer)) {
if (avoidRigidbodiesOnRaycastEnabled) {
if (hit.rigidbody != null) {
ignoreSurfaceDetected = true;
}
}
if (!ignoreSurfaceDetected && !hit.collider.isTrigger && mainGravitySystem.getCurrentNormal () != hit.normal) {
mainGravitySystem.checkRotateToSurfaceWithoutParent (hit.normal, wallWalkRotationSpeed);
mainPlayerController.setCurrentNormalCharacter (hit.normal);
surfaceInFrontDetected = true;
if (showDebugPrint) {
print ("surface detected below 1");
}
}
}
if (!surfaceInFrontDetected) {
raycastPosition = playerPosition + playerTransformUp + playerTransforForward;
raycastDirection = -playerTransformUp;
ignoreSurfaceDetected = false;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, 2, layer)) {
if (avoidRigidbodiesOnRaycastEnabled) {
if (hit.rigidbody != null) {
ignoreSurfaceDetected = true;
}
}
if (!ignoreSurfaceDetected && !hit.collider.isTrigger && mainGravitySystem.getCurrentNormal () != hit.normal) {
mainGravitySystem.checkRotateToSurfaceWithoutParent (hit.normal, wallWalkRotationSpeed);
mainPlayerController.setCurrentNormalCharacter (hit.normal);
surfaceInFrontDetected = true;
if (showDebugPrint) {
print ("surface detected below 2");
}
}
}
}
}
}
//check if the player is too far from his current ground, to rotate to his previous normal
if (rotateToOriginalNormalOnAirEnabled) {
if (!surfaceInFrontDetected && !Physics.Raycast (playerPosition + playerTransformUp, -playerTransformUp, out hit, 5, layer)) {
if (mainGravitySystem.getCurrentRotatingNormal () != originalNormal && !checkRunGravity) {
checkRunGravity = true;
if (mainGravitySystem.isCharacterRotatingToSurface ()) {
mainGravitySystem.stopRotateToSurfaceWithOutParentCoroutine ();
}
mainGravitySystem.checkRotateToSurface (originalNormal, 2);
mainPlayerController.setCurrentNormalCharacter (originalNormal);
resetingSurfaceRotationAfterWallWalkActive = true;
}
if (checkRunGravity && mainGravitySystem.getCurrentRotatingNormal () == originalNormal) {
checkRunGravity = false;
}
}
}
}
}
public void checkIfActivateWallWalk ()
{
if (wallWalkEnabled) {
if (!wallWalkActive && !mainPlayerController.isWallRunningActive () || mainPlayerController.isExternalControlBehaviorForAirTypeActive ()) {
if (forceWalkWallActiveExternally && mainPlayerController.isPlayerMoving (1) && mainPlayerController.isPlayerOnGround ()) {
mainPlayerController.inputStartToRun ();
originalNormal = mainGravitySystem.getCurrentRotatingNormal ();
lastTimeRunActivated = Time.time;
wallWalkActive = true;
activateWallWalk ();
return;
}
if (lastTimeWallWalkActive > 0) {
if (Time.time > lastTimeWallWalkActive + 1) {
lastTimeWallWalkActive = 0;
}
}
//check the amount of time that the button is being pressed
if (lastTimeRunActivated == 0) {
if (mainPlayerController.isPlayerRunning ()) {
originalNormal = mainGravitySystem.getCurrentRotatingNormal ();
lastTimeRunActivated = Time.time;
}
}
if (lastTimeRunActivated > 0) {
if (mainPlayerController.getRunButtonPressedTimer () > 0.5f) {
if (!resetingSurfaceRotationAfterWallWalkActive || !mainGravitySystem.isCharacterRotatingToSurface ()) {
if (!mainGravitySystem.isCurcumnavigating ()) {
wallWalkActive = true;
activateWallWalk ();
}
}
}
if (!mainPlayerController.isPlayerRunning ()) {
lastTimeRunActivated = 0;
}
}
} else {
if (!mainPlayerController.isPlayerRunning ()) {
lastTimeRunActivated = 0;
stopWallWalk ();
}
}
}
}
//if the player runs, a set of parameters are changed, like the speed of movement, animation, jumppower....
public void activateWallWalk ()
{
if (wallWalkEnabled) {
if (rendererParts.Count == 0) {
storePlayerRenderer ();
}
if (!materialsStored) {
getMaterialList ();
materialsStored = true;
}
bool firstPersonActive = mainPlayerController.isPlayerOnFirstPerson ();
if (trailsActive && !firstPersonActive) {
for (int j = 0; j < trails.Count; j++) {
if (trails [j] != null) {
trails [j].enabled = true;
trails [j].time = 1;
}
}
trailTimer = -1;
}
if (changePlayerMaterialsOnWallRun) {
int rendererPartsCount = rendererParts.Count;
for (int i = 0; i < rendererPartsCount; i++) {
Renderer currentRenderer = rendererParts [i];
if (currentRenderer != null) {
int materialsLength = currentRenderer.materials.Length;
Material [] allMats = currentRenderer.materials;
for (int j = 0; j < materialsLength; j++) {
allMats [j] = runMat;
}
currentRenderer.materials = allMats;
}
}
}
if (setAnimSpeedMultiplierOnWallRun) {
mainPlayerController.setReducedVelocity (animSpeedMultiplierOnWallRun);
}
checkEventsOnWallWalk (true);
}
}
//when the player stops running, those parameters back to their normal values
public void stopWallWalk ()
{
if (wallWalkActive) {
resetingSurfaceRotationAfterWallWalkActive = false;
if (trailsActive) {
trailTimer = 2;
}
if (changePlayerMaterialsOnWallRun) {
int rendererPartsCount = rendererParts.Count;
int currentMaterialIndex = 0;
for (int i = 0; i < rendererPartsCount; i++) {
Renderer currentRenderer = rendererParts [i];
if (currentRenderer != null) {
int materialsLength = currentRenderer.materials.Length;
Material [] allMats = currentRenderer.materials;
for (int j = 0; j < materialsLength; j++) {
allMats [j] = materialList [currentMaterialIndex];
currentMaterialIndex++;
}
currentRenderer.materials = allMats;
}
}
}
if (stopGravityAdherenceWhenStopRun) {
if (mainGravitySystem.getCurrentRotatingNormal () != originalNormal) {
if (mainGravitySystem.isCharacterRotatingToSurface ()) {
mainGravitySystem.stopRotateToSurfaceWithOutParentCoroutine ();
}
mainGravitySystem.checkRotateToSurface (originalNormal, 2);
resetingSurfaceRotationAfterWallWalkActive = true;
}
mainPlayerController.setCurrentNormalCharacter (originalNormal);
} else {
if (mainGravitySystem.isUsingRegularGravity ()) {
mainGravitySystem.changeColor (false);
} else {
mainGravitySystem.changeColor (true);
}
}
wallWalkActive = false;
lastTimeWallWalkActive = Time.time;
lastTimeResetSurfaceRotationBelow = 0;
if (setAnimSpeedMultiplierOnWallRun) {
mainPlayerController.setNormalVelocity ();
}
checkEventsOnWallWalk (false);
}
}
public void setAnimSpeedMultiplierOnWallRunValue (float newValue)
{
animSpeedMultiplierOnWallRun = newValue;
}
public void setOriginalAnimSpeedMultiplierOnWallRunValue ()
{
setAnimSpeedMultiplierOnWallRunValue (originalAnimSpeedMultiplierOnWallRun);
}
public bool isWallWalkActive ()
{
return wallWalkActive;
}
public void setWalkWallEnabledState (bool state)
{
wallWalkEnabled = state;
if (wallWalkEnabled) {
mainCoroutine = StartCoroutine (updateCoroutine ());
mainCoroutineActive = true;
} else {
if (wallWalkActive) {
stopWallWalk ();
}
if (!trailsActive) {
stopUpdateCoroutine ();
}
}
}
public void toggleWalkWallEnabledState ()
{
setWalkWallEnabledState (!wallWalkEnabled);
}
public void disableWalkWallState ()
{
if (wallWalkActive) {
stopWallWalk ();
}
setWalkWallEnabledState (false);
}
public void setForceWalkWallActiveExternallyState (bool state)
{
forceWalkWallActiveExternally = state;
}
public void enableOrDisableWalkWallExternally (bool state, bool activateRunAction)
{
if (state) {
toggleWalkWallEnabledState ();
if (activateRunAction) {
if (!mainPlayerController.isPlayerRunning ()) {
mainPlayerController.inputStartToRun ();
originalNormal = mainGravitySystem.getCurrentRotatingNormal ();
lastTimeRunActivated = Time.time;
wallWalkActive = true;
activateWallWalk ();
}
}
} else {
disableWalkWallState ();
lastTimeRunActivated = 0;
if (!activateRunAction) {
if (mainPlayerController.isPlayerRunning ()) {
mainPlayerController.forceStopRun ();
}
}
}
}
void checkEventsOnWallWalk (bool state)
{
if (state) {
if (useEventOnWallWalkStart) {
eventOnWallWalkStart.Invoke ();
}
} else {
if (useEventOnWallWalkEnd) {
eventOnWallWalkEnd.Invoke ();
}
}
}
public void setMeshesInfo ()
{
trails.Clear ();
if (trailsPrefab != null) {
List<Transform> trailsPositions = mainRagdollActivator.getBodyPartsTransformList ();
for (int i = 0; i < trailsPositions.Count; i++) {
GameObject trailClone = (GameObject)Instantiate (trailsPrefab, Vector3.zero, Quaternion.identity);
//remove the clone string inside the instantiated object
trailClone.name = "Run Power Trail " + (i + 1).ToString ();
trailClone.transform.SetParent (trailsPositions [i]);
trailClone.transform.localPosition = Vector3.zero;
//trailClone.transform.localRotation = Quaternion.identity;
TrailRenderer currentTrailRenderer = trailClone.GetComponent<TrailRenderer> ();
currentTrailRenderer.enabled = false;
trails.Add (currentTrailRenderer);
}
}
storePlayerRendererFromEditor ();
updateComponent ();
}
public void getMaterialList ()
{
if (materialList.Count == 0) {
int rendererPartsCount = rendererParts.Count;
for (int i = 0; i < rendererPartsCount; i++) {
Renderer currentRenderer = rendererParts [i];
if (currentRenderer != null) {
int materialsLength = currentRenderer.materials.Length;
for (int j = 0; j < materialsLength; j++) {
Material currentMaterial = currentRenderer.materials [j];
if (currentMaterial != null) {
materialList.Add (currentMaterial);
}
}
}
}
}
}
public void clearRendererList ()
{
rendererParts.Clear ();
}
public void storePlayerRenderer ()
{
clearRendererList ();
for (int i = 0; i < playerGameObjectList.Count; i++) {
GameObject currentObject = playerGameObjectList [i];
if (currentObject != null) {
Renderer currentRenderer = currentObject.GetComponent<Renderer> ();
rendererParts.Add (currentRenderer);
}
}
for (int i = 0; i < playerGameObjectWithChildList.Count; i++) {
GameObject currentObject = playerGameObjectWithChildList [i];
if (currentObject != null) {
Component [] components = currentObject.GetComponentsInChildren (typeof (Renderer));
foreach (Renderer child in components) {
rendererParts.Add (child);
}
}
}
if (showDebugPrint) {
print ("Total amount of " + rendererParts.Count + " render found");
}
}
public void addplayerGameObjectListFromEditor (GameObject newObject)
{
if (!playerGameObjectList.Contains (newObject)) {
playerGameObjectList.Add (newObject);
}
updateComponent ();
}
public void storePlayerRendererFromEditor ()
{
storePlayerRenderer ();
updateComponent ();
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Gravity Wall Run System", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 261097b8d14b00d4c8ef345fe25b3f37
timeCreated: 1652594811
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/Powers/gravityWallRunSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,91 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class gravityWallRunTriggerSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool wallRunningZoneActive = true;
public bool activateRunAction;
public bool stopWallRunningOnEnter;
public bool stopWallRunningOnExit;
public bool setNewAnimSpeedMultiplierOnWallRun;
public float animSpeedMultiplierOnWallRun = 2;
public bool setForceWalkWallActiveExternally;
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!wallRunningZoneActive) {
return;
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
gravityWallRunSystem currentGravityWallRunSystem = currentPlayerComponentsManager.getGravityWallRunSystem ();
if (currentGravityWallRunSystem != null) {
if (stopWallRunningOnEnter) {
currentGravityWallRunSystem.enableOrDisableWalkWallExternally (false, false);
} else {
if (setNewAnimSpeedMultiplierOnWallRun) {
currentGravityWallRunSystem.setAnimSpeedMultiplierOnWallRunValue (animSpeedMultiplierOnWallRun);
}
if (setForceWalkWallActiveExternally) {
currentGravityWallRunSystem.setForceWalkWallActiveExternallyState (true);
}
currentGravityWallRunSystem.enableOrDisableWalkWallExternally (true, activateRunAction);
}
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
gravityWallRunSystem currentGravityWallRunSystem = currentPlayerComponentsManager.getGravityWallRunSystem ();
if (currentGravityWallRunSystem != null) {
if (stopWallRunningOnExit) {
currentGravityWallRunSystem.enableOrDisableWalkWallExternally (false, false);
}
if (setNewAnimSpeedMultiplierOnWallRun) {
currentGravityWallRunSystem.setOriginalAnimSpeedMultiplierOnWallRunValue ();
}
currentGravityWallRunSystem.setForceWalkWallActiveExternallyState (false);
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d1a630dafd0b09543b9a77b278c53d17
timeCreated: 1654183514
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/Powers/gravityWallRunTriggerSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,698 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
public class hitCombat : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public float hitDamage = 5;
public float damageMultiplier = 1;
public bool configureDamageAsConstant;
[Space]
public bool ignoreShield;
public bool canActivateReactionSystemTemporally;
public int damageReactionID = -1;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
public LayerMask layerMask;
[Space]
public bool checkTriggerSurfaces;
[Space]
public bool checkObjectsWithMultipleDamageReceiversEnabled = true;
[Space]
[Header ("Ignore Tags Settings")]
[Space]
public bool useIgnoreTags;
public List<string> tagsToIgnoreList = new List<string> (new string [] { "enemy" });
[Space]
[Header ("Objects Detected Settings")]
[Space]
public bool sendMessageOnDamageDetected = true;
public string messageOnDamageDetectedName = "setDamageDetectedOnTriggerById";
public bool useCustomObjectToSendMessage;
public GameObject customObjectToSendMessage;
public bool sendMessageOnSurfaceWithNoDamageDetected;
public string messageOnSurfaceWithNoDamageDetectedName = "setNoDamageDetectedOnTriggerById";
public bool storeDetectedObjectOnList;
[Space]
[Header ("Physics Settings")]
[Space]
public bool checkSurfacesForDecals;
public float raycastDistance;
[Space]
[Header ("Push Objects Settings")]
[Space]
public float addForceMultiplier;
public ForceMode forceMode = ForceMode.Impulse;
public bool applyImpactForceToVehicles = true;
public float impactForceToVehiclesMultiplier = 0.2f;
public bool usePushCharacter;
public string pushCharacterFunctionName = "pushCharacter";
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool currentlyEnabled;
public int currentCombatTypeIndex;
public int currentAttackIndex;
public bool damageAppliedInLastAttack;
public int triggerId;
public bool detectSurfaceStateActive;
public bool useCastAllDamageDetection;
public List<GameObject> detectedObjectList = new List<GameObject> ();
public bool ignoreDetectedObjectsOnList;
[Space]
public float customForceAmount;
public float customForceToVehiclesMultiplier;
public ForceMode customForceMode;
public bool customForceModeActive;
[Space]
public bool ignoreObjectListActive;
public List<GameObject> objectToIgnoreList = new List<GameObject> ();
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnDetectSurfaceStateActive;
[Space]
[Header ("Components")]
[Space]
public GameObject currentPlayer;
public Collider mainCollider;
public BoxCollider mainBoxCollider;
public SphereCollider mainSphereCollider;
Rigidbody objectToDamageRigidbody;
bool pushCharacterOnce;
GameObject lastSurfaceDetected;
GameObject currentObjectToSendMessage;
Vector3 customForceDirection;
bool ignoreForcesToApplyOnAttackActive;
bool mainColliderLocated;
//check the collision in the sphere colliders in the hands and feet of the player when the close combat system is active
//else the sphere collider are disabled to avoid damage enemies just with touch it without fight
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (currentlyEnabled) {
if (isEnter) {
GameObject currentObject = col.gameObject;
if (showDebugPrint) {
print ("possible object to process " + currentObject.name);
}
checkObjectDetected (currentObject, col.isTrigger);
}
}
}
public bool checkObjectDetection (GameObject objectDetected, bool isTrigger)
{
if (ignoreObjectListActive) {
if (objectToIgnoreList.Contains (objectDetected)) {
return false;
}
}
if (!useIgnoreTags || !tagsToIgnoreList.Contains (objectDetected.tag)) {
if ((1 << objectDetected.layer & layerMask.value) == 1 << objectDetected.layer) {
if (objectDetected != currentPlayer && (!isTrigger || checkTriggerSurfaces)) {
if (checkObjectsWithMultipleDamageReceiversEnabled) {
if (!applyDamage.checkIfDamageReceiverBelongsToThisCharacter (currentPlayer, objectDetected)) {
return true;
}
} else {
return true;
}
}
}
}
return false;
}
public void checkObjectDetected (GameObject objectDetected, bool isTrigger)
{
if (checkObjectDetection (objectDetected, isTrigger)) {
if (storeDetectedObjectOnList) {
GameObject objectToDamage = applyDamage.getCharacterOrVehicle (objectDetected);
if (objectToDamage != null) {
if (detectedObjectList.Contains (objectToDamage)) {
if (!ignoreDetectedObjectsOnList) {
if (showDebugPrint) {
print ("already detected " + objectToDamage.name);
}
return;
}
} else {
detectedObjectList.Add (objectToDamage);
}
} else {
detectedObjectList.Add (objectDetected);
}
}
if (showDebugPrint) {
print ("current object to process " + objectDetected.name);
}
lastSurfaceDetected = objectDetected;
checkDecalsToApplyOnObject (objectDetected);
checkDamageToApplyOnObject (objectDetected);
checkPushCharactersOnObject (objectDetected);
checkForceToApplyOnObject (objectDetected);
if (detectSurfaceStateActive) {
eventOnDetectSurfaceStateActive.Invoke ();
detectSurfaceStateActive = false;
}
}
}
public void checkDamageToApplyOnObject (GameObject objectToDamage)
{
if (activateDamage (objectToDamage)) {
if (!storeDetectedObjectOnList) {
currentlyEnabled = false;
ignoreForcesToApplyOnAttackActive = false;
}
if (showDebugPrint) {
print ("Object detected " + objectToDamage.name + " " + (objectToDamage == gameObject) + " damage: " + hitDamage * damageMultiplier);
}
damageAppliedInLastAttack = true;
if (sendMessageOnDamageDetected) {
currentObjectToSendMessage = currentPlayer;
if (useCustomObjectToSendMessage) {
currentObjectToSendMessage = customObjectToSendMessage;
}
currentObjectToSendMessage.SendMessage (messageOnDamageDetectedName, triggerId, SendMessageOptions.DontRequireReceiver);
}
} else {
if (sendMessageOnSurfaceWithNoDamageDetected) {
currentObjectToSendMessage = currentPlayer;
if (useCustomObjectToSendMessage) {
currentObjectToSendMessage = customObjectToSendMessage;
}
currentObjectToSendMessage.SendMessage (messageOnSurfaceWithNoDamageDetectedName, objectToDamage, SendMessageOptions.DontRequireReceiver);
}
}
}
public void checkPushCharactersOnObject (GameObject objectToDamage)
{
if (usePushCharacter || pushCharacterOnce) {
if (showDebugPrint) {
print ("Use push character on " + objectToDamage.name);
}
GameObject currentCharacter = applyDamage.getCharacterOrVehicle (objectToDamage);
if (currentCharacter != null) {
currentCharacter.SendMessage (pushCharacterFunctionName, currentPlayer.transform.forward, SendMessageOptions.DontRequireReceiver);
deactivatePushCHaracterOnce ();
}
}
}
public void setCustomForceDirection (Vector3 newValue)
{
customForceDirection = newValue;
}
public void setCustomForceAmount (float newValue)
{
customForceAmount = newValue;
}
public void setCustomForceMode (ForceMode newForceMode)
{
customForceMode = newForceMode;
customForceModeActive = true;
}
public void removeCustomForceMode ()
{
customForceModeActive = false;
}
public void setIgnoreForcesToApplyOnAttackActiveState (bool state)
{
ignoreForcesToApplyOnAttackActive = state;
}
public void setCustomForceToVehiclesMultiplier (float newValue)
{
customForceToVehiclesMultiplier = newValue;
}
public void setAddForceMultiplierValue (float newValue)
{
addForceMultiplier = newValue;
}
public void checkForceToApplyOnObject (GameObject objectToDamage)
{
if (ignoreForcesToApplyOnAttackActive) {
return;
}
objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
Vector3 forceDirection = Vector3.zero;
if (customForceDirection != Vector3.zero) {
forceDirection = customForceDirection;
customForceDirection = Vector3.zero;
} else {
forceDirection = currentPlayer.transform.up + currentPlayer.transform.forward;
}
float forceAmount = addForceMultiplier;
if (customForceAmount != 0) {
forceAmount = customForceAmount;
}
if (forceAmount != 0) {
float forceToVehiclesMultiplier = impactForceToVehiclesMultiplier;
if (customForceToVehiclesMultiplier != 0) {
forceToVehiclesMultiplier = customForceToVehiclesMultiplier;
}
if (applyImpactForceToVehicles) {
Rigidbody objectToDamageMainRigidbody = applyDamage.applyForce (objectToDamage);
if (objectToDamageMainRigidbody != null) {
Vector3 force = forceAmount * forceDirection;
bool isVehicle = applyDamage.isVehicle (objectToDamage);
if (isVehicle) {
force = forceToVehiclesMultiplier * force;
}
if (customForceModeActive) {
objectToDamageMainRigidbody.AddForce (objectToDamageMainRigidbody.mass * force, customForceMode);
} else {
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> ();
}
if (customForceModeActive) {
objectToDamageRigidbody.AddForce (objectToDamageRigidbody.mass * force, customForceMode);
} else {
objectToDamageRigidbody.AddForce (objectToDamageRigidbody.mass * force, forceMode);
}
}
}
}
}
public void checkDecalsToApplyOnObject (GameObject objectToDamage)
{
if (checkSurfacesForDecals) {
// decalManager.setImpactDecal (decalManager.checkIfHasDecalImpact (objectToDamage), raycastCheckTransfrom, objectToDamage, raycastDistance, layerMask, false);
}
}
public GameObject getLastSurfaceDetected ()
{
return lastSurfaceDetected;
}
public void setLastSurfaceDetected (GameObject newSurface)
{
lastSurfaceDetected = newSurface;
}
public void getOwner (GameObject ownerObject)
{
currentPlayer = ownerObject;
assignMainCollider ();
//ignore collision between the owner and the sphere colliders, to avoid hurt him self
Collider mainPlayerCollider = currentPlayer.GetComponent<Collider> ();
if (mainPlayerCollider != null) {
Physics.IgnoreCollision (mainPlayerCollider, mainCollider);
}
}
public Collider getMainCollider ()
{
assignMainCollider ();
return mainCollider;
}
public void setMainColliderEnabledState (bool state)
{
if (!mainColliderLocated) {
mainColliderLocated = mainCollider != null;
}
if (mainColliderLocated) {
if (mainCollider.enabled != state) {
mainCollider.enabled = state;
}
}
}
public void reloadMainColliderEnabled ()
{
setMainColliderEnabledState (false);
setMainColliderEnabledState (true);
}
void assignMainCollider ()
{
if (mainCollider == null) {
mainCollider = GetComponent<Collider> ();
}
}
public void setCurrentState (bool value)
{
currentlyEnabled = value;
if (!currentlyEnabled) {
deactivatePushCHaracterOnce ();
}
damageAppliedInLastAttack = false;
if (storeDetectedObjectOnList) {
detectedObjectList.Clear ();
}
if (!currentlyEnabled) {
ignoreForcesToApplyOnAttackActive = false;
}
}
public void setIgnoreDetectedObjectsOnListState (bool state)
{
ignoreDetectedObjectsOnList = state;
}
public void setConfigureDamageAsConstant (bool state)
{
configureDamageAsConstant = state;
}
public void setUseCastAllDamageDetectionState (bool state)
{
useCastAllDamageDetection = state;
// if (showDebugPrint) {
// print ("useCastAllDamageDetection " + useCastAllDamageDetection);
// }
if (useCastAllDamageDetection) {
Collider [] colliders = null;
if (mainSphereCollider != null) {
colliders = Physics.OverlapSphere (transform.position, mainSphereCollider.radius, layerMask);
} else {
colliders = Physics.OverlapBox (transform.position, mainBoxCollider.size, transform.rotation, layerMask);
}
for (int i = 0; i < colliders.Length; i++) {
if (!colliders [i].isTrigger || checkTriggerSurfaces) {
checkTriggerInfo (colliders [i], true);
}
}
useCastAllDamageDetection = false;
}
}
public void setNewHitDamage (float newValue)
{
hitDamage = newValue;
}
public void setIgnoreShieldState (bool state)
{
ignoreShield = state;
}
public void setCurrentExtraDamageValue (float extraDamageValue)
{
damageMultiplier = extraDamageValue;
if (damageMultiplier <= 0) {
damageMultiplier = 1;
}
}
public void activePushCharacterOnce ()
{
pushCharacterOnce = true;
}
public void deactivatePushCHaracterOnce ()
{
pushCharacterOnce = false;
}
public void setUsePushCharacterState (bool state)
{
usePushCharacter = state;
}
public void setCurrentAttackInfoIndex (int combatTypeIndex, int attackIndex)
{
currentCombatTypeIndex = combatTypeIndex;
currentAttackIndex = attackIndex;
}
public bool getDamageAppliedInLastAttackState ()
{
return damageAppliedInLastAttack;
}
public void setDetectSurfaceStateActive (bool state)
{
detectSurfaceStateActive = state;
}
public bool isDetectSurfaceStateActive ()
{
return detectSurfaceStateActive;
}
public bool activateDamage (GameObject objectToDamage)
{
return applyDamage.checkCanBeDamaged (gameObject, objectToDamage, hitDamage * damageMultiplier, -transform.forward,
transform.position, currentPlayer, configureDamageAsConstant, true, ignoreShield, false, damageCanBeBlocked,
canActivateReactionSystemTemporally, damageReactionID, damageTypeID);
}
public float getLastDamageApplied ()
{
return hitDamage * damageMultiplier;
}
public void setCustomDamageCanBeBlockedState (bool state)
{
if (showDebugPrint) {
print ("setting can be blocked state " + state);
}
damageCanBeBlocked = state;
}
public void setTriggerId (int newValue)
{
triggerId = newValue;
}
public void setTriggerIdOnEditor (int newValue)
{
triggerId = newValue;
updateComponent ();
}
public void setCheckTriggerSurfacesState (bool state)
{
checkTriggerSurfaces = state;
}
public void setCustomObjectToSendMessage (GameObject newObject)
{
customObjectToSendMessage = newObject;
}
public void setCustomLayerMask (LayerMask newLayerMask)
{
layerMask = newLayerMask;
}
public void setCustomTagsToIgnore (List<string> newTagList)
{
if (newTagList != null) {
useIgnoreTags = true;
tagsToIgnoreList = newTagList;
} else {
useIgnoreTags = false;
tagsToIgnoreList.Clear ();
}
}
public void setSendMessageOnDamageDetectedState (bool state)
{
sendMessageOnDamageDetected = state;
}
public void setCanActivateReactionSystemTemporallyState (bool state)
{
canActivateReactionSystemTemporally = state;
}
public void setNewDamageReactionID (int newValue)
{
damageReactionID = newValue;
}
public void setNewDamageTypeID (int newValue)
{
damageTypeID = newValue;
}
public void setNewSphereColliderTriggerRadius (float newValue)
{
if (mainSphereCollider != null) {
mainSphereCollider.radius = newValue;
}
}
public void setNewBoxColliderTriggerSize (Vector3 newValue)
{
if (mainBoxCollider != null) {
mainBoxCollider.size = newValue;
}
}
public void addOrRemoveObjectToIgnore (GameObject newObject, bool state)
{
if (newObject != null) {
if (state) {
if (!objectToIgnoreList.Contains (newObject)) {
objectToIgnoreList.Add (newObject);
}
} else {
if (objectToIgnoreList.Contains (newObject)) {
objectToIgnoreList.Remove (newObject);
}
}
}
ignoreObjectListActive = (objectToIgnoreList.Count > 0);
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Hit Combat", gameObject);
}
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: d9a2ac9676dfdc045b960d4963b2e188
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/Powers/hitCombat.cs
uploadId: 814740

View File

@@ -0,0 +1,218 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class launchedObjects : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool checkCollisionsEnabled = true;
public bool removeComponentOnCollisionEnabled = true;
[Space]
[Header ("Damage Settings")]
[Space]
public bool useCustomDamageAmount;
public float customDamageAmount;
public bool searchPlayerAsDamageAttacker;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
[Space]
[Header ("Other Settings")]
[Space]
public bool checkOnTriggerEnterEnabled;
public LayerMask layermaskToCheckOnTriggerEnter;
[Space]
[Header ("Events Settings")]
[Space]
public bool useRemoteEventOnObjectsFound;
public List<string> remoteEventNameList = new List<string> ();
bool ignoreShield;
bool canActivateReactionSystemTemporally;
int damageReactionID = -1;
float timer = 0;
GameObject currentPlayer;
Collider currentPlayerCollider;
Collider mainCollider;
//this script is for the objects launched by the player, to check the object which collides with them
void Update ()
{
if (!checkCollisionsEnabled) {
return;
}
//if the launched objects does not collide with other object, remove the script
if (timer > 0) {
timer -= Time.deltaTime;
if (timer < 0) {
activateCollision ();
}
}
}
void OnCollisionEnter (Collision collision)
{
if (!checkCollisionsEnabled) {
return;
}
checkObjectDetected (collision.collider, collision.relativeVelocity.magnitude, collision.contacts [0].point, false);
}
public void setOnTriggerInfoCheckState (bool state, LayerMask newLayermask)
{
checkOnTriggerEnterEnabled = state;
layermaskToCheckOnTriggerEnter = newLayermask;
}
void OnTriggerEnter (Collider colliderDetected)
{
if (!checkCollisionsEnabled) {
return;
}
if (checkOnTriggerEnterEnabled) {
if ((1 << colliderDetected.gameObject.layer & layermaskToCheckOnTriggerEnter.value) != 1 << colliderDetected.gameObject.layer) {
return;
}
checkObjectDetected (colliderDetected, GetComponent<Rigidbody> ().linearVelocity.magnitude, transform.position, true);
}
}
public void setUseCustomDamageAmountValues (bool state, float amount)
{
useCustomDamageAmount = state;
customDamageAmount = amount;
}
void checkObjectDetected (Collider colliderDetected, float collisionVelocity, Vector3 collisionPosition, bool checkIfIsTrigger)
{
if (!colliderDetected.isTrigger || checkIfIsTrigger) {
//if the object has a health script, it reduces the amount of life according to the launched object velocity
float damageAmountToUse = 0;
if (useCustomDamageAmount) {
damageAmountToUse = customDamageAmount;
} else {
damageAmountToUse = GetComponent<Rigidbody> ().linearVelocity.magnitude;
if (damageAmountToUse == 0) {
damageAmountToUse = collisionVelocity;
}
}
GameObject currentObjectFound = colliderDetected.gameObject;
bool objectToDamageFound = applyDamage.objectCanBeDamaged (currentObjectFound);
if (objectToDamageFound) {
if (searchPlayerAsDamageAttacker && currentPlayer == null) {
currentPlayer = GKC_Utils.findMainPlayerOnScene ();
}
if (damageAmountToUse > 0) {
applyDamage.checkHealth (gameObject, currentObjectFound, damageAmountToUse, -transform.forward, transform.position, currentPlayer,
false, true, ignoreShield, false, damageCanBeBlocked, canActivateReactionSystemTemporally, damageReactionID, damageTypeID);
}
bool isVehicle = applyDamage.isVehicle (currentObjectFound);
if (isVehicle) {
Rigidbody objectToDamageMainRigidbody = applyDamage.applyForce (currentObjectFound);
if (objectToDamageMainRigidbody != null) {
Vector3 collisionDirection = (collisionPosition - transform.position).normalized;
objectToDamageMainRigidbody.AddForce (collisionDirection * damageAmountToUse * objectToDamageMainRigidbody.mass, ForceMode.Impulse);
}
}
activateCollision ();
if (currentObjectFound != null) {
if (useRemoteEventOnObjectsFound) {
remoteEventSystem currentRemoteEventSystem = currentObjectFound.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameList.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameList [i]);
}
}
}
}
}
//else, set the timer to disable the script
else {
timer = 1;
}
}
}
void activateCollision ()
{
if (currentPlayerCollider != null) {
mainCollider = GetComponent<Collider> ();
if (mainCollider != null) {
Physics.IgnoreCollision (mainCollider, currentPlayerCollider, false);
}
}
if (removeComponentOnCollisionEnabled) {
Destroy (this);
}
}
public void setCurrentPlayer (GameObject player)
{
currentPlayer = player;
}
public void setCurrentPlayerAndCollider (GameObject player, Collider playerCollider)
{
currentPlayer = player;
currentPlayerCollider = playerCollider;
}
public void setIgnoreShieldState (bool state)
{
ignoreShield = state;
}
public void setCanActivateReactionSystemTemporally (bool state)
{
canActivateReactionSystemTemporally = state;
}
public void setCamageReactionID (int newValue)
{
damageReactionID = newValue;
}
public void setCheckCollisionsEnabledState (bool state)
{
checkCollisionsEnabled = state;
}
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: e3d92866d1fecbe4b95d42c9aa75c53c
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/Powers/launchedObjects.cs
uploadId: 814740

View File

@@ -0,0 +1,128 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
public class nanoBlade : projectileSystem
{
//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 ();
Vector3 previousVelocity = mainRigidbody.linearVelocity;
//print (objectToDamage.name);
mainRigidbody.isKinematic = true;
Rigidbody objectToDamageRigidbody = objectToDamage.GetComponent<Rigidbody> ();
Transform currentCharacter = null;
GameObject currentCharacterGameObject = applyDamage.getCharacterOrVehicle (objectToDamage);
if (currentCharacterGameObject != null) {
currentCharacter = currentCharacterGameObject.transform;
}
bool isCharacter = applyDamage.isCharacter (objectToDamage);
if (objectToDamageRigidbody != null) {
ragdollActivator currentRagdollActivator = objectToDamage.GetComponent<ragdollActivator> ();
if (currentRagdollActivator == null) {
if (currentCharacter != null) {
currentRagdollActivator = currentCharacter.GetComponent<ragdollActivator> ();
}
}
if (currentRagdollActivator != null) {
Vector3 currentPosition = transform.position;
List<ragdollActivator.bodyPart> bones = currentRagdollActivator.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) {
transform.SetParent (bones [index].transform);
//print (bones [index].transform.name);
if (applyDamage.checkIfDead (objectToDamage)) {
mainRigidbody.isKinematic = false;
mainRigidbody.linearVelocity = previousVelocity;
setProjectileUsedState (false);
}
}
} 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 ();
//add velocity if the touched object has rigidbody
if (currentProjectileInfo.killInOneShot) {
applyDamage.killCharacter (gameObject, objectToDamage, -transform.forward, transform.position, currentProjectileInfo.owner, false);
} 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) {
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 ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 06cab8522e57b9c40acaef0aed818f6f
timeCreated: 1475772466
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/Powers/nanoBlade.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 034dd58f63872a340ae60c07308a24e2
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/Powers/otherPowers.cs
uploadId: 814740

View File

@@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class powerSlotElement : MonoBehaviour
{
public powersListManager.powerSlotInfo slotInfo;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 87bc8005538328f4b9490b64898e9968
timeCreated: 1538091607
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/Powers/powerSlotElement.cs
uploadId: 814740

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class powersAndAbilitiesSystem : MonoBehaviour
{
public List<powerInfo> powerInfoList = new List<powerInfo> ();
public void disableGeneralPower (string powerName)
{
for (int i = 0; i < powerInfoList.Count; i++) {
if (powerInfoList [i].Name.Equals (powerName)) {
powerInfoList [i].eventToDisable.Invoke ();
return;
}
}
}
public void enableGeneralPower (string powerName)
{
for (int i = 0; i < powerInfoList.Count; i++) {
if (powerInfoList [i].Name.Equals (powerName)) {
powerInfoList [i].eventToEnable.Invoke ();
return;
}
}
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
}
[System.Serializable]
public class powerInfo
{
public string Name;
public UnityEvent eventToEnable;
public UnityEvent eventToDisable;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: dc3f3960b08a9bf4e91a7a6e8fa1db4f
timeCreated: 1540397857
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/Powers/powersAndAbilitiesSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,42 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Events;
using UnityEngine.EventSystems;
public class powersListElement : MonoBehaviour
{
//info about every power created in otherPowers
//public otherPowers.Powers powerData;
public powerListType listType;
//public int defaultKeyNumber;
void Start ()
{
}
//set the type of power elememt, list is for show the list of powers in the right of the screen, where will appear all of them
//slot is for the wheel power and there will be only the powers selected
public enum powerListType
{
list,
slot
}
// //create the whole list of powers in the right of the screen, according to the powers created in the otherPowers inspector
// //setting the data power with the info of the power and the icon of the power
// public void setData (otherPowers.Powers data)
// {
// powerData = data;
// Component iconTexture = GetComponentInChildren (typeof(RawImage));
// iconTexture.GetComponent<RawImage> ().texture = powerData.texture;
// }
//
// //get the default key number of every slot in the wheel when a power is drop from the list to the powers wheel
// public void setKey ()
// {
// powerData.numberKey = defaultKeyNumber;
// }
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 4f0d4080f5a6b764db4c46031007d813
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/Powers/powersListElement.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 3d544eace35ff1c47b96ec2e0088059d
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/Powers/powersListManager.cs
uploadId: 814740

View File

@@ -0,0 +1,78 @@
using UnityEngine;
using System.Collections;
using GameKitController.Audio;
public class slowDownTarget : projectileSystem
{
[Header ("Main Settings")]
[Space]
public string characterStateAffectedName = "Character Freeze Velocity";
public float slowDownDuration = 6;
[Range (0, 1)] public float slowValue = 0.2f;
public bool useSlowObjectColor = true;
public Color slowObjectsColor = Color.blue;
void OnTriggerEnter (Collider col)
{
if (canActivateEffect (col)) {
if (currentProjectileInfo.impactAudioElement != null) {
currentProjectileInfo.impactAudioElement.audioSource = GetComponent<AudioSource> ();
AudioPlayer.PlayOneShot (currentProjectileInfo.impactAudioElement, gameObject);
}
setProjectileUsedState (true);
objectToDamage = col.GetComponent<Collider> ().gameObject;
characterDamageReceiver currentCharacterDamageReceiver = objectToDamage.GetComponent<characterDamageReceiver> ();
if (currentCharacterDamageReceiver != null) {
objectToDamage = currentCharacterDamageReceiver.character;
}
slowObject currentSlowObject = objectToDamage.GetComponent<slowObject> ();
if (currentSlowObject == null) {
playerComponentsManager mainPlayerComponentsManager = objectToDamage.GetComponent<playerComponentsManager> ();
if (mainPlayerComponentsManager != null) {
characterPropertiesSystem currentCharacterPropertiesSystem = mainPlayerComponentsManager.getCharacterPropertiesSystem ();
if (currentCharacterPropertiesSystem != null) {
characterStateAffectedInfo currentCharacterStateAffectedInfo = currentCharacterPropertiesSystem.getCharacterStateAffectedInfoByName (characterStateAffectedName);
if (currentCharacterStateAffectedInfo != null) {
currentSlowObject = currentCharacterStateAffectedInfo as slowObject;
}
}
}
}
if (currentSlowObject != null) {
slowObjectsColor currentSlowObjectsColor = currentSlowObject.getObjectToCallFunction ().GetComponent<slowObjectsColor> ();
if (currentSlowObjectsColor == null) {
currentSlowObjectsColor = currentSlowObject.getObjectToCallFunction ().AddComponent<slowObjectsColor> ();
}
if (currentSlowObjectsColor != null) {
currentSlowObjectsColor.startSlowObject (useSlowObjectColor, slowObjectsColor, slowValue, slowDownDuration, currentSlowObject);
}
}
disableBullet (currentProjectileInfo.impactDisableTimer);
}
}
public override void resetProjectile ()
{
base.resetProjectile ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: cbf5181c330655f4586773273751afe1
timeCreated: 1503857904
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/Powers/slowDownTarget.cs
uploadId: 814740

View File

@@ -0,0 +1,109 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
public class slowObject : characterStateAffectedInfo
{
[Header ("Main Settings")]
[Space]
public bool useCustomSlowSpeed;
public float customSlowSpeed;
public GameObject objectToCallFunction;
public bool useSlowObjectColor = true;
public Color customSlowObjectsColor;
[Space]
[Header ("Other Settings")]
[Space]
public bool useMeshesToIgnore;
public List<Transform> meshesToIgnore = new List<Transform> ();
[Space]
[Header ("Event Settings")]
[Space]
public UnityEvent eventOnReducedSpeed;
public UnityEvent eventOnRegularSpeed;
List<Transform> objectsToIgnoreChildren = new List<Transform> ();
void Start ()
{
if (objectToCallFunction == null) {
objectToCallFunction = gameObject;
}
if (useMeshesToIgnore) {
for (int i = 0; i < meshesToIgnore.Count; i++) {
if (meshesToIgnore [i] != null) {
Component[] childrens = meshesToIgnore [i].GetComponentsInChildren (typeof(Transform));
foreach (Transform child in childrens) {
objectsToIgnoreChildren.Add (child);
}
}
}
}
}
public GameObject getObjectToCallFunction ()
{
return objectToCallFunction;
}
public bool isUseCustomSlowSpeedEnabled ()
{
return useCustomSlowSpeed;
}
public float getCustomSlowSpeed ()
{
return customSlowSpeed;
}
public bool checkChildsObjectsToIgnore (Transform obj)
{
bool value = false;
if (meshesToIgnore.Contains (obj) || objectsToIgnoreChildren.Contains (obj)) {
value = true;
return value;
}
return value;
}
public bool useMeshesToIgnoreEnabled ()
{
return useMeshesToIgnore;
}
public void checkEventOnReducedSpeed ()
{
eventOnReducedSpeed.Invoke ();
}
public void checkEventOnRegularSpeed ()
{
eventOnRegularSpeed.Invoke ();
}
public override void activateStateAffected (float stateDuration, float stateAmount)
{
slowObjectsColor currentSlowObjectsColor = objectToCallFunction.GetComponent<slowObjectsColor> ();
if (currentSlowObjectsColor == null) {
currentSlowObjectsColor = objectToCallFunction.AddComponent<slowObjectsColor> ();
}
if (currentSlowObjectsColor != null) {
currentSlowObjectsColor.startSlowObject (useSlowObjectColor, customSlowObjectsColor, stateAmount, stateDuration, this);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6558d88b13a31c84cabf97f21c2087f0
timeCreated: 1473733991
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/Powers/slowObject.cs
uploadId: 814740

View File

@@ -0,0 +1,173 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class slowObjectsColor : MonoBehaviour
{
public Color slowColor;
public bool changeToSlow = true;
public bool changeToNormal;
public float slowDownDuration;
public float timer = 0;
public string setNormalVelocityString = "setNormalVelocity";
public string setReducedVelocityString = "setReducedVelocity";
public string setCanMoveAIStateString = "setCanMoveAIState";
public string setOverrideAnimationSpeedActiveStateString = "setOverrideAnimationSpeedActiveState";
public List<Renderer> rendererParts = new List<Renderer> ();
public List<Color> originalColor = new List<Color> ();
public List<Color> transistionColor = new List<Color> ();
bool renderPartsStored;
float slowValue;
int i = 0;
int j = 0;
slowObject slowObjectManager;
GameObject objectToCallFunction;
int rendererPartsCount;
int materialsLength;
Renderer currentRenderer;
Material currentMaterial;
bool useSlowObjectColor;
void Update ()
{
//change the color smoothly from the original, to the other
timer += Time.deltaTime;
if (useSlowObjectColor) {
rendererPartsCount = rendererParts.Count;
for (i = 0; i < rendererPartsCount; i++) {
currentRenderer = rendererParts [i];
if (currentRenderer != null) {
materialsLength = currentRenderer.materials.Length;
for (j = 0; j < materialsLength; j++) {
currentMaterial = currentRenderer.materials [j];
currentMaterial.color = Color.Lerp (currentMaterial.color, transistionColor [i], timer);
}
}
}
}
//after the 80% of the time has passed, the color will change from the slowObjectsColor, to the original
if (timer >= slowDownDuration * 0.8f && changeToSlow) {
//set the transition color to the original
changeToSlow = false;
changeToNormal = true;
transistionColor = originalColor;
timer = 0;
}
//when the time is over, set the color and remove the script
if (timer >= slowDownDuration * 0.2f && !changeToSlow && changeToNormal) {
if (useSlowObjectColor) {
rendererPartsCount = rendererParts.Count;
for (i = 0; i < rendererPartsCount; i++) {
currentRenderer = rendererParts [i];
if (currentRenderer != null) {
materialsLength = currentRenderer.materials.Length;
for (j = 0; j < materialsLength; j++) {
currentRenderer.materials [j].color = transistionColor [i];
}
}
}
}
if (objectToCallFunction != null) {
objectToCallFunction.BroadcastMessage (setNormalVelocityString, SendMessageOptions.DontRequireReceiver);
if (slowValue < 0.09f) {
objectToCallFunction.BroadcastMessage (setCanMoveAIStateString, true, SendMessageOptions.DontRequireReceiver);
objectToCallFunction.BroadcastMessage (setOverrideAnimationSpeedActiveStateString, false, SendMessageOptions.DontRequireReceiver);
}
}
slowObjectManager.checkEventOnRegularSpeed ();
Destroy (gameObject.GetComponent<slowObjectsColor> ());
}
}
public void startSlowObject (bool useSlowObjectColorValue, Color newSlowColor, float newSlowValue, float newSlowDownDuration, slowObject newSlowObjectComponent)
{
useSlowObjectColor = useSlowObjectColorValue;
slowColor = newSlowColor;
slowValue = newSlowValue;
slowDownDuration = newSlowDownDuration;
timer = 0;
changeToSlow = true;
changeToNormal = false;
slowObjectManager = newSlowObjectComponent;
objectToCallFunction = slowObjectManager.getObjectToCallFunction ();
if (slowObjectManager.isUseCustomSlowSpeedEnabled ()) {
slowValue = slowObjectManager.getCustomSlowSpeed ();
}
slowObjectManager.checkEventOnReducedSpeed ();
//send a message to slow down the object
if (objectToCallFunction != null) {
objectToCallFunction.BroadcastMessage (setReducedVelocityString, slowValue, SendMessageOptions.DontRequireReceiver);
if (slowValue < 0.09f) {
objectToCallFunction.BroadcastMessage (setCanMoveAIStateString, false, SendMessageOptions.DontRequireReceiver);
objectToCallFunction.BroadcastMessage (setOverrideAnimationSpeedActiveStateString, true, SendMessageOptions.DontRequireReceiver);
}
}
if (!renderPartsStored) {
if (useSlowObjectColor) {
bool useCustomSlowSpeed = slowObjectManager.useMeshesToIgnoreEnabled ();
int propertyNameID = Shader.PropertyToID ("_Color");
//get all the renderers inside of it, to change their color with the slowObjectsColor from otherpowers
Component[] components = GetComponentsInChildren (typeof(Renderer));
foreach (Renderer child in components) {
if (!useCustomSlowSpeed || !slowObjectManager.checkChildsObjectsToIgnore (child.transform)) {
if (child.material.HasProperty (propertyNameID)) {
materialsLength = child.materials.Length;
for (j = 0; j < materialsLength; j++) {
rendererParts.Add (child);
originalColor.Add (child.materials [j].color);
transistionColor.Add (slowColor);
}
}
}
}
}
renderPartsStored = true;
}
}
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 823f25ade69bcb944a7f47cc11c0410a
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/Powers/slowObjectsColor.cs
uploadId: 814740

View File

@@ -0,0 +1,243 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class timeBullet : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool timeBulletEnabled;
public float timeBulletTimeSpeed = 0.1f;
public bool restoreAudioPitch;
[Space]
[Header ("Input Settings")]
[Space]
public bool timeBulletByInputEnabled = true;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public float timeBulletTime = 1;
public bool timeBulletActivated;
public bool previouslyActivated;
AudioSource [] audios;
Coroutine timeCoroutine;
Coroutine timeBulletXSecondsCoroutine;
float customTimeBulletDuration;
float originalTimeBulletTimeSpeed;
void Start ()
{
originalTimeBulletTimeSpeed = timeBulletTimeSpeed;
}
public void activateTime ()
{
//check that the player is not using a device, the game is not paused and that this feature is enabled
if (Time.deltaTime != 0 && timeBulletEnabled) {
timeBulletActivated = !timeBulletActivated;
if (timeBulletActivated) {
timeBulletTime = timeBulletTimeSpeed;
} else {
timeBulletTime = 1;
changeAudioPitch ();
}
updateTimeScaleValue ();
}
}
public void updateTimeBulletTime (float newValue)
{
timeBulletTime = newValue;
}
public void updateTimeScaleValue ()
{
Time.timeScale = timeBulletTime;
Time.fixedDeltaTime = timeBulletTime * 0.02f;
}
public void disableTimeBullet ()
{
if (timeBulletActivated) {
activateTime ();
previouslyActivated = true;
}
}
public void disableTimeBulletTotally ()
{
if (timeBulletActivated) {
activateTime ();
}
previouslyActivated = false;
}
public void reActivateTime ()
{
if (previouslyActivated) {
stopReactivateTime ();
timeCoroutine = StartCoroutine (reActivateTimeCoroutine ());
previouslyActivated = false;
}
}
void stopReactivateTime ()
{
if (timeCoroutine != null) {
StopCoroutine (timeCoroutine);
}
}
IEnumerator reActivateTimeCoroutine ()
{
WaitForSeconds delay = new WaitForSeconds (0.001f);
yield return delay;
activateTime ();
}
public void changeAudioPitch ()
{
if (restoreAudioPitch) {
audios = FindObjectsOfType (typeof (AudioSource)) as AudioSource [];
for (int i = 0; i < audios.Length; i++) {
audios [i].pitch = 1;
}
}
}
public void activateTimeBulletXSeconds (float timeBulletDuration, float timeScale)
{
if (timeBulletXSecondsCoroutine != null) {
StopCoroutine (timeBulletXSecondsCoroutine);
}
timeBulletXSecondsCoroutine = StartCoroutine (activateTimeBulletXSecondsCoroutine (timeBulletDuration, timeScale));
}
IEnumerator activateTimeBulletXSecondsCoroutine (float timeBulletDuration, float timeScale)
{
setBulletTimeState (true, timeScale);
WaitForSeconds delay = new WaitForSeconds (timeBulletDuration * timeScale);
yield return delay;
setBulletTimeState (false, 1);
}
public void setCustomTimeBulletDuration (float timeScale)
{
customTimeBulletDuration = timeScale;
}
public void activateTimeBulletXSeconds (float timeBulletDuration)
{
if (timeBulletXSecondsCoroutine != null) {
StopCoroutine (timeBulletXSecondsCoroutine);
}
timeBulletXSecondsCoroutine = StartCoroutine (activateTimeBulletXSecondsCoroutine (timeBulletDuration));
}
IEnumerator activateTimeBulletXSecondsCoroutine (float timeScale)
{
setBulletTimeState (true, timeScale);
yield return new WaitForSecondsRealtime (customTimeBulletDuration);
setBulletTimeState (false, 1);
}
public void setBulletTimeState (bool state, float timeScale)
{
//check that the player is not using a device, the game is not paused and that this feature is enabled
if (Time.deltaTime != 0) {
setTimeValues (state, timeScale);
}
}
public void setNewTimeBulletTimeSpeedValue (float newValue)
{
timeBulletTimeSpeed = newValue;
}
public void setOriginalTimeBulletTimeSpeed ()
{
setNewTimeBulletTimeSpeedValue (originalTimeBulletTimeSpeed);
}
public void setTimeValues (bool state, float timeScale)
{
if (timeBulletEnabled) {
stopReactivateTime ();
timeBulletActivated = state;
timeBulletTime = timeScale;
updateTimeScaleValue ();
changeAudioPitch ();
if (showDebugPrint) {
print ("setTimeValues " + state + " " + timeScale);
}
}
}
public void inputActivateBulletTime ()
{
if (timeBulletEnabled && timeBulletByInputEnabled) {
activateTime ();
}
}
public void setTimeBulletByInputEnabledState (bool state)
{
timeBulletByInputEnabled = state;
}
public bool isTimeBulletActivated ()
{
return timeBulletActivated;
}
//EDITOR FUNCTIONS
public void setTimeBulletByInputEnabledStateFromEditor (bool state)
{
setTimeBulletByInputEnabledState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Time Bullet System", gameObject);
}
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 13d59bff7f4902149b06822d93ba63db
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/Powers/timeBullet.cs
uploadId: 814740