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,77 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class activateReactionSystem : applyEffectOnArea
{
[Space]
[Header ("Custom Settings")]
[Space]
public bool activateCustomAction;
public string customActionName;
public bool activateReaction;
public string reactionName;
public float damageToSendOnReaction;
public bool checkToActivateReactionSystemTemporally;
public bool useCustomDamageReactionID;
public int damageReactionID;
[Space]
[Header ("Other Settings")]
[Space]
public Transform mainReactionTransform;
public GameObject objectBlocked;
public override void applyEffect (GameObject objectToAffect)
{
playerComponentsManager currentPlayerComponentsManager = objectToAffect.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
if (activateCustomAction) {
playerActionSystem currentPlayerActionSystem = currentPlayerComponentsManager.getPlayerActionSystem ();
if (currentPlayerActionSystem != null) {
currentPlayerActionSystem.activateCustomAction (customActionName);
}
}
if (activateReaction) {
damageHitReactionSystem currentDamageHitReactionSystem = currentPlayerComponentsManager.getDamageHitReactionSystem ();
if (currentDamageHitReactionSystem != null) {
if (mainReactionTransform == null) {
mainReactionTransform = transform;
}
bool currentDamageHitReactionSystemActiveState = currentDamageHitReactionSystem.getHitReactionActiveState ();
if (checkToActivateReactionSystemTemporally) {
currentDamageHitReactionSystem.setHitReactionActiveState (true);
}
if (objectBlocked == null) {
objectBlocked = gameObject;
}
if (useCustomDamageReactionID) {
currentDamageHitReactionSystem.activateDamageReactionByID (damageToSendOnReaction, mainReactionTransform.position, objectBlocked, damageReactionID);
} else {
currentDamageHitReactionSystem.checkReactionToTriggerExternally (damageToSendOnReaction, mainReactionTransform.position, objectBlocked);
}
if (checkToActivateReactionSystemTemporally) {
currentDamageHitReactionSystem.setHitReactionActiveState (currentDamageHitReactionSystemActiveState);
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: bdfbd74aeef20f34eb8c0b408e4bb797
timeCreated: 1601818729
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/Health/activateReactionSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ea43c62e54035774684b337d5653f65f
timeCreated: 1469728683
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/Health/applyDamage.cs
uploadId: 814740

View File

@@ -0,0 +1,61 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class applyDamageOnArea : applyEffectOnArea
{
[Space]
[Header ("Custom Settings")]
[Space]
public bool ignoreShield;
public bool canActivateReactionSystemTemporally;
public int damageReactionID = -1;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
public bool damageObjectOverTimeOnExit;
public float damageOverTimeOnExitAmount;
public float damageOverTimeOnExitDuration;
public float damageOverTimeOnExitRate;
public bool damageOverTimeOnExitUntilDeath;
public GameObject attackerGameObject;
bool attackerAssigned;
public override void applyEffect (GameObject objectToAffect)
{
if (applyValueAtOnce) {
valueToAdd = applyDamage.getCurrentHealthAmount (objectToAffect);
}
if (valueToAdd > 0) {
if (!attackerAssigned) {
if (attackerGameObject == null) {
attackerGameObject = gameObject;
}
attackerAssigned = true;
}
applyDamage.checkHealth (gameObject, objectToAffect, valueToAdd, Vector3.zero,
objectToAffect.transform.position + objectToAffect.transform.up, attackerGameObject,
true, true, ignoreShield, false, damageCanBeBlocked, canActivateReactionSystemTemporally, damageReactionID, damageTypeID);
if (applyDamage.checkIfDead (objectToAffect)) {
removeDetectedObject (objectToAffect);
}
}
}
public override void checkApplyEffectOnExit (GameObject objectToAffect)
{
if (applyEffectOnExit && damageObjectOverTimeOnExit) {
applyDamage.setDamageTargetOverTimeState (objectToAffect, 0, damageOverTimeOnExitDuration, damageOverTimeOnExitAmount, damageOverTimeOnExitRate, damageOverTimeOnExitUntilDeath, damageTypeID);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: adc2dae47b4c3f44f85d93d5212ae6cf
timeCreated: 1580029774
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/Health/applyDamageOnArea.cs
uploadId: 814740

View File

@@ -0,0 +1,44 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class applyDissolveOnArea : applyEffectOnArea
{
[Header ("Custom Settings")]
[Space]
public Shader shaderToApply;
public Texture dissolveTexture;
public Color dissolveColor;
public float dissolveColorAlpha;
public float timeToDestroyObject;
public float dissolveSpeed = 0.2f;
public override void applyEffect (GameObject objectToAffect)
{
dissolveObject currentDissolveObject = objectToAffect.GetComponent<dissolveObject> ();
if (currentDissolveObject) {
removeDetectedObject (objectToAffect);
return;
}
if (currentDissolveObject == null) {
currentDissolveObject = objectToAffect.AddComponent<dissolveObject> ();
}
if (currentDissolveObject) {
currentDissolveObject.shaderToApply = shaderToApply;
currentDissolveObject.dissolveTexture = dissolveTexture;
currentDissolveObject.dissolveColor = dissolveColor;
currentDissolveObject.dissolveColorAlpha = dissolveColorAlpha;
currentDissolveObject.timeToDestroyObject = timeToDestroyObject;
currentDissolveObject.dissolveSpeed = dissolveSpeed;
currentDissolveObject.activateDissolve (objectToAffect);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 40897a8de279434459d5ea7549ceb29f
timeCreated: 1582962950
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/Health/applyDissolveOnArea.cs
uploadId: 814740

View File

@@ -0,0 +1,480 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
public class applyEffectOnArea : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool effectEnabled = true;
public bool effectActive;
public bool useEffectRate;
public float effectRate;
public float effectAmount;
public bool disableEffectAreaTriggerOnDisableArea = true;
public bool applyValueAtOnce;
public float areaEffectDuration;
public bool activateAreaEffectAtStart;
public bool applyEffectOnExit;
[Space]
[Header ("Object Detection Settings")]
[Space]
public bool useColliderTriggerForDetection = true;
public bool useOverlapSphereForDetection;
public float overlapSphereRadius;
public Transform overlapCenterPosition;
public bool useOverlapOnUpdate;
public bool checkIfObjectHasRigidbody = true;
[Space]
public bool checkObstacleBetweenAreaAndTargetFound;
public LayerMask obstacleToCheckLayermask;
[Space]
[Header ("Objects To Affect Settings")]
[Space]
public LayerMask layerToAffect;
public List<string> tagToAffectList = new List<string> ();
[Space]
[Space]
public bool useObjectsToIgnoreList;
public List<GameObject> objectsToIgnoreList = new List<GameObject> ();
[Space]
[Space]
public bool ignoreMainCharacterColliders;
public GameObject mainCharacterGameObject;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public List<GameObject> detectedObjectList = new List<GameObject> ();
public List<playerStatsSystem> playerStatsSystemList = new List<playerStatsSystem> ();
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEventOnObjectsFound;
public List<string> removeEventNameList = new List<string> ();
[Space]
[Header ("Stats To Affect Settings")]
[Space]
public List<statInfo> statInfoList = new List<statInfo> ();
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnEffectActive;
public UnityEvent eventOnEffectDeactivate;
public bool sendObjectsDetectedOnEvent;
public eventParameters.eventToCallWithGameObject eventToSendObjectsDetected;
[Space]
[Header ("Components")]
[Space]
public Collider mainCollider;
bool objectsInside;
float lastTime;
[HideInInspector] public float valueToAdd;
GameObject currentObject;
Coroutine areaDurationCoroutine;
void Start ()
{
if (activateAreaEffectAtStart) {
if (areaEffectDuration > 0) {
setEffectActiveStateWithDuration ();
} else {
setEffectActiveState (true);
}
}
}
void Update ()
{
if (!effectActive) {
return;
}
if (objectsInside) {
if (useEffectRate) {
if (Time.time > lastTime + effectRate) {
lastTime = Time.time;
checkEffectToDetectedObjects ();
applyEffectOnStats ();
}
}
}
if (useOverlapOnUpdate) {
checkObjectsWithOverlap ();
}
}
public void checkEffectToDetectedObjects ()
{
for (int i = 0; i < detectedObjectList.Count; i++) {
currentObject = detectedObjectList [i];
if (currentObject != null) {
valueToAdd = effectAmount;
applyEffect (currentObject);
}
}
}
public virtual void applyEffect (GameObject objectToAffect)
{
if (sendObjectsDetectedOnEvent) {
eventToSendObjectsDetected.Invoke (objectToAffect);
}
}
public virtual void checkApplyEffectOnExit (GameObject objectToAffect)
{
}
public void applyEffectOnStats ()
{
for (int i = 0; i < playerStatsSystemList.Count; i++) {
for (int k = 0; k < statInfoList.Count; k++) {
playerStatsSystemList [i].addOrRemovePlayerStatAmount (statInfoList [k].Name, statInfoList [k].amountToAdd);
}
}
}
public void setObjectToCheckManually (GameObject objectToCheck)
{
Collider newCollider = objectToCheck.GetComponent<Collider> ();
if (newCollider != null) {
OnTriggerEnter (newCollider);
}
}
void OnTriggerEnter (Collider col)
{
if (useColliderTriggerForDetection) {
checkTriggerInfo (col, true);
}
}
void OnTriggerExit (Collider col)
{
if (useColliderTriggerForDetection) {
checkTriggerInfo (col, false);
}
}
public void checkObjectsWithOverlap ()
{
if (useOverlapSphereForDetection) {
if (overlapCenterPosition == null) {
overlapCenterPosition = transform;
}
//if the power selected is push objects, check the objects close to pushObjectsCenter and add force to them in camera forward direction
Collider [] colliders = Physics.OverlapSphere (overlapCenterPosition.position, overlapSphereRadius, layerToAffect);
for (int i = 0; i < colliders.Length; i++) {
if (!colliders [i].isTrigger) {
checkTriggerInfo (colliders [i], true);
}
}
}
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (isEnter) {
if (tagToAffectList.Contains (col.gameObject.tag) || ((1 << col.gameObject.layer & layerToAffect.value) == 1 << col.gameObject.layer)) {
if (useObjectsToIgnoreList) {
if (objectsToIgnoreList.Contains (col.gameObject)) {
return;
}
}
if (ignoreMainCharacterColliders) {
if (GKC_Utils.checkIfObjectIsOnCharacterExtraColliderList (col, mainCharacterGameObject)) {
if (showDebugPrint) {
print ("character is part of colliders detected, ignoring " + mainCharacterGameObject.name + " " + col.gameObject.name);
}
return;
}
}
if (checkObstacleBetweenAreaAndTargetFound) {
Vector3 temporaltargetPosition = col.gameObject.transform.position;
Transform temporalPlaceToShoot = applyDamage.getPlaceToShoot (col.gameObject);
if (temporalPlaceToShoot != null) {
temporaltargetPosition = temporalPlaceToShoot.position;
}
Vector3 direction = temporaltargetPosition - transform.position;
direction = direction / direction.magnitude;
float distance = GKC_Utils.distance (temporaltargetPosition, transform.position);
RaycastHit hit;
if (Physics.Raycast (temporaltargetPosition, -direction, out hit, distance, obstacleToCheckLayermask)) {
if (hit.collider != col) {
return;
}
}
}
GameObject objectDetected = applyDamage.getCharacterOrVehicle (col.gameObject);
if (objectDetected != null) {
if (!detectedObjectList.Contains (objectDetected)) {
detectedObjectList.Add (objectDetected);
if (showDebugPrint) {
print ("Object detected " + objectDetected.name);
}
playerComponentsManager currentPlayerComponentsManager = objectDetected.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
playerStatsSystem currentPlayerStatsSystem = currentPlayerComponentsManager.getPlayerStatsSystem ();
if (currentPlayerStatsSystem != null) {
playerStatsSystemList.Add (currentPlayerStatsSystem);
}
}
objectsInside = true;
if (useRemoteEventOnObjectsFound) {
remoteEventSystem currentRemoteEventSystem = objectDetected.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem == null && currentPlayerComponentsManager != null) {
currentRemoteEventSystem = currentPlayerComponentsManager.getRemoteEventSystem ();
}
if (currentRemoteEventSystem != null) {
for (int i = 0; i < removeEventNameList.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (removeEventNameList [i]);
}
}
}
if (!useEffectRate) {
checkEffectToDetectedObjects ();
applyEffectOnStats ();
removeDetectedObject (objectDetected);
}
}
} else {
if (!checkIfObjectHasRigidbody || col.gameObject.GetComponent<Rigidbody> ()) {
objectDetected = col.gameObject;
if (!detectedObjectList.Contains (objectDetected)) {
detectedObjectList.Add (objectDetected);
if (showDebugPrint) {
print ("Object detected " + objectDetected.name);
}
objectsInside = true;
if (useRemoteEventOnObjectsFound) {
remoteEventSystem currentRemoteEventSystem = objectDetected.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < removeEventNameList.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (removeEventNameList [i]);
}
}
}
if (!useEffectRate) {
checkEffectToDetectedObjects ();
applyEffectOnStats ();
removeDetectedObject (objectDetected);
}
}
}
}
}
} else {
if (detectedObjectList.Contains (col.gameObject)) {
int objectToRemoveIndex = detectedObjectList.IndexOf (col.gameObject);
checkApplyEffectOnExit (col.gameObject);
if (detectedObjectList.Count > objectToRemoveIndex) {
detectedObjectList.RemoveAt (objectToRemoveIndex);
}
playerComponentsManager currentPlayerComponentsManager = col.gameObject.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
playerStatsSystem currentPlayerStatsSystem = currentPlayerComponentsManager.getPlayerStatsSystem ();
if (currentPlayerStatsSystem != null) {
for (int i = 0; i < playerStatsSystemList.Count; i++) {
if (playerStatsSystemList [i] == currentPlayerStatsSystem) {
playerStatsSystemList.RemoveAt (i);
}
}
}
}
if (detectedObjectList.Count == 0) {
objectsInside = false;
}
}
}
}
public void toggleEffectActive ()
{
setEffectActiveState (!effectActive);
}
public void setEffectActiveState (bool state)
{
if (!effectEnabled) {
return;
}
effectActive = state;
if (state || disableEffectAreaTriggerOnDisableArea) {
if (mainCollider != null) {
mainCollider.enabled = state;
if (showDebugPrint) {
print ("Setting main collider on area effect as " + state);
}
}
}
detectedObjectList.Clear ();
playerStatsSystemList.Clear ();
objectsInside = false;
lastTime = 0;
if (effectActive) {
eventOnEffectActive.Invoke ();
} else {
eventOnEffectDeactivate.Invoke ();
}
if (effectActive) {
if (!useOverlapOnUpdate) {
checkObjectsWithOverlap ();
}
}
}
public void removeDetectedObject (GameObject objectToRemove)
{
if (detectedObjectList.Contains (objectToRemove)) {
int objectToRemoveIndex = detectedObjectList.IndexOf (objectToRemove);
if (detectedObjectList.Count > objectToRemoveIndex) {
detectedObjectList.RemoveAt (objectToRemoveIndex);
}
playerComponentsManager currentPlayerComponentsManager = objectToRemove.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
playerStatsSystem currentPlayerStatsSystem = currentPlayerComponentsManager.getPlayerStatsSystem ();
if (currentPlayerStatsSystem != null) {
for (int i = 0; i < playerStatsSystemList.Count; i++) {
if (playerStatsSystemList [i] == currentPlayerStatsSystem) {
playerStatsSystemList.RemoveAt (i);
}
}
}
}
if (detectedObjectList.Count == 0) {
objectsInside = false;
}
}
}
public void setEffectActiveStateWithDuration ()
{
if (areaDurationCoroutine != null) {
StopCoroutine (areaDurationCoroutine);
}
areaDurationCoroutine = StartCoroutine (setEffectActiveStateWithDurationCoroutine ());
}
IEnumerator setEffectActiveStateWithDurationCoroutine ()
{
setEffectActiveState (true);
WaitForSeconds delay = new WaitForSeconds (areaEffectDuration);
yield return delay;
setEffectActiveState (false);
}
[System.Serializable]
public class statInfo
{
public string Name;
public float amountToAdd;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: f84e57dd172ebd74eae296674313c45b
timeCreated: 1580273246
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/Health/applyEffectOnArea.cs
uploadId: 814740

View File

@@ -0,0 +1,21 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class applyHealOnArea : applyEffectOnArea
{
public override void applyEffect (GameObject objectToAffect)
{
if (applyValueAtOnce) {
valueToAdd = applyDamage.getMaxHealthAmount (objectToAffect);
}
if (!applyDamage.checkIfMaxHealth (objectToAffect)) {
applyDamage.setHeal (valueToAdd, objectToAffect);
} else {
removeDetectedObject (objectToAffect);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 50fe41e30ae8e534eb8e2b463edff65b
timeCreated: 1580289464
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/Health/applyHealOnArea.cs
uploadId: 814740

View File

@@ -0,0 +1,360 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class characterDamageReceiver : healthManagement
{
[Header ("Main Setting")]
[Space]
[Range (1, 20)] public float damageMultiplier = 1;
public bool applyForceOnThisObjectIfDetected;
[Space]
[Header ("Components")]
[Space]
public GameObject character;
public health healthManager;
[Space]
[Header ("Debug")]
[Space]
public bool characterAssigned;
//this script is added to every collider in a vehicle, so when a projectile hits the vehicle, its health component receives the damge
//like this the damage detection is really accurated.
//the function sends the amount of damage, the direction of the projectile, the position where hits, the object that fired the projectile,
//and if the damaged is done just once, like a bullet, or the damaged is constant like a laser
//health and damage management
public void setDamage (float amount, Vector3 fromDirection, Vector3 damagePos, GameObject bulletOwner, GameObject projectile,
bool damageConstant, bool searchClosestWeakSpot, bool ignoreDamageInScreen, bool damageCanBeBlocked,
bool canActivateReactionSystemTemporally, int damageReactionID, int damageTypeID)
{
healthManager.setDamage ((amount * damageMultiplier), fromDirection, damagePos, bulletOwner, projectile, damageConstant,
searchClosestWeakSpot, false, ignoreDamageInScreen, damageCanBeBlocked, canActivateReactionSystemTemporally,
damageReactionID, damageTypeID);
if (useHealthAmountOnSpot) {
checkHealthAmountOnSpot (amount * damageMultiplier);
}
}
public void setHeal (float amount)
{
healthManager.getHealth (amount);
}
public override float getCurrentHealthAmount ()
{
return healthManager.getCurrentHealthAmount ();
}
public float getMaxHealthAmount ()
{
return healthManager.getMaxHealthAmount ();
}
public float getAuxHealthAmount ()
{
return healthManager.getAuxHealthAmount ();
}
public void addAuxHealthAmount (float amount)
{
healthManager.addAuxHealthAmount (amount);
}
public float getHealthAmountToLimit ()
{
return healthManager.getHealthAmountToLimit ();
}
public bool isApplyForceOnThisObjectIfDetectedActive ()
{
return applyForceOnThisObjectIfDetected;
}
public bool compareObjectTag (string tagToCompare)
{
if (characterAssigned) {
return character.CompareTag (tagToCompare);
} else {
return gameObject.CompareTag (tagToCompare);
}
}
//kill character
public void killCharacter (GameObject projectile, Vector3 direction, Vector3 position, GameObject attacker, bool damageConstant)
{
healthManager.killCharacter (direction, position, attacker, projectile, damageConstant);
}
//impact decal management
public int getDecalImpactIndex ()
{
return healthManager.getDecalImpactIndex ();
}
public bool isCharacterDead ()
{
return healthManager.dead;
}
//set character component
public void setCharacter (GameObject characterGameObject, health currentHealth)
{
character = characterGameObject;
healthManager = currentHealth;
characterAssigned = true;
if (!GKC_Utils.isApplicationPlaying ()) {
updateComponent ();
}
}
public void setDamageMultiplierValue (float newValue)
{
damageMultiplier = newValue;
if (!GKC_Utils.isApplicationPlaying ()) {
updateComponent ();
}
}
public void setDamageTargetOverTimeState (float damageOverTimeDelay, float damageOverTimeDuration, float damageOverTimeAmount, float damageOverTimeRate, bool damageOverTimeToDeath, int damageTypeID)
{
healthManager.setDamageTargetOverTimeState (damageOverTimeDelay, damageOverTimeDuration, damageOverTimeAmount, damageOverTimeRate, damageOverTimeToDeath, damageTypeID);
}
public void removeDamagetTargetOverTimeState ()
{
healthManager.stopDamageOverTime ();
}
public void sedateCharacter (Vector3 position, float sedateDelay, bool useWeakSpotToReduceDelay, bool sedateUntilReceiveDamage, float sedateDuration)
{
healthManager.sedateCharacter (position, sedateDelay, useWeakSpotToReduceDelay, sedateUntilReceiveDamage, sedateDuration);
}
public health getHealthManager ()
{
return healthManager;
}
void OnCollisionEnter (Collision col)
{
if (characterAssigned && !healthManager.isDead ()) {
if (healthManager.canRagdollReceiveDamageOnImpact ()) {
healthManager.setRagdollImpactReceivedInfo (col.relativeVelocity, col.collider);
}
if (healthManager.isReceiveDamageFromCollisionsEnabled ()) {
healthManager.setImpactReceivedInfo (col.relativeVelocity);
}
}
}
public float getShieldAmountToLimit ()
{
return healthManager.getShieldAmountToLimit ();
}
public void addAuxShieldAmount (float amount)
{
healthManager.addAuxShieldAmount (amount);
}
public void setShield (float amount)
{
healthManager.setShield (amount);
}
public bool characterIsOnRagdollState ()
{
return healthManager.characterIsOnRagdollState ();
}
public Transform getTransformToAttachWeaponsByClosestPosition (Vector3 positionToCheck)
{
return healthManager.getTransformToAttachWeaponsByClosestPosition (positionToCheck);
}
//Override functions from Health Management
public override void setDamageWithHealthManagement (float damageAmount, Vector3 fromDirection, Vector3 damagePos, GameObject attacker,
GameObject projectile, bool damageConstant, bool searchClosestWeakSpot, bool ignoreShield,
bool ignoreDamageInScreen, bool damageCanBeBlocked, bool canActivateReactionSystemTemporally,
int damageReactionID, int damageTypeID)
{
healthManager.setDamage ((damageAmount * damageMultiplier), fromDirection, damagePos, attacker, projectile,
damageConstant, searchClosestWeakSpot, false, ignoreDamageInScreen, damageCanBeBlocked,
canActivateReactionSystemTemporally, damageReactionID, damageTypeID);
if (useHealthAmountOnSpot) {
checkHealthAmountOnSpot (damageAmount * damageMultiplier);
}
}
public override bool checkIfDeadWithHealthManagement ()
{
return healthManager.isDead ();
}
public override bool checkIfMaxHealthWithHealthManagement ()
{
return healthManager.checkIfMaxHealth ();
}
public override void setDamageTargetOverTimeStateWithHealthManagement (float damageOverTimeDelay, float damageOverTimeDuration, float damageOverTimeAmount,
float damageOverTimeRate, bool damageOverTimeToDeath, int damageTypeID)
{
healthManager.setDamageTargetOverTimeState (damageOverTimeDelay, damageOverTimeDuration, damageOverTimeAmount, damageOverTimeRate, damageOverTimeToDeath, damageTypeID);
}
public override void removeDamagetTargetOverTimeStateWithHealthManagement ()
{
healthManager.stopDamageOverTime ();
}
public override void sedateCharacterithHealthManagement (Vector3 position, float sedateDelay, bool useWeakSpotToReduceDelay, bool sedateUntilReceiveDamage, float sedateDuration)
{
healthManager.sedateCharacter (position, sedateDelay, useWeakSpotToReduceDelay, sedateUntilReceiveDamage, sedateDuration);
}
public override void setHealWithHealthManagement (float healAmount)
{
healthManager.getHealth (healAmount);
}
public override void setShieldWithHealthManagement (float shieldAmount)
{
healthManager.setShield (shieldAmount);
}
public override float getCurrentHealthAmountWithHealthManagement ()
{
return healthManager.getCurrentHealthAmount ();
}
public override float getMaxHealthAmountWithHealthManagement ()
{
return healthManager.getMaxHealthAmount ();
}
public override float getAuxHealthAmountWithHealthManagement ()
{
return healthManager.getAuxHealthAmount ();
}
public override void addAuxHealthAmountWithHealthManagement (float amount)
{
healthManager.addAuxHealthAmount (amount);
}
public override float getHealthAmountToPickWithHealthManagement (float amount)
{
return healthManager.getHealthAmountToPick (amount);
}
public override void killCharacterWithHealthManagement (GameObject projectile, Vector3 direction, Vector3 position, GameObject attacker, bool damageConstant)
{
healthManager.killCharacter (direction, position, attacker, projectile, damageConstant);
}
public override void killCharacterWithHealthManagement ()
{
healthManager.killCharacter ();
}
public override Transform getPlaceToShootWithHealthManagement ()
{
return healthManager.getPlaceToShoot ();
}
public override GameObject getPlaceToShootGameObjectWithHealthManagement ()
{
return healthManager.getPlaceToShoot ().gameObject;
}
public override bool isCharacterWithHealthManagement ()
{
return true;
}
public override List<health.weakSpot> getCharacterWeakSpotListWithHealthManagement ()
{
return healthManager.advancedSettings.weakSpots;
}
public override GameObject getCharacterOrVehicleWithHealthManagement ()
{
return character;
}
public override GameObject getCharacterWithHealthManagement ()
{
return character;
}
public override bool checkIfWeakSpotListContainsTransformWithHealthManagement (Transform transformToCheck)
{
return healthManager.checkIfWeakSpotListContainsTransform (transformToCheck);
}
public override int getDecalImpactIndexWithHealthManagement ()
{
return healthManager.getDecalImpactIndex ();
}
public override bool isUseImpactSurfaceActiveWithHealthManagement ()
{
return healthManager.isUseImpactSurfaceActive ();
}
public override bool isCharacterInRagdollState ()
{
return characterIsOnRagdollState ();
}
public override Transform getCharacterRootMotionTransform ()
{
return healthManager.getCharacterRootMotionTransform ();
}
public override bool characterHasWeakSpotListWithHealthManagement ()
{
return healthManager.characterHasWeakSpotList ();
}
public override bool checkIfDamagePositionIsCloseEnoughToWeakSpotByNameWithHealthManagement (Vector3 collisionPosition, List<string> weakSpotNameList, float maxDistanceToWeakSpot)
{
return healthManager.checkIfDamagePositionIsCloseEnoughToWeakSpotByName (collisionPosition, weakSpotNameList, maxDistanceToWeakSpot);
}
public override Vector3 getClosestWeakSpotPositionToPositionWithHealthManagement (Vector3 positionToCheck, List<string> weakListNameToCheck, bool checkWeakListName, float maxDistanceToBodyPart)
{
return healthManager.getClosestWeakSpotPositionToPosition (positionToCheck, weakListNameToCheck, checkWeakListName, maxDistanceToBodyPart);
}
public override void killCharacterIfCurrentlyDrivingVehicle ()
{
healthManager.killCharacterIfCurrentlyDrivingVehicle ();
}
public override void explodeVehicleIfCharacterCurrentlyDriving ()
{
healthManager.explodeVehicleIfCharacterCurrentlyDriving ();
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Damage Receiver", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: f11dcf12465140941a2a9ff4ad4aa0c6
timeCreated: 1473727031
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/Health/characterDamageReceiver.cs
uploadId: 814740

View File

@@ -0,0 +1,786 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class damageHitReactionSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool hitReactionsEnabled = true;
public string defaultCategoryReaction = "Melee";
[Space]
[Header ("Reaction Probability Settings")]
[Space]
[Range (0, 1)] public float probabilityToActivateReactionMultiplier = 1;
public bool canChangeProbabilityMultiplierExternally = true;
[Space]
public bool ignoreMinWaitTimeToPlayHitReactionAgain;
public bool ignoreMinAmountToReceiveDamage;
[Space]
[Header ("Hit Reaction Settings")]
[Space]
public List<hitReactionInfo> hitReactionInfoList = new List<hitReactionInfo> ();
[Space]
public List<damageStateInfo> damageStateInfoList = new List<damageStateInfo> ();
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool hitReactionActive;
public int currentBlockID;
public string currentReactionCategory;
public bool damageReactionPaused;
public bool ignoreParryActive;
[Space]
[Header ("Events Settings")]
[Space]
public bool useMainEventOnHitReactionFound;
public UnityEvent mainEventOnHitReactionFound;
[Space]
[Header ("Components")]
[Space]
public Transform playerControllerTransform;
public playerActionSystem mainPlayerActionSystem;
hitReactionInfo currentHitReactionInfo;
Coroutine perfectBlockCoroutine;
float lastTimeBlockActive;
int currentBlockIDToCheck;
hitDamageDirection currenthitDamageDirection;
public void checkDamageReceived (float damageReceived, Vector3 damagePosition, GameObject objectBlocked)
{
if (!hitReactionsEnabled || !hitReactionActive) {
return;
}
if (damageReactionPaused) {
return;
}
checkHitReaction (damageReceived, 0, damagePosition, false, false, false, objectBlocked, -1);
}
public void checkDamageReceivedTemporally (float damageReceived, Vector3 damagePosition, GameObject objectBlocked)
{
if (!hitReactionsEnabled) {
return;
}
if (damageReactionPaused) {
return;
}
checkHitReaction (damageReceived, 0, damagePosition, false, false, false, objectBlocked, -1);
}
public void checkDamageBlocked (float damageReceived, float originalDamageAmountReceived, Vector3 damagePosition, bool damageBlocked, GameObject objectBlocked)
{
if (!hitReactionsEnabled || !hitReactionActive) {
return;
}
if (damageReactionPaused) {
return;
}
checkHitReaction (damageReceived, originalDamageAmountReceived, damagePosition, damageBlocked, true, false, objectBlocked, -1);
}
public void checkDamageReceivedUnblockable (float damageReceived, Vector3 damagePosition, GameObject objectBlocked)
{
if (!hitReactionsEnabled || !hitReactionActive) {
return;
}
if (damageReactionPaused) {
return;
}
checkHitReaction (damageReceived, 0, damagePosition, false, false, true, objectBlocked, -1);
}
public void checkReactionToTriggerExternally (float damageReceived, Vector3 damagePosition, GameObject objectBlocked)
{
if (!hitReactionsEnabled || !hitReactionActive) {
return;
}
if (damageReactionPaused) {
return;
}
checkHitReaction (damageReceived, 0, damagePosition, false, false, false, objectBlocked, -1);
}
public void activateDamageReactionByID (float damageReceived, Vector3 damagePosition, GameObject objectBlocked, int damageReactionID)
{
if (!hitReactionsEnabled) {
return;
}
if (damageReactionPaused) {
return;
}
checkHitReaction (damageReceived, 0, damagePosition, false, false, false, objectBlocked, damageReactionID);
}
void checkHitReaction (float damageReceived, float originalDamageAmountReceived, Vector3 damagePosition, bool damageBlocked,
bool blockDamageActive, bool unblockableDamage, GameObject objectBlocked, int damageReactionID)
{
if (damageReactionID == -1) {
Vector3 damageDirection = damagePosition - playerControllerTransform.position;
damageDirection = damageDirection / damageDirection.magnitude;
float damageAngle = Vector3.SignedAngle (playerControllerTransform.forward, damageDirection, playerControllerTransform.up);
float damageAngleAbs = Mathf.Abs (damageAngle);
currenthitDamageDirection = hitDamageDirection.front;
bool isPlayerMovingOn3dWorld = mainPlayerActionSystem.isPlayerMovingOn3dWorld ();
if (isPlayerMovingOn3dWorld) {
if (damageAngleAbs > 45 && damageAngleAbs < 135) {
if (damageAngle < 0) {
currenthitDamageDirection = hitDamageDirection.left;
} else {
currenthitDamageDirection = hitDamageDirection.right;
}
} else if (damageAngleAbs > 135) {
currenthitDamageDirection = hitDamageDirection.backward;
}
} else {
if (!isFacingToAttacker (objectBlocked.transform.position)) {
currenthitDamageDirection = hitDamageDirection.backward;
}
}
if (showDebugPrint) {
print (currenthitDamageDirection);
}
}
int hitReactionIndex = -1;
float maxDamageFound = -1;
bool damageStateFound = false;
if (damageReceived > 0) {
for (int i = 0; i < damageStateInfoList.Count; i++) {
damageStateInfo currentDamageStateInfo = damageStateInfoList [i];
if (!damageStateFound && currentDamageStateInfo.damageStateEnabled) {
if (currentDamageStateInfo.damageStateRange.x <= damageReceived &&
currentDamageStateInfo.damageStateRange.y >= damageReceived) {
if (showDebugPrint) {
print (currentDamageStateInfo.Name);
}
currentDamageStateInfo.eventOnDamageState.Invoke ();
damageStateFound = true;
}
}
}
}
if (!damageStateFound) {
for (int i = 0; i < damageStateInfoList.Count; i++) {
damageStateInfo currentDamageStateInfo = damageStateInfoList [i];
if (!damageStateFound && currentDamageStateInfo.damageStateEnabled) {
if (currentDamageStateInfo.useAsDefaultState) {
currentDamageStateInfo.eventOnDamageState.Invoke ();
if (showDebugPrint) {
print (currentDamageStateInfo.Name);
}
damageStateFound = true;
}
}
}
}
bool canCheckReaction = false;
if (currentReactionCategory == "") {
currentReactionCategory = defaultCategoryReaction;
}
bool searchingReactionByID = damageReactionID > -1;
bool canCheckRegularReaction = false;
for (int i = 0; i < hitReactionInfoList.Count; i++) {
currentHitReactionInfo = hitReactionInfoList [i];
if (currentHitReactionInfo.reactionEnabled) {
if (searchingReactionByID) {
if (hitReactionIndex == -1) {
if (damageReactionID == currentHitReactionInfo.damageReactionID) {
canCheckRegularReaction = true;
if (showDebugPrint) {
print ("Damage reaction activated by ID, checking reaction" + currentHitReactionInfo.Name);
}
}
}
} else {
canCheckRegularReaction = false;
if (currentHitReactionInfo.reactionCategory == currentReactionCategory) {
if (currentHitReactionInfo.reactionOnBlock == blockDamageActive) {
if (!blockDamageActive || currentHitReactionInfo.blockID == currentBlockID) {
canCheckRegularReaction = true;
}
}
}
}
if (canCheckRegularReaction) {
canCheckReaction = false;
if (damageReceived >= currentHitReactionInfo.minAmountToReceiveDamage) {
canCheckReaction = true;
}
if (ignoreMinAmountToReceiveDamage) {
canCheckReaction = true;
}
if (blockDamageActive && (damageBlocked || damageReceived == 0)) {
canCheckReaction = true;
}
if (showDebugPrint) {
print (currentHitReactionInfo.Name + " " + damageReceived + " " + blockDamageActive + " " + damageBlocked + " " + canCheckReaction);
}
if (canCheckReaction) {
if (currentHitReactionInfo.minAmountToReceiveDamage > maxDamageFound) {
if (damageReactionID > -1 ||
(currentHitReactionInfo.damageDirection == hitDamageDirection.anyDirection ||
currentHitReactionInfo.damageDirection == currenthitDamageDirection)) {
maxDamageFound = currentHitReactionInfo.minAmountToReceiveDamage;
hitReactionIndex = i;
}
}
}
}
}
}
if (hitReactionIndex > -1) {
activateHitReactionByIndex (hitReactionIndex, damageReceived, originalDamageAmountReceived, unblockableDamage, objectBlocked);
}
}
bool isFacingToAttacker (Vector3 attackerPosition)
{
Vector3 directionDamage = (attackerPosition - playerControllerTransform.position).normalized;
Vector3 playerForward = playerControllerTransform.forward;
bool isFacingDamage = Vector2.Dot (directionDamage, playerForward) > 0;
if (isFacingDamage) {
return true;
}
return false;
}
float lastTimeHitReaction;
float currentReactionDelayUntilNextReaction = 0;
void activateHitReactionByIndex (int hitReactionIndex, float damageReceived, float originalDamageAmountReceived, bool unblockableDamage, GameObject objectBlocked)
{
if (hitReactionIndex > -1) {
currentHitReactionInfo = hitReactionInfoList [hitReactionIndex];
if (currentHitReactionInfo.useProbabilityToActivateReaction) {
float probabilityToActivateReaction = Random.Range (0, 100);
float currentProbability = currentHitReactionInfo.probabilityToActivateReaction * probabilityToActivateReactionMultiplier;
if (currentProbability < probabilityToActivateReaction) {
return;
}
}
if (!currentHitReactionInfo.ignoreReactionDelayFromPreviousReaction) {
if (currentReactionDelayUntilNextReaction > 0 && Time.time < currentReactionDelayUntilNextReaction + lastTimeHitReaction) {
if (showDebugPrint) {
print ("\n reaction delay from previous reaction is active, disabling reaction activation \n");
}
return;
}
currentReactionDelayUntilNextReaction = 0;
if (currentHitReactionInfo.setReactionDelayUntilNextReaction) {
currentReactionDelayUntilNextReaction = currentHitReactionInfo.reactionDelayUntilNextReaction;
}
}
lastTimeHitReaction = Time.time;
bool checkMinWaitTimeResult = false;
if (Time.time > currentHitReactionInfo.minWaitTimeToPlayHitReactionAgain +
currentHitReactionInfo.lastTimeHitReaction) {
checkMinWaitTimeResult = true;
}
if (ignoreMinWaitTimeToPlayHitReactionAgain) {
checkMinWaitTimeResult = true;
}
if (checkMinWaitTimeResult) {
currentHitReactionInfo.lastTimeHitReaction = Time.time;
bool canActivateHitReaction = true;
bool perfectBlockActivated = false;
if (!currentHitReactionInfo.activateHitReactionOnPerfectBlock && !unblockableDamage) {
if (currentHitReactionInfo.reactionOnBlock && currentHitReactionInfo.canUsePerfectBlock) {
if (lastTimeBlockActive != 0) {
if (Time.time < lastTimeBlockActive + currentHitReactionInfo.maxTimeToPerfectBlock) {
canActivateHitReaction = false;
perfectBlockActivated = true;
}
}
}
}
if (showDebugPrint) {
print ("\n\n");
print (currentHitReactionInfo.Name + " " + damageReceived + " " + playerControllerTransform.name + " " + perfectBlockActivated + " " + canActivateHitReaction);
}
if (canActivateHitReaction) {
if (useMainEventOnHitReactionFound) {
mainEventOnHitReactionFound.Invoke ();
}
if (currentHitReactionInfo.stopPreviousActionIfActive) {
mainPlayerActionSystem.stopAllActions ();
}
if (currentHitReactionInfo.playHitAction) {
mainPlayerActionSystem.activateCustomAction (currentHitReactionInfo.hitActionName);
}
} else {
if (perfectBlockActivated) {
if (currentHitReactionInfo.stopPreviousActionIfActive) {
mainPlayerActionSystem.stopAllActions ();
}
if (currentHitReactionInfo.playHitAction) {
mainPlayerActionSystem.activateCustomAction (currentHitReactionInfo.hitActionNameOnPerfectBlock);
}
}
}
if (currentHitReactionInfo.useStaminaOnBlock) {
float currentDamageReceived = damageReceived;
if (currentDamageReceived == 0) {
currentDamageReceived = originalDamageAmountReceived;
}
float staminaAmountToUse = currentHitReactionInfo.staminaToUseMultiplier * currentDamageReceived;
currentHitReactionInfo.eventToUseStamina.Invoke (staminaAmountToUse);
}
if (canActivateHitReaction) {
currentHitReactionInfo.eventOnHit.Invoke ();
} else {
if (perfectBlockActivated) {
currentHitReactionInfo.eventOnHitReactionOnPerfectBlock.Invoke ();
if (currentHitReactionInfo.useRemoteEvent) {
bool useRemoteEvents = false;
if (objectBlocked != null) {
if (currentHitReactionInfo.checkObjectsToUseRemoteEventsOnDamage) {
if ((1 << objectBlocked.layer & currentHitReactionInfo.layerToUseRemoteEventsOnDamage.value) == 1 << objectBlocked.layer) {
useRemoteEvents = true;
}
} else {
useRemoteEvents = true;
}
if (useRemoteEvents) {
remoteEventSystem currentRemoteEventSystem = objectBlocked.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
int remoteEventNameListCount = currentHitReactionInfo.remoteEventNameList.Count;
for (int j = 0; j < remoteEventNameListCount; j++) {
currentRemoteEventSystem.callRemoteEvent (currentHitReactionInfo.remoteEventNameList [j]);
}
if (!ignoreParryActive) {
if (currentHitReactionInfo.useRemoteEventToEnableParryInteraction) {
for (int j = 0; j < currentHitReactionInfo.remoteEventToEnableParryInteractionNameList.Count; j++) {
currentRemoteEventSystem.callRemoteEvent (currentHitReactionInfo.remoteEventToEnableParryInteractionNameList [j]);
}
}
}
}
}
}
}
}
}
}
}
}
public void checkDamageStateTemporally (float damageReceived, bool damageBlockedByShieldSystem)
{
// print (damageReceived);
bool damageStateFound = false;
if (damageReceived > 0) {
if (damageBlockedByShieldSystem) {
damageReceived /= 2;
}
for (int i = 0; i < damageStateInfoList.Count; i++) {
damageStateInfo currentDamageStateInfo = damageStateInfoList [i];
if (!damageStateFound && currentDamageStateInfo.damageStateEnabled) {
if (currentDamageStateInfo.damageStateRange.x <= damageReceived &&
currentDamageStateInfo.damageStateRange.y >= damageReceived) {
// print (currentDamageStateInfoName);
currentDamageStateInfo.eventOnDamageState.Invoke ();
damageStateFound = true;
}
}
}
}
if (!damageStateFound) {
for (int i = 0; i < damageStateInfoList.Count; i++) {
damageStateInfo currentDamageStateInfo = damageStateInfoList [i];
if (!damageStateFound && currentDamageStateInfo.damageStateEnabled) {
if (currentDamageStateInfo.useAsDefaultState) {
currentDamageStateInfo.eventOnDamageState.Invoke ();
// print (currentDamageStateInfo.Name);
damageStateFound = true;
}
}
}
}
}
public void setHitReactionActiveState (bool state)
{
hitReactionActive = state;
}
public bool getHitReactionActiveState ()
{
return hitReactionActive;
}
public void setHitReactionBlockIDValue (int newBlockID)
{
currentBlockID = newBlockID;
if (currentBlockID != -1) {
currentBlockIDToCheck = -1;
for (int i = 0; i < hitReactionInfoList.Count; i++) {
hitReactionInfo temporalReationInfo = hitReactionInfoList [i];
if (currentBlockIDToCheck == -1 &&
temporalReationInfo.reactionOnBlock &&
temporalReationInfo.reactionCategory.Equals (currentReactionCategory) &&
temporalReationInfo.canUsePerfectBlock &&
temporalReationInfo.blockID == currentBlockID) {
float probabilityForPerfectBlock = Random.Range (0, 100);
if (temporalReationInfo.probabilityForPerfectBlock >= probabilityForPerfectBlock) {
currentBlockIDToCheck = i;
}
}
}
if (currentBlockIDToCheck > -1) {
lastTimeBlockActive = Time.time;
setPerfectBlockDuration ();
} else {
lastTimeBlockActive = 0;
}
} else {
lastTimeBlockActive = 0;
stopSetPerfectBlockDurationCoroutine ();
if (currentBlockIDToCheck > -1) {
hitReactionInfoList [currentBlockIDToCheck].eventOnDisablePerfectBlock.Invoke ();
currentBlockIDToCheck = -1;
}
}
}
public void setPerfectBlockDuration ()
{
stopSetPerfectBlockDurationCoroutine ();
perfectBlockCoroutine = StartCoroutine (setPerfectBlockDurationCoroutine ());
}
void stopSetPerfectBlockDurationCoroutine ()
{
if (perfectBlockCoroutine != null) {
StopCoroutine (perfectBlockCoroutine);
}
}
IEnumerator setPerfectBlockDurationCoroutine ()
{
hitReactionInfo temporalReationInfo = hitReactionInfoList [currentBlockIDToCheck];
temporalReationInfo.eventOnEnablePerfectBlock.Invoke ();
float maxTimeToPerfectBlock = temporalReationInfo.maxTimeToPerfectBlock;
var currentWaitTime = new WaitForSeconds (maxTimeToPerfectBlock);
yield return currentWaitTime;
temporalReationInfo.eventOnDisablePerfectBlock.Invoke ();
}
public void setCurrentReactionCategory (string newCategory)
{
currentReactionCategory = newCategory;
}
public void setNewProbabilityToActivateReactionMultiplierValue (float newValue)
{
if (!canChangeProbabilityMultiplierExternally) {
return;
}
probabilityToActivateReactionMultiplier = newValue;
}
public void setHitReactionsEnabledState (bool state)
{
hitReactionsEnabled = state;
}
public void setDamageReactionPausedState (bool state)
{
damageReactionPaused = state;
}
public bool isDamageReactionPaused ()
{
return damageReactionPaused;
}
public void setIgnoreParryActiveState (bool state)
{
ignoreParryActive = state;
}
public void setHitReactionsEnabledStateFromEditor (bool state)
{
setHitReactionsEnabledState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Updating Damage Reaction System " + gameObject.name, gameObject);
}
[System.Serializable]
public class hitReactionInfo
{
[Header ("Main Settings")]
[Space]
public string Name;
public bool reactionEnabled = true;
public int damageReactionID = -1;
public string reactionCategory;
public float minAmountToReceiveDamage;
public hitDamageDirection damageDirection;
public bool useProbabilityToActivateReaction = true;
public float probabilityToActivateReaction = 100;
public float minWaitTimeToPlayHitReactionAgain;
[Space]
[Header ("Pause Reaction Activation Settings")]
[Space]
public bool setReactionDelayUntilNextReaction;
public float reactionDelayUntilNextReaction;
public bool ignoreReactionDelayFromPreviousReaction;
[Space]
[Header ("Action Settings")]
[Space]
public bool playHitAction;
public string hitActionName;
public string hitActionNameOnPerfectBlock;
public bool stopPreviousActionIfActive;
[Space]
[Header ("Hit Reaction On Block Settings")]
[Space]
public bool reactionOnBlock;
public int blockID;
public bool useStaminaOnBlock;
public float staminaToUseMultiplier = 1;
[Space]
public eventParameters.eventToCallWithAmount eventToUseStamina;
[Space]
[Header ("Perfect Block Settings")]
[Space]
public bool canUsePerfectBlock;
public bool activateHitReactionOnPerfectBlock;
public float probabilityForPerfectBlock = 100;
public float maxTimeToPerfectBlock = 0.5f;
[Space]
public UnityEvent eventOnEnablePerfectBlock;
public UnityEvent eventOnDisablePerfectBlock;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnHit;
[HideInInspector] public float lastTimeHitReaction;
public UnityEvent eventOnHitReactionOnPerfectBlock;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool checkObjectsToUseRemoteEventsOnDamage;
public LayerMask layerToUseRemoteEventsOnDamage;
public bool useRemoteEvent;
public List<string> remoteEventNameList;
[Space]
[Space]
public bool useRemoteEventToEnableParryInteraction;
public List<string> remoteEventToEnableParryInteractionNameList;
}
public enum hitDamageDirection
{
front,
backward,
right,
left,
anyDirection
}
[System.Serializable]
public class damageStateInfo
{
public string Name;
public bool damageStateEnabled;
public Vector2 damageStateRange;
public bool useAsDefaultState;
public UnityEvent eventOnDamageState;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 38795578de5578144b0512bb0006a616
timeCreated: 1594503281
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/Health/damageHitReactionSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,111 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class damageInScreen : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
[Tooltip ("Show or hide the damage and healing numbers for the player and friends in the game window.")]
public bool showScreenInfoEnabled;
public int damageOnScreenId;
public bool removeDamageInScreenOnDeath = true;
public Vector3 iconOffset;
public string mainManagerName = "Damage On Screen Info Manager";
[Space]
[Header ("Debug")]
[Space]
public bool pauseDamageInScreen;
[Space]
[Header ("Components")]
[Space]
public Transform targetTransform;
bool damageOnScreenInfoManagerLocated;
damageOnScreenInfoSystem damageOnScreenInfoManager;
void Start ()
{
initializeDamageInScreenComponent ();
}
public void showScreenInfo (float amount, bool damage, Vector3 direction, float healthAmount, float criticalDamageProbability)
{
if (showScreenInfoEnabled && !pauseDamageInScreen) {
if (showScreenInfoEnabled && !pauseDamageInScreen) {
if (damageOnScreenInfoManagerLocated) {
damageOnScreenInfoManager.setDamageInfo (damageOnScreenId, amount, damage, direction,
healthAmount, criticalDamageProbability);
}
}
}
}
public void pauseOrPlayDamageInScreen (bool state)
{
pauseDamageInScreen = state;
}
public void setShowScreenInfoEnabledState (bool state)
{
showScreenInfoEnabled = state;
}
public void setShowScreenInfoEnabledStateFromEditor (bool state)
{
setShowScreenInfoEnabledState (state);
updateComponent ();
}
public void initializeDamageInScreenComponent ()
{
if (targetTransform == null) {
targetTransform = transform;
}
damageOnScreenInfoManagerLocated = damageOnScreenInfoManager != null;
if (!damageOnScreenInfoManagerLocated) {
damageOnScreenInfoManager = damageOnScreenInfoSystem.Instance;
damageOnScreenInfoManagerLocated = damageOnScreenInfoManager != null;
}
if (!damageOnScreenInfoManagerLocated) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (damageOnScreenInfoSystem.getMainManagerName (), typeof(damageOnScreenInfoSystem), true);
damageOnScreenInfoManager = damageOnScreenInfoSystem.Instance;
damageOnScreenInfoManagerLocated = (damageOnScreenInfoManager != null);
}
if (!damageOnScreenInfoManagerLocated) {
damageOnScreenInfoManager = FindObjectOfType<damageOnScreenInfoSystem> ();
damageOnScreenInfoManagerLocated = damageOnScreenInfoManager != null;
}
if (damageOnScreenInfoManagerLocated) {
damageOnScreenId = damageOnScreenInfoManager.addNewTarget (targetTransform, removeDamageInScreenOnDeath, iconOffset);
} else {
showScreenInfoEnabled = false;
}
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: e38539b6354282345abf4dc1924ff441
timeCreated: 1470437874
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/Health/damageInScreen.cs
uploadId: 814740

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class damageInfo
{
public GameObject projectile;
public GameObject objectToDamage;
public float damageAmount;
public Vector3 direction;
public Vector3 position;
public GameObject projectileOwner;
public bool damageConstant;
public bool searchClosestWeakSpot;
public bool ignoreShield;
public bool ignoreDamageInScreen;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: befbb0fdacd9c144592deb61ae26d6d2
timeCreated: 1580887482
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/Health/damageInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,201 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class damageOnScreenInfoSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool showDamageActive = true;
[Space]
[Header ("Debug")]
[Space]
public List<targetInfo> targetInfoList = new List<targetInfo> ();
public List<playerDamageOnScreenInfoSystem> playerDamageOnScreenInfoSystemList = new List<playerDamageOnScreenInfoSystem> ();
int currentID = 0;
public const string mainManagerName = "Damage On Screen Info Manager";
public static string getMainManagerName ()
{
return mainManagerName;
}
private static damageOnScreenInfoSystem _damageOnScreenInfoSystemInstance;
public static damageOnScreenInfoSystem Instance { get { return _damageOnScreenInfoSystemInstance; } }
bool instanceInitialized;
public void getComponentInstance ()
{
if (instanceInitialized) {
return;
}
if (_damageOnScreenInfoSystemInstance != null && _damageOnScreenInfoSystemInstance != this) {
Destroy (this.gameObject);
return;
}
_damageOnScreenInfoSystemInstance = this;
instanceInitialized = true;
}
void Awake ()
{
getComponentInstance ();
}
public void addNewPlayer (playerDamageOnScreenInfoSystem newPlayer)
{
if (!showDamageActive) {
return;
}
newPlayer.damageOnScreenId = currentID;
playerDamageOnScreenInfoSystemList.Add (newPlayer);
currentID++;
int targetInfoListCount = targetInfoList.Count;
if (targetInfoListCount > 0) {
for (int i = 0; i < targetInfoListCount; i++) {
newPlayer.addNewTarget (targetInfoList [i]);
}
}
}
public int addNewTarget (Transform newTarget, bool removeDamageInScreenOnDeathValue, Vector3 iconOffset)
{
if (!showDamageActive) {
return -1;
}
targetInfo newTargetInfo = new targetInfo ();
newTargetInfo.Name = newTarget.name;
newTargetInfo.target = newTarget;
newTargetInfo.iconOffset = iconOffset;
newTargetInfo.useIconOffset = iconOffset != Vector3.zero;
newTargetInfo.ID = currentID;
newTargetInfo.removeDamageInScreenOnDeath = removeDamageInScreenOnDeathValue;
targetInfoList.Add (newTargetInfo);
for (int i = 0; i < playerDamageOnScreenInfoSystemList.Count; i++) {
playerDamageOnScreenInfoSystemList [i].addNewTarget (newTargetInfo);
}
currentID++;
return currentID - 1;
}
public void setDamageInfo (int objectId, float amount, bool isDamage, Vector3 direction, float healhtAmount, float criticalDamageProbability)
{
if (!showDamageActive) {
return;
}
for (int j = 0; j < targetInfoList.Count; j++) {
if (targetInfoList [j].ID == objectId) {
for (int i = 0; i < playerDamageOnScreenInfoSystemList.Count; i++) {
playerDamageOnScreenInfoSystemList [i].setDamageInfo (j, amount, isDamage, direction, healhtAmount, criticalDamageProbability);
}
return;
}
}
}
//if the target is reached, disable all the parameters and clear the list, so a new objective can be added in any moment
public void removeElementFromList (int objectId)
{
if (!showDamageActive) {
return;
}
for (int j = 0; j < targetInfoList.Count; j++) {
if (targetInfoList [j].ID == objectId) {
for (int i = 0; i < playerDamageOnScreenInfoSystemList.Count; i++) {
playerDamageOnScreenInfoSystemList [i].removeElementFromList (objectId);
}
targetInfoList.RemoveAt (j);
return;
}
}
}
public void removeElementFromTargetListCalledByPlayer (int objectId, GameObject currentPlayer)
{
if (!showDamageActive) {
return;
}
for (int i = 0; i < targetInfoList.Count; i++) {
if (targetInfoList [i].ID == objectId) {
targetInfoList.Remove (targetInfoList [i]);
for (int j = 0; j < playerDamageOnScreenInfoSystemList.Count; j++) {
if (playerDamageOnScreenInfoSystemList [j].player != currentPlayer) {
playerDamageOnScreenInfoSystemList [j].removeElementFromList (objectId);
}
}
return;
}
}
}
[System.Serializable]
public class targetInfo
{
public string Name;
public Transform target;
public Vector3 iconOffset;
public bool useIconOffset;
public int ID;
public RectTransform targetRectTransform;
public GameObject targetRectTransformGameObject;
public CanvasGroup mainCanvasGroup;
public bool removeDamageInScreenOnDeath;
public bool iconActive;
public bool isDead;
public bool containsNumberToShow;
public List<damageNumberInfo> damageNumberInfoList = new List<damageNumberInfo> ();
}
[System.Serializable]
public class damageNumberInfo
{
public Text damageNumberText;
public RectTransform damageNumberRectTransform;
public Coroutine movementCoroutine;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 23d720b085a49de44ae99b215f45e4ac
timeCreated: 1552373165
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/Health/damageOnScreenInfoSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,263 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class damageOrHealTrigger : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool useWithPlayer;
public bool useWithVehicles;
public bool useWithCharacters;
public List<string> tagToAffectList = new List<string> ();
[Space]
[Header ("Damage-Health Settinga")]
[Space]
public bool addAmountEnabled;
public bool removeAmountEnabled;
public bool canHeal;
public float healRate;
public float healtAmount;
public bool canRefillEnergy;
public float energyRate;
public float energyAmount;
public bool canRefillFuel;
public float fuelRate;
public float fuelAmount;
[Space]
[Header ("Other Settinga")]
[Space]
public bool ignoreShield;
public bool canActivateReactionSystemTemporally;
public int damageReactionID = -1;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
public bool applyValueAtOnce;
[Space]
[Header ("Components")]
[Space]
public GameObject player;
public GameObject objectWithHealth;
bool objectInside;
float lastTime;
float valueToAdd;
void Update ()
{
//if an object which can be damaged is inside the trigger, then
if (objectInside && objectWithHealth) {
if (addAmountEnabled) {
//if the trigger heals
if (canHeal) {
if (Time.time > lastTime + healRate) {
//while the object is not fully healed, then
if (!applyDamage.checkIfMaxHealth (objectWithHealth)) {
valueToAdd = healtAmount;
if (applyValueAtOnce) {
valueToAdd = applyDamage.getMaxHealthAmount (objectWithHealth);
}
//heal it
applyDamage.setHeal (valueToAdd, objectWithHealth);
lastTime = Time.time;
} else {
//else, stop healing it
changeTriggerState (false, null, 0);
return;
}
}
}
if (canRefillFuel) {
//if the trigger recharges fuel
if (Time.time > lastTime + fuelRate) {
//while the vehicle has not the max fuel amount, then
if (!applyDamage.checkIfMaxFuel (objectWithHealth)) {
valueToAdd = fuelAmount;
if (applyValueAtOnce) {
valueToAdd = applyDamage.getMaxFuelAmount (objectWithHealth);
}
//fill it
applyDamage.setFuel (valueToAdd, objectWithHealth);
lastTime = Time.time;
} else {
//else, stop refill it
changeTriggerState (false, null, 0);
return;
}
}
}
if (canRefillEnergy) {
//if the trigger recharges energy
if (Time.time > lastTime + energyRate) {
//while the vehicle has not the max fuel amount, then
if (!applyDamage.checkIfMaxEnergy (objectWithHealth)) {
valueToAdd = energyAmount;
if (applyValueAtOnce) {
valueToAdd = applyDamage.getMaxEnergyAmount (objectWithHealth);
}
//fill it
applyDamage.setEnergy (valueToAdd, objectWithHealth);
lastTime = Time.time;
} else {
//else, stop refill it
changeTriggerState (false, null, 0);
return;
}
}
}
}
if (removeAmountEnabled) {
if (canHeal) {
//apply damage or heal it accordint to the time rate
if (Time.time > lastTime + healRate) {
//if the trigger damages
valueToAdd = healtAmount;
if (applyValueAtOnce) {
valueToAdd = applyDamage.getCurrentHealthAmount (objectWithHealth);
}
//apply damage
applyDamage.checkHealth (gameObject, objectWithHealth, valueToAdd, Vector3.zero, objectWithHealth.transform.position + objectWithHealth.transform.up,
gameObject, true, true, ignoreShield, false, damageCanBeBlocked, canActivateReactionSystemTemporally, damageReactionID, damageTypeID);
lastTime = Time.time;
//if the object inside the trigger is dead, stop applying damage
if (applyDamage.checkIfDead (objectWithHealth)) {
changeTriggerState (false, null, 0);
return;
}
}
}
if (canRefillFuel) {
if (Time.time > lastTime + fuelRate) {
//while the vehicle has not the max fuel amount, then
if (applyDamage.getCurrentFuelAmount (objectWithHealth) > 0) {
valueToAdd = fuelAmount;
if (applyValueAtOnce) {
valueToAdd = applyDamage.getMaxFuelAmount (objectWithHealth);
}
//fill it
applyDamage.removeFuel (valueToAdd, objectWithHealth);
lastTime = Time.time;
} else {
//else, stop refill it
changeTriggerState (false, null, 0);
return;
}
}
}
if (Time.time > lastTime + energyRate) {
if (canRefillEnergy) {
//while the vehicle has not the max fuel amount, then
if (applyDamage.getCurrentEnergyAmount (objectWithHealth) > 0) {
valueToAdd = energyAmount;
if (applyValueAtOnce) {
valueToAdd = applyDamage.getMaxEnergyAmount (objectWithHealth);
}
//fill it
applyDamage.removeEnergy (valueToAdd, objectWithHealth);
lastTime = Time.time;
} else {
//else, stop refill it
changeTriggerState (false, null, 0);
return;
}
}
}
}
}
}
void OnTriggerEnter (Collider col)
{
//if the player enters the trigger and it can used with him, then
if (col.gameObject.CompareTag ("Player") && useWithPlayer) {
player = col.gameObject;
//if he is not driving, apply damage or heal
if (!player.GetComponent<playerController> ().driving) {
changeTriggerState (true, player, Time.time);
}
}
//else, if a vehicle is inside the trigger and it can be used with vehicles, them
else if (isInTagToAffectList (col.gameObject) && col.gameObject.GetComponent<vehicleHUDManager> () && useWithVehicles) {
changeTriggerState (true, col.gameObject, Time.time);
} else if (isInTagToAffectList (col.gameObject) && col.gameObject.GetComponent<AINavMesh> () && useWithCharacters) {
changeTriggerState (true, col.gameObject, Time.time);
}
}
void OnTriggerExit (Collider col)
{
//if the player or a vehicle exits, stop the healing or the damaging
if (col.gameObject.CompareTag ("Player") && useWithPlayer) {
changeTriggerState (false, null, 0);
} else if (isInTagToAffectList (col.gameObject) && col.gameObject.GetComponent<vehicleHUDManager> () && useWithVehicles) {
changeTriggerState (false, null, 0);
} else if (isInTagToAffectList (col.gameObject) && col.gameObject.GetComponent<AINavMesh> () && useWithCharacters) {
changeTriggerState (false, null, 0);
}
}
//stop or start the heal or damage action
void changeTriggerState (bool inside, GameObject obj, float time)
{
objectInside = inside;
objectWithHealth = obj;
lastTime = time;
}
public bool isInTagToAffectList (GameObject objectToCheck)
{
if (tagToAffectList.Contains (objectToCheck.tag)) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 86e738f1c371bdf41b17001989464e30
timeCreated: 1471278176
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/Health/damageOrHealTrigger.cs
uploadId: 814740

View File

@@ -0,0 +1,357 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
public class damageScreenSystem : MonoBehaviour
{
[Header ("Main Setting")]
[Space]
public bool damageScreenEnabled;
public Color damageColor;
public float maxAlphaDamage = 0.6f;
public float fadeToDamageColorSpeed;
public float fadeToTransparentSpeed;
public float timeToStartToHeal;
public bool showDamageDirection;
public bool showDamagePositionWhenEnemyVisible;
public bool showAllDamageDirections;
public bool checkHealthAmountOnStart;
public bool usedByAI;
[Space]
[Header ("Components")]
[Space]
public GameObject damageScreen;
public GameObject damageDirectionIcon;
public GameObject damagePositionIcon;
public GameObject playerControllerGameObject;
public playerCamera mainPlayerCamera;
public Camera mainCamera;
public RawImage damageImage;
public health healtManager;
[Space]
[Header ("Debug")]
[Space]
public List<damageInfo> enemiesDamageList = new List<damageInfo> ();
bool wounding;
bool healWounds;
int i, j;
Vector2 mainCanvasSizeDelta;
Vector2 halfMainCanvasSizeDelta;
Vector2 iconPosition2d;
bool usingScreenSpaceCamera;
bool targetOnScreen;
Vector3 screenPoint;
float angle;
Vector3 screenCenter;
bool showDamageImage;
float screenWidth;
float screenHeight;
Vector3 currentPosition;
damageInfo currentDamageInfo;
float lastTimeWounded;
bool canStartToHeal;
bool noAttackerFound;
void Start ()
{
if (usedByAI) {
return;
}
damageImage.color = damageColor;
mainCanvasSizeDelta = mainPlayerCamera.getMainCanvasSizeDelta ();
halfMainCanvasSizeDelta = mainCanvasSizeDelta * 0.5f;
usingScreenSpaceCamera = mainPlayerCamera.isUsingScreenSpaceCamera ();
if (checkHealthAmountOnStart) {
checkHealthState ();
}
if (mainCamera == null) {
mainCamera = mainPlayerCamera.getMainCamera ();
}
}
void FixedUpdate ()
{
if (usedByAI) {
return;
}
if (damageScreenEnabled) {
//if the player is wounded, then activate the icon that aims to the enemy position, so the player can see the origin of the damage
//also, the screen color changes to red, setting the alpha value of a panel in the hud
if (wounding) {
if (showDamageImage) {
Color alpha = damageImage.color;
if (alpha.a < maxAlphaDamage) {
float alphaValue = 1 - healtManager.getCurrentHealthAmount () / healtManager.getMaxHealthAmount ();
alpha.a = Mathf.Lerp (alpha.a, alphaValue, Time.deltaTime * fadeToDamageColorSpeed);
} else {
alpha.a = maxAlphaDamage;
}
damageImage.color = alpha;
}
if (showDamageDirection) {
if (!usingScreenSpaceCamera) {
updateScreenValues ();
}
for (i = 0; i < enemiesDamageList.Count; i++) {
currentDamageInfo = enemiesDamageList [i];
if (currentDamageInfo.enemy != null && currentDamageInfo.enemy != playerControllerGameObject) {
//get the target position from global to local in the screen
currentPosition = currentDamageInfo.enemy.transform.position;
if (usingScreenSpaceCamera) {
screenPoint = mainCamera.WorldToViewportPoint (currentPosition);
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1;
} else {
screenPoint = mainCamera.WorldToScreenPoint (currentPosition);
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < screenWidth && screenPoint.y > 0 && screenPoint.y < screenHeight;
}
//if the target is visible in the screen, disable the arrow
if (targetOnScreen) {
if (currentDamageInfo.damageDirection.activeSelf) {
currentDamageInfo.damageDirection.SetActive (false);
}
if (showDamagePositionWhenEnemyVisible) {
if (!currentDamageInfo.damagePosition.activeSelf) {
currentDamageInfo.damagePosition.SetActive (true);
}
if (usingScreenSpaceCamera) {
iconPosition2d = new Vector2 ((screenPoint.x * mainCanvasSizeDelta.x) - halfMainCanvasSizeDelta.x,
(screenPoint.y * mainCanvasSizeDelta.y) - halfMainCanvasSizeDelta.y);
currentDamageInfo.damagePositionRectTransform.anchoredPosition = iconPosition2d;
} else {
currentDamageInfo.damagePosition.transform.position = new Vector3 (screenPoint.x, screenPoint.y, 0);
}
}
} else {
//if the target is off screen, rotate the arrow to the target direction
if (!currentDamageInfo.damageDirection.activeSelf) {
currentDamageInfo.damageDirection.SetActive (true);
currentDamageInfo.damagePosition.SetActive (false);
}
if (usingScreenSpaceCamera) {
iconPosition2d = new Vector2 ((screenPoint.x * mainCanvasSizeDelta.x) - halfMainCanvasSizeDelta.x, (screenPoint.y * mainCanvasSizeDelta.y) - halfMainCanvasSizeDelta.y);
if (screenPoint.z < 0) {
iconPosition2d *= -1;
}
angle = Mathf.Atan2 (iconPosition2d.y, iconPosition2d.x);
angle -= 90 * Mathf.Deg2Rad;
} else {
if (screenPoint.z < 0) {
screenPoint *= -1;
}
screenCenter = new Vector3 (screenWidth, screenHeight, 0) / 2;
screenPoint -= screenCenter;
angle = Mathf.Atan2 (screenPoint.y, screenPoint.x);
angle -= 90 * Mathf.Deg2Rad;
}
currentDamageInfo.damageDirection.transform.rotation = Quaternion.Euler (0, 0, angle * Mathf.Rad2Deg);
}
//if the player is not damaged for a while, disable the arrow
if (Time.time > currentDamageInfo.woundTime + timeToStartToHeal) {
Destroy (currentDamageInfo.damageDirection);
Destroy (currentDamageInfo.damagePosition);
enemiesDamageList.RemoveAt (i);
}
} else {
enemiesDamageList.RemoveAt (i);
}
}
}
}
if (wounding) {
canStartToHeal = (Time.time > lastTimeWounded + timeToStartToHeal);
if ((!showAllDamageDirections && canStartToHeal) ||
(showAllDamageDirections && enemiesDamageList.Count == 0)) {
if (!noAttackerFound || canStartToHeal) {
healWounds = true;
wounding = false;
}
}
}
//if the player is not reciving damage for a while, then set alpha of the red color of the background to 0
if (healWounds || (wounding && enemiesDamageList.Count == 0 && showAllDamageDirections)) {
if (showDamageImage) {
Color alpha = damageImage.color;
alpha.a -= Time.deltaTime * fadeToTransparentSpeed;
damageImage.color = alpha;
if (alpha.a <= 0) {
damageScreen.SetActive (false);
healWounds = false;
}
} else {
damageScreen.SetActive (false);
healWounds = false;
}
}
}
}
public void checkHealthState ()
{
if (!damageScreenEnabled) {
return;
}
if (healtManager.getCurrentHealthAmount () < healtManager.getMaxHealthAmount ()) {
lastTimeWounded = Time.time;
showDamageImage = true;
wounding = true;
if (!damageScreen.activeSelf) {
damageScreen.SetActive (true);
}
}
}
public void setDamageDirectionWithDamageScreen (GameObject enemy)
{
setDamageDir (enemy, true);
}
public void setDamageDirectionWithoutDamageScreen (GameObject enemy)
{
setDamageDir (enemy, false);
}
//set the direction of the damage arrow to see the enemy that injured the player
public void setDamageDir (GameObject enemy, bool showDamageImageValue)
{
if (showAllDamageDirections) {
bool enemyFound = false;
int index = -1;
if (enemy == null) {
noAttackerFound = true;
}
for (j = 0; j < enemiesDamageList.Count; j++) {
if (enemiesDamageList [j].enemy == enemy) {
index = j;
enemyFound = true;
noAttackerFound = false;
}
}
if (!enemyFound) {
damageInfo newEnemy = new damageInfo ();
newEnemy.enemy = enemy;
GameObject newDirection = (GameObject)Instantiate (damageDirectionIcon, Vector3.zero, Quaternion.identity, damageScreen.transform);
newDirection.transform.localScale = Vector3.one;
newDirection.transform.localPosition = Vector3.zero;
newEnemy.damageDirection = newDirection;
GameObject newPosition = (GameObject)Instantiate (damagePositionIcon, Vector3.zero, Quaternion.identity, damageScreen.transform);
newPosition.transform.localScale = Vector3.one;
newPosition.transform.localPosition = Vector3.zero;
newEnemy.damagePosition = newPosition;
newEnemy.woundTime = Time.time;
newEnemy.damagePositionRectTransform = newPosition.GetComponent<RectTransform> ();
enemiesDamageList.Add (newEnemy);
} else {
if (index != -1) {
enemiesDamageList [index].woundTime = Time.time;
}
}
}
lastTimeWounded = Time.time;
showDamageImage = showDamageImageValue;
wounding = true;
if (!damageScreen.activeSelf) {
damageScreen.SetActive (true);
}
}
public void setUsedByAIState (bool state)
{
usedByAI = state;
}
public void setDamageScreenEnabledState (bool state)
{
damageScreenEnabled = state;
}
public void updateScreenValues ()
{
screenWidth = Screen.width;
screenHeight = Screen.height;
}
public void setDamageScreenEnabledStateFromEditor (bool state)
{
damageScreenEnabled = state;
GKC_Utils.updateComponent (this);
}
[System.Serializable]
public class damageInfo
{
public GameObject enemy;
public GameObject damageDirection;
public GameObject damagePosition;
public float woundTime;
public RectTransform damagePositionRectTransform;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c0fabb2a90d9a5a488e4d3b739f90b61
timeCreated: 1469638828
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/Health/damageScreenSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,378 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
using UnityEngine.Events;
public class destroyableObject : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool explosionEnabled = true;
public GameObject destroyedParticles;
public AudioClip destroyedSound;
public AudioElement destroyedAudioElement;
[Space]
[Header ("Explosion Settings")]
[Space]
public bool useExplosionForceWhenDestroyed;
public float explosionRadius;
public float explosionForce;
public float explosionDamage;
public bool ignoreShield;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
public bool killObjectsInRadius;
public ForceMode forceMode;
public bool applyExplosionForceToVehicles = true;
public float explosionForceToVehiclesMultiplier = 0.2f;
public bool pushCharactersOnExplosion = true;
public bool searchClosestWeakSpot;
[Space]
[Header ("Damage Over Time Settings")]
[Space]
public bool damageTargetOverTime;
public float damageOverTimeDelay;
public float damageOverTimeDuration;
public float damageOverTimeAmount;
public float damageOverTimeRate;
public bool damageOverTimeToDeath;
public bool removeDamageOverTimeState;
[Space]
[Header ("Detect Objects Settings")]
[Space]
public bool userLayerMask;
public LayerMask layer;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEventOnObjectsFound;
public string removeEventName;
[Space]
[Header ("Object Pieces Settings")]
[Space]
public bool fadePiecesEnabled = true;
public float timeToFadePieces;
public bool storeRendererParts = true;
public bool disableColliders = true;
public bool destroyObjectAfterFacePieces = true;
public Shader transparentShader;
public string defaultShaderName = "Legacy Shaders/Transparent/Diffuse";
[Space]
[Header ("Meshes Force Settings")]
[Space]
public float meshesExplosionForce = 500;
public float meshesExplosionRadius = 50;
public ForceMode meshesExplosionForceMode;
[Space]
[Header ("Extra Pieces Settings")]
[Space]
public bool useExtraParts;
public List<GameObject> extraParts = new List<GameObject> ();
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnObjectDestroyed;
public UnityEvent eventOnObjectDestroyed;
public bool useEventOnObjectBeforeDestroyed;
public UnityEvent eventOnObjectBeforeDestroyed;
[Space]
[Header ("Debug")]
[Space]
public bool destroyed;
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
[Space]
[Header ("Components")]
[Space]
public Rigidbody mainRigidbody;
public mapObjectInformation mapInformationManager;
public AudioSource destroyedSource;
public Transform explosionCenter;
List<Material> rendererParts = new List<Material> ();
bool objectDisabled;
void Start ()
{
if (mainRigidbody == null) {
mainRigidbody = GetComponent<Rigidbody> ();
}
if (mapInformationManager == null) {
mapInformationManager = GetComponent<mapObjectInformation> ();
}
if (destroyedSource == null) {
destroyedSource = GetComponent<AudioSource> ();
}
if (destroyedSound != null) {
destroyedAudioElement.clip = destroyedSound;
}
if (destroyedSource != null) {
destroyedAudioElement.audioSource = destroyedSource;
}
}
void Update ()
{
if (destroyed && !objectDisabled) {
if (destroyObjectAfterFacePieces) {
if (timeToFadePieces > 0) {
timeToFadePieces -= Time.deltaTime;
}
if (storeRendererParts) {
if (timeToFadePieces <= 0) {
if (fadePiecesEnabled) {
int piecesAmountFade = 0;
for (int i = 0; i < rendererParts.Count; i++) {
Color alpha = rendererParts [i].color;
alpha.a -= Time.deltaTime / 5;
rendererParts [i].color = alpha;
if (alpha.a <= 0) {
piecesAmountFade++;
}
}
if (piecesAmountFade == rendererParts.Count) {
Destroy (gameObject);
}
} else {
Destroy (gameObject);
}
}
} else {
if (timeToFadePieces <= 0) {
Destroy (gameObject);
}
}
} else {
objectDisabled = true;
}
}
}
//Destroy the object
public void destroyObject ()
{
if (!explosionEnabled) {
return;
}
if (destroyed) {
return;
}
//instantiated an explosiotn particles
if (destroyedParticles != null) {
GameObject destroyedParticlesClone = (GameObject)Instantiate (destroyedParticles, transform.position, transform.rotation);
destroyedParticlesClone.transform.SetParent (transform);
}
if (destroyedAudioElement != null) {
AudioPlayer.PlayOneShot (destroyedAudioElement, gameObject);
}
//set the velocity of the object to zero
if (mainRigidbody != null) {
mainRigidbody.linearVelocity = Vector3.zero;
mainRigidbody.isKinematic = true;
}
//get every renderer component if the object
if (storeRendererParts) {
if (fadePiecesEnabled) {
if (transparentShader == null) {
transparentShader = Shader.Find (defaultShaderName);
}
}
Component[] components = GetComponentsInChildren (typeof(MeshRenderer));
List<Component> componentsList = new List<Component> (components);
if (useExtraParts) {
int extraPartsCount = extraParts.Count;
for (int j = 0; j < extraPartsCount; j++) {
GameObject currentObject = extraParts [j];
if (currentObject != null) {
Component[] extraComponents = currentObject.GetComponentsInChildren (typeof(MeshRenderer));
if (extraComponents.Length > 0) {
componentsList.AddRange (extraComponents);
}
}
}
}
int ignoreRaycastLayerIndex = LayerMask.NameToLayer ("Ignore Raycast");
int layerToIgnoreIndex = LayerMask.NameToLayer ("Scanner");
int componentsListCount = componentsList.Count;
for (int i = 0; i < componentsListCount; i++) {
MeshRenderer child = componentsList [i] as MeshRenderer;
if (child != null && child.gameObject.layer != layerToIgnoreIndex) {
if (child.enabled) {
if (fadePiecesEnabled) {
//for every renderer object, change every shader in it for a transparent shader
for (int j = 0; j < child.materials.Length; j++) {
child.materials [j].shader = transparentShader;
rendererParts.Add (child.materials [j]);
}
}
//set the layer ignore raycast to them
child.gameObject.layer = ignoreRaycastLayerIndex;
//add rigidbody and box collider to them
Rigidbody currentRigidbody = child.gameObject.GetComponent<Rigidbody> ();
if (currentRigidbody == null) {
currentRigidbody = child.gameObject.AddComponent<Rigidbody> ();
} else {
currentRigidbody.isKinematic = false;
currentRigidbody.useGravity = true;
}
Collider currentCollider = child.gameObject.GetComponent<Collider> ();
if (currentCollider == null) {
currentCollider = child.gameObject.AddComponent<BoxCollider> ();
}
//apply explosion force
currentRigidbody.AddExplosionForce (meshesExplosionForce, transform.position, meshesExplosionRadius, 3, meshesExplosionForceMode);
}
}
}
}
if (disableColliders) {
//any other object with a collider but with out renderer, is disabled
Component[] collidersInObject = GetComponentsInChildren (typeof(Collider));
int collidersInObjectLength = collidersInObject.Length;
for (int i = 0; i < collidersInObjectLength; i++) {
Collider currentCollider = collidersInObject [i] as Collider;
if (currentCollider != null && !currentCollider.GetComponent<Renderer> ()) {
currentCollider.enabled = false;
}
}
}
if (mapInformationManager != null) {
mapInformationManager.removeMapObject ();
}
if (useEventOnObjectBeforeDestroyed) {
eventOnObjectBeforeDestroyed.Invoke ();
}
if (useExplosionForceWhenDestroyed) {
if (explosionCenter == null) {
explosionCenter = transform;
}
Vector3 currentPosition = explosionCenter.position;
applyDamage.setExplosion (currentPosition, explosionRadius, userLayerMask, layer, gameObject, false, gameObject,
killObjectsInRadius, true, false, explosionDamage, pushCharactersOnExplosion, applyExplosionForceToVehicles,
explosionForceToVehiclesMultiplier, explosionForce, forceMode, true, transform, ignoreShield,
useRemoteEventOnObjectsFound, removeEventName, damageTypeID,
damageTargetOverTime, damageOverTimeDelay, damageOverTimeDuration, damageOverTimeAmount,
damageOverTimeRate, damageOverTimeToDeath, removeDamageOverTimeState, damageCanBeBlocked, searchClosestWeakSpot);
}
if (useEventOnObjectDestroyed) {
eventOnObjectDestroyed.Invoke ();
}
destroyed = true;
}
#if UNITY_EDITOR
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
if (useExplosionForceWhenDestroyed) {
Gizmos.color = Color.red;
Gizmos.DrawWireSphere (transform.position, explosionRadius);
}
}
}
#endif
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 413612fd125a12e44b58a8354b33c4c5
timeCreated: 1488306625
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/Health/destroyableObject.cs
uploadId: 814740

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class externalDamageProperties : MonoBehaviour
{
public eventParameters.eventToCallWithGameObject eventToSetDamageOwner;
public GameObject currentDamageOwner;
public void setDamageOwner (GameObject newOwner)
{
currentDamageOwner = newOwner;
eventToSetDamageOwner.Invoke (currentDamageOwner);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8b1e202681c0f6049a7ba0cb39a6cfae
timeCreated: 1581616738
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/Health/externalDamageProperties.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c23d6bae7a883c047961b819ec997d00
timeCreated: 1583943082
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 899cf2b718f6df34585a8cfa509eebd4, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Health/health.cs
uploadId: 814740

View File

@@ -0,0 +1,354 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class healthBarManagementSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool showSlidersActive = true;
[Space]
[Header ("Debug")]
[Space]
public List<healthSliderInfo> healthSliderInfoList = new List<healthSliderInfo> ();
public List<playerHealthBarManagementSystem> playerHealthBarManagementSystemList = new List<playerHealthBarManagementSystem> ();
int currentID = 0;
public const string mainManagerName = "Health Bar Manager";
public static string getMainManagerName ()
{
return mainManagerName;
}
private static healthBarManagementSystem _healthBarManagementSystemInstance;
public static healthBarManagementSystem Instance { get { return _healthBarManagementSystemInstance; } }
bool instanceInitialized;
public void getComponentInstance ()
{
if (instanceInitialized) {
// print ("already initialized manager");
return;
}
if (_healthBarManagementSystemInstance != null && _healthBarManagementSystemInstance != this) {
Destroy (this.gameObject);
// print (_healthBarManagementSystemInstance.gameObject.name);
// this.gameObject.SetActive (false);
// print ("destroy health bar");
return;
}
_healthBarManagementSystemInstance = this;
instanceInitialized = true;
}
void Awake ()
{
getComponentInstance ();
}
public void addNewPlayer (playerHealthBarManagementSystem newPlayer)
{
if (!showSlidersActive) {
return;
}
playerHealthBarManagementSystemList.Add (newPlayer);
int healthSliderInfoListCount = healthSliderInfoList.Count;
if (healthSliderInfoListCount > 0) {
for (int i = 0; i < healthSliderInfoListCount; i++) {
newPlayer.addNewTargetSlider (
healthSliderInfoList [i].sliderOwner.gameObject,
healthSliderInfoList [i].sliderPrefab,
healthSliderInfoList [i].sliderOffset,
healthSliderInfoList [i].healthAmount,
healthSliderInfoList [i].shieldAmount,
healthSliderInfoList [i].Name,
healthSliderInfoList [i].textColor,
healthSliderInfoList [i].sliderColor,
healthSliderInfoList [i].ID,
healthSliderInfoList [i].healthBarSliderActiveOnStart,
healthSliderInfoList [i].useHealthSlideInfoOnScreen,
healthSliderInfoList [i].useCircleHealthSlider);
}
}
}
public void disableHealhtBars ()
{
if (!showSlidersActive) {
return;
}
enableOrDisableHealhtBars (false);
}
public void enableHealhtBars ()
{
if (!showSlidersActive) {
return;
}
enableOrDisableHealhtBars (true);
}
public void enableOrDisableHealhtBars (bool state)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].enableOrDisableHealhtBars (state);
}
}
public int addNewTargetSlider (GameObject sliderOwner, GameObject sliderPrefab, Vector3 sliderOffset, float healthAmount,
float shieldAmount, string ownerName, Color textColor, Color sliderColor, bool healthBarSliderActiveOnStart,
bool useHealthSlideInfoOnScreen, bool useCircleHealthSlider)
{
if (!showSlidersActive) {
return -1;
}
healthSliderInfo newHealthSliderInfo = new healthSliderInfo ();
newHealthSliderInfo.Name = ownerName;
newHealthSliderInfo.sliderOwner = sliderOwner.transform;
currentID++;
newHealthSliderInfo.ID = currentID;
newHealthSliderInfo.sliderPrefab = sliderPrefab;
newHealthSliderInfo.sliderOffset = sliderOffset;
newHealthSliderInfo.healthAmount = healthAmount;
newHealthSliderInfo.shieldAmount = shieldAmount;
newHealthSliderInfo.textColor = textColor;
newHealthSliderInfo.sliderColor = sliderColor;
newHealthSliderInfo.healthBarSliderActiveOnStart = healthBarSliderActiveOnStart;
newHealthSliderInfo.useHealthSlideInfoOnScreen = useHealthSlideInfoOnScreen;
newHealthSliderInfo.useCircleHealthSlider = useCircleHealthSlider;
healthSliderInfoList.Add (newHealthSliderInfo);
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].addNewTargetSlider (sliderOwner, sliderPrefab, sliderOffset, healthAmount, shieldAmount, ownerName,
textColor, sliderColor, currentID, healthBarSliderActiveOnStart, useHealthSlideInfoOnScreen, useCircleHealthSlider);
}
return currentID;
}
public void removeTargetSlider (int objectID)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].removeTargetSlider (objectID);
}
for (int i = 0; i < healthSliderInfoList.Count; i++) {
if (healthSliderInfoList [i].ID == objectID) {
healthSliderInfoList.RemoveAt (i);
return;
}
}
}
public void removeElementFromObjectiveListCalledByPlayer (int objectId, GameObject currentPlayer)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < healthSliderInfoList.Count; i++) {
if (healthSliderInfoList [i].ID == objectId) {
healthSliderInfoList.Remove (healthSliderInfoList [i]);
for (int j = 0; j < playerHealthBarManagementSystemList.Count; j++) {
if (playerHealthBarManagementSystemList [j].playerGameObject != currentPlayer) {
playerHealthBarManagementSystemList [j].removeTargetSlider (objectId);
}
}
return;
}
}
}
public void udpateSliderInfo (int objectID, string newName, Color textColor, Color backgroundColor)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].setSliderInfo (objectID, newName, textColor, backgroundColor);
}
}
public void updateSliderAmount (int objectID, float value)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].setSliderAmount (objectID, value);
}
}
public void setSliderAmount (int objectID, float sliderValue)
{
if (!showSlidersActive) {
return;
}
updateSliderAmount (objectID, sliderValue);
}
public void updateShieldSliderAmount (int objectID, float value)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].setShieldSliderAmount (objectID, value);
}
}
public void setShieldSliderAmount (int objectID, float sliderValue)
{
if (!showSlidersActive) {
return;
}
updateShieldSliderAmount (objectID, sliderValue);
}
public void updateSliderMaxValue (int objectID, float maxSliderValue)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].updateSliderMaxValue (objectID, maxSliderValue);
}
}
public void updateShieldSliderMaxValue (int objectID, float maxSliderValue)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].updateShieldSliderMaxValue (objectID, maxSliderValue);
}
}
public void updateSliderOffset (int objectID, float value)
{
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].updateSliderOffset (objectID, value);
}
}
public void setSliderInfo (int objectID, string newName, Color textColor, Color backgroundColor)
{
if (!showSlidersActive) {
return;
}
udpateSliderInfo (objectID, newName, textColor, backgroundColor);
}
public void setSliderVisibleStateForPlayer (int objectID, GameObject player, bool state)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
if (playerHealthBarManagementSystemList [i].getPlayerGameObject () == player) {
playerHealthBarManagementSystemList [i].setSliderVisibleState (objectID, state);
}
}
}
public void setSliderLocatedState (int objectID, bool state)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].setSliderLocatedState (objectID, state);
}
}
public void setSliderLocatedStateForPlayer (int objectID, GameObject player, bool state)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
if (playerHealthBarManagementSystemList [i].getPlayerGameObject () == player) {
playerHealthBarManagementSystemList [i].setSliderLocatedState (objectID, state);
}
}
}
public void setSliderVisibleState (int objectID, bool state)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].setSliderVisibleState (objectID, state);
}
}
public void pauseOrResumeShowHealthSliders (bool state)
{
if (!showSlidersActive) {
return;
}
for (int i = 0; i < playerHealthBarManagementSystemList.Count; i++) {
playerHealthBarManagementSystemList [i].pauseOrResumeShowHealthSliders (state);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 029c5a2123abab145bd43d28f1eba171
timeCreated: 1535160064
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/Health/healthBarManagementSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,13 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
[System.Serializable]
public class healthElementInfo
{
public bool used;
public GameObject healthElementGameObject;
public Text healthSpot;
public Transform target;
public RectTransform healthElementRectTransform;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 0d43d630b978c4a47bfb55c1129b093e
timeCreated: 1509211903
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/Health/healthElementInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,414 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class healthManagement : MonoBehaviour
{
[Header ("Main Setting")]
[Space]
public bool useHealthAmountOnSpot;
public float healhtAmountOnSpot;
public bool killCharacterOnEmtpyHealthAmountOnSpot;
public bool removeComponentOnEmptyHealth;
public bool ignoreUseHealthAmountOnSpot;
[Space]
public bool useCustomCharacterRadius;
public float customCharacterRadius;
[Space]
[Header ("Events Setting")]
[Space]
public UnityEvent eventOnEmtpyHealthAmountOnSpot;
[Space]
[Header ("Debug")]
[Space]
public bool healthAmountOnSpotEmpty;
public virtual void setDamageWithHealthManagement (float damageAmount, Vector3 fromDirection, Vector3 damagePos, GameObject attacker,
GameObject projectile, bool damageConstant, bool searchClosestWeakSpot,
bool ignoreShield, bool ignoreDamageInScreen, bool damageCanBeBlocked,
bool canActivateReactionSystemTemporally,
int damageReactionID, int damageTypeID)
{
}
public virtual float getCurrentHealthAmount ()
{
return -1;
}
public virtual bool isUseShieldActive ()
{
return false;
}
public virtual float getCurrentShieldAmount ()
{
return 0;
}
public virtual bool checkIfDeadWithHealthManagement ()
{
return false;
}
public virtual bool checkIfMaxHealthWithHealthManagement ()
{
return false;
}
public virtual void setDamageTargetOverTimeStateWithHealthManagement (float damageOverTimeDelay, float damageOverTimeDuration, float damageOverTimeAmount,
float damageOverTimeRate, bool damageOverTimeToDeath, int damageTypeID)
{
}
public virtual void removeDamagetTargetOverTimeStateWithHealthManagement ()
{
}
public virtual void sedateCharacterithHealthManagement (Vector3 position, float sedateDelay, bool useWeakSpotToReduceDelay, bool sedateUntilReceiveDamage, float sedateDuration)
{
}
public virtual void setHealWithHealthManagement (float healAmount)
{
}
public virtual void setShieldWithHealthManagement (float shieldAmount)
{
}
public virtual float getCurrentHealthAmountWithHealthManagement ()
{
return 0;
}
public virtual float getMaxHealthAmountWithHealthManagement ()
{
return 0;
}
public virtual float getAuxHealthAmountWithHealthManagement ()
{
return 0;
}
public virtual void addAuxHealthAmountWithHealthManagement (float amount)
{
}
public virtual float getHealthAmountToPickWithHealthManagement (float amount)
{
return 0;
}
public virtual void killCharacterWithHealthManagement (GameObject projectile, Vector3 direction, Vector3 position, GameObject attacker, bool damageConstant)
{
}
public virtual void killCharacterWithHealthManagement ()
{
}
public virtual Transform getPlaceToShootWithHealthManagement ()
{
return null;
}
public virtual GameObject getPlaceToShootGameObjectWithHealthManagement ()
{
return null;
}
public virtual bool isCharacterWithHealthManagement ()
{
return false;
}
public virtual bool isVehicleWithHealthManagement ()
{
return false;
}
public virtual List<health.weakSpot> getCharacterWeakSpotListWithHealthManagement ()
{
return null;
}
public virtual bool isCharacterInRagdollState ()
{
return false;
}
public virtual Transform getCharacterRootMotionTransform ()
{
return null;
}
public virtual GameObject getCharacterOrVehicleWithHealthManagement ()
{
return null;
}
public virtual void setFuelWithHealthManagement (float fuelAmount)
{
}
public virtual void removeFuelWithHealthManagement (float fuelAmount)
{
}
public virtual float getCurrentFuelAmountWithHealthManagement ()
{
return 0;
}
public virtual bool checkIfMaxFuelWithHealthManagement ()
{
return false;
}
public virtual GameObject getCharacterWithHealthManagement ()
{
return null;
}
public virtual GameObject getVehicleWithHealthManagement ()
{
return null;
}
public virtual vehicleHUDManager getVehicleHUDManagerWithHealthManagement ()
{
return null;
}
public virtual GameObject getVehicleDriverWithHealthManagement ()
{
return null;
}
public virtual bool isVehicleBeingDrivenWithHealthManagement ()
{
return false;
}
public virtual bool checkIfDetectSurfaceBelongToVehicleWithHealthManagement (Collider surfaceFound)
{
return false;
}
public virtual bool checkIfWeakSpotListContainsTransformWithHealthManagement (Transform transformToCheck)
{
return false;
}
public virtual void setEnergyWithHealthManagement (float energyAmount)
{
}
public virtual void removeEnergyWithHealthManagement (float energyAmount)
{
}
public virtual float getCurrentEnergyAmountWithHealthManagement ()
{
return 0;
}
public virtual bool checkIfMaxEnergyWithHealthManagement ()
{
return false;
}
public virtual bool isUseImpactSurfaceActiveWithHealthManagement ()
{
return false;
}
public virtual int getDecalImpactIndexWithHealthManagement ()
{
return -1;
}
public virtual void changePlaceToShootPosition (bool state)
{
}
public virtual void setPlaceToShootPositionOffset (float newValue)
{
}
public virtual void setPlaceToShootLocalPosition (Vector3 newValue)
{
}
public virtual bool isDead ()
{
return false;
}
public virtual void setBlockDamageActiveState (bool state)
{
}
public virtual bool isBlockDamageActiveState ()
{
return false;
}
public virtual void setBlockDamageProtectionAmount (float newValue)
{
}
public virtual void setBlockDamageRangleAngleState (bool useMaxBlockRangeAngleValue, float maxBlockRangeAngleValue)
{
}
public virtual void setHitReactionBlockIDValue (int newBlockID)
{
}
public virtual void updateSliderOffset (float value)
{
}
public virtual void updateOriginalSliderOffset ()
{
}
public virtual void setIgnoreParryActiveState (bool state)
{
}
public virtual bool characterHasWeakSpotListWithHealthManagement ()
{
return false;
}
public virtual bool checkIfDamagePositionIsCloseEnoughToWeakSpotByNameWithHealthManagement (Vector3 collisionPosition, List<string> weakSpotNameList, float maxDistanceToWeakSpot)
{
return false;
}
public virtual Vector3 getClosestWeakSpotPositionToPositionWithHealthManagement (Vector3 positionToCheck, List<string> weakListNameToCheck, bool checkWeakListName, float maxDistanceToBodyPart)
{
return -Vector3.one;
}
public virtual void checkHealthAmountOnSpot (float damageAmount)
{
if (ignoreUseHealthAmountOnSpot) {
return;
}
if (useHealthAmountOnSpot) {
if (!healthAmountOnSpotEmpty) {
healhtAmountOnSpot -= damageAmount;
if (healhtAmountOnSpot <= 0) {
eventOnEmtpyHealthAmountOnSpot.Invoke ();
healthAmountOnSpotEmpty = true;
if (killCharacterOnEmtpyHealthAmountOnSpot) {
killCharacterWithHealthManagement ();
}
if (removeComponentOnEmptyHealth) {
Destroy (this);
}
}
}
}
}
public virtual void setUseHealthAmountOnSpotState (bool state)
{
useHealthAmountOnSpot = state;
}
public virtual void setIgnoreUseHealthAmountOnSpot (bool state)
{
ignoreUseHealthAmountOnSpot = state;
}
public virtual void killCharacterIfCurrentlyDrivingVehicle ()
{
}
public virtual void explodeVehicleIfCharacterCurrentlyDriving ()
{
}
public virtual void setPlayerMenuActiveState (bool state)
{
}
public virtual void setDamageReactionPausedState (bool state)
{
}
public virtual List<Collider> getDamageReceiverColliderList ()
{
return null;
}
public virtual void setIgnoreWeakSpotsActiveState (bool state)
{
}
public virtual bool checkIfDamageReceiverBelongsToThisCharacter (GameObject objectToCheck)
{
return false;
}
public virtual float getUseCustomCharacterRadiusValue ()
{
if (useCustomCharacterRadius) {
return customCharacterRadius;
}
return -1;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6babf4e0253f2ab4d889a336dae775d8
timeCreated: 1570959214
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/Health/healthManagement.cs
uploadId: 814740

View File

@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[System.Serializable]
public class healthSliderInfo
{
public string Name;
public Transform sliderOwner;
public GameObject sliderGameObject;
public RectTransform sliderRectTransform;
public CanvasGroup mainCanvasGroup;
public AIHealtSliderInfo sliderInfo;
public bool sliderOwnerLocated;
public bool sliderCanBeShown = true;
public bool useSliderOffset;
public Vector3 sliderOffset;
public Slider healthSlider;
public bool useCircleHealthSlider;
public Image circleHealthSlider;
public Slider shieldSlider;
public bool iconCurrentlyEnabled;
public int ID;
public bool useHealthSlideInfoOnScreen;
public float healthAmount;
public float maxHealthAmount;
public GameObject sliderPrefab;
public float shieldAmount;
public Color textColor;
public Color sliderColor;
public bool healthBarSliderActiveOnStart;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 845f7fcc45fec32409b1836abfbb4a05
timeCreated: 1551746275
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/Health/healthSliderInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,592 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class playerDamageOnScreenInfoSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool showDamageActive = true;
public bool showDamagePaused;
public int damageOnScreenId;
public bool placeMarkAboveDamagedTargets;
public bool useRandomDirection;
public bool useProjectileDirection;
public float movementSpeed;
public float movementAmount;
public float maxRadiusToInstantiate;
public float downMovementAmount = 2;
public bool checkDistanceToTarget;
public float distanceMultiplierAmount;
public string criticalDamageText = "CRITICAL!";
[Space]
[Header ("Text Color Settings")]
[Space]
public bool useRandomColor;
public float randomColorAlpha;
public Color damageColor = Color.red;
public Color healColor = Color.green;
[Space]
[Header ("Other Settings")]
[Space]
// public string mainManagerName = "Damage On Screen Info Manager";
public string mainPanelName = "Damage On Screen Info";
public bool useCanvasGroupOnIcons;
[Space]
[Header ("Debug")]
[Space]
public List<damageOnScreenInfoSystem.targetInfo> targetInfoList = new List<damageOnScreenInfoSystem.targetInfo> ();
public bool ignoreShowDamageInfoActive;
[Space]
[Header ("Components")]
[Space]
public GameObject player;
public Transform damageNumberParent;
public GameObject damageNumberTargetParent;
public GameObject damageNumberText;
public Camera mainCamera;
public playerCamera mainPlayerCamera;
public damageOnScreenInfoSystem damageOnScreenInfoManager;
Vector3 currenMapObjectPosition;
Vector3 screenPoint;
bool targetOnScreen;
damageOnScreenInfoSystem.targetInfo currentTargetInfo;
Vector2 mainCanvasSizeDelta;
Vector2 halfMainCanvasSizeDelta;
Vector2 iconPosition2d;
bool usingScreenSpaceCamera;
int targetInfoListCount;
bool mainPanelParentLocated;
bool mainPanelParentChecked;
void Awake ()
{
if (showDamageActive) {
initializeElements ();
}
}
void initializeElements ()
{
bool damageOnScreenInfoManagerAssigned = damageOnScreenInfoManager != null;
if (!damageOnScreenInfoManagerAssigned) {
damageOnScreenInfoManager = damageOnScreenInfoSystem.Instance;
damageOnScreenInfoManagerAssigned = damageOnScreenInfoManager != null;
}
if (!damageOnScreenInfoManagerAssigned) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (damageOnScreenInfoSystem.getMainManagerName (), typeof(damageOnScreenInfoSystem), true);
damageOnScreenInfoManager = damageOnScreenInfoSystem.Instance;
damageOnScreenInfoManagerAssigned = (damageOnScreenInfoManager != null);
}
if (!damageOnScreenInfoManagerAssigned) {
damageOnScreenInfoManager = FindObjectOfType<damageOnScreenInfoSystem> ();
damageOnScreenInfoManagerAssigned = damageOnScreenInfoManager != null;
}
if (damageOnScreenInfoManagerAssigned) {
damageOnScreenInfoManager.addNewPlayer (this);
} else {
showDamageActive = false;
}
}
void Start ()
{
mainCanvasSizeDelta = mainPlayerCamera.getMainCanvasSizeDelta ();
halfMainCanvasSizeDelta = mainCanvasSizeDelta * 0.5f;
usingScreenSpaceCamera = mainPlayerCamera.isUsingScreenSpaceCamera ();
if (mainCamera == null) {
mainCamera = mainPlayerCamera.getMainCamera ();
}
}
void FixedUpdate ()
{
if (!showDamageActive || showDamagePaused) {
return;
}
targetInfoListCount = targetInfoList.Count;
if (targetInfoListCount == 0) {
return;
}
for (int i = 0; i < targetInfoListCount; i++) {
currentTargetInfo = targetInfoList [i];
if (currentTargetInfo.containsNumberToShow) {
if (currentTargetInfo.target != null && currentTargetInfo.targetRectTransform != null) {
currenMapObjectPosition = currentTargetInfo.target.position;
if (currentTargetInfo.useIconOffset) {
currenMapObjectPosition += currentTargetInfo.iconOffset;
}
if (usingScreenSpaceCamera) {
screenPoint = mainCamera.WorldToViewportPoint (currenMapObjectPosition);
} else {
screenPoint = mainCamera.WorldToScreenPoint (currenMapObjectPosition);
}
targetOnScreen = screenPoint.z > 0;
if (targetOnScreen) {
if (!currentTargetInfo.iconActive) {
if (useCanvasGroupOnIcons) {
if (currentTargetInfo.mainCanvasGroup.alpha != 1) {
currentTargetInfo.mainCanvasGroup.alpha = 1;
}
} else {
if (!currentTargetInfo.targetRectTransformGameObject.activeSelf) {
currentTargetInfo.targetRectTransformGameObject.SetActive (true);
}
}
currentTargetInfo.iconActive = true;
}
if (usingScreenSpaceCamera) {
iconPosition2d = new Vector2 ((screenPoint.x * mainCanvasSizeDelta.x) - halfMainCanvasSizeDelta.x, (screenPoint.y * mainCanvasSizeDelta.y) - halfMainCanvasSizeDelta.y);
currentTargetInfo.targetRectTransform.anchoredPosition = iconPosition2d;
} else {
currentTargetInfo.targetRectTransform.position = new Vector3 (screenPoint.x, screenPoint.y, 0);
}
} else {
if (currentTargetInfo.iconActive) {
if (useCanvasGroupOnIcons) {
if (currentTargetInfo.mainCanvasGroup.alpha != 0) {
currentTargetInfo.mainCanvasGroup.alpha = 0;
}
} else {
if (currentTargetInfo.targetRectTransformGameObject.activeSelf) {
currentTargetInfo.targetRectTransformGameObject.SetActive (false);
}
}
currentTargetInfo.iconActive = false;
}
}
for (int j = 0; j < currentTargetInfo.damageNumberInfoList.Count; j++) {
if (currentTargetInfo.damageNumberInfoList [j].damageNumberRectTransform == null) {
currentTargetInfo.damageNumberInfoList.RemoveAt (j);
j--;
}
}
if (currentTargetInfo.damageNumberInfoList.Count == 0) {
currentTargetInfo.containsNumberToShow = false;
}
} else {
removeElementFromListByPlayer (currentTargetInfo.ID);
i--;
}
} else {
if (currentTargetInfo.iconActive) {
if (useCanvasGroupOnIcons) {
if (currentTargetInfo.mainCanvasGroup.alpha != 0) {
currentTargetInfo.mainCanvasGroup.alpha = 0;
}
} else {
if (currentTargetInfo.targetRectTransformGameObject.activeSelf) {
currentTargetInfo.targetRectTransformGameObject.SetActive (false);
}
}
currentTargetInfo.iconActive = false;
}
if (currentTargetInfo.isDead && !currentTargetInfo.containsNumberToShow && currentTargetInfo.removeDamageInScreenOnDeath) {
removeElementFromListByPlayer (currentTargetInfo.ID);
i--;
}
}
}
}
public void addNewTarget (damageOnScreenInfoSystem.targetInfo newTarget)
{
if (!showDamageActive) {
return;
}
if (mainPanelParentChecked) {
if (!mainPanelParentLocated) {
return;
}
} else {
mainPanelParentChecked = true;
if (!mainPanelParentLocated) {
mainPanelParentLocated = damageNumberParent != null;
if (!mainPanelParentLocated) {
GameObject newPanelParentGameObject = GKC_Utils.getHudElementParent (player, mainPanelName);
if (newPanelParentGameObject != null) {
damageNumberParent = newPanelParentGameObject.transform;
mainPanelParentLocated = damageNumberParent != null;
GKC_Utils.updateCanvasValuesByPlayer (player, null, newPanelParentGameObject);
}
}
if (!mainPanelParentLocated) {
return;
}
}
}
targetInfoListCount = targetInfoList.Count;
for (int i = 0; i < targetInfoListCount; i++) {
if (targetInfoList [i].ID == newTarget.ID) {
return;
}
}
damageOnScreenInfoSystem.targetInfo newTargetInfo = new damageOnScreenInfoSystem.targetInfo ();
newTargetInfo.Name = newTarget.Name;
newTargetInfo.target = newTarget.target;
newTargetInfo.iconOffset = newTarget.iconOffset;
newTargetInfo.useIconOffset = newTarget.useIconOffset;
newTargetInfo.ID = newTarget.ID;
newTargetInfo.removeDamageInScreenOnDeath = newTarget.removeDamageInScreenOnDeath;
GameObject newDamageNumberTargetParent = (GameObject)Instantiate (damageNumberTargetParent, Vector3.zero, Quaternion.identity, damageNumberParent);
newDamageNumberTargetParent.transform.localScale = Vector3.one;
newDamageNumberTargetParent.transform.localPosition = Vector3.zero;
newTargetInfo.targetRectTransformGameObject = newDamageNumberTargetParent;
newTargetInfo.targetRectTransform = newDamageNumberTargetParent.GetComponent<RectTransform> ();
if (placeMarkAboveDamagedTargets) {
RawImage markForDamageTarget = newDamageNumberTargetParent.GetComponent<RawImage> ();
if (markForDamageTarget != null) {
if (markForDamageTarget.enabled != placeMarkAboveDamagedTargets) {
markForDamageTarget.enabled = placeMarkAboveDamagedTargets;
}
}
}
if (useCanvasGroupOnIcons) {
newTargetInfo.mainCanvasGroup = newDamageNumberTargetParent.GetComponent<CanvasGroup> ();
}
if (useCanvasGroupOnIcons) {
if (newTargetInfo.mainCanvasGroup.alpha != 0) {
newTargetInfo.mainCanvasGroup.alpha = 0;
}
} else {
if (newTargetInfo.targetRectTransformGameObject.activeSelf) {
newTargetInfo.targetRectTransformGameObject.SetActive (false);
}
}
newTargetInfo.iconActive = false;
targetInfoList.Add (newTargetInfo);
targetInfoListCount = targetInfoList.Count;
}
public void setDamageInfo (int targetIndex, float amount, bool isDamage, Vector3 direction, float healthAmount, float criticalDamageProbability)
{
if (!showDamageActive) {
return;
}
if (ignoreShowDamageInfoActive) {
return;
}
if (!mainPanelParentLocated) {
return;
}
if (targetIndex > targetInfoListCount) {
return;
}
damageOnScreenInfoSystem.targetInfo currentTargetInfoToCheck = targetInfoList [targetIndex];
if (currentTargetInfoToCheck != null) {
if (currentTargetInfoToCheck.isDead) {
if (healthAmount > 0) {
currentTargetInfoToCheck.isDead = false;
} else {
return;
}
}
GameObject newDamageNumberText = (GameObject)Instantiate (damageNumberText, Vector3.zero, Quaternion.identity, currentTargetInfoToCheck.targetRectTransform);
if (!newDamageNumberText.activeSelf) {
newDamageNumberText.SetActive (true);
}
newDamageNumberText.transform.localScale = Vector3.one;
newDamageNumberText.transform.localPosition = Vector3.zero;
damageOnScreenInfoSystem.damageNumberInfo newDamageNumberInfo = new damageOnScreenInfoSystem.damageNumberInfo ();
newDamageNumberInfo.damageNumberText = newDamageNumberText.GetComponent<Text> ();
newDamageNumberInfo.damageNumberRectTransform = newDamageNumberText.GetComponent<RectTransform> ();
currentTargetInfoToCheck.damageNumberInfoList.Add (newDamageNumberInfo);
currentTargetInfoToCheck.containsNumberToShow = true;
string text = "";
if (useRandomColor) {
if (isDamage) {
text = "-";
} else {
text = "+";
}
newDamageNumberInfo.damageNumberText.color = new Vector4 (Random.Range (0f, 1f), Random.Range (0f, 1f), Random.Range (0f, 1f), randomColorAlpha);
} else {
if (isDamage) {
newDamageNumberInfo.damageNumberText.color = damageColor;
} else {
newDamageNumberInfo.damageNumberText.color = healColor;
}
}
if (amount >= 1) {
text += amount.ToString ("0");
} else {
if (amount < 0.1 && amount > 0) {
amount = 0.1f;
}
text += amount.ToString ("F1");
}
if (criticalDamageProbability == 1) {
createCriticalDamageText (currentTargetInfoToCheck, -direction);
}
newDamageNumberInfo.damageNumberText.text = text;
newDamageNumberInfo.movementCoroutine = StartCoroutine (moveNumber (currentTargetInfoToCheck.target, newDamageNumberInfo.damageNumberRectTransform, isDamage, direction));
if (healthAmount <= 0) {
currentTargetInfoToCheck.isDead = true;
}
}
}
public void createCriticalDamageText (damageOnScreenInfoSystem.targetInfo currentTargetInfoToCheck, Vector3 movementDirection)
{
GameObject newDamageNumberText = (GameObject)Instantiate (damageNumberText, Vector3.zero, Quaternion.identity, currentTargetInfoToCheck.targetRectTransform);
if (!newDamageNumberText.activeSelf) {
newDamageNumberText.SetActive (true);
}
newDamageNumberText.transform.localScale = Vector3.one;
newDamageNumberText.transform.localPosition = Vector3.zero;
damageOnScreenInfoSystem.damageNumberInfo newDamageNumberInfo = new damageOnScreenInfoSystem.damageNumberInfo ();
newDamageNumberInfo.damageNumberText = newDamageNumberText.GetComponent<Text> ();
newDamageNumberInfo.damageNumberRectTransform = newDamageNumberText.GetComponent<RectTransform> ();
currentTargetInfoToCheck.damageNumberInfoList.Add (newDamageNumberInfo);
newDamageNumberInfo.damageNumberText.color = damageColor;
newDamageNumberInfo.damageNumberText.text = criticalDamageText;
newDamageNumberInfo.damageNumberText.fontStyle = FontStyle.Bold;
newDamageNumberInfo.movementCoroutine = StartCoroutine (moveNumber (currentTargetInfoToCheck.target, newDamageNumberInfo.damageNumberRectTransform, true, movementDirection));
}
public void removeElementFromList (int objectID)
{
if (!showDamageActive) {
return;
}
for (int i = 0; i < targetInfoList.Count; i++) {
if (targetInfoList [i].ID == objectID) {
if (targetInfoList [i].targetRectTransformGameObject != null) {
Destroy (targetInfoList [i].targetRectTransformGameObject);
}
targetInfoList.RemoveAt (i);
targetInfoListCount = targetInfoList.Count;
return;
}
}
}
public void removeElementFromListByPlayer (int objectID)
{
if (!showDamageActive) {
return;
}
damageOnScreenInfoManager.removeElementFromTargetListCalledByPlayer (objectID, player);
removeElementFromList (objectID);
}
IEnumerator moveNumber (Transform targetTransform, RectTransform damageNumberRectTransform, bool damage, Vector2 direction)
{
float currentDistance = 0;
float newMovementAmount = movementAmount;
float newMaxRadiusToInstantiate = maxRadiusToInstantiate;
if (checkDistanceToTarget) {
currentDistance = GKC_Utils.distance (player.transform.position, targetTransform.position);
newMovementAmount = newMovementAmount - currentDistance * distanceMultiplierAmount;
newMovementAmount = Mathf.Abs (newMovementAmount);
newMaxRadiusToInstantiate = newMaxRadiusToInstantiate - currentDistance * distanceMultiplierAmount;
newMaxRadiusToInstantiate = Mathf.Abs (newMaxRadiusToInstantiate);
}
if (!useRandomDirection) {
damageNumberRectTransform.anchoredPosition += Random.insideUnitCircle * newMaxRadiusToInstantiate;
}
Vector2 currentPosition = damageNumberRectTransform.anchoredPosition;
Vector2 targetPosition = currentPosition + newMovementAmount * Vector2.up;
if (useRandomDirection) {
targetPosition = currentPosition + newMovementAmount * getRandomDirection ();
}
if (useProjectileDirection && damage) {
targetPosition = currentPosition + newMovementAmount * direction;
}
bool targetReached = false;
currentDistance = 0;
while (!targetReached) {
if (damageNumberRectTransform != null) {
damageNumberRectTransform.anchoredPosition = Vector2.MoveTowards (damageNumberRectTransform.anchoredPosition, targetPosition, Time.deltaTime * movementSpeed);
currentDistance = GKC_Utils.distance (damageNumberRectTransform.anchoredPosition, targetPosition);
if (currentDistance < 0.1f) {
targetReached = true;
}
} else {
targetReached = true;
}
yield return null;
}
if (!useRandomDirection) {
targetReached = false;
currentDistance = 0;
if (damageNumberRectTransform != null) {
currentPosition = damageNumberRectTransform.anchoredPosition;
targetPosition = currentPosition - (newMovementAmount * downMovementAmount) * Vector2.up;
}
while (!targetReached) {
if (damageNumberRectTransform != null) {
damageNumberRectTransform.anchoredPosition = Vector2.MoveTowards (damageNumberRectTransform.anchoredPosition, targetPosition, Time.deltaTime * movementSpeed);
currentDistance = GKC_Utils.distance (damageNumberRectTransform.anchoredPosition, targetPosition);
if (currentDistance < 0.1f) {
targetReached = true;
}
} else {
targetReached = true;
}
yield return null;
}
}
if (damageNumberRectTransform != null) {
Destroy (damageNumberRectTransform.gameObject);
}
}
public Vector2 getRandomDirection ()
{
return new Vector2 (Random.Range (-1f, 1f), Random.Range (-1f, 1f));
}
public void setShowDamageActiveState (bool state)
{
showDamageActive = state;
}
public void setIgnoreShowDamageInfoActiveState (bool state)
{
ignoreShowDamageInfoActive = state;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 395a4e8939b2ce84a92bac3d36a93c88
timeCreated: 1552373099
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/Health/playerDamageOnScreenInfoSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 9bfb7550a4837174c97485e9ff34eb25
timeCreated: 1551745479
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/Health/playerHealthBarManagementSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,166 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class setHealthCustomWeakSpotID : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool healthCustomWeakSpotEnabled = true;
[Space]
public List<customStateInfo> customStateInfoList = new List<customStateInfo> ();
[Space]
[Header ("Debug")]
[Space]
public bool healthCustomWeakSpotIgnoreActive;
[Space]
[Header ("Components")]
[Space]
public health mainHealth;
public void setHealthCustomWeakSpotIDByName (string newName)
{
if (!healthCustomWeakSpotEnabled) {
return;
}
if (healthCustomWeakSpotIgnoreActive) {
return;
}
int currentIndex = customStateInfoList.FindIndex (s => s.Name.Equals (newName));
if (currentIndex > -1) {
customStateInfo currentCustomStateInfo = customStateInfoList [currentIndex];
if (currentCustomStateInfo.customStateEnabled) {
for (int i = 0; i < currentCustomStateInfo.healthCustomWeakSpotInfoList.Count; i++) {
healthCustomWeakSpotInfo currentHealthCustomWeakSpotInfo =
currentCustomStateInfo.healthCustomWeakSpotInfoList [i];
mainHealth.setUseCustomStateHealthAmountOnSpotEnabledState (currentHealthCustomWeakSpotInfo.useCustomStateHealthAmountOnSpotEnabled,
currentHealthCustomWeakSpotInfo.Name);
if (currentHealthCustomWeakSpotInfo.useCustomStateHealthAmountOnSpotEnabled) {
mainHealth.setCurrentCustomStateHealthAmountOnSpotID (currentHealthCustomWeakSpotInfo.ID,
currentHealthCustomWeakSpotInfo.Name);
}
if (currentHealthCustomWeakSpotInfo.setSendFunctionWhenDamageState) {
mainHealth.setSendFunctionWhenDamageStateOnWeakSpot (currentHealthCustomWeakSpotInfo.Name,
currentHealthCustomWeakSpotInfo.sendFunctionWhenDamageState);
}
if (currentHealthCustomWeakSpotInfo.setUseHealthAmountOnSpot) {
mainHealth.setUseHealthAmountOnSpotState (currentHealthCustomWeakSpotInfo.useHealthAmountOnSpotState,
currentHealthCustomWeakSpotInfo.Name);
}
}
}
}
}
public void enableOrDisableCustomStateInfo (bool state, string newName)
{
int currentIndex = customStateInfoList.FindIndex (s => s.Name.Equals (newName));
if (currentIndex > -1) {
customStateInfo currentCustomStateInfo = customStateInfoList [currentIndex];
currentCustomStateInfo.customStateEnabled = state;
}
}
public void enableCustomStateInfo (string newName)
{
enableOrDisableCustomStateInfo (true, newName);
}
public void disableCustomStateInfo (string newName)
{
enableOrDisableCustomStateInfo (false, newName);
}
public void setHealthCustomWeakSpotEnabledState (bool state)
{
healthCustomWeakSpotEnabled = state;
}
public void setHealthCustomWeakSpotIgnoreActiveState (bool state)
{
healthCustomWeakSpotIgnoreActive = state;
}
//EDITOR FUNCTIONS
public void setHealthCustomWeakSpotEnabledStateFromEditor (bool state)
{
setHealthCustomWeakSpotEnabledState (state);
updateComponent ();
}
public void enableCustomStateInfoFromEditor (string newName)
{
enableOrDisableCustomStateInfo (true, newName);
updateComponent ();
}
public void disableCustomStateInfoFromEditor (string newName)
{
enableOrDisableCustomStateInfo (false, newName);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Health Custom Info " + gameObject.name, gameObject);
}
[System.Serializable]
public class customStateInfo
{
public string Name;
public bool customStateEnabled = true;
[Space]
public List<healthCustomWeakSpotInfo> healthCustomWeakSpotInfoList = new List<healthCustomWeakSpotInfo> ();
}
[System.Serializable]
public class healthCustomWeakSpotInfo
{
public string Name;
public int ID;
public bool useCustomStateHealthAmountOnSpotEnabled;
[Space]
public bool setSendFunctionWhenDamageState;
public bool sendFunctionWhenDamageState;
[Space]
public bool setUseHealthAmountOnSpot;
public bool useHealthAmountOnSpotState;
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2392728b3e715d245bdaf707d816db51
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/Health/setHealthCustomWeakSpotID.cs
uploadId: 814740

View File

@@ -0,0 +1,506 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class shieldSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool useShield;
public float maxShieldAmount;
public float shieldAmount = 100;
public bool regenerateShield;
public bool constantShieldRegenerate;
public float regenerateShieldSpeed = 0;
public float regenerateShieldTime;
public float regenerateShieldAmount;
public bool useHealthBarManager = true;
public string shieldStatName = "Current Shield";
public string maxShieldStatName = "Max Shield";
public string mainManagerName = "Health Bar Manager";
[Space]
[Header ("Shield Slider Setting")]
[Space]
public bool showShieldBarPanelEnabled = true;
public bool hideSliderWhenNotDamageReceived;
public float timeToHideSliderAfterDamage;
public RectTransform mainSliderParent;
public RectTransform hiddenSliderParent;
public RectTransform mainSliderTransform;
Coroutine hideSliderCoroutine;
float lastTimeHideSliderChecked;
[Space]
[Header ("Events Setting")]
[Space]
public UnityEvent eventOnStartShield;
public UnityEvent eventOnDamageShield;
public eventParameters.eventToCallWithGameObject eventOnDamageShieldWithAttacker;
public UnityEvent eventOnShieldDestroyed;
public UnityEvent eventOnStartRegenerateShield;
public UnityEvent eventToCheckIfShieldIsActive;
public UnityEvent eventToCheckIfShieldIsNotActive;
public UnityEvent eventToCheckIfShieldIsDestroyed;
[Space]
[Header ("Components")]
[Space]
public GameObject shieldPanel;
public Slider shieldSlider;
public Text shieldSliderText;
public health mainHealth;
public healthBarManagementSystem healthBarManager;
public playerStatsSystem playerStatsManager;
bool hasPlayerStatsManager;
float auxShieldAmount;
float lastShieldDamageTime = 0;
bool shieldPreviouslyDestroyed;
bool hasShieldSlider;
bool dead;
bool originalUseShield;
bool healthBarManagerLocated;
void getHealthManager ()
{
healthBarManagerLocated = healthBarManager != null;
if (!healthBarManagerLocated) {
healthBarManager = healthBarManagementSystem.Instance;
healthBarManagerLocated = healthBarManager != null;
}
if (!healthBarManagerLocated) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (healthBarManagementSystem.getMainManagerName (), typeof (healthBarManagementSystem), true);
healthBarManager = healthBarManagementSystem.Instance;
healthBarManagerLocated = healthBarManager != null;
}
}
public void startShieldComponents ()
{
if (!healthBarManagerLocated) {
getHealthManager ();
}
if (maxShieldAmount == 0) {
maxShieldAmount = shieldAmount;
}
auxShieldAmount = shieldAmount;
if (shieldSlider != null) {
hasShieldSlider = true;
shieldSlider.maxValue = maxShieldAmount;
shieldSlider.value = shieldAmount;
if (shieldSliderText != null) {
shieldSliderText.text = maxShieldAmount.ToString ();
}
if (hideSliderWhenNotDamageReceived) {
checkSetSliderParent (false);
}
}
if (useHealthBarManager) {
hasShieldSlider = true;
}
if (playerStatsManager != null) {
hasPlayerStatsManager = true;
}
eventOnStartShield.Invoke ();
originalUseShield = useShield;
}
public void disableShield ()
{
setUseShieldState (false);
}
public void updateSliderState ()
{
if (!useShield) {
return;
}
if (!dead) {
if (regenerateShield) {
if (constantShieldRegenerate) {
if (regenerateShieldSpeed > 0 && shieldAmount < maxShieldAmount) {
if (Time.time > lastShieldDamageTime + regenerateShieldTime && Time.time > mainHealth.getLastDamageTime () + regenerateShieldTime) {
getShield (regenerateShieldSpeed * Time.deltaTime);
}
}
} else {
if (shieldAmount < maxShieldAmount) {
if (Time.time > lastShieldDamageTime + regenerateShieldTime && Time.time > mainHealth.getLastDamageTime () + regenerateShieldTime) {
getShield (regenerateShieldAmount);
lastShieldDamageTime = Time.time;
}
}
}
}
}
}
public void updateShieldSlider (float value)
{
if (hasShieldSlider) {
if (shieldSlider != null) {
shieldSlider.value = value;
if (shieldSliderText != null) {
shieldSliderText.text = Mathf.RoundToInt (value).ToString ();
}
checkHideSliderParent ();
}
if (useHealthBarManager && healthBarManagerLocated) {
healthBarManager.setShieldSliderAmount (mainHealth.getHealthID (), value);
}
updatePlayerStatsManagerShieldValue ();
}
}
void updatePlayerStatsManagerShieldValue ()
{
if (hasPlayerStatsManager) {
playerStatsManager.updateStatValue (shieldStatName, shieldAmount);
}
}
void updatePlayerStatsManagerMaxShieldValue ()
{
if (hasPlayerStatsManager) {
playerStatsManager.updateStatValue (maxShieldStatName, maxShieldAmount);
}
}
void updateShieldSliderInternally (float value)
{
if (hasShieldSlider) {
if (shieldSlider != null) {
shieldSlider.value = value;
if (shieldSliderText != null) {
shieldSliderText.text = Mathf.RoundToInt (value).ToString ();
}
}
}
}
public void updateShieldSliderMaxValue (float newMaxValue)
{
if (hasShieldSlider) {
if (shieldSlider != null) {
shieldSlider.maxValue = newMaxValue;
}
if (useHealthBarManager && healthBarManagerLocated) {
healthBarManager.updateShieldSliderMaxValue (mainHealth.getHealthID (), newMaxValue);
}
checkHideSliderParent ();
}
}
void updateShieldSliderMaxValueInternally (float newMaxValue)
{
if (hasShieldSlider) {
if (shieldSlider != null) {
shieldSlider.maxValue = newMaxValue;
}
}
}
public void checkHideSliderParent ()
{
if (hideSliderWhenNotDamageReceived) {
stopCheckHideSliderCoroutine ();
lastTimeHideSliderChecked = Time.time;
hideSliderCoroutine = StartCoroutine (checkHideSliderCoroutine ());
}
}
void stopCheckHideSliderCoroutine ()
{
if (hideSliderCoroutine != null) {
StopCoroutine (hideSliderCoroutine);
}
}
IEnumerator checkHideSliderCoroutine ()
{
checkSetSliderParent (true);
bool targetReached = false;
while (!targetReached) {
if (Time.time > timeToHideSliderAfterDamage + lastTimeHideSliderChecked) {
targetReached = true;
}
if (mainHealth.isPlayerMenuActive ()) {
targetReached = true;
}
yield return null;
}
checkSetSliderParent (false);
}
void checkSetSliderParent (bool setOnMainParent)
{
if (hideSliderWhenNotDamageReceived) {
if (setOnMainParent) {
mainSliderTransform.transform.SetParent (mainSliderParent);
} else {
mainSliderTransform.transform.SetParent (hiddenSliderParent);
}
mainSliderTransform.transform.localPosition = Vector3.zero;
mainSliderTransform.transform.localRotation = Quaternion.identity;
}
}
public void getShield (float amount)
{
if (!dead) {
shieldPreviouslyDestroyed = false;
if (shieldAmount == 0) {
shieldPreviouslyDestroyed = true;
}
shieldAmount += amount;
//check that the shield amount is not higher that the shield max value of the slider
if (shieldAmount >= maxShieldAmount) {
shieldAmount = maxShieldAmount;
}
updateShieldSlider (shieldAmount);
if (shieldPreviouslyDestroyed && shieldAmount > 0) {
eventOnStartRegenerateShield.Invoke ();
}
}
auxShieldAmount = shieldAmount;
}
public void setDeadState (bool state)
{
dead = state;
}
public bool receiveDamage (float damageAmount, GameObject attacker)
{
if (useShield && shieldAmount > 0) {
if (damageAmount > shieldAmount) {
damageAmount = shieldAmount;
}
shieldAmount -= damageAmount;
auxShieldAmount = shieldAmount;
eventOnDamageShield.Invoke ();
eventOnDamageShieldWithAttacker.Invoke (attacker);
if (shieldAmount <= 0) {
shieldAmount = 0;
eventOnShieldDestroyed.Invoke ();
}
updateShieldSlider (shieldAmount);
lastShieldDamageTime = Time.time;
return true;
} else {
return false;
}
}
public float getShieldAmountToLimit ()
{
return maxShieldAmount - auxShieldAmount;
}
public void addAuxShieldAmount (float amount)
{
auxShieldAmount += amount;
}
public void increaseMaxShieldAmount (float newAmount)
{
maxShieldAmount += newAmount;
updateShieldSliderMaxValue (maxShieldAmount);
}
public void setShieldAmountOnMaxValue ()
{
getShield (maxShieldAmount - shieldAmount);
}
public void increaseRegenerateShieldSpeed (float newAmount)
{
regenerateShieldSpeed += newAmount;
}
public void initializeShieldAmount (float newValue)
{
shieldAmount = newValue;
}
public void initializeMaxShieldAmount (float newValue)
{
maxShieldAmount = newValue;
}
public void initializeRegenerateShieldSpeed (float newValue)
{
regenerateShieldSpeed = newValue;
}
public void increaseMaxShieldAmountByMultiplier (float amountMultiplier)
{
maxShieldAmount *= amountMultiplier;
updateShieldSliderMaxValue (maxShieldAmount);
updatePlayerStatsManagerMaxShieldValue ();
updateShieldAmountWithoutUpdatingStatManager (0, maxShieldAmount);
updatePlayerStatsManagerShieldValue ();
}
public void updateShieldAmountWithoutUpdatingStatManager (int statId, float amount)
{
shieldAmount = amount;
updateShieldSliderInternally (shieldAmount);
auxShieldAmount = shieldAmount;
}
public void updateMaxShieldAmountWithoutUpdatingStatManager (int statId, float amount)
{
maxShieldAmount = amount;
updateShieldSliderMaxValueInternally (maxShieldAmount);
}
public void updateRegenerateShieldSpeedAmountWithoutUpdatingStatManager (int statId, float amount)
{
regenerateShieldSpeed = amount;
}
public void setUseShieldState (bool state)
{
useShield = state;
if (showShieldBarPanelEnabled) {
if (shieldPanel != null) {
if (shieldPanel.activeSelf != useShield) {
shieldPanel.SetActive (useShield);
}
}
}
}
public void setShowShieldBarPanelEnabledState (bool state)
{
showShieldBarPanelEnabled = state;
}
public void setOriginalUseShieldState ()
{
setUseShieldState (originalUseShield);
}
public void checkEventsForShieldState ()
{
if (useShield) {
if (shieldAmount > 0) {
eventToCheckIfShieldIsActive.Invoke ();
} else {
eventToCheckIfShieldIsDestroyed.Invoke ();
}
} else {
eventToCheckIfShieldIsNotActive.Invoke ();
}
}
public float getCurrentShieldAmount ()
{
return shieldAmount;
}
public void setShowShieldBarPanelEnabledStateFromEditor (bool state)
{
setShowShieldBarPanelEnabledState (state);
updateComponent ();
}
public void setUseShieldStateFromEditor (bool state)
{
setUseShieldState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Shield System", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8d208cf3f8980954196e619710d0ae2b
timeCreated: 1566387342
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/Health/shieldSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,7 @@
using UnityEngine;
using System.Collections;
public class weakSpotInfo : MonoBehaviour {
public healthElementInfo elementInfo;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 2cd2f0c19ee05f342b8c972e0254fe11
timeCreated: 1509212113
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/Health/weakSpotInfo.cs
uploadId: 814740