add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 891ff65a08f0dc0408c8494cdf0801bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,338 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class sharedActionButtonActivator : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool buttonActivatorEnabled = true;
|
||||
|
||||
public bool buttonActive;
|
||||
|
||||
public bool setActiveStateOnStart;
|
||||
|
||||
public string sharedActionNameOnStart;
|
||||
|
||||
public bool useRandomSharedActionName;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public string sharedActionName;
|
||||
|
||||
public float currentTimeToDisableActivator;
|
||||
|
||||
public GameObject currentExternalCharacter;
|
||||
|
||||
public bool checkToDisableActivatorInProcess;
|
||||
|
||||
[Space]
|
||||
[Header ("Event Info List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<sharedActionEventInfo> sharedActionEventInfoList = new List<sharedActionEventInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventsItTargetDetected;
|
||||
public UnityEvent eventsItTargetDetected;
|
||||
|
||||
public bool useEventsItTargetNotDetected;
|
||||
public UnityEvent eventsItTargetNotDetected;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnAssigningNewInfo;
|
||||
|
||||
[Space]
|
||||
|
||||
public eventParameters.eventToCallWithString eventToSendNewActionName;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnEnableActivator;
|
||||
public UnityEvent eventOnDisableActivator;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public sharedActionSystem mainSharedActionSystem;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (setActiveStateOnStart) {
|
||||
enableOrDisableaActivator (true);
|
||||
|
||||
setSharedActionName (sharedActionNameOnStart);
|
||||
}
|
||||
}
|
||||
|
||||
public void setuseRandomSharedActionNameState (bool state)
|
||||
{
|
||||
useRandomSharedActionName = state;
|
||||
}
|
||||
|
||||
public void enableActivatorAndSetSharedActioName (string newName)
|
||||
{
|
||||
enableOrDisableaActivator (true);
|
||||
|
||||
setSharedActionName (newName);
|
||||
}
|
||||
|
||||
public void setSharedActionName (string newName)
|
||||
{
|
||||
if (!buttonActivatorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
sharedActionName = newName;
|
||||
|
||||
if (sharedActionName != "") {
|
||||
eventOnAssigningNewInfo.Invoke ();
|
||||
|
||||
eventToSendNewActionName.Invoke (sharedActionName);
|
||||
|
||||
int currentActionIndex = sharedActionEventInfoList.FindIndex (s => s.sharedActionName.Equals (sharedActionName));
|
||||
|
||||
if (currentActionIndex > -1) {
|
||||
sharedActionEventInfo currentSharedActionEventInfo = sharedActionEventInfoList [currentActionIndex];
|
||||
|
||||
currentSharedActionEventInfo.eventOnSetSharedActionName.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSharedActionNameAndEnableWithDuration (string newName)
|
||||
{
|
||||
if (!buttonActivatorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool splitSymbolLocated = newName.Contains (";");
|
||||
|
||||
if (splitSymbolLocated) {
|
||||
string [] nameAndDuration = newName.Split (';');
|
||||
|
||||
if (nameAndDuration.Length > 0) {
|
||||
newName = nameAndDuration [0];
|
||||
|
||||
setSharedActionName (newName);
|
||||
}
|
||||
|
||||
if (nameAndDuration.Length > 1) {
|
||||
float durationAmount = float.Parse (nameAndDuration [1]);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (nameAndDuration [0] + " " + nameAndDuration [1]);
|
||||
}
|
||||
|
||||
if (durationAmount > 0) {
|
||||
enableActivatorWithDuration (durationAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setExternalCharacter (GameObject newCharacter)
|
||||
{
|
||||
currentExternalCharacter = newCharacter;
|
||||
}
|
||||
|
||||
public void activateRandomSharedActionByName ()
|
||||
{
|
||||
bool previousUseRandomSharedActionNameValue = useRandomSharedActionName;
|
||||
|
||||
useRandomSharedActionName = true;
|
||||
|
||||
activateSharedActionByName ();
|
||||
|
||||
useRandomSharedActionName = previousUseRandomSharedActionNameValue;
|
||||
}
|
||||
|
||||
public void activateSharedActionByName ()
|
||||
{
|
||||
bool activateActionResult = true;
|
||||
|
||||
if (!buttonActivatorEnabled) {
|
||||
activateActionResult = false;
|
||||
}
|
||||
|
||||
if (!mainSharedActionSystem.isSharedActionEnabled ()) {
|
||||
activateActionResult = false;
|
||||
}
|
||||
|
||||
if (currentExternalCharacter == null) {
|
||||
activateActionResult = false;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activate action result " + activateActionResult + " " + sharedActionName);
|
||||
}
|
||||
|
||||
if (activateActionResult) {
|
||||
mainSharedActionSystem.setExternalCharacter (currentExternalCharacter);
|
||||
|
||||
if (useRandomSharedActionName) {
|
||||
mainSharedActionSystem.activateRandomSharedActionByName (sharedActionName);
|
||||
} else {
|
||||
mainSharedActionSystem.activateSharedActionByName (sharedActionName);
|
||||
}
|
||||
}
|
||||
|
||||
checkEventOnTargetDetectedResult (activateActionResult);
|
||||
}
|
||||
|
||||
void checkEventOnTargetDetectedResult (bool state)
|
||||
{
|
||||
if (state) {
|
||||
if (useEventsItTargetDetected) {
|
||||
eventsItTargetDetected.Invoke ();
|
||||
}
|
||||
} else {
|
||||
if (useEventsItTargetNotDetected) {
|
||||
eventsItTargetNotDetected.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableActivator ()
|
||||
{
|
||||
enableOrDisableaActivator (true);
|
||||
}
|
||||
|
||||
public void disableActivator ()
|
||||
{
|
||||
enableOrDisableaActivator (false);
|
||||
}
|
||||
|
||||
public void enableOrDisableaActivator (bool state)
|
||||
{
|
||||
if (!buttonActivatorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
buttonActive = state;
|
||||
|
||||
checkEventOnChangeActivatorState (state);
|
||||
}
|
||||
|
||||
public void enableActivatorWithDuration (float newDuration)
|
||||
{
|
||||
enableOrDisableActivatorWithDuration (true, newDuration);
|
||||
}
|
||||
|
||||
public void disableActivatorWithDuration ()
|
||||
{
|
||||
if (checkToDisableActivatorInProcess || buttonActive) {
|
||||
enableOrDisableActivatorWithDuration (false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableOrDisableActivatorWithDuration (bool state, float newDuration)
|
||||
{
|
||||
if (!buttonActivatorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentTimeToDisableActivator = newDuration;
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
bool buttonPreviouslyActive = buttonActive || checkToDisableActivatorInProcess;
|
||||
|
||||
buttonActive = state;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("enableOrDisableActivatorWithDuration " + state + " " + buttonPreviouslyActive);
|
||||
}
|
||||
|
||||
if (state) {
|
||||
if (gameObject.activeInHierarchy) {
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
}
|
||||
} else {
|
||||
if (buttonPreviouslyActive) {
|
||||
checkEventOnChangeActivatorState (false);
|
||||
}
|
||||
|
||||
checkToDisableActivatorInProcess = false;
|
||||
}
|
||||
}
|
||||
|
||||
void checkEventOnChangeActivatorState (bool state)
|
||||
{
|
||||
if (state) {
|
||||
eventOnEnableActivator.Invoke ();
|
||||
} else {
|
||||
eventOnDisableActivator.Invoke ();
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("checkEventOnChangeActivatorState " + state);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
checkToDisableActivatorInProcess = true;
|
||||
|
||||
checkEventOnChangeActivatorState (true);
|
||||
|
||||
WaitForSeconds delay = new WaitForSeconds (currentTimeToDisableActivator);
|
||||
|
||||
yield return delay;
|
||||
|
||||
checkEventOnChangeActivatorState (false);
|
||||
|
||||
checkToDisableActivatorInProcess = false;
|
||||
|
||||
buttonActive = false;
|
||||
}
|
||||
|
||||
public void setButtonActivatorEnabledState (bool state)
|
||||
{
|
||||
buttonActivatorEnabled = state;
|
||||
}
|
||||
|
||||
public void setButtonActivatorEnabledStateFromEditor (bool state)
|
||||
{
|
||||
setButtonActivatorEnabledState (state);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Shared Action Button " + gameObject.name, gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class sharedActionEventInfo
|
||||
{
|
||||
public string sharedActionName;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnSetSharedActionName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a0434bf3fd90274bacd7514423eed8a
|
||||
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/Action System/Shared Action System/sharedActionButtonActivator.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,114 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using static sharedActionSystem;
|
||||
|
||||
public class sharedActionContent : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool firstCharacterIsPlayer;
|
||||
|
||||
[Space]
|
||||
[Header ("Match Settings")]
|
||||
[Space]
|
||||
|
||||
public bool adjustPositionToFirstCharacter;
|
||||
public bool adjustPositionToSecondCharacter;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool matchPositionUsedOnAction;
|
||||
public bool adjustMatchPositionOnFirstCharacter;
|
||||
public bool adjustMatchPositionOnSecondCharacter;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool alignMainSharedActionGameObjectToBothCharacters;
|
||||
|
||||
[Space]
|
||||
[Header ("Probability Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useProbabilityToUseAction;
|
||||
[Range (0, 100)] public float probabilityToUseAction;
|
||||
|
||||
|
||||
[Space]
|
||||
[Header ("Distance Condition Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useMinDistanceToActivateAction;
|
||||
public float minDistanceToActivateAction;
|
||||
|
||||
public bool useMinAngleToActivateAction;
|
||||
public float minAngleToActivateAction;
|
||||
|
||||
[Space]
|
||||
[Header ("Stats Condition Settings")]
|
||||
[Space]
|
||||
|
||||
public bool checkCharacterStats;
|
||||
|
||||
public List<sharedActionConditionStatInfo> sharedActionConditionStatInfoList = new List<sharedActionConditionStatInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Weapon Condition Settings")]
|
||||
[Space]
|
||||
|
||||
public bool checkWeaponsOnFirstCharacter;
|
||||
public bool useMeleeWeaponOnFirstCharacter;
|
||||
public bool useFireWeaponOnFirstCharacter;
|
||||
public bool checkWeaponNameOnFirstCharacter;
|
||||
public string weaponNameOnFirstCharacter;
|
||||
|
||||
|
||||
[Space]
|
||||
|
||||
public bool checkWeaponsOnSecondCharacter;
|
||||
public bool useMeleeWeaponOnSecondCharacter;
|
||||
public bool useFireWeaponOnSecondCharacter;
|
||||
public bool checkWeaponNameOnSecondCharacter;
|
||||
public string weaponNameOnSecondCharacter;
|
||||
|
||||
[Space]
|
||||
[Header ("Character Dead Condition Settings")]
|
||||
[Space]
|
||||
|
||||
public bool stopActionIfAnyCharacterIsDead = true;
|
||||
public bool stopActionIfFirstCharacterIsDead;
|
||||
public bool stopActionIfSecondCharacterIsDead;
|
||||
|
||||
[Space]
|
||||
[Header ("Conditions Failed Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useAlternativeSharedActionIfConditionsFailed;
|
||||
public string alternativeSharedActionName;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public actionSystem firstCharacterActionSystem;
|
||||
public actionSystem secondCharacterActionSystem;
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class sharedActionConditionStatInfo
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public string statName;
|
||||
|
||||
public bool statIsAmount;
|
||||
|
||||
public bool checkStatIsHigher;
|
||||
|
||||
public float statAmount;
|
||||
|
||||
public bool stateValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2455fd955d41f764581e3953ece2f78f
|
||||
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/Action System/Shared Action System/sharedActionContent.cs
|
||||
uploadId: 814740
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9eb104970a7511e42a3e21dfcf8588ff
|
||||
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/Action System/Shared Action System/sharedActionSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,333 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UIElements;
|
||||
using static sharedActionSystem;
|
||||
|
||||
public class sharedActionSystemRemoteActivator : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool remoteActivatorEnabled = true;
|
||||
|
||||
public GameObject characterGameObject;
|
||||
|
||||
[Space]
|
||||
[Header ("Target Raycast Detection Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useRaycastDetection;
|
||||
|
||||
public float raycastDistance;
|
||||
|
||||
public LayerMask raycastLayermask;
|
||||
|
||||
public Transform raycastPositionTransform;
|
||||
|
||||
public Vector3 raycastOffset;
|
||||
|
||||
[Space]
|
||||
[Header ("Shared Action Activated Settings")]
|
||||
[Space]
|
||||
|
||||
public List<remoteSharedActionSystemInfo> remoteSharedActionSystemInfoList = new List<remoteSharedActionSystemInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Actions To Ignore Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useActionsToIgnoreList;
|
||||
public List<string> actionsToIgnoreList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Target Match Detection Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useMatchTargetSystemToGetTarget;
|
||||
|
||||
public matchPlayerToTargetSystem mainMatchPlayerToTargetSystem;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool checkOnFriendListManagerToGetTarget;
|
||||
|
||||
public friendListManager mainFriendListManager;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool useFindObjectivesSystemToGetTarget;
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public bool getPartnerIfNotTargetDetected;
|
||||
|
||||
[Space]
|
||||
[Header ("Editor Settings")]
|
||||
[Space]
|
||||
|
||||
public string sharedActionName;
|
||||
|
||||
public GameObject currentExternalCharacter;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public string customSharedActionName;
|
||||
public bool customSharedActionNameActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventsItTargetDetected;
|
||||
public UnityEvent eventsItTargetDetected;
|
||||
|
||||
public bool useEventsItTargetNotDetected;
|
||||
public UnityEvent eventsItTargetNotDetected;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public sharedActionSystem mainSharedActionSystem;
|
||||
|
||||
|
||||
public void setCustomSharedActionNameToUse (string newName)
|
||||
{
|
||||
customSharedActionName = newName;
|
||||
|
||||
customSharedActionNameActive = customSharedActionName != "";
|
||||
}
|
||||
|
||||
public void removeCustomSharedActionName ()
|
||||
{
|
||||
setCustomSharedActionNameToUse ("");
|
||||
}
|
||||
|
||||
public void checkSharedActionSystemByExternalDetection (string actionName)
|
||||
{
|
||||
if (!remoteActivatorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!useRaycastDetection && !useMatchTargetSystemToGetTarget && !useFindObjectivesSystemToGetTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (customSharedActionNameActive) {
|
||||
if (showDebugPrint) {
|
||||
print ("custom shared action name active " + customSharedActionName);
|
||||
}
|
||||
|
||||
actionName = customSharedActionName;
|
||||
}
|
||||
|
||||
if (useActionsToIgnoreList) {
|
||||
if (actionsToIgnoreList.Contains (actionName)) {
|
||||
if (showDebugPrint) {
|
||||
print ("action found on the action to ignore list " + actionName);
|
||||
}
|
||||
|
||||
checkEventOnTargetDetectedResult (false, actionName);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GameObject objectDetected = null;
|
||||
|
||||
bool objectDetectedResult = false;
|
||||
|
||||
if (useRaycastDetection) {
|
||||
RaycastHit hit;
|
||||
|
||||
Vector3 raycastPosition = raycastPositionTransform.position + raycastOffset;
|
||||
|
||||
Vector3 raycastDirection = raycastPositionTransform.forward;
|
||||
|
||||
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, raycastLayermask)) {
|
||||
objectDetected = hit.collider.gameObject;
|
||||
|
||||
objectDetectedResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (useMatchTargetSystemToGetTarget) {
|
||||
Transform targetTransform = mainMatchPlayerToTargetSystem.getCurrentTargetToMatchPosition ();
|
||||
|
||||
if (targetTransform != null) {
|
||||
objectDetected = targetTransform.gameObject;
|
||||
|
||||
objectDetectedResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!objectDetectedResult) {
|
||||
if (checkOnFriendListManagerToGetTarget) {
|
||||
Transform targetTransform = mainFriendListManager.getClosestByDistanceFriend ();
|
||||
|
||||
if (targetTransform != null) {
|
||||
objectDetected = targetTransform.gameObject;
|
||||
|
||||
objectDetectedResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useFindObjectivesSystemToGetTarget) {
|
||||
objectDetected = mainFindObjectivesSystem.getCurrentTargetToAttack ();
|
||||
|
||||
if (objectDetected != null) {
|
||||
|
||||
objectDetectedResult = true;
|
||||
} else {
|
||||
if (getPartnerIfNotTargetDetected) {
|
||||
Transform targetTransform = mainFindObjectivesSystem.getCurrentPartner ();
|
||||
|
||||
if (targetTransform != null) {
|
||||
objectDetected = targetTransform.gameObject;
|
||||
|
||||
objectDetectedResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("checking if target detected " + actionName + " " + objectDetectedResult);
|
||||
}
|
||||
|
||||
if (objectDetectedResult) {
|
||||
if (showDebugPrint) {
|
||||
print ("target detected " + objectDetected.name);
|
||||
}
|
||||
|
||||
objectDetected = applyDamage.getCharacter (objectDetected);
|
||||
|
||||
if (objectDetected != null) {
|
||||
playerComponentsManager currentPlayerComponentsManager = objectDetected.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
mainSharedActionSystem = currentPlayerComponentsManager.getPlayerActionSystem ().getSharedActionSystem ();
|
||||
|
||||
if (mainSharedActionSystem != null) {
|
||||
if (showDebugPrint) {
|
||||
print ("target detected has shared action system, sending info");
|
||||
}
|
||||
|
||||
currentExternalCharacter = characterGameObject;
|
||||
|
||||
sharedActionName = actionName;
|
||||
|
||||
activateSharedActionByName ();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
checkEventOnTargetDetectedResult (false, actionName);
|
||||
}
|
||||
}
|
||||
|
||||
void checkEventOnTargetDetectedResult (bool state, string actionName)
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("checking events on target detected result " + state + " " + actionName);
|
||||
}
|
||||
|
||||
if (state) {
|
||||
if (useEventsItTargetDetected) {
|
||||
eventsItTargetDetected.Invoke ();
|
||||
}
|
||||
} else {
|
||||
if (useEventsItTargetNotDetected) {
|
||||
eventsItTargetNotDetected.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
checkSharedActionActivatedResult (actionName, state);
|
||||
}
|
||||
|
||||
void checkSharedActionActivatedResult (string actionName, bool sharedActionResult)
|
||||
{
|
||||
int currentActionIndex = remoteSharedActionSystemInfoList.FindIndex (s => s.Name.Equals (actionName));
|
||||
|
||||
if (currentActionIndex > -1) {
|
||||
remoteSharedActionSystemInfo currentRemoteSharedActionSystemInfo = remoteSharedActionSystemInfoList [currentActionIndex];
|
||||
|
||||
if (currentRemoteSharedActionSystemInfo.checkSharedActionSystmeResultEnabled) {
|
||||
if (sharedActionResult) {
|
||||
currentRemoteSharedActionSystemInfo.eventOnSharedActionActivated.Invoke ();
|
||||
} else {
|
||||
currentRemoteSharedActionSystemInfo.eventOnSharedActionNotActivated.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void activateSharedActionByName ()
|
||||
{
|
||||
if (!remoteActivatorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mainSharedActionSystem.isSharedActionEnabled ()) {
|
||||
if (showDebugPrint) {
|
||||
print ("character " + characterGameObject + " has his shared action system disabled");
|
||||
}
|
||||
|
||||
checkEventOnTargetDetectedResult (false, sharedActionName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mainSharedActionSystem.setExternalCharacter (currentExternalCharacter);
|
||||
|
||||
mainSharedActionSystem.activateSharedActionByName (sharedActionName);
|
||||
|
||||
if (mainSharedActionSystem.isLastSharedActionFound ()) {
|
||||
checkEventOnTargetDetectedResult (true, sharedActionName);
|
||||
} else {
|
||||
checkEventOnTargetDetectedResult (false, sharedActionName);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRemoteActivatorEnabledState (bool state)
|
||||
{
|
||||
remoteActivatorEnabled = state;
|
||||
}
|
||||
|
||||
//EDITOR FUNCTIONS
|
||||
public void checkSharedActionSystemByExternalDetectionFromEditor ()
|
||||
{
|
||||
checkSharedActionSystemByExternalDetection (sharedActionName);
|
||||
}
|
||||
|
||||
public void activateSharedActionByNameFromEditor ()
|
||||
{
|
||||
activateSharedActionByName ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class remoteSharedActionSystemInfo
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public string Name;
|
||||
|
||||
public bool checkSharedActionSystmeResultEnabled;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnSharedActionActivated;
|
||||
|
||||
public UnityEvent eventOnSharedActionNotActivated;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e57b4d1c898f18449edf435a6aa643e
|
||||
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/Action System/Shared Action System/sharedActionSystemRemoteActivator.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,228 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class sharedActionZone : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool sharedActionZoneEnabled = true;
|
||||
|
||||
public string sharedActionName;
|
||||
|
||||
public bool disableSharedActionZoneAfterUse;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setPlayerAsFirstCharacter;
|
||||
|
||||
public bool setAIAsFirstCharacterIfSignalOwner;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useSharedActionContent = true;
|
||||
|
||||
public sharedActionContent mainSharedActionContent;
|
||||
|
||||
public GameObject sharedActionContentPrefab;
|
||||
|
||||
[Space]
|
||||
[Header ("Range Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useSharedZoneInsideRange;
|
||||
|
||||
public bool useZonePositionRange;
|
||||
public Vector2 xRange;
|
||||
public Vector2 zRange;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useZoneRotationRange;
|
||||
public float rotationRange;
|
||||
|
||||
public bool useCustomSharedZoneRotationCenter;
|
||||
public Transform customSharedZoneTransform;
|
||||
|
||||
[Space]
|
||||
[Header ("Condition Settings")]
|
||||
[Space]
|
||||
|
||||
public float maxDistanceToUseSharedActionZone;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useMaxDistanceXZToUseSharedActionZone;
|
||||
public float maxDistanceXToUseSharedActionZone;
|
||||
public float maxDistanceZToUseSharedActionZone;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool useMinDistanceToActivateActionFirstCharacter;
|
||||
public float minDistanceToActivateActionFirstCharacter;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useMinAngleToActivateActionFirstCharacter;
|
||||
public float minAngleToActivateActionFirstCharacter;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool useMinDistanceToActivateActionSecondCharacter;
|
||||
public float minDistanceToActivateActionSecondCharacter;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useMinAngleToActivateActionSecondCharacter;
|
||||
public float minAngleToActivateActionSecondCharacter;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool useMinAngleToActivateActionOnCharactersDirection;
|
||||
public float minAngleToActivateActionOnCharactersDirection;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool mainSharedActionContentFound;
|
||||
|
||||
|
||||
Vector3 initialPosition = -Vector3.one;
|
||||
Vector3 initialEuler = -Vector3.one;
|
||||
|
||||
|
||||
|
||||
public void storeInitialPosition ()
|
||||
{
|
||||
if (!mainSharedActionContentFound) {
|
||||
spawnSharedActionObjectOnScene ();
|
||||
}
|
||||
|
||||
if (initialPosition == -Vector3.one) {
|
||||
if (mainSharedActionContentFound) {
|
||||
initialPosition = mainSharedActionContent.transform.position;
|
||||
} else {
|
||||
initialPosition = transform.position;
|
||||
}
|
||||
}
|
||||
|
||||
if (initialEuler == -Vector3.one) {
|
||||
if (mainSharedActionContentFound) {
|
||||
initialEuler = mainSharedActionContent.transform.eulerAngles;
|
||||
} else {
|
||||
initialEuler = transform.eulerAngles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 getInitialPosition ()
|
||||
{
|
||||
return initialPosition;
|
||||
}
|
||||
|
||||
public Vector3 getInitialEuler ()
|
||||
{
|
||||
return initialEuler;
|
||||
}
|
||||
|
||||
public void setSharedActionZoneEnabledState (bool state)
|
||||
{
|
||||
sharedActionZoneEnabled = state;
|
||||
}
|
||||
|
||||
public bool isSharedActionZoneEnabled ()
|
||||
{
|
||||
return sharedActionZoneEnabled;
|
||||
}
|
||||
|
||||
public void setDisableSharedActionZoneAfterUseState (bool state)
|
||||
{
|
||||
disableSharedActionZoneAfterUse = state;
|
||||
}
|
||||
|
||||
public string getSharedActionName ()
|
||||
{
|
||||
return sharedActionName;
|
||||
}
|
||||
|
||||
public bool isUseSharedActionContentActive ()
|
||||
{
|
||||
return useSharedActionContent;
|
||||
}
|
||||
|
||||
public sharedActionContent getSharedActionContent ()
|
||||
{
|
||||
return mainSharedActionContent;
|
||||
}
|
||||
|
||||
public bool getSetPlayerAsFirstCharacter ()
|
||||
{
|
||||
return setPlayerAsFirstCharacter;
|
||||
}
|
||||
|
||||
public bool getSetAIAsFirstCharacterIfSignalOwner ()
|
||||
{
|
||||
return setAIAsFirstCharacterIfSignalOwner;
|
||||
}
|
||||
|
||||
public float getMaxDistanceToUseSharedActionZone ()
|
||||
{
|
||||
return maxDistanceToUseSharedActionZone;
|
||||
}
|
||||
|
||||
void spawnSharedActionObjectOnScene ()
|
||||
{
|
||||
mainSharedActionContentFound = mainSharedActionContent != null;
|
||||
|
||||
if (!mainSharedActionContentFound) {
|
||||
if (sharedActionContentPrefab != null) {
|
||||
GameObject sharedActionContentGameObject = (GameObject)Instantiate (sharedActionContentPrefab,
|
||||
transform.position, transform.rotation);
|
||||
|
||||
sharedActionContentGameObject.transform.SetParent (transform);
|
||||
|
||||
mainSharedActionContent = sharedActionContentGameObject.GetComponent<sharedActionContent> ();
|
||||
|
||||
mainSharedActionContentFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (mainSharedActionContentFound && mainSharedActionContent != null) {
|
||||
GKC_Utils.setActiveGameObjectInEditor (mainSharedActionContent.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void spawnSharedActionObjectOnSceneFromEditor ()
|
||||
{
|
||||
spawnSharedActionObjectOnScene ();
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void getSharedActionManagerrOnScene ()
|
||||
{
|
||||
sharedActionZoneManager currentSharedActionZoneManager = FindObjectOfType<sharedActionZoneManager> ();
|
||||
|
||||
if (currentSharedActionZoneManager == null) {
|
||||
GameObject newSharedActionZoneManagerGameObject = new GameObject ();
|
||||
|
||||
currentSharedActionZoneManager = newSharedActionZoneManagerGameObject.AddComponent<sharedActionZoneManager> ();
|
||||
}
|
||||
|
||||
if (currentSharedActionZoneManager != null) {
|
||||
GKC_Utils.setActiveGameObjectInEditor (currentSharedActionZoneManager.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Shared Action Zone", gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55a484ed12e5f244c88f623b363311f0
|
||||
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/Action System/Shared Action System/sharedActionZone.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using static sharedActionSystem;
|
||||
|
||||
public class sharedActionZoneManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool sharedActionZonesEnabled = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Shared Action Zone Settings")]
|
||||
[Space]
|
||||
|
||||
public List<sharedActionZone> sharedActionZoneList = new List<sharedActionZone> ();
|
||||
|
||||
|
||||
public bool isSharedActionZonesEnabled ()
|
||||
{
|
||||
return sharedActionZonesEnabled;
|
||||
}
|
||||
|
||||
public List<sharedActionZone> getSharedActionZoneList ()
|
||||
{
|
||||
return sharedActionZoneList;
|
||||
}
|
||||
|
||||
public void setSharedActionZonesEnabledState (bool state)
|
||||
{
|
||||
sharedActionZonesEnabled = state;
|
||||
}
|
||||
|
||||
public void getAllSharedActionZonesOnScene ()
|
||||
{
|
||||
sharedActionZoneList.Clear ();
|
||||
|
||||
sharedActionZone [] newSharedActionZoneList = FindObjectsOfType<sharedActionZone> ();
|
||||
|
||||
foreach (sharedActionZone currentSharedActionZone in newSharedActionZoneList) {
|
||||
if (!sharedActionZoneList.Contains (currentSharedActionZone)) {
|
||||
sharedActionZoneList.Add (currentSharedActionZone);
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Shared Action Manager", gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0f77b76b97fb2948b708fc79900e7a0
|
||||
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/Action System/Shared Action System/sharedActionZoneManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,150 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class sharedActionZoneTrigger : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool sharedActionZoneTriggerEnabled = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public string sharedActionZoneNameOnEnter;
|
||||
|
||||
public bool useSharedActionTimerOnEnter;
|
||||
public float sharedActionTimerOnEnter;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setSharedActionZoneOnExit;
|
||||
public string sharedActionZoneNameOnExit;
|
||||
|
||||
public bool useSharedActionTimerOnExit;
|
||||
public float sharedActionTimerOnExit;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool enableSharedActionRemoteActivatorOnTriggerEnter;
|
||||
|
||||
public bool disableSharedActionRemoteActivatorOnTriggerExit;
|
||||
|
||||
[Space]
|
||||
[Header ("Custom Shared Action Name Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setCustomSharedActionNameOnEnter;
|
||||
public string customSharedActionNameOnEnter;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool removeCustomSharedActionNameOnExit;
|
||||
|
||||
[Space]
|
||||
[Header ("Check Targets Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useTagList;
|
||||
public List<string> tagList = new List<string> ();
|
||||
|
||||
public bool useLayerMask;
|
||||
public LayerMask layerMask;
|
||||
|
||||
|
||||
void OnTriggerEnter (Collider col)
|
||||
{
|
||||
checkTriggerInfo (col, true);
|
||||
}
|
||||
|
||||
void OnTriggerExit (Collider col)
|
||||
{
|
||||
checkTriggerInfo (col, false);
|
||||
}
|
||||
|
||||
public void checkTriggerInfo (Collider col, bool isEnter)
|
||||
{
|
||||
if (!sharedActionZoneTriggerEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject currentCharacter = col.gameObject;
|
||||
|
||||
bool checkObjectResult = false;
|
||||
|
||||
if (useTagList) {
|
||||
if (tagList.Contains (currentCharacter.tag)) {
|
||||
checkObjectResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (useLayerMask) {
|
||||
if ((1 << currentCharacter.layer & layerMask.value) == 1 << currentCharacter.layer) {
|
||||
checkObjectResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkObjectResult) {
|
||||
return;
|
||||
}
|
||||
|
||||
playerComponentsManager currentPlayerComponentsManager = currentCharacter.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
playerActionSystem currentPlayerActionSystem = currentPlayerComponentsManager.getPlayerActionSystem ();
|
||||
|
||||
sharedActionButtonActivator currentSharedActionButtonActivator = currentPlayerActionSystem.getSharedActionButtonActivator ();
|
||||
|
||||
if (currentSharedActionButtonActivator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isEnter) {
|
||||
if (enableSharedActionRemoteActivatorOnTriggerEnter) {
|
||||
currentSharedActionButtonActivator.enableOrDisableaActivator (true);
|
||||
|
||||
if (useSharedActionTimerOnEnter) {
|
||||
string actionName = sharedActionZoneNameOnEnter + ";" + sharedActionTimerOnEnter.ToString ();
|
||||
|
||||
currentSharedActionButtonActivator.setSharedActionName (actionName);
|
||||
} else {
|
||||
currentSharedActionButtonActivator.setSharedActionName (sharedActionZoneNameOnEnter);
|
||||
}
|
||||
}
|
||||
|
||||
if (setCustomSharedActionNameOnEnter) {
|
||||
sharedActionSystemRemoteActivator currentharedActionSystemRemoteActivator = currentPlayerActionSystem.getSharedActionSystemRemoteActivator ();
|
||||
|
||||
if (currentharedActionSystemRemoteActivator != null) {
|
||||
currentharedActionSystemRemoteActivator.setCustomSharedActionNameToUse (customSharedActionNameOnEnter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (setSharedActionZoneOnExit) {
|
||||
currentSharedActionButtonActivator.enableOrDisableaActivator (true);
|
||||
|
||||
if (useSharedActionTimerOnExit) {
|
||||
string actionName = sharedActionZoneNameOnExit + ";" + sharedActionTimerOnExit.ToString ();
|
||||
|
||||
currentSharedActionButtonActivator.setSharedActionName (actionName);
|
||||
} else {
|
||||
currentSharedActionButtonActivator.setSharedActionName (sharedActionZoneNameOnExit);
|
||||
}
|
||||
}
|
||||
|
||||
if (disableSharedActionRemoteActivatorOnTriggerExit) {
|
||||
currentSharedActionButtonActivator.enableOrDisableaActivator (false);
|
||||
}
|
||||
|
||||
if (removeCustomSharedActionNameOnExit) {
|
||||
sharedActionSystemRemoteActivator currentharedActionSystemRemoteActivator = currentPlayerActionSystem.getSharedActionSystemRemoteActivator ();
|
||||
|
||||
if (currentharedActionSystemRemoteActivator != null) {
|
||||
currentharedActionSystemRemoteActivator.removeCustomSharedActionName ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bd58d4d93174bc4782f400e75ffeb8c
|
||||
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/Action System/Shared Action System/sharedActionZoneTrigger.cs
|
||||
uploadId: 814740
|
||||
1108
Assets/Game Kit Controller/Scripts/Action System/actionSystem.cs
Normal file
1108
Assets/Game Kit Controller/Scripts/Action System/actionSystem.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,964 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
public class actionSystem : MonoBehaviour
|
||||
{
|
||||
public bool useMinDistanceToActivateAction;
|
||||
public float minDistanceToActivateAction;
|
||||
|
||||
public bool useMinAngleToActivateAction;
|
||||
public float minAngleToActivateAction;
|
||||
public bool checkOppositeAngle;
|
||||
|
||||
public bool canStopPreviousAction;
|
||||
|
||||
public bool canForceToPlayCustomAction;
|
||||
|
||||
public int currentActionInfoIndex;
|
||||
|
||||
public List<actionInfo> actionInfoList = new List<actionInfo> ();
|
||||
|
||||
public List<GameObject> playerList = new List<GameObject> ();
|
||||
|
||||
public bool useEventsOnPlayerInsideOutside;
|
||||
|
||||
public UnityEvent eventOnPlayerInside;
|
||||
|
||||
public UnityEvent eventOnPlayerOutside;
|
||||
|
||||
public bool useEventsOnStartEndAction;
|
||||
|
||||
public UnityEvent eventOnStartAction;
|
||||
public UnityEvent eventOnEndAction;
|
||||
|
||||
public bool useEventAfterResumePlayer;
|
||||
public UnityEvent eventAfterResumePlayer;
|
||||
|
||||
public Transform actionTransform;
|
||||
|
||||
public bool sendCurrentPlayerOnEvent;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendCurrentPlayer;
|
||||
|
||||
public bool useEventBeforeStartAction;
|
||||
public UnityEvent eventBeforeStartAction;
|
||||
|
||||
public Collider mainTrigger;
|
||||
|
||||
public bool activateCustomActionAfterActionComplete;
|
||||
public string customActionToActiveAfterActionComplete;
|
||||
|
||||
public bool addActionToListStoredToPlay;
|
||||
public bool playActionAutomaticallyIfStoredAtEnd;
|
||||
|
||||
public bool clearAddActionToListStoredToPlay;
|
||||
|
||||
public bool useEventsToEnableDisableActionObject;
|
||||
public UnityEvent eventToEnableActionObject;
|
||||
public UnityEvent eventToDisableActionObject;
|
||||
|
||||
public string categoryName;
|
||||
|
||||
public bool canInterruptOtherActionActive;
|
||||
public List<string> actionListToInterrupt = new List<string> ();
|
||||
public bool useCategoryToCheckInterrupt;
|
||||
public List<string> actionCategoryListToInterrupt;
|
||||
public UnityEvent eventOnInterrupOtherActionActive;
|
||||
|
||||
public bool useEventOnInterruptedAction;
|
||||
public UnityEvent eventOnInterruptedAction;
|
||||
|
||||
public bool useProbabilityToActivateAction;
|
||||
public float probablityToActivateAction;
|
||||
|
||||
public bool animationUsedOnUpperBody;
|
||||
public bool disableRegularActionActiveState;
|
||||
public bool disableRegularActionActiveStateOnEnd;
|
||||
|
||||
public bool changeCameraViewToThirdPersonOnAction;
|
||||
|
||||
public bool changeCameraViewToThirdPersonOnActionOnFullBodyAwareness;
|
||||
|
||||
public bool keepCameraRotationToHeadOnFullBodyAwareness;
|
||||
|
||||
public bool actionsCanBeUsedOnFirstPerson;
|
||||
public bool ignoreChangeToThirdPerson;
|
||||
|
||||
public bool disableIgnorePlayerListChange;
|
||||
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public bool showGizmo;
|
||||
public bool showAllGizmo;
|
||||
|
||||
bool ignorePlayerList;
|
||||
|
||||
|
||||
public Animator mainAnimator;
|
||||
public AnimationClip newAnimationClip;
|
||||
|
||||
public bool enableAnimatorLayerOnAction;
|
||||
public string animatorLayerToEnableName;
|
||||
|
||||
public string actionNameToReplace;
|
||||
|
||||
public string animationLayerName = "Base Layer";
|
||||
|
||||
public float newAnimationSpeed = 1;
|
||||
|
||||
public bool activateAnimationReplace;
|
||||
|
||||
public bool newAnimationIsMirror;
|
||||
|
||||
int numberOfLoops;
|
||||
|
||||
public bool setPlayerParentDuringActionActive;
|
||||
public Transform playerParentDuringAction;
|
||||
|
||||
public void setPlayerParentDuringActionActiveValues (bool state, Transform newParent)
|
||||
{
|
||||
setPlayerParentDuringActionActive = state;
|
||||
|
||||
playerParentDuringAction = newParent;
|
||||
}
|
||||
|
||||
public void setUseMovingPlayerToPositionTargetValues (bool state, float newSpeed, float newDelay)
|
||||
{
|
||||
if (actionInfoList.Count > 0) {
|
||||
actionInfo currentactionInfo = actionInfoList [0];
|
||||
|
||||
currentactionInfo.useMovingPlayerToPositionTarget = state;
|
||||
|
||||
if (state) {
|
||||
currentactionInfo.movingPlayerToPositionTargetSpeed = newSpeed;
|
||||
currentactionInfo.movingPlayerToPositionTargetDelay = newDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void activateCustomAction (GameObject playerDetected)
|
||||
{
|
||||
if (!disableIgnorePlayerListChange) {
|
||||
ignorePlayerList = true;
|
||||
}
|
||||
|
||||
setPlayerActionActive (playerDetected);
|
||||
}
|
||||
|
||||
public void setIgnorePlayerListValue (bool state)
|
||||
{
|
||||
ignorePlayerList = state;
|
||||
}
|
||||
|
||||
public void setPlayerActionActive (GameObject playerDetected)
|
||||
{
|
||||
if (ignorePlayerList || !playerList.Contains (playerDetected)) {
|
||||
if (!ignorePlayerList) {
|
||||
if (useEventsOnPlayerInsideOutside) {
|
||||
if (playerList.Count == 0) {
|
||||
eventOnPlayerInside.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
playerList.Add (playerDetected);
|
||||
}
|
||||
|
||||
playerComponentsManager currentPlayerComponentsManager = playerDetected.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
|
||||
playerActionSystem currentPlayerActionSystem = currentPlayerComponentsManager.getPlayerActionSystem ();
|
||||
|
||||
if (actionTransform == null) {
|
||||
actionTransform = transform;
|
||||
}
|
||||
|
||||
if (currentPlayerActionSystem != null) {
|
||||
if (showDebugPrint) {
|
||||
print ("Sending action to player action system " + actionInfoList [0].Name);
|
||||
}
|
||||
|
||||
currentPlayerActionSystem.setPlayerActionActive (this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerActionDeactivate (GameObject playerDetected)
|
||||
{
|
||||
if (ignorePlayerList || playerList.Contains (playerDetected)) {
|
||||
if (!ignorePlayerList) {
|
||||
playerList.Remove (playerDetected);
|
||||
}
|
||||
|
||||
playerComponentsManager currentPlayerComponentsManager = playerDetected.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
|
||||
playerActionSystem currentPlayerActionSystem = currentPlayerComponentsManager.getPlayerActionSystem ();
|
||||
|
||||
if (currentPlayerActionSystem != null) {
|
||||
currentPlayerActionSystem.setPlayerActionDeactivate (this);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignorePlayerList) {
|
||||
if (useEventsOnPlayerInsideOutside) {
|
||||
if (playerList.Count == 0) {
|
||||
eventOnPlayerOutside.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkSendCurrentPlayerOnEvent (GameObject currentPlayer)
|
||||
{
|
||||
if (sendCurrentPlayerOnEvent) {
|
||||
eventToSendCurrentPlayer.Invoke (currentPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventBeforeStartAction ()
|
||||
{
|
||||
if (useEventBeforeStartAction) {
|
||||
eventBeforeStartAction.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomActionTransform (Transform newTransform)
|
||||
{
|
||||
actionTransform = newTransform;
|
||||
}
|
||||
|
||||
public actionInfo getCurrentactionInfo ()
|
||||
{
|
||||
return actionInfoList [currentActionInfoIndex];
|
||||
}
|
||||
|
||||
public void increaseCurrentActionInfoIndex ()
|
||||
{
|
||||
currentActionInfoIndex++;
|
||||
|
||||
if (currentActionInfoIndex >= actionInfoList.Count - 1) {
|
||||
currentActionInfoIndex = actionInfoList.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void decreaseCurrentActionInfoIndex ()
|
||||
{
|
||||
currentActionInfoIndex--;
|
||||
|
||||
if (currentActionInfoIndex < 0) {
|
||||
currentActionInfoIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentActionInfoIndex (int newIndex)
|
||||
{
|
||||
currentActionInfoIndex = newIndex;
|
||||
|
||||
if (currentActionInfoIndex >= actionInfoList.Count - 1) {
|
||||
currentActionInfoIndex = actionInfoList.Count - 1;
|
||||
}
|
||||
|
||||
if (currentActionInfoIndex < 0) {
|
||||
currentActionInfoIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetCurrentActionInfoIndex ()
|
||||
{
|
||||
currentActionInfoIndex = 0;
|
||||
}
|
||||
|
||||
public int getCurrentActionInfoIndex ()
|
||||
{
|
||||
return currentActionInfoIndex;
|
||||
}
|
||||
|
||||
public void destroyAction ()
|
||||
{
|
||||
for (int i = 0; i < actionInfoList.Count; i++) {
|
||||
if (actionInfoList [i].setObjectParent) {
|
||||
Destroy (actionInfoList [i].objectToSetParent.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Destroy (gameObject);
|
||||
}
|
||||
|
||||
public void checkEventOnStartAction ()
|
||||
{
|
||||
if (useEventsOnStartEndAction) {
|
||||
eventOnStartAction.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnEndAction ()
|
||||
{
|
||||
if (useEventsOnStartEndAction) {
|
||||
eventOnEndAction.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventAfterResumePlayer ()
|
||||
{
|
||||
if (useEventAfterResumePlayer) {
|
||||
eventAfterResumePlayer.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnEnableActionObject ()
|
||||
{
|
||||
if (useEventsToEnableDisableActionObject) {
|
||||
if (showDebugPrint) {
|
||||
print ("checkEventOnEnableActionObject " + gameObject.name);
|
||||
}
|
||||
|
||||
eventToEnableActionObject.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnDisableActionObject ()
|
||||
{
|
||||
if (useEventsToEnableDisableActionObject) {
|
||||
eventToDisableActionObject.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearPlayerList ()
|
||||
{
|
||||
playerList.Clear ();
|
||||
}
|
||||
|
||||
public void removePlayerFromList (GameObject playerToRemove)
|
||||
{
|
||||
if (playerList.Contains (playerToRemove)) {
|
||||
playerList.Remove (playerToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
public void disableAction ()
|
||||
{
|
||||
for (int i = 0; i < playerList.Count; i++) {
|
||||
usingDevicesSystem currentUsingDevicesSystem = playerList [i].GetComponent<usingDevicesSystem> ();
|
||||
|
||||
if (currentUsingDevicesSystem != null) {
|
||||
currentUsingDevicesSystem.removeDeviceFromList (gameObject);
|
||||
}
|
||||
|
||||
setPlayerActionDeactivate (playerList [i]);
|
||||
}
|
||||
|
||||
if (mainTrigger == null) {
|
||||
mainTrigger = GetComponent<Collider> ();
|
||||
}
|
||||
|
||||
if (mainTrigger != null) {
|
||||
mainTrigger.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void inputPlayCurrentAnimation ()
|
||||
{
|
||||
inputPlayCurrentAnimation (true);
|
||||
}
|
||||
|
||||
public void inputPlayCurrentAnimationWithoutCheckingIfExistsOnaDeviceList ()
|
||||
{
|
||||
inputPlayCurrentAnimation (false);
|
||||
}
|
||||
|
||||
void inputPlayCurrentAnimation (bool checkIfObjectOnDeviceList)
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("players detected " + playerList.Count);
|
||||
}
|
||||
|
||||
for (int i = 0; i < playerList.Count; i++) {
|
||||
playerComponentsManager currentPlayerComponentsManager = playerList [i].GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
|
||||
playerActionSystem currentPlayerActionSystem = currentPlayerComponentsManager.getPlayerActionSystem ();
|
||||
|
||||
if (currentPlayerActionSystem != null) {
|
||||
usingDevicesSystem currentUsingDevicesSystem = currentPlayerComponentsManager.getUsingDevicesSystem ();
|
||||
|
||||
currentUsingDevicesSystem.updateClosestDeviceList ();
|
||||
|
||||
if (currentPlayerActionSystem.getCurrentActionSystem () == this) {
|
||||
if (showDebugPrint) {
|
||||
print ("player with this action as current");
|
||||
}
|
||||
|
||||
if (checkIfObjectOnDeviceList) {
|
||||
currentPlayerActionSystem.inputPlayCurrentAnimation ();
|
||||
} else {
|
||||
currentPlayerActionSystem.inputPlayCurrentAnimationWithoutCheckingIfExistsOnaDeviceList ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addNewAction ()
|
||||
{
|
||||
actionInfo newActionInfo = new actionInfo ();
|
||||
|
||||
newActionInfo.Name = "New Action";
|
||||
|
||||
actionInfoList.Add (newActionInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addNewActionFromEditor (string actionSystemName, float actionSystemDuration, float actionSystemSpeed,
|
||||
bool useActionSystemID, int actionSystemID, string actionSystemAnimationName)
|
||||
{
|
||||
actionInfo currentactionInfo = actionInfoList [0];
|
||||
|
||||
currentactionInfo.Name = actionSystemName;
|
||||
currentactionInfo.animationDuration = actionSystemDuration;
|
||||
currentactionInfo.animationSpeed = actionSystemSpeed;
|
||||
currentactionInfo.useActionID = useActionSystemID;
|
||||
currentactionInfo.actionID = actionSystemID;
|
||||
currentactionInfo.useActionName = !useActionSystemID;
|
||||
currentactionInfo.actionName = actionSystemAnimationName;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addNewEvent (int actionInfoIndex)
|
||||
{
|
||||
actionInfo currentActionInfo = actionInfoList [actionInfoIndex];
|
||||
|
||||
eventInfo newEventInfo = new eventInfo ();
|
||||
|
||||
currentActionInfo.eventInfoList.Add (newEventInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addNewEventFirstPerson (int actionInfoIndex)
|
||||
{
|
||||
actionInfo currentActionInfo = actionInfoList [actionInfoIndex];
|
||||
|
||||
eventInfo newEventInfo = new eventInfo ();
|
||||
|
||||
currentActionInfo.firstPersonEventInfoList.Add (newEventInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void duplicateThirdPersonEventsOnFirstPerson (int actionInfoIndex)
|
||||
{
|
||||
actionInfo currentActionInfo = actionInfoList [actionInfoIndex];
|
||||
|
||||
currentActionInfo.firstPersonEventInfoList.Clear ();
|
||||
|
||||
for (int i = 0; i < currentActionInfo.eventInfoList.Count; i++) {
|
||||
eventInfo newEventInfo = new eventInfo (currentActionInfo.eventInfoList [i]);
|
||||
|
||||
currentActionInfo.firstPersonEventInfoList.Add (newEventInfo);
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void replaceAnimationAction ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (actionInfoList.Count > 0) {
|
||||
if (newAnimationClip == null) {
|
||||
print ("No new animation clip has been assigned to replace the previous animation, make sure to configure the settings properly");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainAnimator == null) {
|
||||
GameObject mainPlayer = GameObject.FindGameObjectWithTag ("Player");
|
||||
|
||||
if (mainPlayer == null) {
|
||||
print ("No animator or main player found in the scene, make sure to drop it on the hierarchy or assign an animator into " +
|
||||
" the proper field of the Action System Component");
|
||||
|
||||
return;
|
||||
} else {
|
||||
mainAnimator = mainPlayer.GetComponent<Animator> ();
|
||||
|
||||
if (mainAnimator == null) {
|
||||
print ("No animator found on scene");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actionInfo currentactionInfo = actionInfoList [0];
|
||||
|
||||
if (actionNameToReplace != "") {
|
||||
bool actionFound = false;
|
||||
|
||||
for (int i = 0; i < actionInfoList.Count; i++) {
|
||||
if (!actionFound && actionInfoList [i].actionName.Equals (actionNameToReplace)) {
|
||||
actionFound = true;
|
||||
|
||||
currentactionInfo = actionInfoList [i];
|
||||
|
||||
if (actionInfoList [i].useActionID) {
|
||||
actionNameToReplace = currentactionInfo.Name;
|
||||
} else {
|
||||
actionNameToReplace = currentactionInfo.actionName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool animationStateFound = false;
|
||||
|
||||
UnityEditor.Animations.AnimatorController ac = mainAnimator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
|
||||
|
||||
foreach (var layer in ac.layers) {
|
||||
if (layer.name == animationLayerName) {
|
||||
print ("Animator Layer to check: " + layer.name);
|
||||
|
||||
print ("\n\n\n");
|
||||
|
||||
getChildAnimatorState (actionNameToReplace, layer.stateMachine);
|
||||
|
||||
print ("\n\n\n");
|
||||
|
||||
if (animatorStateToReplace.state != null) {
|
||||
print ("\n\n\n");
|
||||
|
||||
print ("STATE FOUND ############################################################################################");
|
||||
|
||||
print ("Last animator state found " + animatorStateToReplace.state.name + " " + numberOfLoops);
|
||||
|
||||
if (animatorStateToReplace.state.name == actionNameToReplace) {
|
||||
animationStateFound = true;
|
||||
|
||||
animatorStateToReplace.state.speed = newAnimationSpeed;
|
||||
animatorStateToReplace.state.motion = newAnimationClip;
|
||||
animatorStateToReplace.state.mirror = newAnimationIsMirror;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (animationStateFound) {
|
||||
currentactionInfo.animationSpeed = newAnimationSpeed;
|
||||
currentactionInfo.animationDuration = newAnimationClip.length;
|
||||
|
||||
updateComponent ();
|
||||
|
||||
print ("Animation State found and replaced properly");
|
||||
} else {
|
||||
print ("Animation State not found");
|
||||
}
|
||||
|
||||
newAnimationIsMirror = false;
|
||||
|
||||
activateAnimationReplace = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
UnityEditor.Animations.ChildAnimatorState animatorStateToReplace;
|
||||
|
||||
public void getChildAnimatorState (string stateName, UnityEditor.Animations.AnimatorStateMachine stateMachine)
|
||||
{
|
||||
print ("State Machine to check: " + stateMachine.name + " " + stateMachine.stateMachines.Length);
|
||||
|
||||
if (stateMachine.stateMachines.Length > 0) {
|
||||
foreach (var currentStateMachine in stateMachine.stateMachines) {
|
||||
numberOfLoops++;
|
||||
|
||||
if (numberOfLoops > 3000) {
|
||||
print ("number of loops too big");
|
||||
return;
|
||||
}
|
||||
|
||||
getChildAnimatorState (stateName, currentStateMachine.stateMachine);
|
||||
}
|
||||
} else {
|
||||
foreach (var currentState in stateMachine.states) {
|
||||
if (currentState.state.name == stateName) {
|
||||
animatorStateToReplace = currentState;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Action System " + gameObject.name, gameObject);
|
||||
}
|
||||
|
||||
void OnDrawGizmos ()
|
||||
{
|
||||
if (!showGizmo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
|
||||
DrawGizmos ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected ()
|
||||
{
|
||||
DrawGizmos ();
|
||||
}
|
||||
|
||||
void DrawGizmos ()
|
||||
{
|
||||
if (showGizmo) {
|
||||
for (int i = 0; i < actionInfoList.Count; i++) {
|
||||
if (showAllGizmo || actionInfoList [i].showGizmo) {
|
||||
if (actionInfoList [i].usePlayerWalkTarget && actionInfoList [i].playerWalkTarget != null) {
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawSphere (actionInfoList [i].playerWalkTarget.position, 0.1f);
|
||||
}
|
||||
|
||||
if (actionInfoList [i].setPlayerFacingDirection && actionInfoList [i].facingDirectionPositionTransform != null) {
|
||||
Gizmos.color = Color.green;
|
||||
Gizmos.DrawSphere (actionInfoList [i].facingDirectionPositionTransform.position, 0.1f);
|
||||
}
|
||||
|
||||
if (actionInfoList [i].usePositionToAdjustPlayer && actionInfoList [i].positionToAdjustPlayer != null) {
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawSphere (actionInfoList [i].positionToAdjustPlayer.position, 0.1f);
|
||||
|
||||
if (actionInfoList [i].matchTargetTransform) {
|
||||
Gizmos.color = Color.grey;
|
||||
Gizmos.DrawSphere (actionInfoList [i].matchTargetTransform.position, 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class actionInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool useActionName;
|
||||
|
||||
public string actionName;
|
||||
|
||||
public bool useActionID;
|
||||
public int actionID;
|
||||
|
||||
public bool removeActionIDValueImmediately;
|
||||
|
||||
public bool useCrossFadeAnimation = true;
|
||||
|
||||
public bool pausePlayerActionsInput;
|
||||
public bool pausePlayerMovementInput = true;
|
||||
public bool resetPlayerMovementInput;
|
||||
public bool resetPlayerMovementInputSmoothly;
|
||||
public bool removePlayerMovementInputValues;
|
||||
|
||||
public bool enablePlayerCanMoveAfterAction;
|
||||
|
||||
public bool allowDownVelocityDuringAction;
|
||||
|
||||
public bool pauseInteractionButton;
|
||||
public bool pauseInputListDuringActionActive;
|
||||
public bool ignorePauseInputListDuringAction;
|
||||
|
||||
public bool pausePlayerCameraRotationInput;
|
||||
public bool pausePlayerCameraActionsInput;
|
||||
public bool pausePlayerCameraViewChange = true;
|
||||
public bool pausePlayerCameraMouseWheel = true;
|
||||
public bool disableHeadBob = true;
|
||||
public bool pauseHeadBob = true;
|
||||
public bool ignoreCameraDirectionOnMovement;
|
||||
public bool ignoreCameraDirectionOnStrafeMovement;
|
||||
|
||||
public bool pauseStrafeState;
|
||||
|
||||
public bool useNewCameraStateOnActionStart;
|
||||
public string newCameraStateNameOnActionStart;
|
||||
public bool setPreviousCameraStateOnActionEnd;
|
||||
public bool useNewCameraStateOnActionEnd;
|
||||
public string newCameraStateNameOnActionEnd;
|
||||
|
||||
public bool ignorePivotCameraCollision;
|
||||
|
||||
public bool useExtraFollowTransformPositionOffsetActiveFBA;
|
||||
|
||||
public Vector3 currentExtraFollowTransformPositionOffsetFBA;
|
||||
|
||||
public bool ignorePlayerRotationToCameraOnFBA;
|
||||
|
||||
public bool ignoreHorizontalCameraRotationOnFBA;
|
||||
public bool ignoreVerticalCameraRotationOnFBA;
|
||||
|
||||
public bool resetCameraRotationForwardOnFBA;
|
||||
|
||||
public bool disablePlayerGravity;
|
||||
public bool disablePlayerOnGroundState;
|
||||
public bool disablePlayerCollider;
|
||||
public bool disablePlayerColliderComponent;
|
||||
public bool enablePlayerColliderComponentOnActionEnd;
|
||||
public bool ignoreSetLastTimeFallingOnActionEnd;
|
||||
|
||||
public bool reloadMainColliderOnCharacterOnActionEnd;
|
||||
|
||||
public bool changePlayerColliderScale;
|
||||
public bool disableIKOnHands = true;
|
||||
public bool disableIKOnFeet = true;
|
||||
|
||||
public bool pauseHeadTrack = true;
|
||||
|
||||
public bool usCustomPauseHeadTrackOnFBA;
|
||||
public bool customPauseHeadTrackOnFBA;
|
||||
|
||||
public bool setNoFrictionOnCollider = true;
|
||||
public bool forceRootMotionDuringAction = true;
|
||||
public bool actionCanHappenOnAir;
|
||||
|
||||
public bool jumpCanResumePlayer;
|
||||
|
||||
public bool useMovementInput;
|
||||
|
||||
public bool useInteractionButtonToActivateAnimation = true;
|
||||
|
||||
public bool animationTriggeredByExternalEvent;
|
||||
|
||||
public bool resumePlayerAfterAction;
|
||||
|
||||
public bool increaseActionIndexAfterComplete;
|
||||
public bool waitForNextPlayerInteractionButtonPress;
|
||||
|
||||
public bool stayInState;
|
||||
|
||||
public bool resetActionIndexAfterComplete;
|
||||
|
||||
|
||||
public float animationDuration;
|
||||
|
||||
public float animationSpeed = 1;
|
||||
|
||||
public float actionDurationOnFirstPerson = 1;
|
||||
|
||||
|
||||
public bool actionUsesMovement;
|
||||
|
||||
public bool adjustRotationDuringMovement;
|
||||
|
||||
public float delayToPlayAnimation;
|
||||
|
||||
public bool usePositionToAdjustPlayer;
|
||||
public Transform positionToAdjustPlayer;
|
||||
public float adjustPlayerPositionSpeed;
|
||||
|
||||
|
||||
public bool movePlayerOnDirection;
|
||||
public float movePlayerOnDirectionRaycastDistance;
|
||||
public float movePlayerOnDirectionSpeed;
|
||||
public Vector3 movePlayerDirection;
|
||||
public LayerMask movePlayerOnDirectionLayermask;
|
||||
|
||||
public bool usePhysicsForceOnMovePlayer;
|
||||
public float physicsForceOnMovePlayer;
|
||||
public float physicsForceOnMovePlayerDuration;
|
||||
public bool checkIfPositionReachedOnPhysicsForceOnMovePlayer;
|
||||
|
||||
public AvatarTarget mainAvatarTarget;
|
||||
|
||||
public Transform matchTargetTransform;
|
||||
|
||||
public Vector3 matchTargetPositionWeightMask;
|
||||
public float matchTargetRotationWeightMask;
|
||||
|
||||
public bool matchPlayerRotation;
|
||||
public float matchPlayerRotationSpeed;
|
||||
|
||||
public Transform playerTargetTransform;
|
||||
|
||||
public bool adjustPlayerPositionRotationDuring;
|
||||
|
||||
public float matchStartValue;
|
||||
public float matchEndValue;
|
||||
|
||||
public bool usePlayerWalkTarget;
|
||||
public bool useWalkAtTheEndOfAction;
|
||||
public Transform playerWalkTarget;
|
||||
|
||||
public bool pausePlayerInputDuringWalk;
|
||||
|
||||
public float maxWalkSpeed = 1;
|
||||
|
||||
public bool activateDynamicObstacleDetection;
|
||||
|
||||
public bool setPlayerFacingDirection;
|
||||
public Transform playerFacingDirectionTransform;
|
||||
public float maxRotationAmount = 1;
|
||||
public float minRotationAmount = 0.3f;
|
||||
public float minRotationAngle = 5;
|
||||
public bool adjustFacingDirectionBasedOnPlayerPosition;
|
||||
public Transform facingDirectionPositionTransform;
|
||||
public bool adjustRotationAtOnce;
|
||||
|
||||
public bool useMovingPlayerToPositionTarget;
|
||||
public float movingPlayerToPositionTargetSpeed = 5;
|
||||
public float movingPlayerToPositionTargetDelay;
|
||||
|
||||
|
||||
public bool destroyActionOnEnd;
|
||||
public bool removeActionOnEnd;
|
||||
|
||||
public bool setActionState;
|
||||
public string actionStateName;
|
||||
public bool actionStateToConfigure;
|
||||
|
||||
public bool setObjectParent;
|
||||
public HumanBodyBones boneParent;
|
||||
public Transform objectToSetParent;
|
||||
public Transform bonePositionReference;
|
||||
public float waitTimeToParentObject;
|
||||
public float setObjectParentSpeed;
|
||||
|
||||
public bool useMountPoint;
|
||||
public string mountPointName;
|
||||
|
||||
public bool useEventInfoList;
|
||||
|
||||
public bool useAccumulativeDelay;
|
||||
public Coroutine eventInfoListCoroutine;
|
||||
public List<eventInfo> eventInfoList = new List<eventInfo> ();
|
||||
|
||||
public List<eventInfo> firstPersonEventInfoList = new List<eventInfo> ();
|
||||
|
||||
public bool disableHUDOnAction;
|
||||
|
||||
public bool showGizmo;
|
||||
|
||||
public bool keepWeaponsDuringAction;
|
||||
public bool drawWeaponsAfterAction;
|
||||
public bool disableIKWeaponsDuringAction;
|
||||
|
||||
public bool stopAimOnFireWeapons;
|
||||
public bool stopShootOnFireWeapons;
|
||||
|
||||
public bool hideMeleWeaponMeshOnAction;
|
||||
|
||||
public bool setInvincibilityStateActive;
|
||||
public float invincibilityStateDuration;
|
||||
public bool checkEventsOnTemporalInvincibilityActive;
|
||||
|
||||
public bool disableDamageReactionDuringAction;
|
||||
|
||||
public bool addHealthAmountOnAction;
|
||||
public float healthAmountToAdd;
|
||||
public bool removeHealthAmountOnAction;
|
||||
public float healthAmountToRemove;
|
||||
|
||||
public bool checkIfPlayerOnGround = true;
|
||||
public bool checkConditionsToStartActionOnUpdate;
|
||||
public bool playerMovingToStartAction;
|
||||
public bool checkPlayerToNotCrouch;
|
||||
|
||||
public bool stopActionIfPlayerIsOnAir;
|
||||
public float delayToStopActionIfPlayerIsOnAir;
|
||||
|
||||
public bool getUpIfPlayerCrouching = true;
|
||||
public bool crouchOnActionEnd;
|
||||
public bool setPreviousCrouchStateOnActionEnd;
|
||||
public bool checkIfPlayerCanGetUpFromCrouch;
|
||||
|
||||
public bool dropGrabbedObjectsOnAction = true;
|
||||
public bool dropOnlyIfNotGrabbedPhysically = true;
|
||||
public bool dropIfGrabbedPhysicallyWithIK = true;
|
||||
public bool keepGrabbedObjectOnActionIfNotDropped;
|
||||
|
||||
public bool keepMeleeWeaponGrabbed;
|
||||
public bool drawMeleeWeaponGrabbedOnActionEnd;
|
||||
|
||||
public bool stopCurrentMeleeAttackInProcess;
|
||||
|
||||
public bool useEventIfActionStopped;
|
||||
public UnityEvent eventIfActionStopped;
|
||||
|
||||
public bool pauseCustomInputListDuringActionActive;
|
||||
public List<playerActionSystem.inputToPauseOnActionIfo> customInputToPauseOnActionInfoList = new List<playerActionSystem.inputToPauseOnActionIfo> ();
|
||||
|
||||
public bool useRaycastToAdjustMatchTransform;
|
||||
public bool useRaycastToAdjustTargetTransform;
|
||||
public bool useRaycastToAdjustPositionToAdjustPlayer;
|
||||
public LayerMask layerForRaycast;
|
||||
|
||||
public bool pauseAIOnActionStart;
|
||||
public bool resumeAIOnActionEnd;
|
||||
public bool assignPartnerOnActionEnd;
|
||||
public bool checkUseMinAngleToActivateAction;
|
||||
|
||||
public bool ignoreAnimationTransitionCheck;
|
||||
|
||||
public bool pauseActivationOfOtherCustomActions;
|
||||
|
||||
public bool disableAnyStateConfiguredWithExitTime;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventInfo
|
||||
{
|
||||
public float delayToActivate;
|
||||
|
||||
public UnityEvent eventToUse;
|
||||
|
||||
public bool useRemoteEvent;
|
||||
|
||||
public string remoteEventName;
|
||||
|
||||
public bool eventTriggered;
|
||||
|
||||
public bool sendCurrentPlayerOnEvent;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendCurrentPlayer;
|
||||
|
||||
public bool callThisEventIfActionStopped;
|
||||
|
||||
public eventInfo ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public eventInfo (eventInfo newState)
|
||||
{
|
||||
delayToActivate = newState.delayToActivate;
|
||||
|
||||
eventToUse = newState.eventToUse;
|
||||
|
||||
useRemoteEvent = newState.useRemoteEvent;
|
||||
|
||||
remoteEventName = newState.remoteEventName;
|
||||
|
||||
eventTriggered = newState.eventTriggered;
|
||||
|
||||
sendCurrentPlayerOnEvent = newState.sendCurrentPlayerOnEvent;
|
||||
|
||||
eventToSendCurrentPlayer = newState.eventToSendCurrentPlayer;
|
||||
|
||||
callThisEventIfActionStopped = newState.callThisEventIfActionStopped;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03af2e4c8e425d040bb8e026109390ea
|
||||
timeCreated: 1703835081
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Action System/actionSystem.cs.bak
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc1db0794fd4b9e4ebf007f9e3afdf44
|
||||
timeCreated: 1578192035
|
||||
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/Action System/actionSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,124 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class activateActionOnCharactersOnScene : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool activateActionEnabled = true;
|
||||
public int currentCharacterActionInfoIndex;
|
||||
|
||||
public Transform playerTransform;
|
||||
|
||||
[Space]
|
||||
[Header ("Character Action Info List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<characterActionInfo> characterActionInfoList = new List<characterActionInfo> ();
|
||||
|
||||
public void activateActionOnCharacters (string actionName)
|
||||
{
|
||||
if (!activateActionEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < characterActionInfoList.Count; i++) {
|
||||
if (characterActionInfoList [i].Name.Equals (actionName)) {
|
||||
currentCharacterActionInfoIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
characterActionInfo currentCharacterActionInfo = characterActionInfoList [currentCharacterActionInfoIndex];
|
||||
|
||||
playerActionSystem[] playerActionSystemList = FindObjectsOfType<playerActionSystem> ();
|
||||
|
||||
foreach (playerActionSystem currentPlayerActionSystem in playerActionSystemList) {
|
||||
bool canActivateAction = true;
|
||||
|
||||
Transform characterTransform = currentPlayerActionSystem.playerTransform;
|
||||
|
||||
if (currentCharacterActionInfo.ignoreCharacters) {
|
||||
if (currentCharacterActionInfo.characterObjectToIgnoreList.Count > 0) {
|
||||
if (currentCharacterActionInfo.characterObjectToIgnoreList.Contains (characterTransform.gameObject)) {
|
||||
canActivateAction = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentCharacterActionInfo.tagsToIgnore.Contains (characterTransform.tag)) {
|
||||
canActivateAction = false;
|
||||
}
|
||||
|
||||
if (currentCharacterActionInfo.ignoreCharacterByLayer) {
|
||||
if ((1 << characterTransform.gameObject.layer & currentCharacterActionInfo.layerToIgnore.value) == 1 << characterTransform.gameObject.layer) {
|
||||
canActivateAction = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentCharacterActionInfo.useMaxDistance) {
|
||||
float currentDistance = GKC_Utils.distance (playerTransform.position, characterTransform.position);
|
||||
|
||||
if (currentDistance > currentCharacterActionInfo.maxDistance) {
|
||||
canActivateAction = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateAction) {
|
||||
if (currentCharacterActionInfo.activateAction) {
|
||||
currentPlayerActionSystem.activateCustomAction (currentCharacterActionInfo.Name);
|
||||
}
|
||||
|
||||
if (currentCharacterActionInfo.useRemoteEvents) {
|
||||
remoteEventSystem currentRemoteEventSystem = currentPlayerActionSystem.mainRemoteEventSystem;
|
||||
|
||||
if (currentRemoteEventSystem != null) {
|
||||
for (int i = 0; i < currentCharacterActionInfo.remoteEventNameList.Count; i++) {
|
||||
currentRemoteEventSystem.callRemoteEvent (currentCharacterActionInfo.remoteEventNameList [i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class characterActionInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool activateAction;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool ignoreCharacters;
|
||||
|
||||
public List<string> tagsToIgnore = new List<string> ();
|
||||
|
||||
[Space]
|
||||
|
||||
public bool ignoreCharacterByLayer;
|
||||
|
||||
public LayerMask layerToIgnore;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<GameObject> characterObjectToIgnoreList = new List<GameObject> ();
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool useMaxDistance;
|
||||
public float maxDistance;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool useRemoteEvents;
|
||||
public List<string> remoteEventNameList = new List<string> ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88953eb65467dd84099e1a0adbc18376
|
||||
timeCreated: 1652010681
|
||||
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/Action System/activateActionOnCharactersOnScene.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class characterActionSystemChecker : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool actionSystemCheckerEnabled = true;
|
||||
|
||||
public List<string> actionsToPlayAutomaticallyList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerActionSystem mainPlayerActionSystem;
|
||||
|
||||
|
||||
|
||||
public void checkToPlayActionAutomatically ()
|
||||
{
|
||||
if (!actionSystemCheckerEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool isActionActive = mainPlayerActionSystem.isActionActive ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Is action active " + isActionActive);
|
||||
}
|
||||
|
||||
if (isActionActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
string currentActionDetected = mainPlayerActionSystem.getCurrentActionName ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("checking action detected " + currentActionDetected);
|
||||
}
|
||||
|
||||
if (currentActionDetected != "" && actionsToPlayAutomaticallyList.Contains (currentActionDetected)) {
|
||||
if (showDebugPrint) {
|
||||
print ("action detected, calling to play animation for " + currentActionDetected);
|
||||
}
|
||||
|
||||
mainPlayerActionSystem.playCurrentAnimation ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d30811e90d173654eb677254b73ab14c
|
||||
timeCreated: 1625077606
|
||||
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/Action System/characterActionSystemChecker.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,135 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class customActionSystemTrigger : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool activateActionOnEnter;
|
||||
public bool activateActionOnExit;
|
||||
|
||||
public string actionToActivateName;
|
||||
|
||||
public bool stopActionActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Condition Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useMinAngleToActivateAction;
|
||||
public float minAngleToActivateAction;
|
||||
public bool checkOppositeAngle;
|
||||
public Transform actionSystemDirectionTransform;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useMinDistanceToActivateAction;
|
||||
public float minDistanceToActivateAction;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setCustomActionSystemTransform;
|
||||
public Transform customActionSystemTransform;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public void setPlayerOnEnter (GameObject newPlayer)
|
||||
{
|
||||
if (activateActionOnEnter) {
|
||||
activateCustomAction (newPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerOnExit (GameObject newPlayer)
|
||||
{
|
||||
if (activateActionOnExit) {
|
||||
activateCustomAction (newPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public void activateCustomAction (GameObject newPlayer)
|
||||
{
|
||||
if (newPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkActionCondition (newPlayer.transform)) {
|
||||
return;
|
||||
}
|
||||
|
||||
playerComponentsManager currentPlayerComponentsManager = newPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
playerActionSystem currentPlayerActionSystem = currentPlayerComponentsManager.getPlayerActionSystem ();
|
||||
|
||||
if (currentPlayerActionSystem != null) {
|
||||
if (stopActionActive) {
|
||||
currentPlayerActionSystem.stopCustomAction (actionToActivateName);
|
||||
} else {
|
||||
if (setCustomActionSystemTransform) {
|
||||
currentPlayerActionSystem.setCustomActionTransform (actionToActivateName, customActionSystemTransform);
|
||||
}
|
||||
|
||||
currentPlayerActionSystem.activateCustomAction (actionToActivateName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool checkActionCondition (Transform playerTransform)
|
||||
{
|
||||
if (useMinAngleToActivateAction) {
|
||||
if (actionSystemDirectionTransform == null) {
|
||||
actionSystemDirectionTransform = transform;
|
||||
}
|
||||
|
||||
float currentAngleWithTarget = Vector3.SignedAngle (playerTransform.forward, actionSystemDirectionTransform.forward, playerTransform.up);
|
||||
|
||||
if (Mathf.Abs (currentAngleWithTarget) > minAngleToActivateAction) {
|
||||
if (checkOppositeAngle) {
|
||||
currentAngleWithTarget = Mathf.Abs (currentAngleWithTarget) - 180;
|
||||
|
||||
if (Mathf.Abs (currentAngleWithTarget) > minAngleToActivateAction) {
|
||||
if (showDebugPrint) {
|
||||
print ("can't play animation for angle");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("can't play animation for angle");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useMinDistanceToActivateAction) {
|
||||
if (actionSystemDirectionTransform == null) {
|
||||
actionSystemDirectionTransform = transform;
|
||||
}
|
||||
|
||||
float currentDistanceToTarget = GKC_Utils.distance (actionSystemDirectionTransform.position, playerTransform.position);
|
||||
|
||||
if (currentDistanceToTarget > minDistanceToActivateAction) {
|
||||
if (showDebugPrint) {
|
||||
print ("can't play animation for distance");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ab617dabe2143b4ba6296ac82ae2ff1
|
||||
timeCreated: 1581122918
|
||||
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/Action System/customActionSystemTrigger.cs
|
||||
uploadId: 814740
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bedb1c4c2d8f0894497afe0cc24b2eed
|
||||
timeCreated: 1703835081
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Action System/playerActionSystem.cs.bak
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac48c055136760f47abcd19c6d137f4f
|
||||
timeCreated: 1578192077
|
||||
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/Action System/playerActionSystem.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user