add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,711 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class changePlayerStateOnTriggerSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool changePlayerStatesEnabled = true;
|
||||
|
||||
public bool disableTriggerAfterEnter;
|
||||
|
||||
[Space]
|
||||
[Header ("Player Mode Settings")]
|
||||
[Space]
|
||||
|
||||
public bool changePlayerMode;
|
||||
|
||||
public string playerModeName;
|
||||
|
||||
[Space]
|
||||
[Header ("Jump Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setJumpEnabledState;
|
||||
public bool jumpEnabledState;
|
||||
|
||||
public bool setDoubleJumpState;
|
||||
public bool doubleJumpState;
|
||||
|
||||
[Space]
|
||||
[Header ("Camera Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setCameraViewState;
|
||||
public bool setCameraToFirstPerson;
|
||||
|
||||
public bool setNewDefaultThirdPersonCameraState;
|
||||
public string newDefaultThirdPersonCameraStateName;
|
||||
|
||||
public bool setActionToChangeBetweenViewsState;
|
||||
public bool actionToChangeBetweenViewsState;
|
||||
|
||||
public bool setCameraStateName;
|
||||
public string cameraStateName;
|
||||
|
||||
public bool resetCameraRotationState;
|
||||
|
||||
[Space]
|
||||
[Header ("Input Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setPlayerInputActionState;
|
||||
public bool playerInputActionState;
|
||||
public string multiAxesInputName;
|
||||
public string axesInputName;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setIgnoreCheckInputActiveState;
|
||||
public bool ignoreCheckInputActiveState;
|
||||
public List<string> multiAxesInputNameList;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setPauseAllInputActionsState;
|
||||
public bool pauseAllInputActionState;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setPauseMovementAxisInputState;
|
||||
public bool pauseMovementAxisInputState;
|
||||
|
||||
public bool setPauseCameraAxisInputState;
|
||||
public bool pauseCameraAxisInputState;
|
||||
|
||||
[Space]
|
||||
[Header ("Animation Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setActionActiveState;
|
||||
public bool actionActiveState;
|
||||
public int actionId = -1;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool enableAnimatorLayerOnAction;
|
||||
public string animatorLayerToEnableName;
|
||||
|
||||
[Space]
|
||||
[Header ("Weapon Settings")]
|
||||
[Space]
|
||||
|
||||
public bool drawWeapon;
|
||||
public bool drawCurrentWeapon;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool drawCertainWeapon;
|
||||
public string weaponNameToDraw;
|
||||
public bool isFireWeapon;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool keepWeapon;
|
||||
|
||||
[Space]
|
||||
[Header ("Fire Weapon Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setCarryWeaponOnLowerPositionState;
|
||||
public bool carryWeaponOnLowerPositionState;
|
||||
public bool setCanFireWeaponsState;
|
||||
public bool canFireWeaponsState;
|
||||
|
||||
[Space]
|
||||
[Header ("Gravity Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setGravityPowerState;
|
||||
public bool gravityPowerState;
|
||||
|
||||
public bool setZeroGravityModeState;
|
||||
public bool zeroGravityModeState;
|
||||
|
||||
public bool setGravityDirection;
|
||||
public setGravity setGravityManager;
|
||||
|
||||
[Space]
|
||||
[Header ("Free Floating Mode Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setFreeFloatingModeState;
|
||||
public bool freeFloatingModeState;
|
||||
|
||||
[Space]
|
||||
[Header ("Look At Target Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setLookAtPointState;
|
||||
public bool lookAtPointState;
|
||||
public Transform pointToLook;
|
||||
public bool useDurationToLookAtPoint;
|
||||
public float durationToLookAtPoint;
|
||||
public bool enableLookAtPointStateAfterDuration;
|
||||
public bool setLookAtPointSpeed;
|
||||
public float lookAtPointSpeed;
|
||||
|
||||
public bool setMaxDistanceToFindTarget;
|
||||
public float maxDistanceToFindTarget;
|
||||
|
||||
public bool setUseLookTargetIconState;
|
||||
public bool useLookTargetIconState;
|
||||
|
||||
public bool setOriginalUseLookTargetIconState;
|
||||
|
||||
[Space]
|
||||
[Header ("Camera Zoom Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setCameraZoomState;
|
||||
public bool cameraZoomState;
|
||||
public bool useCameraZoomDuration;
|
||||
public float cameraZoomDuration;
|
||||
public bool enableCameraZoonInputAfterDuration;
|
||||
|
||||
[Space]
|
||||
[Header ("Transparent Surface Detection Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setTransparentSurfaceDetectionState;
|
||||
public bool transparentSurfaceDetectionState;
|
||||
|
||||
[Space]
|
||||
[Header ("Movement Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setWalkSpeedValue;
|
||||
public float walkSpeedValue;
|
||||
public bool setOriginalWalkSpeedValue;
|
||||
|
||||
public bool setIncreaseWalkSpeedValue;
|
||||
public float increaseWalkSpeedValue;
|
||||
|
||||
public bool setIncreaseWalkSpeedEnabled;
|
||||
public bool increaseWalkSpeedEnabled;
|
||||
public bool setOriginalIncreaseWalkSpeedEnabledValue;
|
||||
|
||||
public bool setPlayerStatusID;
|
||||
public int playerStatusID;
|
||||
public bool setOriginalPlayerStatusID;
|
||||
|
||||
public bool setCrouchState;
|
||||
public bool crouchStateToActivate;
|
||||
|
||||
[Space]
|
||||
[Header ("Sprint Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setSprintEnabledState;
|
||||
public bool sprintEnabledState;
|
||||
public bool setOriginalSprintEnabledState;
|
||||
|
||||
[Space]
|
||||
[Header ("Stairs Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setStairsAdherenceValue;
|
||||
public float stairsMaxValue = 0.25f;
|
||||
public float stairsMinValue = 0.2f;
|
||||
public float stairsGroundAdherence = 8;
|
||||
|
||||
[Space]
|
||||
[Header ("Root Motion Settings")]
|
||||
[Space]
|
||||
|
||||
public bool changeRootMotionActive;
|
||||
public bool useRootMotionActive = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Ragdoll Settings")]
|
||||
[Space]
|
||||
|
||||
public bool activateRagdollState;
|
||||
public Transform ragdollPushDirection;
|
||||
public float ragdollPushForceAmount;
|
||||
|
||||
[Space]
|
||||
[Header ("Ability Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setAbility;
|
||||
public string abilityNameToSet;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useAbilitiesListToEnable;
|
||||
|
||||
public List<string> abilitiesListToEnable = new List<string> ();
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useAbilitiesListToDisable;
|
||||
|
||||
public List<string> abilitiesListToDisable = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Powers Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setCurrentPower;
|
||||
public string currentPowerName;
|
||||
|
||||
[Space]
|
||||
[Header ("Map Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setCompassEnableValue;
|
||||
public bool compassEnabledValue;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
[Space]
|
||||
[Header ("Remote Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useRemoteEventOnObjectsFound;
|
||||
public List<string> removeEventNameList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventOnTrigger;
|
||||
public UnityEvent eventOnTrigger;
|
||||
public bool sendPlayerOnEvent;
|
||||
public eventParameters.eventToCallWithGameObject playerSendEvent;
|
||||
|
||||
[Space]
|
||||
[Header ("Player Manual Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setPlayerManually;
|
||||
public GameObject playerToConfigure;
|
||||
|
||||
public GameObject currentPlayer;
|
||||
|
||||
public bool searchPlayerOnSceneIfNotAssigned = true;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager;
|
||||
playerController playerControllerManager;
|
||||
playerCamera playerCameraManager;
|
||||
playerWeaponsManager weaponsManager;
|
||||
inventoryManager mainInventoryManager;
|
||||
meleeWeaponsGrabbedManager mainMeleeWeaponsGrabbedManager;
|
||||
|
||||
gravitySystem gravityManager;
|
||||
playerInputManager playerInput;
|
||||
Collider currentCollider;
|
||||
grabObjects grabObjectsManager;
|
||||
playerAbilitiesSystem mainPlayerAbilitySystem;
|
||||
remoteEventSystem currentRemoteEventSystem;
|
||||
otherPowers mainOtherPowers;
|
||||
playerStatesManager mainPlayerStatesManager;
|
||||
ragdollActivator mainRagdollActivator;
|
||||
mapSystem mainMapSystem;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (setPlayerManually) {
|
||||
setCurrentPlayer (playerToConfigure);
|
||||
}
|
||||
}
|
||||
|
||||
public void findPlayerOnScene ()
|
||||
{
|
||||
if (searchPlayerOnSceneIfNotAssigned) {
|
||||
setCurrentPlayer (GKC_Utils.findMainPlayerOnScene ());
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentPlayer (GameObject player)
|
||||
{
|
||||
currentPlayer = player;
|
||||
}
|
||||
|
||||
public void changePlayerState ()
|
||||
{
|
||||
if (currentPlayer == null) {
|
||||
|
||||
findPlayerOnScene ();
|
||||
|
||||
if (currentPlayer == null) {
|
||||
print ("WARNING: no player controller has been assigned to the change player state on trigger." +
|
||||
" Make sure to use a trigger to activate the element or assign the player manually");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!changePlayerStatesEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("current character detected " + currentPlayer.name);
|
||||
}
|
||||
|
||||
mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//get all the components needed
|
||||
playerControllerManager = mainPlayerComponentsManager.getPlayerController ();
|
||||
|
||||
if (playerControllerManager == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
playerCameraManager = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
|
||||
weaponsManager = mainPlayerComponentsManager.getPlayerWeaponsManager ();
|
||||
|
||||
mainInventoryManager = mainPlayerComponentsManager.getInventoryManager ();
|
||||
|
||||
mainMeleeWeaponsGrabbedManager = mainPlayerComponentsManager.getMeleeWeaponsGrabbedManager ();
|
||||
|
||||
gravityManager = mainPlayerComponentsManager.getGravitySystem ();
|
||||
|
||||
playerInput = mainPlayerComponentsManager.getPlayerInputManager ();
|
||||
|
||||
currentCollider = playerControllerManager.getMainCollider ();
|
||||
|
||||
grabObjectsManager = mainPlayerComponentsManager.getGrabObjects ();
|
||||
|
||||
mainPlayerAbilitySystem = mainPlayerComponentsManager.getPlayerAbilitiesSystem ();
|
||||
|
||||
currentRemoteEventSystem = mainPlayerComponentsManager.getRemoteEventSystem ();
|
||||
|
||||
mainOtherPowers = mainPlayerComponentsManager.getOtherPowers ();
|
||||
|
||||
mainPlayerStatesManager = mainPlayerComponentsManager.getPlayerStatesManager ();
|
||||
|
||||
mainRagdollActivator = mainPlayerComponentsManager.getRagdollActivator ();
|
||||
|
||||
mainMapSystem = mainPlayerComponentsManager.getMapSystem ();
|
||||
|
||||
|
||||
//Player Mode Settings
|
||||
if (changePlayerMode) {
|
||||
mainPlayerStatesManager.setPlayerModeByName (playerModeName);
|
||||
}
|
||||
|
||||
//Jump settings
|
||||
if (setJumpEnabledState) {
|
||||
playerControllerManager.enableOrDisableJump (jumpEnabledState);
|
||||
}
|
||||
|
||||
if (setDoubleJumpState) {
|
||||
playerControllerManager.enableOrDisableDoubleJump (doubleJumpState);
|
||||
}
|
||||
|
||||
|
||||
//Camera settings
|
||||
if (setCameraViewState) {
|
||||
playerCameraManager.changeCameraToThirdOrFirstView (setCameraToFirstPerson);
|
||||
}
|
||||
|
||||
if (setActionToChangeBetweenViewsState) {
|
||||
playerCameraManager.enableOrDisableChangeCameraView (actionToChangeBetweenViewsState);
|
||||
}
|
||||
|
||||
if (setCameraStateName) {
|
||||
if (!playerCameraManager.isFirstPersonActive ()) {
|
||||
playerCameraManager.setCameraStateExternally (cameraStateName);
|
||||
}
|
||||
}
|
||||
|
||||
if (setNewDefaultThirdPersonCameraState) {
|
||||
playerCameraManager.setDefaultThirdPersonStateName (newDefaultThirdPersonCameraStateName);
|
||||
}
|
||||
|
||||
if (resetCameraRotationState) {
|
||||
playerCameraManager.resetCameraRotation ();
|
||||
}
|
||||
|
||||
//Weapon settings
|
||||
if (drawWeapon) {
|
||||
if (drawCurrentWeapon) {
|
||||
GKC_Utils.drawOrHolsterWeapon (currentPlayer, true, "", false);
|
||||
}
|
||||
|
||||
if (drawCertainWeapon) {
|
||||
GKC_Utils.drawOrHolsterWeapon (currentPlayer, true, weaponNameToDraw, isFireWeapon);
|
||||
}
|
||||
}
|
||||
|
||||
if (keepWeapon) {
|
||||
GKC_Utils.drawOrHolsterWeapon (currentPlayer, false, "", false);
|
||||
}
|
||||
|
||||
if (setCarryWeaponOnLowerPositionState) {
|
||||
if (carryWeaponOnLowerPositionState) {
|
||||
weaponsManager.setCarryWeaponInLowerPositionActiveState (true);
|
||||
|
||||
grabObjectsManager.enableOrDisableGeneralCursorFromExternalComponent (false);
|
||||
} else {
|
||||
weaponsManager.setCarryWeaponInLowerPositionActiveState (false);
|
||||
|
||||
grabObjectsManager.enableOrDisableGeneralCursorFromExternalComponent (true);
|
||||
}
|
||||
}
|
||||
|
||||
if (setCanFireWeaponsState) {
|
||||
weaponsManager.setFireWeaponsInputActiveState (canFireWeaponsState);
|
||||
}
|
||||
|
||||
//Gravity settings
|
||||
if (setGravityPowerState) {
|
||||
gravityManager.setGravityPowerEnabledState (gravityPowerState);
|
||||
}
|
||||
|
||||
if (setZeroGravityModeState) {
|
||||
gravityManager.setZeroGravityModeOnState (zeroGravityModeState);
|
||||
}
|
||||
|
||||
if (setFreeFloatingModeState) {
|
||||
gravityManager.setfreeFloatingModeOnState (freeFloatingModeState);
|
||||
}
|
||||
|
||||
if (setGravityDirection) {
|
||||
setGravityManager.checkTriggerType (currentCollider, true);
|
||||
}
|
||||
|
||||
if (setPlayerInputActionState) {
|
||||
playerInput.setPlayerInputActionState (playerInputActionState, multiAxesInputName, axesInputName);
|
||||
}
|
||||
|
||||
if (setIgnoreCheckInputActiveState) {
|
||||
playerInput.setIgnoreCheckInputActiveStateOnList (ignoreCheckInputActiveState, multiAxesInputNameList);
|
||||
}
|
||||
|
||||
if (setPauseAllInputActionsState) {
|
||||
playerInput.setIgnoreAllActionsInputState (pauseAllInputActionState);
|
||||
}
|
||||
|
||||
if (setPauseMovementAxisInputState) {
|
||||
playerInput.setMovementAxisInputPausedState (pauseMovementAxisInputState);
|
||||
}
|
||||
|
||||
if (setPauseCameraAxisInputState) {
|
||||
playerInput.setCameraAxisInputPausedState (pauseCameraAxisInputState);
|
||||
}
|
||||
|
||||
if (setActionActiveState) {
|
||||
playerControllerManager.setActionActiveExternally (actionActiveState);
|
||||
|
||||
if (actionId != -1) {
|
||||
playerControllerManager.setNewActionIDExternally (actionId);
|
||||
}
|
||||
|
||||
if (enableAnimatorLayerOnAction) {
|
||||
playerControllerManager.enableAnimatorLayerWeight (animatorLayerToEnableName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (setUseLookTargetIconState) {
|
||||
playerCameraManager.setUseLookTargetIconState (useLookTargetIconState);
|
||||
}
|
||||
|
||||
//Player camera look at point settings
|
||||
if (setLookAtPointState) {
|
||||
if (lookAtPointState) {
|
||||
playerCameraManager.setLookAtTargetEnabledState (true);
|
||||
}
|
||||
|
||||
if (setMaxDistanceToFindTarget) {
|
||||
playerCameraManager.setMaxDistanceToFindTargetValue (maxDistanceToFindTarget);
|
||||
}
|
||||
|
||||
playerCameraManager.setLookAtTargetStateManual (lookAtPointState, pointToLook);
|
||||
|
||||
if (lookAtPointState) {
|
||||
playerCameraManager.setLookAtTargetEnabledState (false);
|
||||
}
|
||||
|
||||
if (setLookAtPointSpeed) {
|
||||
playerCameraManager.setLookAtTargetSpeedValue (lookAtPointSpeed);
|
||||
}
|
||||
|
||||
if (useDurationToLookAtPoint) {
|
||||
playerCameraManager.setLookAtTargetEnabledStateDuration (false, durationToLookAtPoint, enableLookAtPointStateAfterDuration);
|
||||
}
|
||||
|
||||
if (setMaxDistanceToFindTarget) {
|
||||
playerCameraManager.setOriginalmaxDistanceToFindTargetValue ();
|
||||
}
|
||||
}
|
||||
|
||||
if (setOriginalUseLookTargetIconState) {
|
||||
playerCameraManager.setOriginalUseLookTargetIconValue ();
|
||||
}
|
||||
|
||||
//Camera zoom settings
|
||||
if (setCameraZoomState) {
|
||||
playerCameraManager.setZoom (cameraZoomState);
|
||||
|
||||
if (useCameraZoomDuration) {
|
||||
playerCameraManager.setZoomStateDuration (false, cameraZoomDuration, enableCameraZoonInputAfterDuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Transparent Surface Detection Settings
|
||||
if (setTransparentSurfaceDetectionState) {
|
||||
setTransparentSurfaces currentSetTransparentSurfaces = mainPlayerComponentsManager.getSetTransparentSurfaces ();
|
||||
|
||||
if (currentSetTransparentSurfaces != null) {
|
||||
currentSetTransparentSurfaces.setCheckSurfaceActiveState (transparentSurfaceDetectionState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Sprint settings
|
||||
if (setSprintEnabledState) {
|
||||
if (setOriginalSprintEnabledState) {
|
||||
playerControllerManager.setOriginalSprintEnabledValue ();
|
||||
} else {
|
||||
if (!sprintEnabledState) {
|
||||
playerControllerManager.stopSprint ();
|
||||
}
|
||||
|
||||
playerControllerManager.setSprintEnabledState (sprintEnabledState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Movements settings
|
||||
if (setWalkSpeedValue) {
|
||||
if (setOriginalWalkSpeedValue) {
|
||||
playerControllerManager.setOriginalWalkSpeed ();
|
||||
} else {
|
||||
playerControllerManager.setWalkSpeedValue (walkSpeedValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (setIncreaseWalkSpeedEnabled) {
|
||||
if (setOriginalIncreaseWalkSpeedEnabledValue) {
|
||||
playerControllerManager.setOriginalIncreaseWalkSpeedEnabledValue ();
|
||||
} else {
|
||||
playerControllerManager.setIncreaseWalkSpeedEnabled (increaseWalkSpeedEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
if (setIncreaseWalkSpeedValue) {
|
||||
playerControllerManager.setIncreaseWalkSpeedValue (increaseWalkSpeedValue);
|
||||
}
|
||||
|
||||
if (setPlayerStatusID) {
|
||||
if (setOriginalPlayerStatusID) {
|
||||
playerControllerManager.resetPlayerStatusID ();
|
||||
} else {
|
||||
playerControllerManager.setPlayerStatusIDValue (playerStatusID);
|
||||
}
|
||||
}
|
||||
|
||||
if (setCrouchState) {
|
||||
if (crouchStateToActivate) {
|
||||
if (!playerControllerManager.isCrouching ()) {
|
||||
playerControllerManager.setCrouchState (true);
|
||||
}
|
||||
} else {
|
||||
if (playerControllerManager.isCrouching ()) {
|
||||
playerControllerManager.setCrouchState (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Stairs settings
|
||||
if (setStairsAdherenceValue) {
|
||||
playerControllerManager.setStairsValues (stairsMaxValue, stairsMinValue, stairsGroundAdherence);
|
||||
}
|
||||
|
||||
|
||||
//Root motion settings
|
||||
if (changeRootMotionActive) {
|
||||
playerControllerManager.setUseRootMotionActiveState (useRootMotionActive);
|
||||
}
|
||||
|
||||
|
||||
//Ragdoll settings
|
||||
if (activateRagdollState) {
|
||||
Vector3 pushDirection = transform.forward;
|
||||
|
||||
if (ragdollPushDirection != null) {
|
||||
pushDirection = ragdollPushDirection.forward;
|
||||
}
|
||||
|
||||
mainRagdollActivator.pushCharacter (pushDirection * ragdollPushForceAmount);
|
||||
}
|
||||
|
||||
|
||||
//Ability settings
|
||||
if (setAbility) {
|
||||
mainPlayerAbilitySystem.setCurrentAbilityByName (abilityNameToSet);
|
||||
}
|
||||
|
||||
if (useAbilitiesListToEnable) {
|
||||
mainPlayerAbilitySystem.enableOrDisableAbilityGroupByName (abilitiesListToEnable, true);
|
||||
|
||||
GKC_Utils.setUnlockStateOnSkillList (currentPlayer.transform, abilitiesListToEnable, true);
|
||||
}
|
||||
|
||||
if (useAbilitiesListToDisable) {
|
||||
mainPlayerAbilitySystem.enableOrDisableAbilityGroupByName (abilitiesListToDisable, false);
|
||||
}
|
||||
|
||||
//Powers settings
|
||||
if (setCurrentPower) {
|
||||
mainOtherPowers.setCurrentPowerByName (currentPowerName);
|
||||
}
|
||||
|
||||
//Map Settings
|
||||
if (setCompassEnableValue) {
|
||||
if (mainMapSystem != null) {
|
||||
mainMapSystem.setCompassEnabledStateAndUpdateState (compassEnabledValue);
|
||||
}
|
||||
}
|
||||
|
||||
//Remote Event Settings
|
||||
if (useRemoteEventOnObjectsFound) {
|
||||
if (currentRemoteEventSystem != null) {
|
||||
for (int i = 0; i < removeEventNameList.Count; i++) {
|
||||
currentRemoteEventSystem.callRemoteEvent (removeEventNameList [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Events to be called after any state is triggred
|
||||
if (sendPlayerOnEvent) {
|
||||
playerSendEvent.Invoke (currentPlayer);
|
||||
}
|
||||
|
||||
if (useEventOnTrigger) {
|
||||
eventOnTrigger.Invoke ();
|
||||
}
|
||||
|
||||
if (disableTriggerAfterEnter) {
|
||||
gameObject.SetActive (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 415646ac301bfa544b2959ae07c4bef4
|
||||
timeCreated: 1528218808
|
||||
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/Event System/changePlayerStateOnTriggerSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,191 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class eventInfoSystem : MonoBehaviour
|
||||
{
|
||||
public bool eventInfoEnabled = true;
|
||||
|
||||
public bool useDelayEnabled = true;
|
||||
|
||||
public List<eventInfo> eventInfoList = new List<eventInfo> ();
|
||||
|
||||
public remoteEventSystem mainRemoteEventSystem;
|
||||
|
||||
public bool useSpeedMultiplier;
|
||||
|
||||
public float speedMultiplier;
|
||||
|
||||
public bool useAccumulativeDelay;
|
||||
|
||||
public bool eventInProcess;
|
||||
|
||||
public bool useEventOnStopCoroutineIfActive;
|
||||
public UnityEvent eventOnStopCoroutineIfActive;
|
||||
|
||||
eventInfo currentEventInfo;
|
||||
|
||||
Coroutine eventInfoListCoroutine;
|
||||
|
||||
public void stopCheckActionEventInfoList ()
|
||||
{
|
||||
if (eventInfoListCoroutine != null) {
|
||||
StopCoroutine (eventInfoListCoroutine);
|
||||
}
|
||||
|
||||
if (eventInProcess) {
|
||||
if (useEventOnStopCoroutineIfActive) {
|
||||
eventOnStopCoroutineIfActive.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
eventInProcess = false;
|
||||
}
|
||||
|
||||
public void activateActionEventInfoList ()
|
||||
{
|
||||
if (!eventInfoEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool mainRemoteEventSystemLocated = mainRemoteEventSystem != null;
|
||||
|
||||
if (useDelayEnabled) {
|
||||
|
||||
stopCheckActionEventInfoList ();
|
||||
|
||||
eventInfoListCoroutine = StartCoroutine (checkActionEventInfoListCoroutine ());
|
||||
} else {
|
||||
for (int i = 0; i < eventInfoList.Count; i++) {
|
||||
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
currentEventInfo.eventToUse.Invoke ();
|
||||
|
||||
if (mainRemoteEventSystemLocated) {
|
||||
if (currentEventInfo.useRemoteEvent) {
|
||||
mainRemoteEventSystem.callRemoteEvent (currentEventInfo.remoteEventName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator checkActionEventInfoListCoroutine ()
|
||||
{
|
||||
eventInProcess = true;
|
||||
|
||||
for (int i = 0; i < eventInfoList.Count; i++) {
|
||||
eventInfoList [i].eventTriggered = false;
|
||||
}
|
||||
|
||||
bool mainRemoteEventSystemLocated = mainRemoteEventSystem != null;
|
||||
|
||||
if (useAccumulativeDelay) {
|
||||
|
||||
for (int i = 0; i < eventInfoList.Count; i++) {
|
||||
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
float currentDelay = currentEventInfo.delayToActivate;
|
||||
|
||||
if (useSpeedMultiplier) {
|
||||
currentDelay /= speedMultiplier;
|
||||
}
|
||||
|
||||
WaitForSeconds delay = new WaitForSeconds (currentDelay);
|
||||
|
||||
yield return delay;
|
||||
|
||||
currentEventInfo.eventToUse.Invoke ();
|
||||
|
||||
if (mainRemoteEventSystemLocated) {
|
||||
if (currentEventInfo.useRemoteEvent) {
|
||||
mainRemoteEventSystem.callRemoteEvent (currentEventInfo.remoteEventName);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int numberOfEvents = eventInfoList.Count;
|
||||
|
||||
int numberOfEventsTriggered = 0;
|
||||
|
||||
float timer = Time.time;
|
||||
|
||||
bool allEventsTriggered = false;
|
||||
|
||||
while (!allEventsTriggered) {
|
||||
for (int i = 0; i < eventInfoList.Count; i++) {
|
||||
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (!currentEventInfo.eventTriggered) {
|
||||
float currentDelay = currentEventInfo.delayToActivate;
|
||||
|
||||
if (useSpeedMultiplier) {
|
||||
currentDelay /= speedMultiplier;
|
||||
}
|
||||
|
||||
if (Time.time > timer + currentDelay) {
|
||||
currentEventInfo.eventToUse.Invoke ();
|
||||
|
||||
if (mainRemoteEventSystemLocated) {
|
||||
if (currentEventInfo.useRemoteEvent) {
|
||||
mainRemoteEventSystem.callRemoteEvent (currentEventInfo.remoteEventName);
|
||||
}
|
||||
}
|
||||
|
||||
currentEventInfo.eventTriggered = true;
|
||||
|
||||
numberOfEventsTriggered++;
|
||||
|
||||
if (numberOfEvents == numberOfEventsTriggered) {
|
||||
allEventsTriggered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
eventInProcess = false;
|
||||
}
|
||||
|
||||
public void addNewEvent ()
|
||||
{
|
||||
eventInfo newEventInfo = new eventInfo ();
|
||||
|
||||
eventInfoList.Add (newEventInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setEventInfoEnabledState (bool state)
|
||||
{
|
||||
eventInfoEnabled = state;
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Event Info System " + gameObject.name, gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventInfo
|
||||
{
|
||||
public float delayToActivate;
|
||||
|
||||
public UnityEvent eventToUse;
|
||||
|
||||
public bool useRemoteEvent;
|
||||
|
||||
public string remoteEventName;
|
||||
|
||||
public bool eventTriggered;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e2cda57c11c67e4e9326b07c20c6521
|
||||
timeCreated: 1587772245
|
||||
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/Event System/eventInfoSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class eventObjectFoundOnCaptureSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool eventEnabled = true;
|
||||
|
||||
public bool callEventMultipleTimes;
|
||||
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public bool eventTriggered;
|
||||
public bool eventTriggeredWithGameObject;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventToCallOnCapture;
|
||||
|
||||
public bool useEventToSendObject;
|
||||
|
||||
public eventParameters.eventToCallWithGameObject eventToSendObject;
|
||||
|
||||
public void callEventOnCapture ()
|
||||
{
|
||||
if (eventEnabled && !eventTriggered) {
|
||||
eventToCallOnCapture.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Event Called on Capture");
|
||||
}
|
||||
|
||||
if (!callEventMultipleTimes) {
|
||||
eventTriggered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void callEventOnCaptureWithGameObject (GameObject newObject)
|
||||
{
|
||||
if (eventEnabled) {
|
||||
if (useEventToSendObject) {
|
||||
if (newObject == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!eventTriggeredWithGameObject) {
|
||||
if (showDebugPrint) {
|
||||
print ("Event Called on Capture With GameObject");
|
||||
}
|
||||
|
||||
eventToSendObject.Invoke (newObject);
|
||||
|
||||
if (!callEventMultipleTimes) {
|
||||
eventTriggeredWithGameObject = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setEventEnabledState (bool state)
|
||||
{
|
||||
eventEnabled = state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcd6adc13942fdd4b9927765ef853af6
|
||||
timeCreated: 1541109541
|
||||
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/Event System/eventObjectFoundOnCaptureSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class eventParameters
|
||||
{
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithAmount : UnityEvent<float>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithBool : UnityEvent<bool>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithVector3 : UnityEvent<Vector3>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithGameObject : UnityEvent<GameObject>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithTransform: UnityEvent<Transform>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithString: UnityEvent<string>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithInteger : UnityEvent<int>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithTransformList : UnityEvent<List<Transform>>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithIntAndFloat : UnityEvent<int, float>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventToCallWithCollision: UnityEvent<Collision>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16d0ab9ce848fef4c821daa7901e3329
|
||||
timeCreated: 1530324277
|
||||
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/Event System/eventParameters.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,594 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class eventTriggerSystem : MonoBehaviour
|
||||
{
|
||||
public List<eventInfo> eventList = new List<eventInfo> ();
|
||||
public List<eventInfo> enterEventList = new List<eventInfo> ();
|
||||
public List<eventInfo> exitEventList = new List<eventInfo> ();
|
||||
public bool useSameFunctionInList;
|
||||
public List<string> sameFunctionList = new List<string> ();
|
||||
public bool useSameObjectToCall;
|
||||
public bool callThisObject;
|
||||
public GameObject sameObjectToCall;
|
||||
public bool triggeredByButton;
|
||||
public bool useObjectToTrigger;
|
||||
public GameObject objectNeededToTrigger;
|
||||
|
||||
public bool useTagToTrigger;
|
||||
public string tagNeededToTrigger;
|
||||
public bool useTagList;
|
||||
public List<string> tagList = new List<string> ();
|
||||
|
||||
public bool loopEventAtTheEndEnabled;
|
||||
|
||||
public bool justCallOnTrigger;
|
||||
public bool callFunctionEveryTimeTriggered;
|
||||
public bool eventTriggered;
|
||||
|
||||
public bool dontUseDelay;
|
||||
public bool useSameDelay;
|
||||
public float generalDelay;
|
||||
|
||||
public bool useRandomDelay;
|
||||
public Vector2 randomDelayRange;
|
||||
|
||||
public triggerType triggerEventType;
|
||||
public bool useLayerMask;
|
||||
public LayerMask layerMask;
|
||||
public bool coroutineActive;
|
||||
public bool setParentToNull;
|
||||
public GameObject objectDetected;
|
||||
|
||||
public bool triggerEventAtStart;
|
||||
|
||||
public enum triggerType
|
||||
{
|
||||
enter,
|
||||
exit,
|
||||
both
|
||||
}
|
||||
|
||||
public bool isEnter;
|
||||
public bool isExit;
|
||||
|
||||
Coroutine eventCoroutine;
|
||||
|
||||
GameObject currentObjectToCall;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (triggerEventAtStart) {
|
||||
activateEvent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void activateEventIfObjectActiveSelf ()
|
||||
{
|
||||
if (gameObject.activeInHierarchy) {
|
||||
activateEvent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void activateEvent ()
|
||||
{
|
||||
if (!eventTriggered || callFunctionEveryTimeTriggered) {
|
||||
eventTriggered = true;
|
||||
|
||||
if (setParentToNull) {
|
||||
transform.SetParent (null);
|
||||
}
|
||||
|
||||
if (dontUseDelay) {
|
||||
activateEventAtOnce ();
|
||||
} else {
|
||||
stopEventCoroutine ();
|
||||
|
||||
if (gameObject.activeInHierarchy) {
|
||||
eventCoroutine = StartCoroutine (activateEventInTime ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopEventCoroutineIfActive ()
|
||||
{
|
||||
if (coroutineActive) {
|
||||
stopEventCoroutine ();
|
||||
|
||||
coroutineActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopEventCoroutine ()
|
||||
{
|
||||
if (eventCoroutine != null) {
|
||||
StopCoroutine (eventCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopAllEventsAndDisableTriggerSystem ()
|
||||
{
|
||||
stopEventCoroutine ();
|
||||
|
||||
eventTriggered = true;
|
||||
|
||||
callFunctionEveryTimeTriggered = false;
|
||||
}
|
||||
|
||||
IEnumerator activateEventInTime ()
|
||||
{
|
||||
coroutineActive = true;
|
||||
|
||||
List<eventInfo> currentEventList = eventList;
|
||||
|
||||
if (triggerEventType == triggerType.both) {
|
||||
if (isEnter) {
|
||||
currentEventList = enterEventList;
|
||||
}
|
||||
|
||||
if (isExit) {
|
||||
currentEventList = exitEventList;
|
||||
}
|
||||
} else if (triggerEventType == triggerType.exit) {
|
||||
if (isExit) {
|
||||
currentEventList = exitEventList;
|
||||
}
|
||||
}
|
||||
|
||||
int currentEventListCount = currentEventList.Count;
|
||||
|
||||
for (int i = 0; i < currentEventListCount; i++) {
|
||||
if (useSameDelay) {
|
||||
float currentDelay = generalDelay;
|
||||
|
||||
if (useRandomDelay) {
|
||||
currentDelay = Random.Range (randomDelayRange.x, randomDelayRange.y);
|
||||
}
|
||||
|
||||
WaitForSeconds delay = new WaitForSeconds (currentDelay);
|
||||
|
||||
yield return delay;
|
||||
} else {
|
||||
float currentDelay = currentEventList [i].secondsDelay;
|
||||
|
||||
if (currentEventList [i].useRandomDelay) {
|
||||
currentDelay = Random.Range (currentEventList [i].randomDelayRange.x, currentEventList [i].randomDelayRange.y);
|
||||
}
|
||||
|
||||
WaitForSeconds delay = new WaitForSeconds (currentDelay);
|
||||
|
||||
yield return delay;
|
||||
}
|
||||
|
||||
callElementFromList (currentEventList [i]);
|
||||
}
|
||||
|
||||
coroutineActive = false;
|
||||
|
||||
if (loopEventAtTheEndEnabled) {
|
||||
activateEvent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void activateEventAtOnce ()
|
||||
{
|
||||
List<eventInfo> currentEventList = eventList;
|
||||
|
||||
if (triggerEventType == triggerType.both) {
|
||||
if (isEnter) {
|
||||
currentEventList = enterEventList;
|
||||
}
|
||||
|
||||
if (isExit) {
|
||||
currentEventList = exitEventList;
|
||||
}
|
||||
} else if (triggerEventType == triggerType.exit) {
|
||||
if (isExit) {
|
||||
currentEventList = exitEventList;
|
||||
}
|
||||
}
|
||||
|
||||
int currentEventListCount = currentEventList.Count;
|
||||
|
||||
for (int i = 0; i < currentEventListCount; i++) {
|
||||
callElementFromList (currentEventList [i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void callElementFromList (eventInfo currentEventInfo)
|
||||
{
|
||||
if (useSameFunctionInList) {
|
||||
int sameFunctionListCount = sameFunctionList.Count;
|
||||
|
||||
for (int j = 0; j < sameFunctionListCount; j++) {
|
||||
currentObjectToCall = getObjectToCall (currentEventInfo.objectToCall);
|
||||
|
||||
if (currentObjectToCall != null) {
|
||||
if (currentEventInfo.sendGameObject) {
|
||||
currentObjectToCall.SendMessage (sameFunctionList [j], currentEventInfo.objectToSend, SendMessageOptions.DontRequireReceiver);
|
||||
} else {
|
||||
currentObjectToCall.SendMessage (sameFunctionList [j], SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
} else {
|
||||
print ("WARNING: no object to call has been configure on the event trigger system " + gameObject.name + ", check it is correctly assigned");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentEventInfo.useEventFunction) {
|
||||
if (currentEventInfo.sendObjectDetected) {
|
||||
if (objectDetected != null) {
|
||||
|
||||
if (currentEventInfo.sendObjectDetectedByEvent) {
|
||||
currentEventInfo.eventToSendObjectDetected.Invoke (objectDetected);
|
||||
} else {
|
||||
currentObjectToCall = getObjectToCall (currentEventInfo.objectToCall);
|
||||
|
||||
// print (objectDetected.name + " " + currentObjectToCall.name);
|
||||
if (currentObjectToCall != null) {
|
||||
currentObjectToCall.SendMessage (currentEventInfo.sendObjectDetectedFunction, objectDetected, SendMessageOptions.DontRequireReceiver);
|
||||
} else {
|
||||
print ("WARNING: no object to call has been configure on the event trigger system " + gameObject.name + ", check it is correctly assigned");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentEventInfo.useRemoteEvent) {
|
||||
checkRemoteEventsOnObjectDetected (currentEventInfo, objectDetected);
|
||||
}
|
||||
|
||||
currentEventInfo.eventFunction.Invoke ();
|
||||
|
||||
} else {
|
||||
if (currentEventInfo.sendObjectDetected) {
|
||||
if (objectDetected != null) {
|
||||
|
||||
if (currentEventInfo.sendObjectDetectedByEvent) {
|
||||
currentEventInfo.eventToSendObjectDetected.Invoke (objectDetected);
|
||||
} else {
|
||||
currentObjectToCall = getObjectToCall (currentEventInfo.objectToCall);
|
||||
|
||||
if (currentObjectToCall != null) {
|
||||
|
||||
currentObjectToCall.SendMessage (currentEventInfo.sendObjectDetectedFunction, objectDetected, SendMessageOptions.DontRequireReceiver);
|
||||
|
||||
} else {
|
||||
print ("WARNING: no object to call has been configure on the event trigger system " + gameObject.name + ", check it is correctly assigned");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentEventInfo.useRemoteEvent) {
|
||||
checkRemoteEventsOnObjectDetected (currentEventInfo, objectDetected);
|
||||
}
|
||||
|
||||
if (currentEventInfo.useBroadcastMessage) {
|
||||
int broadcastMessageStringListCount = currentEventInfo.broadcastMessageStringList.Count;
|
||||
|
||||
for (int j = 0; j < broadcastMessageStringListCount; j++) {
|
||||
// print (currentEventInfo.broadcastMessageStringList [j]);
|
||||
|
||||
currentObjectToCall = getObjectToCall (currentEventInfo.objectToCall);
|
||||
|
||||
if (currentObjectToCall != null) {
|
||||
currentObjectToCall.BroadcastMessage (currentEventInfo.broadcastMessageStringList [j], SendMessageOptions.DontRequireReceiver);
|
||||
} else {
|
||||
print ("WARNING: no object to call has been configure on the event trigger system " + gameObject.name + ", check it is correctly assigned");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int functionNameListCount = currentEventInfo.functionNameList.Count;
|
||||
|
||||
for (int j = 0; j < functionNameListCount; j++) {
|
||||
currentObjectToCall = getObjectToCall (currentEventInfo.objectToCall);
|
||||
|
||||
if (currentObjectToCall != null) {
|
||||
if (currentEventInfo.sendGameObject) {
|
||||
currentObjectToCall.SendMessage (currentEventInfo.functionNameList [j], currentEventInfo.objectToSend, SendMessageOptions.DontRequireReceiver);
|
||||
} else {
|
||||
currentObjectToCall.SendMessage (currentEventInfo.functionNameList [j], SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
} else {
|
||||
print ("WARNING: no object to call has been configure on the event trigger system " + gameObject.name + ", check it is correctly assigned");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkRemoteEventsOnObjectDetected (eventInfo currentEventInfo, GameObject newObjectDetected)
|
||||
{
|
||||
if (newObjectDetected != null) {
|
||||
remoteEventSystem currentRemoteEventSystem = newObjectDetected.GetComponent<remoteEventSystem> ();
|
||||
|
||||
if (currentRemoteEventSystem == null) {
|
||||
playerComponentsManager currentPlayerComponetsManager = newObjectDetected.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponetsManager != null) {
|
||||
currentRemoteEventSystem = currentPlayerComponetsManager.getRemoteEventSystem ();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRemoteEventSystem != null) {
|
||||
int remoteEventNameListCount = currentEventInfo.remoteEventNameList.Count;
|
||||
|
||||
for (int i = 0; i < remoteEventNameListCount; i++) {
|
||||
currentRemoteEventSystem.callRemoteEvent (currentEventInfo.remoteEventNameList [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject getObjectToCall (GameObject defaultObjectToCall)
|
||||
{
|
||||
GameObject objectToCall = defaultObjectToCall;
|
||||
|
||||
if (useSameObjectToCall) {
|
||||
if (callThisObject) {
|
||||
objectToCall = gameObject;
|
||||
} else {
|
||||
objectToCall = sameObjectToCall;
|
||||
}
|
||||
}
|
||||
|
||||
return objectToCall;
|
||||
}
|
||||
|
||||
public void checkTriggerEventEnterType (GameObject objectToCheck)
|
||||
{
|
||||
checkTriggerEventType (objectToCheck, triggerType.enter);
|
||||
}
|
||||
|
||||
public void checkTriggerEventExitType (GameObject objectToCheck)
|
||||
{
|
||||
checkTriggerEventType (objectToCheck, triggerType.exit);
|
||||
}
|
||||
|
||||
public void checkTriggerEventType (GameObject objectToCheck, triggerType trigger)
|
||||
{
|
||||
if ((!eventTriggered || callFunctionEveryTimeTriggered) && !triggeredByButton) {
|
||||
if (trigger == triggerEventType || triggerEventType == triggerType.both) {
|
||||
|
||||
if (triggerEventType == triggerType.both) {
|
||||
if (trigger == triggerType.enter) {
|
||||
isEnter = true;
|
||||
isExit = false;
|
||||
} else {
|
||||
isEnter = false;
|
||||
isExit = true;
|
||||
}
|
||||
} else if (triggerEventType == triggerType.exit) {
|
||||
if (isExit) {
|
||||
isEnter = false;
|
||||
isExit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (useObjectToTrigger) {
|
||||
if (objectToCheck == objectNeededToTrigger) {
|
||||
objectDetected = objectToCheck;
|
||||
|
||||
activateEvent ();
|
||||
}
|
||||
}
|
||||
|
||||
if (checkTag (objectToCheck)) {
|
||||
objectDetected = objectToCheck;
|
||||
|
||||
activateEvent ();
|
||||
}
|
||||
|
||||
if (justCallOnTrigger) {
|
||||
objectDetected = objectToCheck;
|
||||
|
||||
activateEvent ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject getLastObjectDetected ()
|
||||
{
|
||||
return objectDetected;
|
||||
}
|
||||
|
||||
public bool checkTag (GameObject objectToCheck)
|
||||
{
|
||||
if (useTagToTrigger) {
|
||||
if (useTagList) {
|
||||
if (tagList.Contains (objectToCheck.tag)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (objectToCheck.CompareTag (tagNeededToTrigger)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void checkTriggerEventTypeByFunction ()
|
||||
{
|
||||
if ((!eventTriggered || callFunctionEveryTimeTriggered) && !triggeredByButton) {
|
||||
activateEvent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void resetEventTriggered ()
|
||||
{
|
||||
eventTriggered = false;
|
||||
}
|
||||
|
||||
public void setEventAsTriggered ()
|
||||
{
|
||||
eventTriggered = true;
|
||||
}
|
||||
|
||||
public void setObjectOnTriggerEnterExternally (GameObject newObject)
|
||||
{
|
||||
Collider newCollider = newObject.GetComponent<Collider> ();
|
||||
|
||||
if (newCollider != null) {
|
||||
OnTriggerEnter (newCollider);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLoopEventAtTheEndEnabledState (bool state)
|
||||
{
|
||||
loopEventAtTheEndEnabled = state;
|
||||
}
|
||||
|
||||
void OnTriggerEnter (Collider col)
|
||||
{
|
||||
//if it uses layermask and the object touched have a different layer, ignore it
|
||||
if (useLayerMask) {
|
||||
if ((1 << col.gameObject.layer & layerMask.value) != 1 << col.gameObject.layer) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
checkTriggerEventType (col.gameObject, triggerType.enter);
|
||||
}
|
||||
|
||||
void OnTriggerExit (Collider col)
|
||||
{
|
||||
//if it uses layermask and the object touched have a different layer, ignore it
|
||||
if (useLayerMask) {
|
||||
if ((1 << col.gameObject.layer & layerMask.value) != 1 << col.gameObject.layer) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
checkTriggerEventType (col.gameObject, triggerType.exit);
|
||||
}
|
||||
|
||||
//EDITOR FUNCTIONS
|
||||
public void addNewEvent ()
|
||||
{
|
||||
eventInfo newEvent = new eventInfo ();
|
||||
|
||||
eventList.Add (newEvent);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void InsertEventAtIndex (int index)
|
||||
{
|
||||
eventInfo newEvent = new eventInfo ();
|
||||
|
||||
eventList.Insert (index + 1, newEvent);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setSimpleFunctionByTag (string functionName, GameObject objectTocall, string tag)
|
||||
{
|
||||
addNewEvent ();
|
||||
|
||||
eventInfo newEvent = eventList [eventList.Count - 1];
|
||||
|
||||
newEvent.objectToCall = objectTocall;
|
||||
|
||||
newEvent.functionNameList.Add (functionName);
|
||||
|
||||
useTagToTrigger = true;
|
||||
|
||||
tagNeededToTrigger = tag;
|
||||
}
|
||||
|
||||
public void setUseLayerMaskState (bool state)
|
||||
{
|
||||
useLayerMask = state;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
public void setLayerMaskValue (LayerMask newLayer)
|
||||
{
|
||||
layerMask = newLayer;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setUseTagToTriggerState (bool state)
|
||||
{
|
||||
useTagToTrigger = state;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setUseTagListState (bool state)
|
||||
{
|
||||
useTagList = state;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setTagList (List<string> newList)
|
||||
{
|
||||
tagList = newList;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addElementToTagList (string newElement)
|
||||
{
|
||||
if (!tagList.Contains (newElement)) {
|
||||
tagList.Add (newElement);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeElementToTagList (string newElement)
|
||||
{
|
||||
if (tagList.Contains (newElement)) {
|
||||
tagList.Remove (newElement);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Event Trigger System " + gameObject.name, gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventInfo
|
||||
{
|
||||
public string name;
|
||||
public GameObject objectToCall;
|
||||
public List<string> functionNameList = new List<string> ();
|
||||
|
||||
public float secondsDelay;
|
||||
public bool useRandomDelay;
|
||||
public Vector2 randomDelayRange;
|
||||
|
||||
public bool sendGameObject;
|
||||
public GameObject objectToSend;
|
||||
public bool sendObjectDetected;
|
||||
public string sendObjectDetectedFunction;
|
||||
|
||||
public bool sendObjectDetectedByEvent;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendObjectDetected;
|
||||
|
||||
public bool useEventFunction;
|
||||
|
||||
public UnityEvent eventFunction = new UnityEvent ();
|
||||
|
||||
public bool useBroadcastMessage;
|
||||
public List<string> broadcastMessageStringList = new List<string> ();
|
||||
|
||||
public bool useRemoteEvent;
|
||||
public List<string> remoteEventNameList = new List<string> ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45fc770a0dc8169449e7164daf5e37bf
|
||||
timeCreated: 1485628194
|
||||
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/Event System/eventTriggerSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,197 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class randomEventSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool randomEventsEnabled = true;
|
||||
|
||||
public bool useSameIndexValue;
|
||||
public int sameIndexValueToUse;
|
||||
|
||||
[Space]
|
||||
|
||||
public int currentEventIndexInOrder;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public bool ignoreRandomEventActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Random Events Settings")]
|
||||
[Space]
|
||||
|
||||
public List<randomEventInfo> randomEventInfoList = new List<randomEventInfo> ();
|
||||
|
||||
|
||||
bool ignoreProbabilityCheckActive;
|
||||
|
||||
randomEventInfo currentEventInfo;
|
||||
|
||||
|
||||
public void callEventInOrderByIndex (int newValue)
|
||||
{
|
||||
currentEventIndexInOrder = newValue;
|
||||
|
||||
callEventInOrder ();
|
||||
}
|
||||
|
||||
public void callEventInOrder ()
|
||||
{
|
||||
activateEvent (currentEventIndexInOrder);
|
||||
|
||||
currentEventIndexInOrder++;
|
||||
|
||||
if (currentEventIndexInOrder >= randomEventInfoList.Count) {
|
||||
currentEventIndexInOrder = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setEventIndexInOrderValue (int newValue)
|
||||
{
|
||||
currentEventIndexInOrder = newValue;
|
||||
|
||||
if (currentEventIndexInOrder >= randomEventInfoList.Count) {
|
||||
currentEventIndexInOrder = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetEventIndexInOrder ()
|
||||
{
|
||||
currentEventIndexInOrder = 0;
|
||||
}
|
||||
|
||||
public void callRandomEventIgnoringProbabilityByName (string eventName)
|
||||
{
|
||||
ignoreProbabilityCheckActive = true;
|
||||
|
||||
callRandomEventByName (eventName);
|
||||
|
||||
ignoreProbabilityCheckActive = false;
|
||||
}
|
||||
|
||||
public void callRandomEventByName (string eventName)
|
||||
{
|
||||
if (ignoreRandomEventActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!randomEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
int eventIndex = randomEventInfoList.FindIndex (s => s.Name == eventName);
|
||||
|
||||
if (eventIndex > -1) {
|
||||
activateEvent (eventIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public void callRandomEvent ()
|
||||
{
|
||||
if (ignoreRandomEventActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!randomEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
int randomIndex = Random.Range (0, randomEventInfoList.Count);
|
||||
|
||||
if (useSameIndexValue) {
|
||||
randomIndex = sameIndexValueToUse;
|
||||
}
|
||||
|
||||
activateEvent (randomIndex);
|
||||
}
|
||||
|
||||
void activateEvent (int currentIndex)
|
||||
{
|
||||
if (currentIndex <= randomEventInfoList.Count - 1) {
|
||||
currentEventInfo = randomEventInfoList [currentIndex];
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("checking event " + currentEventInfo.Name + " " + currentIndex);
|
||||
}
|
||||
|
||||
if (currentEventInfo.eventEnabled) {
|
||||
if (showDebugPrint) {
|
||||
print (currentEventInfo.Name);
|
||||
}
|
||||
|
||||
bool activateEventResult = true;
|
||||
|
||||
if (!ignoreProbabilityCheckActive) {
|
||||
if (currentEventInfo.useProbabilityToActivateEvent) {
|
||||
float currentProbability = Random.Range (0, 100);
|
||||
|
||||
if (currentProbability > currentEventInfo.probabilityToActivateEvent) {
|
||||
activateEventResult = false;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("probability result " + currentProbability + " " + activateEventResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (activateEventResult) {
|
||||
currentEventInfo.eventToActive.Invoke ();
|
||||
|
||||
if (currentEventInfo.disableEventAfterActivation) {
|
||||
currentEventInfo.eventEnabled = false;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (currentEventInfo.Name + " event activated properly");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRandomEventsEnabledState (bool state)
|
||||
{
|
||||
randomEventsEnabled = state;
|
||||
}
|
||||
|
||||
public void setIgnoreRandomEventActiveState (bool state)
|
||||
{
|
||||
ignoreRandomEventActive = state;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class randomEventInfo
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public string Name;
|
||||
|
||||
public bool eventEnabled = true;
|
||||
|
||||
public bool disableEventAfterActivation;
|
||||
|
||||
[Space]
|
||||
[Header ("Probability Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useProbabilityToActivateEvent;
|
||||
|
||||
[Range (0, 100)] public float probabilityToActivateEvent = 0;
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventToActive;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7accb57875057b449a649a4352f60514
|
||||
timeCreated: 1671545303
|
||||
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/Event System/randomEventSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,82 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class remoteAnimatorEventTriggerSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool remoteEventsEnabled = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public List<remoteEventSystem.eventInfo> eventInfoList = new List<remoteEventSystem.eventInfo> ();
|
||||
|
||||
remoteEventSystem.eventInfo currentEventInfo;
|
||||
|
||||
|
||||
public void callRemoteEvent (string eventName)
|
||||
{
|
||||
if (!remoteEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
int eventInfoListCount = eventInfoList.Count;
|
||||
|
||||
for (int i = 0; i < eventInfoListCount; i++) {
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.eventEnabled) {
|
||||
if (currentEventInfo.Name.Equals (eventName)) {
|
||||
if (currentEventInfo.useRegularEvent) {
|
||||
currentEventInfo.eventToActive.Invoke ();
|
||||
}
|
||||
|
||||
if (currentEventInfo.disableEventAfterActivation) {
|
||||
currentEventInfo.eventEnabled = false;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (eventName);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnabledEventState (string eventName)
|
||||
{
|
||||
setEnabledOrDisabledEventState (true, eventName);
|
||||
}
|
||||
|
||||
public void setDisabledEventState (string eventName)
|
||||
{
|
||||
setEnabledOrDisabledEventState (false, eventName);
|
||||
}
|
||||
|
||||
public void setEnabledOrDisabledEventState (bool state, string eventName)
|
||||
{
|
||||
int eventInfoListCount = eventInfoList.Count;
|
||||
|
||||
for (int i = 0; i < eventInfoListCount; i++) {
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.Name.Equals (eventName)) {
|
||||
currentEventInfo.eventEnabled = state;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9107eda0dfa6324a83048e005943f9f
|
||||
timeCreated: 1642798845
|
||||
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/Event System/remoteAnimatorEventTriggerSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,187 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class remoteEventActivator : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public string remoteEventToCall;
|
||||
|
||||
public bool searchForRemoteEventSockedEnabled;
|
||||
|
||||
[Space]
|
||||
[Header ("Remote Event Info Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useAmount;
|
||||
public float amountValue;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useBool;
|
||||
public bool boolValue;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useGameObject;
|
||||
public GameObject gameObjectToUse;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useTransform;
|
||||
public Transform transformToUse;
|
||||
|
||||
[Space]
|
||||
[Header ("Remote Event List Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useRemoveEventInfoList;
|
||||
|
||||
public bool useSameRemoteEvenToCall = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<removeEventInfo> removeEventInfoList = new List<removeEventInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Set Object Manually Settings")]
|
||||
[Space]
|
||||
|
||||
public bool assignObjectManually;
|
||||
public GameObject objectToAssign;
|
||||
|
||||
public bool searchPlayerOnSceneIfNotAssigned;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
|
||||
GameObject currentObjectToCall;
|
||||
|
||||
removeEventInfo currentEventInfo;
|
||||
|
||||
|
||||
public void callRemoteEvent (GameObject objectToCall)
|
||||
{
|
||||
currentObjectToCall = objectToCall;
|
||||
|
||||
callEvent ();
|
||||
}
|
||||
|
||||
public void setObjectToCall (GameObject objectToCall)
|
||||
{
|
||||
currentObjectToCall = objectToCall;
|
||||
}
|
||||
|
||||
public void callEvent ()
|
||||
{
|
||||
if (assignObjectManually) {
|
||||
if (objectToAssign == null) {
|
||||
if (searchPlayerOnSceneIfNotAssigned) {
|
||||
findPlayerOnScene ();
|
||||
}
|
||||
}
|
||||
|
||||
if (objectToAssign == null) {
|
||||
print ("WARNING: no object has been assigned manually on remote event activator");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
currentObjectToCall = objectToAssign;
|
||||
}
|
||||
|
||||
//remoteEventSystem currentRemoteEventSystem = currentObjectToCall.GetComponent<remoteEventSystem> ();
|
||||
|
||||
remoteEventSystem currentRemoteEventSystem =
|
||||
GKC_Utils.getRemoteEventSystemFromObject (currentObjectToCall, searchForRemoteEventSockedEnabled);
|
||||
|
||||
if (currentRemoteEventSystem != null) {
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("object detected on remote event activator " + currentObjectToCall.name);
|
||||
}
|
||||
|
||||
if (useRemoveEventInfoList) {
|
||||
int removeEventInfoListCount = removeEventInfoList.Count;
|
||||
|
||||
string currentRemoteEventToCall = remoteEventToCall;
|
||||
|
||||
for (int i = 0; i < removeEventInfoListCount; i++) {
|
||||
currentEventInfo = removeEventInfoList [i];
|
||||
|
||||
if (!useSameRemoteEvenToCall) {
|
||||
currentRemoteEventToCall = currentEventInfo.remoteEventToCall;
|
||||
}
|
||||
|
||||
if (currentEventInfo.useAmount) {
|
||||
currentRemoteEventSystem.callRemoteEventWithAmount (currentRemoteEventToCall, currentEventInfo.amountValue);
|
||||
} else if (currentEventInfo.useBool) {
|
||||
currentRemoteEventSystem.callRemoteEventWithBool (currentRemoteEventToCall, currentEventInfo.boolValue);
|
||||
} else if (currentEventInfo.useGameObject) {
|
||||
currentRemoteEventSystem.callRemoteEventWithGameObject (currentRemoteEventToCall, currentEventInfo.gameObjectToUse);
|
||||
} else if (currentEventInfo.useTransform) {
|
||||
currentRemoteEventSystem.callRemoteEventWithTransform (currentRemoteEventToCall, currentEventInfo.transformToUse);
|
||||
} else {
|
||||
currentRemoteEventSystem.callRemoteEvent (currentRemoteEventToCall);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (useAmount) {
|
||||
currentRemoteEventSystem.callRemoteEventWithAmount (remoteEventToCall, amountValue);
|
||||
} else if (useBool) {
|
||||
currentRemoteEventSystem.callRemoteEventWithBool (remoteEventToCall, boolValue);
|
||||
} else if (useGameObject) {
|
||||
currentRemoteEventSystem.callRemoteEventWithGameObject (remoteEventToCall, gameObjectToUse);
|
||||
} else if (useTransform) {
|
||||
currentRemoteEventSystem.callRemoteEventWithTransform (remoteEventToCall, transformToUse);
|
||||
} else {
|
||||
currentRemoteEventSystem.callRemoteEvent (remoteEventToCall);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void findPlayerOnScene ()
|
||||
{
|
||||
if (searchPlayerOnSceneIfNotAssigned) {
|
||||
objectToAssign = GKC_Utils.findMainPlayerOnScene ();
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class removeEventInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public string remoteEventToCall;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useAmount;
|
||||
public float amountValue;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useBool;
|
||||
public bool boolValue;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useGameObject;
|
||||
public GameObject gameObjectToUse;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useTransform;
|
||||
public Transform transformToUse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f6760227c5775449b0a12c2c3ed74d0
|
||||
timeCreated: 1557458944
|
||||
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/Event System/remoteEventActivator.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,326 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class remoteEventSearcher : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool remoteEventsEnabled = true;
|
||||
|
||||
public bool searchForRemoteEventSockedEnabled;
|
||||
|
||||
public Transform mainTransformCenter;
|
||||
|
||||
[Space]
|
||||
[Header ("Remote Event Searcher Info List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<remoteEventSearcherInfo> remoteEventSearcherInfoList = new List<remoteEventSearcherInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public List<GameObject> objectsLocatedList = new List<GameObject> ();
|
||||
|
||||
|
||||
int currentRemoteEventSearcherInfoIndex;
|
||||
|
||||
remoteEventActivator.removeEventInfo currentEventInfo;
|
||||
|
||||
|
||||
public void activateRemoteEventSearcher (string remoteEventSearcherName)
|
||||
{
|
||||
if (!remoteEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentRemoteEventSearcherInfoIndex = -1;
|
||||
|
||||
for (int i = 0; i < remoteEventSearcherInfoList.Count; i++) {
|
||||
if (remoteEventSearcherInfoList [i].Name.Equals (remoteEventSearcherName)) {
|
||||
currentRemoteEventSearcherInfoIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRemoteEventSearcherInfoIndex == -1) {
|
||||
if (showDebugPrint) {
|
||||
print ("remote event name not found " + remoteEventSearcherName);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
remoteEventSearcherInfo currentRemoteEventSearcherInfo = remoteEventSearcherInfoList [currentRemoteEventSearcherInfoIndex];
|
||||
|
||||
if (!currentRemoteEventSearcherInfo.remoteEventEnabled) {
|
||||
if (showDebugPrint) {
|
||||
print ("remote event not enabled");
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (currentRemoteEventSearcherInfo.useFindObjectsOnScene) {
|
||||
bool useFindObjectsResult = false;
|
||||
|
||||
if (currentRemoteEventSearcherInfo.useFindObjectsOnEachSearch) {
|
||||
objectsLocatedList.Clear ();
|
||||
|
||||
useFindObjectsResult = true;
|
||||
} else {
|
||||
if (objectsLocatedList.Count == 0) {
|
||||
useFindObjectsResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (useFindObjectsResult) {
|
||||
List<remoteEventSystem> remoteEventSystemList = GKC_Utils.FindObjectsOfTypeAll<remoteEventSystem> ();
|
||||
|
||||
int remoteEventSystemListCount = remoteEventSystemList.Count;
|
||||
|
||||
for (int i = 0; i < remoteEventSystemListCount; i++) {
|
||||
if (!objectsLocatedList.Contains (remoteEventSystemList [i].gameObject)) {
|
||||
objectsLocatedList.Add (remoteEventSystemList [i].gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
objectsLocatedList.Clear ();
|
||||
|
||||
if (mainTransformCenter == null) {
|
||||
mainTransformCenter = transform;
|
||||
}
|
||||
|
||||
Collider [] colliders = Physics.OverlapSphere (mainTransformCenter.position, currentRemoteEventSearcherInfo.radiusToSearch, currentRemoteEventSearcherInfo.radiusLayer);
|
||||
|
||||
if (colliders.Length == 0) {
|
||||
if (showDebugPrint) {
|
||||
print ("objects not found on radius");
|
||||
}
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("objects found on radius " + colliders.Length);
|
||||
}
|
||||
}
|
||||
|
||||
int collidersLength = colliders.Length;
|
||||
|
||||
for (int i = 0; i < collidersLength; i++) {
|
||||
objectsLocatedList.Add (colliders [i].gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
int objectsLocatedListCount = objectsLocatedList.Count;
|
||||
|
||||
for (int i = 0; i < objectsLocatedListCount; i++) {
|
||||
bool canActivateEvent = true;
|
||||
|
||||
GameObject currentObjectDetected = objectsLocatedList [i];
|
||||
|
||||
if (currentObjectDetected != null) {
|
||||
|
||||
if (currentRemoteEventSearcherInfo.ignoreCharacters) {
|
||||
if (currentRemoteEventSearcherInfo.characterObjectToIgnoreList.Count > 0) {
|
||||
if (currentRemoteEventSearcherInfo.characterObjectToIgnoreList.Contains (currentObjectDetected.gameObject)) {
|
||||
canActivateEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRemoteEventSearcherInfo.tagsToIgnore.Contains (currentObjectDetected.tag)) {
|
||||
canActivateEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateEvent) {
|
||||
remoteEventSystem currentRemoteEventSystem =
|
||||
GKC_Utils.getRemoteEventSystemFromObject (currentObjectDetected, searchForRemoteEventSockedEnabled);
|
||||
|
||||
//currentObjectDetected.GetComponent<remoteEventSystem> ();
|
||||
|
||||
if (currentRemoteEventSystem != null) {
|
||||
|
||||
bool checkRemoteEventSystemResult = true;
|
||||
|
||||
if (currentRemoteEventSearcherInfo.searchRemoteEventByID) {
|
||||
if (currentRemoteEventSearcherInfo.useSearchRemoteEventByIDList) {
|
||||
if (!currentRemoteEventSearcherInfo.remoteEventIDToSearchList.Contains (currentRemoteEventSystem.getRemoteEventSystemID ())) {
|
||||
checkRemoteEventSystemResult = false;
|
||||
}
|
||||
} else {
|
||||
if (!currentRemoteEventSearcherInfo.remoteEventIDToSearch.Equals (currentRemoteEventSystem.getRemoteEventSystemID ())) {
|
||||
checkRemoteEventSystemResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRemoteEventSearcherInfo.searchRemoteEventByName) {
|
||||
if (currentRemoteEventSearcherInfo.useSearchRemoteEventByNameList) {
|
||||
if (!currentRemoteEventSearcherInfo.remoteEventNameToSearchList.Contains (currentRemoteEventSystem.getRemoteEventSystemName ())) {
|
||||
checkRemoteEventSystemResult = false;
|
||||
}
|
||||
} else {
|
||||
if (!currentRemoteEventSearcherInfo.remoteEventNameToSearch.Equals (currentRemoteEventSystem.getRemoteEventSystemName ())) {
|
||||
checkRemoteEventSystemResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkRemoteEventSystemResult) {
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("remote event system found on object " + currentObjectDetected.name);
|
||||
}
|
||||
|
||||
if (currentRemoteEventSearcherInfo.useRemoveEventInfoList) {
|
||||
int removeEventInfoListCount = currentRemoteEventSearcherInfo.mainRemoveEventInfoList.Count;
|
||||
|
||||
string currentRemoteEventToCall = currentRemoteEventSearcherInfo.remoteEventToCall;
|
||||
|
||||
for (int j = 0; j < removeEventInfoListCount; j++) {
|
||||
currentEventInfo = currentRemoteEventSearcherInfo.mainRemoveEventInfoList [j];
|
||||
|
||||
if (!currentRemoteEventSearcherInfo.useSameRemoteEventToCall) {
|
||||
currentRemoteEventToCall = currentEventInfo.remoteEventToCall;
|
||||
}
|
||||
|
||||
if (currentEventInfo.useAmount) {
|
||||
currentRemoteEventSystem.callRemoteEventWithAmount (currentRemoteEventToCall, currentEventInfo.amountValue);
|
||||
} else if (currentEventInfo.useBool) {
|
||||
currentRemoteEventSystem.callRemoteEventWithBool (currentRemoteEventToCall, currentEventInfo.boolValue);
|
||||
} else if (currentEventInfo.useGameObject) {
|
||||
currentRemoteEventSystem.callRemoteEventWithGameObject (currentRemoteEventToCall, currentEventInfo.gameObjectToUse);
|
||||
} else if (currentEventInfo.useTransform) {
|
||||
currentRemoteEventSystem.callRemoteEventWithTransform (currentRemoteEventToCall, currentEventInfo.transformToUse);
|
||||
} else {
|
||||
currentRemoteEventSystem.callRemoteEvent (currentRemoteEventToCall);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentRemoteEventSearcherInfo.useAmount) {
|
||||
currentRemoteEventSystem.callRemoteEventWithAmount (currentRemoteEventSearcherInfo.remoteEventToCall, currentRemoteEventSearcherInfo.amountValue);
|
||||
} else if (currentRemoteEventSearcherInfo.useBool) {
|
||||
currentRemoteEventSystem.callRemoteEventWithBool (currentRemoteEventSearcherInfo.remoteEventToCall, currentRemoteEventSearcherInfo.boolValue);
|
||||
} else if (currentRemoteEventSearcherInfo.useGameObject) {
|
||||
currentRemoteEventSystem.callRemoteEventWithGameObject (currentRemoteEventSearcherInfo.remoteEventToCall, currentRemoteEventSearcherInfo.gameObjectToUse);
|
||||
} else if (currentRemoteEventSearcherInfo.useTransform) {
|
||||
currentRemoteEventSystem.callRemoteEventWithTransform (currentRemoteEventSearcherInfo.remoteEventToCall, currentRemoteEventSearcherInfo.transformToUse);
|
||||
} else {
|
||||
currentRemoteEventSystem.callRemoteEvent (currentRemoteEventSearcherInfo.remoteEventToCall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("remote event system not found on object " + currentObjectDetected.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class remoteEventSearcherInfo
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public string Name;
|
||||
|
||||
public bool remoteEventEnabled = true;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public string remoteEventToCall;
|
||||
|
||||
public bool useRemoveEventInfoList;
|
||||
|
||||
public bool useSameRemoteEventToCall = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Remote Event Info Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useAmount;
|
||||
public float amountValue;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useBool;
|
||||
public bool boolValue;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useGameObject;
|
||||
public GameObject gameObjectToUse;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useTransform;
|
||||
public Transform transformToUse;
|
||||
|
||||
[Space]
|
||||
[Header ("Ignore Objects Settings")]
|
||||
[Space]
|
||||
|
||||
public bool ignoreCharacters;
|
||||
|
||||
public List<string> tagsToIgnore = new List<string> ();
|
||||
|
||||
public List<GameObject> characterObjectToIgnoreList = new List<GameObject> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Search Objects By Radius Settings")]
|
||||
[Space]
|
||||
|
||||
public float radiusToSearch;
|
||||
public LayerMask radiusLayer;
|
||||
|
||||
[Space]
|
||||
[Header ("Search Objects By Find Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useFindObjectsOnScene;
|
||||
public bool useFindObjectsOnEachSearch = true;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool searchRemoteEventByID;
|
||||
public int remoteEventIDToSearch;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useSearchRemoteEventByIDList;
|
||||
public List<int> remoteEventIDToSearchList = new List<int> ();
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool searchRemoteEventByName;
|
||||
public string remoteEventNameToSearch;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useSearchRemoteEventByNameList;
|
||||
public List<string> remoteEventNameToSearchList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Remote Event List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<remoteEventActivator.removeEventInfo> mainRemoveEventInfoList = new List<remoteEventActivator.removeEventInfo> ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bac4b509ce8afb048805a92d0c9e7f07
|
||||
timeCreated: 1653469289
|
||||
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/Event System/remoteEventSearcher.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class remoteEventSocket : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool remoteEventSocketEnabled = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public remoteEventSystem mainRemoteEventSystem;
|
||||
|
||||
|
||||
public remoteEventSystem getMainRemoteEventSystem ()
|
||||
{
|
||||
if (!remoteEventSocketEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mainRemoteEventSystem;
|
||||
}
|
||||
|
||||
public bool isRemoteEventSocketEnabled ()
|
||||
{
|
||||
return remoteEventSocketEnabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f45391d6d09839840b8a35a054c83306
|
||||
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/Event System/remoteEventSocket.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,437 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class remoteEventSystem : MonoBehaviour
|
||||
{
|
||||
public bool remoteEventsEnabled = true;
|
||||
|
||||
public bool activateRemoteEventsOnStart;
|
||||
|
||||
public List<string> remoteEventsOnStartList = new List<string> ();
|
||||
|
||||
public List<eventInfo> eventInfoList = new List<eventInfo> ();
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public string remoteEventSystemName;
|
||||
public int remoteEventSystemID;
|
||||
|
||||
|
||||
public List<string> objectSearchResultList = new List<string> ();
|
||||
|
||||
public string objectSearcherName = "";
|
||||
|
||||
public bool searchObjectsActive;
|
||||
|
||||
|
||||
eventInfo currentEventInfo;
|
||||
|
||||
int eventInfoListCount;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (activateRemoteEventsOnStart) {
|
||||
|
||||
StartCoroutine (checkRemoteEventsOnStartListCoroutine ());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator checkRemoteEventsOnStartListCoroutine ()
|
||||
{
|
||||
yield return new WaitForEndOfFrame ();
|
||||
|
||||
|
||||
checkRemoteEventsOnStartList ();
|
||||
}
|
||||
|
||||
void checkRemoteEventsOnStartList ()
|
||||
{
|
||||
int remoteEventsOnStartListCount = remoteEventsOnStartList.Count;
|
||||
|
||||
for (int i = 0; i < remoteEventsOnStartListCount; i++) {
|
||||
callRemoteEvent (remoteEventsOnStartList [i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void callRemoveEvent (string eventName)
|
||||
{
|
||||
callRemoteEvent (eventName);
|
||||
}
|
||||
|
||||
public void callRemoteEvent (string eventName)
|
||||
{
|
||||
if (!remoteEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventInfoListCount == 0) {
|
||||
eventInfoListCount = eventInfoList.Count;
|
||||
}
|
||||
|
||||
for (int i = 0; i < eventInfoListCount; i++) {
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.eventEnabled && !currentEventInfo.ignoreEventActive) {
|
||||
if (currentEventInfo.Name.Equals (eventName)) {
|
||||
if (showDebugPrint) {
|
||||
print (eventName);
|
||||
}
|
||||
|
||||
if (currentEventInfo.useRegularEvent) {
|
||||
currentEventInfo.eventToActive.Invoke ();
|
||||
}
|
||||
|
||||
if (currentEventInfo.disableEventAfterActivation) {
|
||||
currentEventInfo.eventEnabled = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void callRemoteEventWithAmount (string eventName, float amount)
|
||||
{
|
||||
if (!remoteEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventInfoListCount == 0) {
|
||||
eventInfoListCount = eventInfoList.Count;
|
||||
}
|
||||
|
||||
for (int i = 0; i < eventInfoListCount; i++) {
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.eventEnabled && !currentEventInfo.ignoreEventActive) {
|
||||
if (currentEventInfo.Name.Equals (eventName)) {
|
||||
if (currentEventInfo.useAmountOnEvent) {
|
||||
currentEventInfo.eventToActiveAmount.Invoke (amount);
|
||||
}
|
||||
|
||||
if (currentEventInfo.disableEventAfterActivation) {
|
||||
currentEventInfo.eventEnabled = false;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (eventName);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void callRemoteEventWithBool (string eventName, bool state)
|
||||
{
|
||||
if (!remoteEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventInfoListCount == 0) {
|
||||
eventInfoListCount = eventInfoList.Count;
|
||||
}
|
||||
|
||||
for (int i = 0; i < eventInfoListCount; i++) {
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.eventEnabled && !currentEventInfo.ignoreEventActive) {
|
||||
if (currentEventInfo.Name.Equals (eventName)) {
|
||||
if (currentEventInfo.useBoolOnEvent) {
|
||||
currentEventInfo.eventToActiveBool.Invoke (state);
|
||||
}
|
||||
|
||||
if (currentEventInfo.disableEventAfterActivation) {
|
||||
currentEventInfo.eventEnabled = false;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (eventName);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void callRemoteEventWithGameObject (string eventName, GameObject objectToSend)
|
||||
{
|
||||
if (!remoteEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventInfoListCount == 0) {
|
||||
eventInfoListCount = eventInfoList.Count;
|
||||
}
|
||||
|
||||
for (int i = 0; i < eventInfoListCount; i++) {
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.eventEnabled && !currentEventInfo.ignoreEventActive) {
|
||||
if (currentEventInfo.Name.Equals (eventName)) {
|
||||
if (currentEventInfo.useGameObjectOnEvent) {
|
||||
currentEventInfo.eventToActiveGameObject.Invoke (objectToSend);
|
||||
}
|
||||
|
||||
if (currentEventInfo.disableEventAfterActivation) {
|
||||
currentEventInfo.eventEnabled = false;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (eventName);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void callRemoteEventWithTransform (string eventName, Transform transformToSend)
|
||||
{
|
||||
if (!remoteEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventInfoListCount == 0) {
|
||||
eventInfoListCount = eventInfoList.Count;
|
||||
}
|
||||
|
||||
for (int i = 0; i < eventInfoListCount; i++) {
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.eventEnabled && !currentEventInfo.ignoreEventActive) {
|
||||
if (currentEventInfo.Name.Equals (eventName)) {
|
||||
if (currentEventInfo.useTransformOnEvent) {
|
||||
currentEventInfo.eventToActiveTransform.Invoke (transformToSend);
|
||||
}
|
||||
|
||||
if (currentEventInfo.disableEventAfterActivation) {
|
||||
currentEventInfo.eventEnabled = false;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (eventName);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void callRemoteEventWithString (string eventName, string strintParameter)
|
||||
{
|
||||
if (!remoteEventsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventInfoListCount == 0) {
|
||||
eventInfoListCount = eventInfoList.Count;
|
||||
}
|
||||
|
||||
for (int i = 0; i < eventInfoListCount; i++) {
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.eventEnabled && !currentEventInfo.ignoreEventActive) {
|
||||
if (currentEventInfo.Name.Equals (eventName)) {
|
||||
if (currentEventInfo.useStringOnEvent) {
|
||||
currentEventInfo.eventToActivateString.Invoke (strintParameter);
|
||||
}
|
||||
|
||||
if (currentEventInfo.disableEventAfterActivation) {
|
||||
currentEventInfo.eventEnabled = false;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (eventName);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setEnabledEventState (string eventName)
|
||||
{
|
||||
setEnabledOrDisabledEventState (true, eventName);
|
||||
}
|
||||
|
||||
public void setDisabledEventState (string eventName)
|
||||
{
|
||||
setEnabledOrDisabledEventState (false, eventName);
|
||||
}
|
||||
|
||||
public void setEnabledOrDisabledEventState (bool state, string eventName)
|
||||
{
|
||||
if (eventInfoListCount == 0) {
|
||||
eventInfoListCount = eventInfoList.Count;
|
||||
}
|
||||
|
||||
for (int i = 0; i < eventInfoListCount; i++) {
|
||||
currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.Name.Equals (eventName)) {
|
||||
currentEventInfo.eventEnabled = state;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setIgnoreEventActiveState (string eventName)
|
||||
{
|
||||
setIgnoreEventState (true, eventName);
|
||||
}
|
||||
|
||||
public void setIgnoreEventDeactiveState (string eventName)
|
||||
{
|
||||
setIgnoreEventState (false, eventName);
|
||||
}
|
||||
|
||||
public void setIgnoreEventState (bool state, string eventName)
|
||||
{
|
||||
int currentIndex = eventInfoList.FindIndex (s => s.Name.Equals (eventName));
|
||||
|
||||
if (currentIndex > -1) {
|
||||
eventInfoList [currentIndex].ignoreEventActive = state;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRemoteEventsEnabledState (bool state)
|
||||
{
|
||||
remoteEventsEnabled = state;
|
||||
}
|
||||
|
||||
public string getRemoteEventSystemName ()
|
||||
{
|
||||
return remoteEventSystemName;
|
||||
}
|
||||
|
||||
public int getRemoteEventSystemID ()
|
||||
{
|
||||
return remoteEventSystemID;
|
||||
}
|
||||
|
||||
//EDITOR FUNCTIONS
|
||||
public void clearObjectsSearcResultList ()
|
||||
{
|
||||
objectSearchResultList.Clear ();
|
||||
|
||||
objectSearcherName = "";
|
||||
|
||||
searchObjectsActive = false;
|
||||
|
||||
int objectToSelectInfoListCount = eventInfoList.Count;
|
||||
|
||||
for (int i = 0; i < objectToSelectInfoListCount; i++) {
|
||||
eventInfo currentEventInfo = eventInfoList [i];
|
||||
|
||||
currentEventInfo.pauseVisibleOnEditor = false;
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void showObjectsBySearchName ()
|
||||
{
|
||||
if (objectSearcherName != null && objectSearcherName != "") {
|
||||
objectSearchResultList.Clear ();
|
||||
|
||||
searchObjectsActive = true;
|
||||
|
||||
string currentTextToSearch = objectSearcherName;
|
||||
|
||||
if (currentTextToSearch != "") {
|
||||
currentTextToSearch = currentTextToSearch.ToLower ();
|
||||
|
||||
int objectToSelectInfoListCount = eventInfoList.Count;
|
||||
|
||||
for (int i = 0; i < objectToSelectInfoListCount; i++) {
|
||||
eventInfo currentEventInfo = eventInfoList [i];
|
||||
|
||||
if (currentEventInfo.Name != "") {
|
||||
string objectName = currentEventInfo.Name.ToLower ();
|
||||
|
||||
if (objectName.Contains (currentTextToSearch) ||
|
||||
objectName.Equals (currentTextToSearch)) {
|
||||
|
||||
if (!objectSearchResultList.Contains (currentEventInfo.Name)) {
|
||||
objectSearchResultList.Add (currentEventInfo.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnabledEventStateFromEditor (string eventName)
|
||||
{
|
||||
setEnabledOrDisabledEventState (true, eventName);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setDisabledEventStateFromEditor (string eventName)
|
||||
{
|
||||
setEnabledOrDisabledEventState (false, eventName);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setRemoteEventsEnabledStateFromEditor (bool state)
|
||||
{
|
||||
setRemoteEventsEnabledState (state);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Remote Event System", gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class eventInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool eventEnabled = true;
|
||||
|
||||
public bool disableEventAfterActivation;
|
||||
|
||||
public bool useRegularEvent = true;
|
||||
public UnityEvent eventToActive;
|
||||
|
||||
public bool useAmountOnEvent;
|
||||
public eventParameters.eventToCallWithAmount eventToActiveAmount;
|
||||
|
||||
public bool useBoolOnEvent;
|
||||
public eventParameters.eventToCallWithBool eventToActiveBool;
|
||||
|
||||
public bool useGameObjectOnEvent;
|
||||
public eventParameters.eventToCallWithGameObject eventToActiveGameObject;
|
||||
|
||||
public bool useTransformOnEvent;
|
||||
public eventParameters.eventToCallWithTransform eventToActiveTransform;
|
||||
|
||||
public bool useStringOnEvent;
|
||||
public eventParameters.eventToCallWithString eventToActivateString;
|
||||
|
||||
public bool pauseVisibleOnEditor;
|
||||
|
||||
public bool ignoreEventActive;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62b07e78566b1a3448770560282b75de
|
||||
timeCreated: 1555188956
|
||||
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/Event System/remoteEventSystem.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user