add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user