plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent 195b696771
commit 779f2c8b20
14443 changed files with 23840465 additions and 452 deletions

View File

@@ -0,0 +1,99 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class craftedObjectPlacedHelper : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string objectName;
public GameObject mainGameObject;
public bool objectCanBeTakenBackToInventoryEnabled = true;
[Space]
[Header ("Debug")]
[Space]
public bool objectPlaced;
[Space]
[Header ("Event Settings")]
[Space]
public bool useEventsOnPlaceOrTakeBackObject;
public UnityEvent eventOnPlaceObject;
public UnityEvent eventOnTakeBackObject;
[Space]
public bool useEventsToSendPlayerOnPlaceOrTakeBackObject;
public eventParameters.eventToCallWithGameObject eventsToSendPlayerOnPlaceObject;
public eventParameters.eventToCallWithGameObject eventsToSendPlayerOnTakeBackObject;
public string getObjectName ()
{
return objectName;
}
public GameObject getObject ()
{
return mainGameObject;
}
public void checkEventsOnStateChange (bool state)
{
if (useEventsOnPlaceOrTakeBackObject) {
if (state) {
eventOnPlaceObject.Invoke ();
} else {
eventOnTakeBackObject.Invoke ();
}
}
}
public void checkStateOnTakeObjectBack ()
{
if (mainGameObject != null) {
craftingStationSystem currentCraftingStationSystem = mainGameObject.GetComponent<craftingStationSystem> ();
if (currentCraftingStationSystem != null) {
currentCraftingStationSystem.checkStateOnTakeObjectBack ();
}
}
}
public void checkEventsOnStateChangeWithPlayer (bool state, GameObject currentPlayer)
{
if (useEventsToSendPlayerOnPlaceOrTakeBackObject) {
if (state) {
eventsToSendPlayerOnPlaceObject.Invoke (currentPlayer);
} else {
eventsToSendPlayerOnTakeBackObject.Invoke (currentPlayer);
}
}
}
public void setObjectPlacedState (bool state)
{
objectPlaced = state;
}
public bool isObjectPlaced ()
{
return objectPlaced;
}
public void setObjectCanBeTakenBackToInventoryEnabledState (bool state)
{
objectCanBeTakenBackToInventoryEnabled = state;
}
public bool isObjectCanBeTakenBackToInventoryEnabled ()
{
return objectCanBeTakenBackToInventoryEnabled;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 3621352eacaef824b8ff25ad78572246
timeCreated: 1662914748
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/Crafting System/craftedObjectPlacedHelper.cs
uploadId: 814740

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class craftingBlueprintInfo
{
public string Name;
public int amountObtained = 1;
[Space]
public List<craftingIngredientObjectInfo> craftingIngredientObjectInfoList = new List<craftingIngredientObjectInfo> ();
}
[System.Serializable]
public class craftingIngredientObjectInfo
{
public string Name;
public int amountRequired;
}
[System.Serializable]
public class craftingStatInfo
{
public string statName;
public int valueRequired;
[Space]
public bool useStatValue;
public int statValueToUse;
}
[System.Serializable]
public class processMaterialInfo
{
public string materialProcessedName;
public string processName;
public int materialAmountNeeded;
public int materialAmountToObtain;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 030bf7d8d466fc449b642d0c357ff637
timeCreated: 1662008574
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/Crafting System/craftingBlueprintInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,93 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu (fileName = "Crafting Blueprint Template", menuName = "GKC/Create Crafting Blueprint Template", order = 51)]
public class craftingBlueprintInfoTemplate : ScriptableObject
{
public string Name;
public int ID = 0;
[Space]
public int amountObtained = 1;
[Space]
public bool isRawMaterial;
[Space]
[Header ("Object To Place Settings")]
[Space]
public bool useObjectToPlace;
public GameObject objectToPlace;
public Vector3 objectToPlacePositionOffset;
[Space]
public bool useCustomLayerMaskToPlaceObject;
public LayerMask customLayerMaskToPlaceObject;
public LayerMask layerMaskToAttachObject;
[Space]
public bool objectCanBeRotatedOnYAxis = true;
public bool objectCanBeRotatedOnXAxis;
[Space]
[Header ("Craft Object In Time Settings")]
[Space]
public bool craftObjectInTime;
public float timeToCraftObject;
[Space]
[Space]
[Header ("Craft Ingredients Settings")]
[Space]
public List<craftingIngredientObjectInfo> craftingIngredientObjectInfoList = new List<craftingIngredientObjectInfo> ();
[Space]
[Header ("Repair Ingredients Settings")]
[Space]
public List<craftingIngredientObjectInfo> repairIngredientObjectInfoList = new List<craftingIngredientObjectInfo> ();
[Space]
[Header ("Broken Ingredients Settings")]
[Space]
public List<craftingIngredientObjectInfo> brokenIngredientObjectInfoList = new List<craftingIngredientObjectInfo> ();
[Space]
[Header ("Disassemble Ingredients Settings")]
[Space]
public List<craftingIngredientObjectInfo> disassembleIngredientObjectInfoList = new List<craftingIngredientObjectInfo> ();
[Space]
[Space]
[Header ("Stats Settings")]
[Space]
public bool checkStatsInfoToCraft;
[Space]
public List<craftingStatInfo> craftingStatInfoToCraftList = new List<craftingStatInfo> ();
[Space]
[Header ("Process Material Settings")]
[Space]
public List<processMaterialInfo> processMaterialInfoList = new List<processMaterialInfo> ();
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 871cdb62c88f27b47b5c390fd70817aa
timeCreated: 1662008890
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/Crafting System/craftingBlueprintInfoTemplate.cs
uploadId: 814740

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu (fileName = "Crafting Blueprint Template List", menuName = "GKC/Create Crafting Blueprint Template List", order = 51)]
public class craftingBlueprintInfoTemplateData : ScriptableObject
{
public string Name;
public int ID = 0;
[Space]
[TextArea (3, 5)] public string description;
[Space]
[Space]
public List<craftingBlueprintInfoTemplate> craftingBlueprintInfoTemplateList = new List<craftingBlueprintInfoTemplate> ();
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 7bec8fa09dba25345b130f97c519453b
timeCreated: 1662009198
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/Crafting System/craftingBlueprintInfoTemplateData.cs
uploadId: 814740

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[System.Serializable]
public class craftingObjectButtonInfo : MonoBehaviour
{
public string objectCategoryName;
public string objectName;
[Space]
public GameObject buttonGameObject;
public Text objectNameText;
public RawImage objectImage;
public Text amountAvailableToCreateText;
public RectTransform buttonNotAvailableAmountPanel;
public Slider objectSlider;
[Space]
public bool objectAssigned;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d9bd8aac4ec53274da0289f70d0790b0
timeCreated: 1661939210
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/Crafting System/craftingObjectButtonInfo.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b475515c35881644c9f698426e448ad9
timeCreated: 1662896626
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/Crafting System/craftingPlacementSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,87 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class craftingSocket : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool isInputSocket;
[Space]
[Header ("Debug")]
[Space]
public bool socketAssigned;
public Transform currentTargetTransform;
[Space]
[Header ("Components")]
[Space]
public craftingStationSystem currentCraftingStationSystemAssigned;
public LineRenderer mainLineRenderer;
public void assignCraftingStationSystem (craftingStationSystem newCraftingStationSystem)
{
currentCraftingStationSystemAssigned = newCraftingStationSystem;
checkIfSocketAssigned ();
}
public void removeCraftingStationSystem ()
{
currentCraftingStationSystemAssigned = null;
}
public void checkIfSocketAssigned ()
{
socketAssigned = currentCraftingStationSystemAssigned != null;
}
public void enableOrDisableLineRenderer (bool state)
{
if (mainLineRenderer != null) {
if (mainLineRenderer.enabled != state) {
mainLineRenderer.enabled = state;
}
}
}
public void enableLineRendererIfSocketAssigned ()
{
if (socketAssigned) {
enableOrDisableLineRenderer (true);
}
}
public void updateLinerenderPositions ()
{
if (currentTargetTransform != null) {
setLineRendererTargetPosition (currentTargetTransform.position);
}
}
public void setLineRendererTargetPosition (Vector3 targetPosition)
{
if (mainLineRenderer != null) {
mainLineRenderer.SetPosition (0, transform.position);
mainLineRenderer.SetPosition (1, targetPosition);
}
}
public void setLineRendererTargetPosition (Transform targetTransform)
{
if (mainLineRenderer != null) {
currentTargetTransform = targetTransform;
mainLineRenderer.SetPosition (0, transform.position);
mainLineRenderer.SetPosition (1, targetTransform.position);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ee6e0e52c15ff5a4d873a05d0d7cd0ff
timeCreated: 1667242318
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/Crafting System/craftingSocket.cs
uploadId: 814740

View File

@@ -0,0 +1,219 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class craftingStationSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string stationName;
public bool inputSockedEnabled = true;
public bool outputSocketEnabled = true;
public craftingSocket inputSocket;
public craftingSocket outputSocket;
public bool chechSocketsOnStart;
[Space]
[Header ("Stations To Connect Settings")]
[Space]
public List<string> stationToConnectNameList = new List<string> ();
[Space]
[Header ("Other Settings")]
[Space]
public energyStationSystem currentEnergyStationSystem;
public bool removeRemainEnergyOnRemoveEnergyStation;
[Space]
[Header ("Debug")]
[Space]
public bool useInfiniteEnergy;
public bool energyStationAssigned;
public List<craftingStationSystem> craftingStationSystemConnectedList = new List<craftingStationSystem> ();
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnInputConnected;
public UnityEvent eventOnInputConnected;
[Space]
public bool useEventOnInputRemoved;
public UnityEvent eventOnInputRemoved;
[Space]
public bool useEventOnOutputConnected;
public UnityEvent eventOnOutputConnected;
[Space]
public bool useEventOnOutputRemoved;
public UnityEvent eventOnOutputRemoved;
void Start ()
{
if (chechSocketsOnStart) {
if (inputSocket != null) {
setInputSocket (inputSocket);
}
if (outputSocket != null) {
setOutputSocket (outputSocket);
}
}
}
public virtual void setInputSocket (craftingSocket newSocket)
{
if (inputSockedEnabled) {
inputSocket = newSocket;
if (useEventOnInputConnected) {
eventOnInputConnected.Invoke ();
}
checkStateOnSetInput ();
}
}
public virtual void removeInputSocket ()
{
if (inputSockedEnabled) {
checkStateOnRemoveInput ();
inputSocket = null;
if (useEventOnInputRemoved) {
eventOnInputRemoved.Invoke ();
}
}
}
public virtual void setOutputSocket (craftingSocket newSocket)
{
if (inputSockedEnabled) {
outputSocket = newSocket;
if (useEventOnOutputConnected) {
eventOnOutputConnected.Invoke ();
}
checkStateOnSetOuput ();
}
}
public virtual void removeOutputSocket ()
{
if (inputSockedEnabled) {
checkStateOnRemoveOuput ();
outputSocket = null;
if (useEventOnOutputConnected) {
eventOnOutputRemoved.Invoke ();
}
}
}
public virtual void sendEnergyValue (float newAmount)
{
}
public virtual void setInfiniteEnergyState (bool state)
{
useInfiniteEnergy = state;
}
public virtual void checkStateOnSetInput ()
{
}
public virtual void checkStateOnSetOuput ()
{
}
public virtual void checkStateOnRemoveInput ()
{
}
public virtual void checkStateOnRemoveOuput ()
{
}
public virtual void setCurrentEnergyStationSystem (energyStationSystem newEnergyStationSystem)
{
currentEnergyStationSystem = newEnergyStationSystem;
energyStationAssigned = currentEnergyStationSystem != null;
checkEnergyStationOnStateChange ();
}
public virtual void checkEnergyStationOnStateChange ()
{
}
public virtual void checkStateOnTakeObjectBack ()
{
if (outputSocket.currentCraftingStationSystemAssigned != null) {
outputSocket.currentCraftingStationSystemAssigned.checkStateOnRemoveInput ();
outputSocket.currentCraftingStationSystemAssigned.checkStateOnRemoveOuput ();
}
if (inputSocket.currentCraftingStationSystemAssigned != null) {
inputSocket.currentCraftingStationSystemAssigned.checkStateOnRemoveInput ();
inputSocket.currentCraftingStationSystemAssigned.checkStateOnRemoveOuput ();
}
checkStateOnRemoveInput ();
checkStateOnRemoveOuput ();
}
public string getStationName ()
{
return stationName;
}
public void addCraftingStationSystem (craftingStationSystem newCraftingStationSystem)
{
if (!craftingStationSystemConnectedList.Contains (newCraftingStationSystem)) {
craftingStationSystemConnectedList.Add (newCraftingStationSystem);
}
}
public void removeCraftingStationSystem (craftingStationSystem newCraftingStationSystem)
{
if (craftingStationSystemConnectedList.Contains (newCraftingStationSystem)) {
craftingStationSystemConnectedList.Remove (newCraftingStationSystem);
}
}
public void clearCraftingStationSystemList ()
{
craftingStationSystemConnectedList.Clear ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b2ceff4d263b7a94591fe5880cf3fdcf
timeCreated: 1667242188
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/Crafting System/craftingStationSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,691 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class craftingSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool craftingSystemEnabled;
bool mainCraftingUISystemAssigned;
public string craftingSystemMenuName = "Crafting System Menu";
public bool ignoreCheckMaterialsNeededToCraftEnabled;
[Space]
[Header ("Blueprints/recipes unlocked")]
[Space]
public bool useOnlyBlueprintsUnlocked;
public List<string> blueprintsUnlockedList = new List<string> ();
[Space]
public bool useEventOnUnlockBlueprint;
public string extraMessageOnUnlockBlueprint;
public eventParameters.eventToCallWithString eventOnUnlockBlueprint;
[Space]
[Header ("Categories To Craft Available")]
[Space]
public bool allowAllObjectCategoriesToCraftAtAnyMomentEnabled = true;
public List<string> objectCategoriesToCraftAvailableAtAnyMoment = new List<string> ();
[Space]
[Header ("Animation Settings")]
[Space]
public bool useAnimationOnCraftObjectAnywhere;
public string animationNameOnCraftAnywhere = "Craft Simple Object";
public bool useAnimationOnCraftObjectOnWorkbench;
public string animationNameOnCraftOnWorkbench = "Craft On Workbench";
[Space]
[Header ("Placement Mode Active Externally Settings")]
[Space]
public bool setPlacementActiveStateExternallyEnabled = true;
public UnityEvent eventOnSetPlacementActiveStateExternallyNotEnabled;
public UnityEvent eventOnNoObjectFoundToUsePlacementExternally;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool menuOpened;
public bool menuOpenedFromWorkbench;
public int currentInventoryObjectSelectedIndex = -1;
public bool placementActiveStatExternallyActive;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnOpenMenu;
public UnityEvent eventOnCloseMenu;
[Space]
public UnityEvent eventToStopUsingWorkbenchOnDamageReceived;
[Space]
public UnityEvent eventOnOpenWorkbench;
public UnityEvent eventOnCloseWorkbench;
[Space]
[Header ("Components")]
[Space]
public craftingUISystem mainCraftingUISystem;
public inventoryManager mainInventorymanager;
public menuPause pauseManager;
public GameObject playerGameObject;
public Transform positionToSpawnObjectsIfNotSpaceOnInventory;
public playerController mainPlayerController;
public craftingPlacementSystem mainCraftingPlacementSystem;
public objectsStatsSystem mainObjectsStatsSystem;
public playerStatsSystem mainPlayerStatsSystem;
void Start ()
{
if (!craftingSystemEnabled) {
pauseManager.setDisabledMenuCanBeUsedState (craftingSystemMenuName);
return;
}
if (!mainCraftingUISystemAssigned) {
checkAssignCraftingUISystem ();
}
}
void checkAssignCraftingUISystem ()
{
if (!mainCraftingUISystemAssigned) {
ingameMenuPanel currentIngameMenuPanel = pauseManager.getIngameMenuPanelByName (craftingSystemMenuName);
if (currentIngameMenuPanel == null) {
pauseManager.checkcreateIngameMenuPanel (craftingSystemMenuName);
currentIngameMenuPanel = pauseManager.getIngameMenuPanelByName (craftingSystemMenuName);
}
if (currentIngameMenuPanel != null) {
mainCraftingUISystem = currentIngameMenuPanel.GetComponent<craftingUISystem> ();
mainCraftingUISystemAssigned = true;
}
if (mainCraftingUISystemAssigned) {
setUseOnlyBlueprintsUnlockedState (useOnlyBlueprintsUnlocked);
if (useOnlyBlueprintsUnlocked) {
setBlueprintsUnlockedListValue (blueprintsUnlockedList);
}
GKC_Utils.updateCanvasValuesByPlayer (null, pauseManager.gameObject, currentIngameMenuPanel.gameObject);
}
}
}
public void openOrCloseCraftingMenu (bool state)
{
if (menuOpened == state) {
return;
}
menuOpened = state;
if (menuOpened) {
if (!mainCraftingUISystemAssigned) {
checkAssignCraftingUISystem ();
}
} else {
}
checkEventOnStateChange (menuOpened);
}
void checkEventOnStateChange (bool state)
{
if (state) {
eventOnOpenMenu.Invoke ();
} else {
eventOnCloseMenu.Invoke ();
}
if (menuOpenedFromWorkbench) {
if (state) {
eventOnOpenWorkbench.Invoke ();
} else {
eventOnCloseWorkbench.Invoke ();
}
}
}
public void checkStateOnCraftObject ()
{
if (useAnimationOnCraftObjectAnywhere || useAnimationOnCraftObjectOnWorkbench) {
if (menuOpenedFromWorkbench) {
if (useAnimationOnCraftObjectOnWorkbench) {
mainPlayerController.playerCrossFadeInFixedTime (animationNameOnCraftOnWorkbench);
}
} else {
if (useAnimationOnCraftObjectAnywhere) {
mainPlayerController.playerCrossFadeInFixedTime (animationNameOnCraftAnywhere);
}
}
}
}
//Get/set inventory info functions
public int getCurrentInventoryObjectIndex ()
{
return mainInventorymanager.getCurrentInventoryObjectIndex ();
}
public int getInventoryObjectAmountByName (string inventoryObjectName)
{
return mainInventorymanager.getInventoryObjectAmountByName (inventoryObjectName);
}
public Texture getInventoryObjectIconByName (string inventoryObjectName)
{
return mainInventorymanager.getInventoryObjectIconByName (inventoryObjectName);
}
public void removeObjectAmountFromInventoryByName (string objectName, int amountToMove)
{
mainInventorymanager.removeObjectAmountFromInventoryByName (objectName, amountToMove);
}
public void removeObjectAmountFromInventoryByIndex (int objectIndex, int amountToMove)
{
mainInventorymanager.removeObjectAmountFromInventory (objectIndex, amountToMove);
}
public void giveInventoryObjectToCharacter (string objectName, int objectAmount)
{
applyDamage.giveInventoryObjectToCharacter (playerGameObject, objectName, objectAmount,
positionToSpawnObjectsIfNotSpaceOnInventory, 0, 2, ForceMode.Force, 0, false, false, false);
}
public List<inventoryInfo> getInventoryList ()
{
return mainInventorymanager.getInventoryList ();
}
public inventoryInfo getInventoryInfoByName (string objectName)
{
return mainInventorymanager.getInventoryInfoByName (objectName);
}
public inventoryInfo getInventoryInfoByIndex (int objectIndex)
{
return mainInventorymanager.getInventoryInfoByIndex (objectIndex);
}
public bool repairDurabilityObjectByIndex (int objectIndex)
{
return mainInventorymanager.repairDurabilityObjectByIndex (objectIndex);
}
public bool isObjectBroken (int objectIndex)
{
return mainInventorymanager.isObjectBroken (objectIndex);
}
public bool isObjectDurabilityComplete (int objectIndex)
{
return mainInventorymanager.isObjectDurabilityComplete (objectIndex);
}
public GameObject getInventoryMeshByName (string objectName)
{
return mainInventorymanager.getInventoryMeshByName (objectName);
}
public GameObject getCurrentObjectToPlace ()
{
return mainCraftingUISystem.getCurrentObjectToPlace ();
}
public GameObject getCurrentObjectToPlaceByName (string objectName)
{
return mainCraftingUISystem.getCurrentObjectToPlaceByName (objectName);
}
public void updateObjectSelectedName (string newCurrentObjectCategorySelectedName, string newCurrentObjectSelectedName)
{
mainCraftingUISystem.updateObjectSelectedName (newCurrentObjectCategorySelectedName, newCurrentObjectSelectedName);
}
public LayerMask getCurrentObjectLayerMaskToAttachObjectByName (string objectName)
{
return mainCraftingUISystem.getCurrentObjectLayerMaskToAttachObjectByName (objectName);
}
public Vector3 getCurrentObjectToPlacePositionOffsetByName (string objectName)
{
return mainCraftingUISystem.getCurrentObjectToPlacePositionOffsetByName (objectName);
}
public bool checkIfCurrentObjectToPlaceUseCustomLayerMaskByName (string objectName)
{
return mainCraftingUISystem.checkIfCurrentObjectToPlaceUseCustomLayerMaskByName (objectName);
}
public LayerMask getCurrentObjectCustomLayerMaskToPlaceObjectByName (string objectName)
{
return mainCraftingUISystem.getCurrentObjectCustomLayerMaskToPlaceObjectByName (objectName);
}
public void getCurrentObjectCanBeRotatedValuesByName (string objectName, ref bool objectCanBeRotatedOnYAxis, ref bool objectCanBeRotatedOnXAxis)
{
mainCraftingUISystem.getCurrentObjectCanBeRotatedValuesByName (objectName, ref objectCanBeRotatedOnYAxis, ref objectCanBeRotatedOnXAxis);
}
public string getCurrentObjectSelectedName ()
{
return mainCraftingUISystem.getCurrentObjectSelectedName ();
}
public bool isIgnoreCheckMaterialsNeededToCraftEnabled ()
{
return ignoreCheckMaterialsNeededToCraftEnabled;
}
public void setPlacementActiveState (bool state)
{
if (mainCraftingPlacementSystem.isPlacementActivePaused ()) {
return;
}
if (mainCraftingUISystem.currentObjectCanBePlaced) {
if (state) {
GameObject currentObjectMesh = getInventoryMeshByName (getCurrentObjectSelectedName ());
if (showDebugPrint) {
print ("current object mesh located on placement active" + (currentObjectMesh != null));
}
if (currentObjectMesh != null) {
mainCraftingPlacementSystem.setCurrentObjectToPlaceMesh (currentObjectMesh);
} else {
return;
}
}
}
if (state) {
if (mainCraftingUISystem.menuOpened) {
mainCraftingUISystem.openOrCloseMenuFromTouch ();
}
}
mainCraftingPlacementSystem.setPlacementActiveState (state);
}
public void setPlacementActiveStateExternally (bool state)
{
if (mainCraftingPlacementSystem.isPlacementActivePaused ()) {
return;
}
if (!setPlacementActiveStateExternallyEnabled) {
eventOnSetPlacementActiveStateExternallyNotEnabled.Invoke ();
if (showDebugPrint) {
print ("placement active externally not enabled");
}
return;
}
placementActiveStatExternallyActive = state;
if (state) {
currentInventoryObjectSelectedIndex = -1;
bool objectFound = selectNextOrPreviousObjectForPlacement (true);
if (objectFound) {
mainCraftingUISystem.currentObjectCanBePlaced = true;
setPlacementActiveState (true);
} else {
eventOnNoObjectFoundToUsePlacementExternally.Invoke ();
if (mainCraftingPlacementSystem.placementActive) {
setPlacementActiveState (false);
}
if (showDebugPrint) {
print ("placement active externally not enabled due to not objects to place located on inventory");
}
}
} else {
setPlacementActiveState (false);
}
}
public void setCurrentInventoryObjectSelectedIndex (int newValue)
{
if (showDebugPrint) {
print ("new index value " + newValue);
}
currentInventoryObjectSelectedIndex = newValue;
}
public bool selectNextOrPreviousObjectForPlacement (bool state)
{
bool objectFound = false;
List<inventoryInfo> inventoryList = getInventoryList ();
// print (currentInventoryObjectSelectedIndex);
if (currentInventoryObjectSelectedIndex == -1) {
currentInventoryObjectSelectedIndex = 0;
// print (currentInventoryObjectSelectedIndex);
} else {
if (state) {
currentInventoryObjectSelectedIndex++;
if (currentInventoryObjectSelectedIndex >= inventoryList.Count - 1) {
currentInventoryObjectSelectedIndex = 0;
}
// print (currentInventoryObjectSelectedIndex);
} else {
currentInventoryObjectSelectedIndex--;
if (currentInventoryObjectSelectedIndex <= 0) {
currentInventoryObjectSelectedIndex = inventoryList.Count - 1;
}
// print (currentInventoryObjectSelectedIndex);
}
}
// print (currentInventoryObjectSelectedIndex);
if (!mainCraftingUISystemAssigned) {
checkAssignCraftingUISystem ();
}
if (!mainCraftingUISystemAssigned) {
return false;
}
if (state) {
for (int i = currentInventoryObjectSelectedIndex; i < inventoryList.Count; i++) {
if (!objectFound && mainCraftingUISystem.canObjectBePlaced (inventoryList [i].categoryName, inventoryList [i].Name)) {
currentInventoryObjectSelectedIndex = i;
objectFound = true;
if (showDebugPrint) {
print ("object located " + inventoryList [i].Name);
}
}
}
if (!objectFound) {
currentInventoryObjectSelectedIndex = 0;
for (int i = 0; i < inventoryList.Count; i++) {
if (!objectFound && mainCraftingUISystem.canObjectBePlaced (inventoryList [i].categoryName, inventoryList [i].Name)) {
currentInventoryObjectSelectedIndex = i;
objectFound = true;
if (showDebugPrint) {
print ("object located " + inventoryList [i].Name);
}
}
}
}
} else {
for (int i = currentInventoryObjectSelectedIndex; i >= 0; i--) {
if (!objectFound && mainCraftingUISystem.canObjectBePlaced (inventoryList [i].categoryName, inventoryList [i].Name)) {
currentInventoryObjectSelectedIndex = i;
objectFound = true;
if (showDebugPrint) {
print ("object located " + inventoryList [i].Name);
}
}
}
if (!objectFound) {
currentInventoryObjectSelectedIndex = 0;
for (int i = inventoryList.Count - 1; i >= 0; i--) {
if (!objectFound && mainCraftingUISystem.canObjectBePlaced (inventoryList [i].categoryName, inventoryList [i].Name)) {
currentInventoryObjectSelectedIndex = i;
objectFound = true;
if (showDebugPrint) {
print ("object located " + inventoryList [i].Name);
}
}
}
}
}
if (objectFound) {
mainCraftingUISystem.updateObjectSelectedName (inventoryList [currentInventoryObjectSelectedIndex].categoryName, inventoryList [currentInventoryObjectSelectedIndex].Name);
}
return objectFound;
}
public void setPlacementActivePausedState (bool state)
{
mainCraftingPlacementSystem.setPlacementActivePausedState (state);
}
public void setOriginalPlacementActivePausedState ()
{
mainCraftingPlacementSystem.setOriginalPlacementActivePausedState ();
}
public bool checkIfStatValueAvailable (string statName, int statAmount)
{
return mainPlayerStatsSystem.checkIfStatValueAvailable (statName, statAmount);
}
public void addOrRemovePlayerStatAmount (string statName, int statAmount)
{
mainPlayerStatsSystem.addOrRemovePlayerStatAmount (statName, statAmount);
}
//blueprints functions
public void setUseOnlyBlueprintsUnlockedState (bool state)
{
useOnlyBlueprintsUnlocked = state;
if (mainCraftingUISystem != null) {
mainCraftingUISystem.setUseOnlyBlueprintsUnlockedState (state);
}
}
public bool isUseOnlyBlueprintsUnlockedActive ()
{
return useOnlyBlueprintsUnlocked;
}
public void setBlueprintsUnlockedListValue (List<string> newBlueprintsUnlockedList)
{
blueprintsUnlockedList = new List<string> (newBlueprintsUnlockedList);
if (mainCraftingUISystem != null) {
mainCraftingUISystem.setBlueprintsUnlockedListValue (newBlueprintsUnlockedList);
}
}
public List<string> getBlueprintsUnlockedListValue ()
{
return blueprintsUnlockedList;
}
public void addNewBlueprintsUnlockedElement (string newBlueprintsUnlockedElement)
{
if (!blueprintsUnlockedList.Contains (newBlueprintsUnlockedElement)) {
blueprintsUnlockedList.Add (newBlueprintsUnlockedElement);
if (useEventOnUnlockBlueprint) {
eventOnUnlockBlueprint.Invoke (newBlueprintsUnlockedElement + " " + extraMessageOnUnlockBlueprint);
}
}
if (mainCraftingUISystem != null) {
mainCraftingUISystem.addNewBlueprintsUnlockedElement (newBlueprintsUnlockedElement);
}
}
public void setObjectCategoriesToCraftAvailableAtAnyMomentValue (List<string> newList)
{
objectCategoriesToCraftAvailableAtAnyMoment = newList;
}
public List<string> getObjectCategoriesToCraftAvailableAtAnyMomentValue ()
{
return objectCategoriesToCraftAvailableAtAnyMoment;
}
public void addObjectCategoriesToCraftAvailableAtAnyMomentElement (string newElement)
{
if (!objectCategoriesToCraftAvailableAtAnyMoment.Contains (newElement)) {
objectCategoriesToCraftAvailableAtAnyMoment.Add (newElement);
}
}
public List<craftObjectInTimeSimpleInfo> getCraftObjectInTimeInfoList ()
{
return mainCraftingUISystem.getCraftObjectInTimeInfoList ();
}
public bool anyObjectToCraftInTimeActive ()
{
if (mainCraftingUISystemAssigned) {
return mainCraftingUISystem.anyObjectToCraftInTimeActive ();
}
return false;
}
public void setCraftObjectInTimeInfoList (List<craftObjectInTimeSimpleInfo> newCraftObjectInTimeSimpleInfoList)
{
mainCraftingUISystem.setCraftObjectInTimeInfoList (newCraftObjectInTimeSimpleInfoList);
}
public void setOpenFromWorkbenchState (bool state, List<string> newObjectCategoriesToCraftAvailableOnCurrentBench)
{
if (mainCraftingUISystem != null) {
mainCraftingUISystem.setOpenFromWorkbenchState (state, newObjectCategoriesToCraftAvailableOnCurrentBench);
menuOpenedFromWorkbench = state;
}
}
public void setCurrentcurrentCraftingWorkbenchSystem (craftingWorkbenchSystem newCraftingWorkbenchSystem)
{
if (mainCraftingUISystem != null) {
mainCraftingUISystem.setCurrentcurrentCraftingWorkbenchSystem (newCraftingWorkbenchSystem);
}
}
public void stopUsingWorkbenchOnDamageReceived ()
{
if (menuOpened) {
if (menuOpenedFromWorkbench) {
eventToStopUsingWorkbenchOnDamageReceived.Invoke ();
mainCraftingUISystem.checkEventToStopUsingWorkbenchOnDamageReceived ();
}
}
}
public void closeMenuOnWorkbenchWithActionSystem ()
{
if (menuOpened) {
if (menuOpenedFromWorkbench) {
if (mainPlayerController.isActionActive ()) {
mainPlayerController.playCurrentAnimationOnPlayerActionSystem ();
}
}
}
}
public void repairCurrentObjectSelectedOnInventoryMenu ()
{
if (mainInventorymanager.checkDurabilityOnObjectEnabled) {
if (mainCraftingUISystem != null) {
mainCraftingUISystem.repairCurrentObjectSelectedOnInventoryMenu ();
}
}
}
public void updateUIAfterRepairingCurrentObjectSelectedOnInventoryMenu (bool state)
{
mainInventorymanager.updateUIAfterRepairingCurrentObjectSelectedOnInventoryMenu (state);
}
public List<objectStatInfo> getStatsFromObjectByName (string objectName)
{
return mainObjectsStatsSystem.getStatsFromObjectByName (objectName);
}
public bool objectCanBeUpgraded (string objectName)
{
return mainObjectsStatsSystem.objectCanBeUpgraded (objectName);
}
//Editor Functions
public void setCraftingSystemEnabledStateFromEditor (bool state)
{
craftingSystemEnabled = state;
updateComponent ();
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Crafting System State", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6a763337cdb536940a9913ba8929fdeb
timeCreated: 1661912978
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/Crafting System/craftingSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8ee2f7bb4d3d2aa49a7051ce708a2c5f
timeCreated: 1661912906
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/Crafting System/craftingUISystem.cs
uploadId: 814740

View File

@@ -0,0 +1,106 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class craftingWorkbenchSystem : MonoBehaviour
{
[Header ("Main Setting")]
[Space]
public int workbenchID;
public bool setObjectCategoriesToCraftAvailableOnCurrentBench;
public List<string> objectCategoriesToCraftAvailableOnCurrentBench = new List<string> ();
[Space]
[Header ("Repair/Disassemble/Upgrade Setting")]
[Space]
public bool repairObjectsOnlyOnWorkbenchEnabled = true;
public bool disassembleObjectsOnlyOnWorkbenchEnabled = true;
public bool upgradeObjectsOnlyOnWorkbencheEnabled = true;
[Space]
[Header ("Other Setting")]
[Space]
public bool showCurrentObjectMesh;
public Transform currentObjectMeshPlaceTransform;
[Space]
[Header ("Inventory Bank Setting")]
[Space]
public bool storeCraftedObjectsOnInventoryBank;
public inventoryBankSystem mainInventoryBankSystem;
[Space]
[Header ("Event Setting")]
[Space]
public UnityEvent eventToStopUsingWorkbenchOnDamageReceived;
public void activateWorkbench (GameObject currentPlayer)
{
if (currentPlayer == null) {
return;
}
playerComponentsManager currentplayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentplayerComponentsManager != null) {
craftingSystem currentCraftingSystem = currentplayerComponentsManager.getCraftingSystem ();
if (currentCraftingSystem != null) {
currentCraftingSystem.setCurrentcurrentCraftingWorkbenchSystem (this);
if (setObjectCategoriesToCraftAvailableOnCurrentBench) {
currentCraftingSystem.setOpenFromWorkbenchState (true, objectCategoriesToCraftAvailableOnCurrentBench);
} else {
currentCraftingSystem.setOpenFromWorkbenchState (true, null);
}
}
}
}
public void deactivateWorkBench (GameObject currentPlayer)
{
if (currentPlayer == null) {
return;
}
playerComponentsManager currentplayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentplayerComponentsManager != null) {
craftingSystem currentCraftingSystem = currentplayerComponentsManager.getCraftingSystem ();
if (currentCraftingSystem != null) {
currentCraftingSystem.setCurrentcurrentCraftingWorkbenchSystem (null);
currentCraftingSystem.setOpenFromWorkbenchState (false, null);
}
}
}
public void addInventoryObjectByName (string objectName, int amountToMove)
{
mainInventoryBankSystem.addInventoryObjectByName (objectName, amountToMove);
}
public void checkEventToStopUsingWorkbenchOnDamageReceived ()
{
eventToStopUsingWorkbenchOnDamageReceived.Invoke ();
}
public int getWorkbenchID ()
{
return workbenchID;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 3d05ec63fe2a63b41b7784b5c86b28b7
timeCreated: 1662619354
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/Crafting System/craftingWorkbenchSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class craftingZoneSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool setCraftingZoneEnabledState;
public bool craftingZoneEnabledState;
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!setCraftingZoneEnabledState) {
return;
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
craftingSystem currentCraftingSystem = currentPlayerComponentsManager.getCraftingSystem ();
if (currentCraftingSystem != null) {
currentCraftingSystem.setPlacementActivePausedState (!craftingZoneEnabledState);
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
craftingSystem currentCraftingSystem = currentPlayerComponentsManager.getCraftingSystem ();
if (currentCraftingSystem != null) {
currentCraftingSystem.setOriginalPlacementActivePausedState ();
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: bd871e50c984af642b4e049153a06d5a
timeCreated: 1669780875
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/Crafting System/craftingZoneSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,372 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class durabilityInfo : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string objectName;
public float maxDurabilityAmount;
public float durabilityAmount;
public bool invulnerabilityActive;
[Space]
[Header ("Regeneration Settings")]
[Space]
public float regenerationSpeed = 4;
public bool activateRegenerationAfterDelay;
public float delayToActivateRegeneration;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool objectIsBroken;
public bool regenerationActive;
public bool regenerationAfterDelayActive;
public bool characterLocated;
public int inventoryObjectIndex = -1;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnEmptyDurability;
public UnityEvent eventOnEmptyDurability;
[Space]
public bool useEventOnRefilledDurability;
public UnityEvent eventOnRefilledDurability;
[Space]
public bool useEventOnInvulnerabilityActive;
public UnityEvent eventOnInvulnerabilityActive;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEventOnEmptyDurability;
public List<string> remoteEventListOnEmptyDurability = new List<string> ();
[Space]
[Header ("Components")]
[Space]
public GameObject mainCharacterGameObject;
Coroutine regenerationCoroutine;
Coroutine regenerationAfterDelayCoroutine;
inventoryManager currentInventoryManager;
bool currentInventoryManagerLocated;
public virtual void initializeDurabilityValue (float newAmount)
{
durabilityAmount = newAmount;
objectIsBroken = durabilityAmount <= 0;
}
public virtual float getDurabilityAmount ()
{
return durabilityAmount;
}
public virtual void repairObjectFully ()
{
addOrRemoveDurabilityAmountToObjectByName (maxDurabilityAmount, true);
}
public virtual void breakFullDurability ()
{
addOrRemoveDurabilityAmountToObjectByName (0, true);
}
public virtual void addOrRemoveDurabilityAmountToObjectByName (float newAmount, bool setAmountAsCurrentValue)
{
if (invulnerabilityActive) {
return;
}
if (setAmountAsCurrentValue) {
durabilityAmount = newAmount;
} else {
durabilityAmount += newAmount;
}
if (durabilityAmount <= 0) {
durabilityAmount = 0;
updateDurabilityAmountState ();
} else {
if (durabilityAmount >= maxDurabilityAmount) {
durabilityAmount = maxDurabilityAmount;
setFullDurabilityState ();
}
objectIsBroken = false;
}
if (showDebugPrint) {
print ("current durability amount " + durabilityAmount);
}
if (newAmount < 0) {
if (activateRegenerationAfterDelay) {
if (regenerationAfterDelayActive) {
stopUpdateRegenerationAfterDelayCoroutine ();
}
regenerationAfterDelayCoroutine = StartCoroutine (updateRegenerationAfterDelayCoroutine ());
}
}
}
public virtual void updateDurabilityAmountState ()
{
checkMainCharacterGameObject ();
if (!characterLocated) {
return;
}
if (durabilityAmount <= 0) {
if (!objectIsBroken) {
if (useEventOnEmptyDurability) {
eventOnEmptyDurability.Invoke ();
}
if (useRemoteEventOnEmptyDurability) {
remoteEventSystem currentRemoteEventSystem = mainCharacterGameObject.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventListOnEmptyDurability.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventListOnEmptyDurability [i]);
}
}
}
objectIsBroken = true;
}
}
if (!currentInventoryManagerLocated) {
currentInventoryManager = mainCharacterGameObject.GetComponent<inventoryManager> ();
currentInventoryManagerLocated = currentInventoryManager != null;
}
if (currentInventoryManagerLocated) {
currentInventoryManager.addOrRemoveDurabilityAmountToObjectByName (objectName, inventoryObjectIndex, durabilityAmount, true);
}
}
public virtual void setFullDurabilityState ()
{
checkMainCharacterGameObject ();
if (!characterLocated) {
return;
}
durabilityAmount = maxDurabilityAmount;
objectIsBroken = false;
if (!currentInventoryManagerLocated) {
currentInventoryManager = mainCharacterGameObject.GetComponent<inventoryManager> ();
currentInventoryManagerLocated = currentInventoryManager != null;
}
if (currentInventoryManagerLocated) {
currentInventoryManager.addOrRemoveDurabilityAmountToObjectByName (objectName, inventoryObjectIndex, maxDurabilityAmount, true);
}
if (useEventOnRefilledDurability) {
eventOnRefilledDurability.Invoke ();
}
}
public virtual void setInvulnerabilityActiveState (bool state)
{
invulnerabilityActive = state;
if (state) {
if (useEventOnInvulnerabilityActive) {
eventOnInvulnerabilityActive.Invoke ();
}
}
}
public void setMainCharacterGameObject (GameObject newObject)
{
mainCharacterGameObject = newObject;
}
public void checkMainCharacterGameObject ()
{
if (characterLocated) {
return;
}
if (mainCharacterGameObject == null) {
getMainCharacterGameObject ();
}
characterLocated = mainCharacterGameObject != null;
}
public virtual void getMainCharacterGameObject ()
{
}
//Coroutine functions
public void activateDurabilityRegeneration ()
{
stopUpdateRegenerationCoroutine ();
regenerationCoroutine = StartCoroutine (updateRegenerationCoroutine ());
}
public void stopUpdateRegenerationCoroutine ()
{
if (regenerationCoroutine != null) {
StopCoroutine (regenerationCoroutine);
}
if (regenerationActive) {
updateDurabilityAmountState ();
}
if (regenerationAfterDelayActive) {
stopUpdateRegenerationAfterDelayCoroutine ();
}
regenerationActive = false;
}
IEnumerator updateRegenerationCoroutine ()
{
regenerationActive = true;
bool targetReached = false;
float timer = 0;
objectIsBroken = false;
while (targetReached) {
timer = Time.deltaTime * regenerationSpeed;
durabilityAmount += timer;
if (durabilityAmount >= maxDurabilityAmount) {
durabilityAmount = maxDurabilityAmount;
targetReached = true;
}
yield return null;
}
regenerationActive = false;
setFullDurabilityState ();
}
public void stopUpdateRegenerationAfterDelayCoroutine ()
{
if (regenerationAfterDelayCoroutine != null) {
StopCoroutine (regenerationAfterDelayCoroutine);
}
regenerationAfterDelayActive = false;
}
IEnumerator updateRegenerationAfterDelayCoroutine ()
{
regenerationAfterDelayActive = true;
yield return new WaitForSeconds (delayToActivateRegeneration);
activateDurabilityRegeneration ();
regenerationAfterDelayActive = false;
}
public bool isDurabilityEmpty ()
{
return durabilityAmount <= 0;
}
public void setObjectName (string newName)
{
objectName = newName;
}
public void setMaxDurabilityAmount (float newValue)
{
maxDurabilityAmount = newValue;
}
public void setInventoryObjectIndex (int newValue)
{
inventoryObjectIndex = newValue;
}
//EDITOR FUNCTIONS
public void setObjectNameFromEditor (string newName)
{
setObjectName (newName);
updateComponent ();
}
public void setMaxDurabilityAmountFromEditor (float newValue)
{
setMaxDurabilityAmount (newValue);
updateComponent ();
}
public void setDurabilityAmountFromEditor (float newValue)
{
durabilityAmount = newValue;
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Updating melee shield object info" + gameObject.name, gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b52f6cf13d3726043bbf756e78a32e51
timeCreated: 1661347702
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/Crafting System/durabilityInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class durabilityInfoOnFireWeapons : durabilityInfo
{
public override void updateDurabilityAmountState ()
{
base.updateDurabilityAmountState ();
}
public override void setFullDurabilityState ()
{
base.setFullDurabilityState ();
}
public override void getMainCharacterGameObject ()
{
IKWeaponSystem currentIKWeaponSystem = GetComponent<IKWeaponSystem> ();
if (currentIKWeaponSystem != null) {
mainCharacterGameObject = currentIKWeaponSystem.getPlayerGameObject ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 4809282284c1bf443bb8248ce119d84d
timeCreated: 1661348042
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/Crafting System/durabilityInfoOnFireWeapons.cs
uploadId: 814740

View File

@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class durabilityInfoOnMeleeShields : durabilityInfo
{
public override void updateDurabilityAmountState ()
{
base.updateDurabilityAmountState ();
}
public override void setFullDurabilityState ()
{
base.setFullDurabilityState ();
}
public override void getMainCharacterGameObject ()
{
meleeShieldObjectSystem currentMeleeShieldObjectSystem = GetComponent<meleeShieldObjectSystem> ();
if (currentMeleeShieldObjectSystem != null) {
mainCharacterGameObject = currentMeleeShieldObjectSystem.getCurrentCharacter ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d26b189c42078064ba9335f60884e9f5
timeCreated: 1680658015
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/Crafting System/durabilityInfoOnMeleeShields.cs
uploadId: 814740

View File

@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class durabilityInfoOnMeleeWeapons : durabilityInfo
{
public override void updateDurabilityAmountState ()
{
base.updateDurabilityAmountState ();
}
public override void setFullDurabilityState ()
{
base.setFullDurabilityState ();
}
public override void getMainCharacterGameObject ()
{
grabPhysicalObjectMeleeAttackSystem currentGrabPhysicalObjectMeleeAttackSystem = GetComponent<grabPhysicalObjectMeleeAttackSystem> ();
if (currentGrabPhysicalObjectMeleeAttackSystem != null) {
mainCharacterGameObject = currentGrabPhysicalObjectMeleeAttackSystem.getCurrentCharacter ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 17d97feec90439146b4bfd270fa5e3d3
timeCreated: 1661448486
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/Crafting System/durabilityInfoOnMeleeWeapons.cs
uploadId: 814740

View File

@@ -0,0 +1,254 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class energyStationSystem : craftingStationSystem
{
[Header ("Main Settings")]
[Space]
public bool energyEnabled = true;
public string energyName;
public float maxEnergyAmount;
public float currentEnergyAmount;
[Space]
public bool useEnergyOverTime;
public float useEnergyRate;
public float energyAmountToUseOverTime;
public bool refillEnergyAfterTime;
public float timeToRefillEnergy;
[Space]
[Header ("Debug")]
[Space]
public bool energyActive;
public bool energyInUse;
public bool refillingEnergyInProcess;
[Space]
[Header ("Event Settings")]
[Space]
public bool checkEventsOnEnergyStateChangeOnlyIfOutputSockedConnected;
public bool useEventsOnEmptyEnergy;
public UnityEvent eventsOnEmptyEnergy;
public bool useEventsOnRefilledEnergy;
public UnityEvent eventsOnRefilledEnergy;
Coroutine updateCoroutine;
float lastTimeEnergyUsed = 0;
float lastTimeEnergyRefilled = 0;
public void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
if (energyInUse) {
if (useEnergyOverTime) {
if (Time.time > lastTimeEnergyUsed + useEnergyRate) {
currentEnergyAmount -= energyAmountToUseOverTime;
lastTimeEnergyUsed = Time.time;
}
}
if (currentEnergyAmount <= 0) {
currentEnergyAmount = 0;
energyInUse = false;
lastTimeEnergyRefilled = Time.time;
checkEventOnEmptyEnergy ();
if (refillEnergyAfterTime) {
refillingEnergyInProcess = true;
}
}
} else {
if (refillEnergyAfterTime) {
if (refillingEnergyInProcess) {
if (Time.time > lastTimeEnergyRefilled + timeToRefillEnergy) {
currentEnergyAmount += energyAmountToUseOverTime;
lastTimeEnergyRefilled = Time.time;
}
if (currentEnergyAmount >= maxEnergyAmount) {
currentEnergyAmount = maxEnergyAmount;
energyInUse = true;
refillingEnergyInProcess = false;
checkEventOnRefilledEnergy ();
}
}
}
}
}
public float getCurrentEnergyAmount ()
{
return currentEnergyAmount;
}
public string getEnergyName ()
{
return energyName;
}
public void setEnergyActiveState (bool state)
{
if (!energyEnabled) {
return;
}
energyActive = state;
lastTimeEnergyUsed = Time.time;
lastTimeEnergyRefilled = Time.time;
if (energyActive) {
stopUpdateCoroutine ();
} else {
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
}
if (!energyActive) {
refillingEnergyInProcess = false;
energyInUse = false;
}
}
public void refillAllEnergy ()
{
setCurrentEnergyAmount (maxEnergyAmount);
}
public void removeAllEnergy ()
{
setCurrentEnergyAmount (0);
}
public void setCurrentEnergyAmount (float newAmount)
{
currentEnergyAmount = newAmount;
checkEnergyAmountState ();
}
public void addOrRemoveToCurrentEnergyAmount (float newAmount)
{
currentEnergyAmount += newAmount;
checkEnergyAmountState ();
}
void checkEnergyAmountState ()
{
if (currentEnergyAmount >= maxEnergyAmount) {
currentEnergyAmount = maxEnergyAmount;
refillingEnergyInProcess = false;
}
if (currentEnergyAmount < 0) {
currentEnergyAmount = 0;
}
if (currentEnergyAmount > 0) {
checkEventOnRefilledEnergy ();
} else {
checkEventOnEmptyEnergy ();
}
}
public void setEnergyInUseState (bool state)
{
energyInUse = state;
}
public override void checkStateOnSetOuput ()
{
if (outputSocket != null) {
if (outputSocket.currentCraftingStationSystemAssigned != null) {
outputSocket.currentCraftingStationSystemAssigned.sendEnergyValue (currentEnergyAmount);
outputSocket.currentCraftingStationSystemAssigned.setInfiniteEnergyState (useInfiniteEnergy);
outputSocket.currentCraftingStationSystemAssigned.setCurrentEnergyStationSystem (this);
}
}
}
public override void checkStateOnRemoveOuput ()
{
if (outputSocket != null) {
if (outputSocket.currentCraftingStationSystemAssigned != null) {
outputSocket.currentCraftingStationSystemAssigned.setInfiniteEnergyState (false);
outputSocket.currentCraftingStationSystemAssigned.setCurrentEnergyStationSystem (null);
}
}
}
public void checkEventOnEmptyEnergy ()
{
if (checkEventsOnEnergyStateChangeOnlyIfOutputSockedConnected) {
if (outputSocket != null) {
} else {
return;
}
}
if (useEventsOnEmptyEnergy) {
eventsOnEmptyEnergy.Invoke ();
}
}
public void checkEventOnRefilledEnergy ()
{
if (checkEventsOnEnergyStateChangeOnlyIfOutputSockedConnected) {
if (outputSocket != null) {
} else {
return;
}
}
if (useEventsOnRefilledEnergy) {
eventsOnRefilledEnergy.Invoke ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 2bb593435e3d3ca4fb4ef897d0851675
timeCreated: 1667256639
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/Crafting System/energyStationSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu (fileName = "Full Crafting Blueprint Template List", menuName = "GKC/Create Full Crafting Blueprint Template List", order = 51)]
public class fullCraftingBlueprintInfoTemplateData : ScriptableObject
{
public string Name;
public int ID = 0;
[Space]
[Header ("Crafting Blueptint Template Data List Settings")]
[Space]
public List<craftingBlueprintInfoTemplateData> craftingBlueprintInfoTemplateDataList = new List<craftingBlueprintInfoTemplateData> ();
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 46b2ba2ee3ccff54589dceeec76d4a8a
timeCreated: 1663238409
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/Crafting System/fullCraftingBlueprintInfoTemplateData.cs
uploadId: 814740

View File

@@ -0,0 +1,617 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class materialExtractionStationSystem : craftingStationSystem
{
[Header ("Main Settings")]
[Space]
public bool stationEnabled = true;
public bool activateStationAtStart;
public float maxDetectionDistance = 10;
public Transform extractionZoneTransform;
public bool useMaxMaterialZonesToExtractAtSameTime;
public int maxMaterialZonesToExtractAtSameTime;
[Space]
[Header ("Extraction Settings")]
[Space]
public bool useGeneralMaterialExtractionRate;
public float generalMaterialExtractionRate;
[Space]
public bool useGeneralMaterialExtractionAmount;
public int generalMaterialExtractionAmount;
[Space]
[Space]
public bool stationCanOnlyExtractCustomMaterialList;
public List<string> customMaterialListToExtract = new List<string> ();
[Space]
[Header ("Custom Materials Zone To Use Settings")]
[Space]
public bool ignoreMaterialZonesFound;
public bool extractMaterialsEvenIfNotZoneFound;
public materialsZoneSystem customMaterialZoneSystem;
[Space]
[Header ("Extraction Conditions Settings")]
[Space]
public bool ignoreToExtractMaterialsFromIDList;
public List<int> materialsIDListToIgnore = new List<int> ();
[Space]
[Header ("Spawn Extracted Objects Settings")]
[Space]
public bool spawnExtractedObjects;
public Transform positionToSpawnExtractedObjects;
public bool addForceToSpawnedObjects;
public ForceMode forceModeOnSpawnedObjects;
public float forceAmountOnSpawnedObjects;
[Space]
public bool packExtractedObjectsBeforeSpawn;
public int minAmountToPackToSpawn;
[Space]
[Header ("Energy Settings")]
[Space]
public bool useEnergyToExtract;
public float maxEnergyAmount;
public float currentEnergyAmount;
public float useEnergyRate;
public float energyToUseAmount;
[Space]
public bool useEnergyFromInventoryBank;
public string energyObjectName;
public bool checkEnergyObjectNameOnEnergyStation;
[Space]
[Header ("Debug")]
[Space]
public bool stationActive;
List<float> lastTimeMaterialExtractedList = new List<float> ();
public List<materialsZoneSystem> materialsZoneSystemLocatedList = new List<materialsZoneSystem> ();
public bool energySourceLocated;
public int numberOfZonesLocated;
public List<int> materialZonesSystemsIDToIgnoreList = new List<int> ();
public List<extractedMaterialInfo> extractedMaterialInfoList = new List<extractedMaterialInfo> ();
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnActivateStation;
public UnityEvent eventonDeactivateStation;
[Space]
public UnityEvent eventOnEnergyEmpty;
public UnityEvent eventOnEnergyRecharge;
public UnityEvent eventOnEnergyRefilled;
[Space]
[Header ("Components")]
[Space]
public inventoryBankSystem mainInventoryBankSystem;
public inventoryBankSystem inventoryBankEnergySource;
Coroutine updateCoroutine;
float lastTimeMaterialExtracted;
float lastTimeEnergyUsed;
materialsZoneSystem currentMaterialsZoneSystem;
inventoryListManager mainInventoryListManager;
bool mainInventoryManagerLocated;
void Start ()
{
if (activateStationAtStart) {
setExtractionActiveState (true);
}
}
void checkGetMainInventoryManager ()
{
if (!mainInventoryManagerLocated) {
mainInventoryManagerLocated = mainInventoryListManager != null;
if (!mainInventoryManagerLocated) {
mainInventoryListManager = inventoryListManager.Instance;
mainInventoryManagerLocated = mainInventoryListManager != null;
}
if (!mainInventoryManagerLocated) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (inventoryListManager.getMainManagerName (), typeof(inventoryListManager), true);
mainInventoryListManager = inventoryListManager.Instance;
mainInventoryManagerLocated = (mainInventoryListManager != null);
}
if (!mainInventoryManagerLocated) {
mainInventoryListManager = FindObjectOfType<inventoryListManager> ();
mainInventoryManagerLocated = mainInventoryListManager != null;
}
}
}
public void toggleExtraction ()
{
setExtractionActiveState (!stationActive);
}
public void setExtractionActiveState (bool state)
{
if (!stationEnabled) {
return;
}
if (stationActive == state) {
return;
}
if (state) {
if (useEnergyToExtract) {
if (currentEnergyAmount <= 0) {
return;
}
}
}
stationActive = state;
if (stationActive) {
eventOnActivateStation.Invoke ();
checkMaterialZonesAround ();
} else {
eventonDeactivateStation.Invoke ();
stopUpdateCoroutine ();
for (int i = 0; i < materialsZoneSystemLocatedList.Count; i++) {
materialsZoneSystemLocatedList [i].setMaterialsZoneExtractionInProcessState (false);
}
}
}
void checkMaterialZonesAround ()
{
materialsZoneSystemLocatedList.Clear ();
lastTimeMaterialExtractedList.Clear ();
extractedMaterialInfoList.Clear ();
if (ignoreMaterialZonesFound) {
if (extractMaterialsEvenIfNotZoneFound) {
materialsZoneSystemLocatedList.Add (customMaterialZoneSystem);
lastTimeMaterialExtractedList.Add (0);
}
} else {
materialsZoneSystem[] temporalMaterialsZoneSystem = FindObjectsOfType<materialsZoneSystem> ();
foreach (materialsZoneSystem currentMaterialsZoneSystem in temporalMaterialsZoneSystem) {
if (currentMaterialsZoneSystem.isMaterialsZoneEnabled ()) {
bool addZoneResult = false;
float currentDistance = GKC_Utils.distance (extractionZoneTransform.position, currentMaterialsZoneSystem.transform.position);
if (currentDistance < maxDetectionDistance) {
addZoneResult = true;
}
if (useMaxMaterialZonesToExtractAtSameTime) {
if (materialsZoneSystemLocatedList.Count >= maxMaterialZonesToExtractAtSameTime) {
addZoneResult = false;
}
}
if (addZoneResult) {
materialsZoneSystemLocatedList.Add (currentMaterialsZoneSystem);
lastTimeMaterialExtractedList.Add (0);
}
}
}
}
energySourceLocated = (!useEnergyFromInventoryBank || inventoryBankEnergySource != null);
lastTimeMaterialExtracted = 0;
lastTimeEnergyUsed = 0;
numberOfZonesLocated = 0;
stopUpdateCoroutine ();
if (materialsZoneSystemLocatedList.Count > 0) {
numberOfZonesLocated = materialsZoneSystemLocatedList.Count;
for (int i = 0; i < materialsZoneSystemLocatedList.Count; i++) {
materialsZoneSystemLocatedList [i].setMaterialsZoneExtractionInProcessState (true);
}
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
}
}
public void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
if (useGeneralMaterialExtractionRate) {
if (Time.time > generalMaterialExtractionRate + lastTimeMaterialExtracted) {
bool allMaterialZonesEmpty = true;
for (int i = 0; i < materialsZoneSystemLocatedList.Count; i++) {
checkMaterialZoneToExtract (i, ref allMaterialZonesEmpty);
}
lastTimeMaterialExtracted = Time.time;
if (allMaterialZonesEmpty) {
setExtractionActiveState (false);
}
}
} else {
bool allMaterialZonesEmpty = true;
for (int i = 0; i < materialsZoneSystemLocatedList.Count; i++) {
if (Time.time > materialsZoneSystemLocatedList [i].materialExtractionRate + lastTimeMaterialExtractedList [i]) {
checkMaterialZoneToExtract (i, ref allMaterialZonesEmpty);
lastTimeMaterialExtractedList [i] = Time.time;
}
}
if (allMaterialZonesEmpty) {
setExtractionActiveState (false);
}
}
updateEnergyUsage ();
}
void checkMaterialZoneToExtract (int zoneIndex, ref bool allMaterialZonesEmpty)
{
currentMaterialsZoneSystem = materialsZoneSystemLocatedList [zoneIndex];
bool checkMaterialZoneResult = true;
if (currentMaterialsZoneSystem.isMaterialsZoneEmpty ()) {
checkMaterialZoneResult = false;
}
if (checkMaterialZoneResult) {
if (materialZonesSystemsIDToIgnoreList.Contains (currentMaterialsZoneSystem.getMaterialZoneID ())) {
checkMaterialZoneResult = false;
}
}
if (checkMaterialZoneResult) {
allMaterialZonesEmpty = false;
bool allMaterialsOnZoneEmpty = true;
int currentExtractionAmount = 0;
for (int j = 0; j < currentMaterialsZoneSystem.materialZoneInfoList.Count; j++) {
materialsZoneSystem.materialZoneInfo currentMaterialZoneInfo = currentMaterialsZoneSystem.materialZoneInfoList [j];
bool canExtractMaterialResult = true;
if (currentMaterialZoneInfo.materialAmount <= 0) {
canExtractMaterialResult = false;
}
if (canExtractMaterialResult) {
if (stationCanOnlyExtractCustomMaterialList && !canExtractMaterial (currentMaterialZoneInfo.materialName)) {
canExtractMaterialResult = false;
}
}
if (canExtractMaterialResult) {
if (ignoreToExtractMaterialsFromIDList && materialsIDListToIgnore.Contains (currentMaterialZoneInfo.materialID)) {
canExtractMaterialResult = false;
}
}
if (canExtractMaterialResult) {
if (useGeneralMaterialExtractionAmount) {
currentExtractionAmount = generalMaterialExtractionAmount;
} else {
currentExtractionAmount = currentMaterialsZoneSystem.materialExtractionAmount;
}
if (currentMaterialZoneInfo.useCustomMaterialExtractionAmount) {
currentExtractionAmount = currentMaterialZoneInfo.customMaterialExtractionAmount;
}
int amountToObtain = currentExtractionAmount;
currentMaterialZoneInfo.materialAmount -= amountToObtain;
if (currentMaterialZoneInfo.useInfiniteMaterialAmount) {
currentMaterialZoneInfo.materialAmount = 1;
}
if (spawnExtractedObjects) {
if (packExtractedObjectsBeforeSpawn) {
int currentIndex = extractedMaterialInfoList.FindIndex (s => s.materialName.Equals (currentMaterialZoneInfo.materialName));
if (currentIndex > -1) {
extractedMaterialInfoList [currentIndex].materialAmount += amountToObtain;
} else {
extractedMaterialInfo newExtractedMaterialInfo = new extractedMaterialInfo ();
newExtractedMaterialInfo.materialName = currentMaterialZoneInfo.materialName;
newExtractedMaterialInfo.materialAmount = amountToObtain;
extractedMaterialInfoList.Add (newExtractedMaterialInfo);
currentIndex = extractedMaterialInfoList.Count - 1;
}
if (extractedMaterialInfoList [currentIndex].materialAmount >= minAmountToPackToSpawn) {
spawnExtractedMaterial (extractedMaterialInfoList [currentIndex].materialName, minAmountToPackToSpawn);
extractedMaterialInfoList [currentIndex].materialAmount -= minAmountToPackToSpawn;
if (extractedMaterialInfoList [currentIndex].materialAmount <= 0) {
extractedMaterialInfoList.RemoveAt (currentIndex);
}
}
} else {
spawnExtractedMaterial (currentMaterialZoneInfo.materialName, amountToObtain);
}
} else {
mainInventoryBankSystem.addInventoryObjectByName (currentMaterialZoneInfo.materialName, amountToObtain);
}
allMaterialsOnZoneEmpty = false;
}
}
if (allMaterialsOnZoneEmpty) {
if (currentMaterialsZoneSystem.getRemainMaterialsAmount () > 0) {
materialZonesSystemsIDToIgnoreList.Add (currentMaterialsZoneSystem.getMaterialZoneID ());
} else {
currentMaterialsZoneSystem.setMaterialsZoneEmptyState (true);
}
}
}
}
void spawnExtractedMaterial (string materialName, int amountToObtain)
{
if (!mainInventoryManagerLocated) {
checkGetMainInventoryManager ();
}
if (mainInventoryManagerLocated) {
GameObject newMaterialObject =
mainInventoryListManager.spawnInventoryObjectByName (materialName,
amountToObtain, positionToSpawnExtractedObjects.position, positionToSpawnExtractedObjects.rotation);
if (addForceToSpawnedObjects) {
if (newMaterialObject != null) {
Rigidbody objectRigidbody = newMaterialObject.GetComponent<Rigidbody> ();
if (objectRigidbody != null) {
objectRigidbody.AddForce (positionToSpawnExtractedObjects.forward * forceAmountOnSpawnedObjects, forceModeOnSpawnedObjects);
}
}
}
}
}
void updateEnergyUsage ()
{
if (useEnergyToExtract) {
if (Time.time > lastTimeEnergyUsed + useEnergyRate) {
if (useEnergyFromInventoryBank) {
if (energySourceLocated) {
currentEnergyAmount = inventoryBankEnergySource.getInventoryObjectAmountByName (energyObjectName);
if (currentEnergyAmount > 0) {
inventoryBankEnergySource.removeObjectAmountFromInventory (energyObjectName, (int)currentEnergyAmount);
}
} else {
currentEnergyAmount = 0;
}
}
if (energyStationAssigned) {
if (checkEnergyObjectNameOnEnergyStation) {
if (energyObjectName.Equals (currentEnergyStationSystem.getEnergyName ())) {
currentEnergyAmount = currentEnergyStationSystem.getCurrentEnergyAmount ();
} else {
currentEnergyAmount = 0;
}
} else {
currentEnergyAmount = currentEnergyStationSystem.getCurrentEnergyAmount ();
}
}
currentEnergyAmount -= energyToUseAmount;
if (useInfiniteEnergy) {
currentEnergyAmount = maxEnergyAmount;
}
if (currentEnergyAmount < 0) {
currentEnergyAmount = 0;
}
lastTimeEnergyUsed = Time.time;
}
if (currentEnergyAmount <= 0) {
setExtractionActiveState (false);
eventOnEnergyEmpty.Invoke ();
}
}
}
public void addEnergy (float newValue)
{
if (useEnergyToExtract) {
currentEnergyAmount += newValue;
if (currentEnergyAmount >= maxEnergyAmount) {
currentEnergyAmount = maxEnergyAmount;
eventOnEnergyRefilled.Invoke ();
} else {
eventOnEnergyRecharge.Invoke ();
}
}
}
public override void sendEnergyValue (float newAmount)
{
addEnergy (newAmount);
}
public void refullEnergy ()
{
addEnergy (maxEnergyAmount);
}
public void removeEnergySource ()
{
inventoryBankEnergySource = null;
energySourceLocated = false;
if (useInfiniteEnergy) {
currentEnergyAmount = 1;
} else {
currentEnergyAmount = 0;
}
}
public float getCurrentEnergyAmount ()
{
return currentEnergyAmount;
}
public float getMaxEnergyAmount ()
{
return maxEnergyAmount;
}
public void setEnergySource (inventoryBankSystem newBank)
{
inventoryBankEnergySource = newBank;
energySourceLocated = inventoryBankEnergySource != null;
}
public override void checkEnergyStationOnStateChange ()
{
if (removeRemainEnergyOnRemoveEnergyStation) {
if (currentEnergyStationSystem == null) {
currentEnergyAmount = 0;
if (stationActive) {
setExtractionActiveState (false);
}
}
}
}
public bool canExtractMaterial (string materialName)
{
if (stationCanOnlyExtractCustomMaterialList) {
if (customMaterialListToExtract.Contains (materialName)) {
return true;
}
return false;
} else {
return true;
}
}
[System.Serializable]
public class extractedMaterialInfo
{
[Header ("Main Settings")]
[Space]
public string materialName;
public int materialAmount;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d5a77761dd1ca574daa7fe05351e4574
timeCreated: 1665742906
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/Crafting System/materialExtractionStationSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,137 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class materialExtractionStationUISystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool stationEnabled = true;
public string noZonesLocatedString = "No Material Zons Located";
public bool showMaxAndRemainEnergyAmount;
[Space]
[Header ("Debug")]
[Space]
public bool stationActive;
public float currentEnergyAmount;
[Space]
[Header ("Events Settings")]
[Space]
public Text numberOfZonesLocatedText;
public Text materialsZonesStateText;
public Text stationEnergyAmountText;
public materialExtractionStationSystem mainMaterialExtractionStationSystem;
int numberOfZonesLocated;
string materialsZonesStateString;
public void setExtractionActiveState (bool state)
{
if (!stationEnabled) {
return;
}
if (stationActive == state) {
return;
}
stationActive = state;
stopUpdateCoroutine ();
if (stationActive) {
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
} else {
updateEnergyAmountText ();
}
}
Coroutine updateCoroutine;
public void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
numberOfZonesLocated = mainMaterialExtractionStationSystem.numberOfZonesLocated;
if (numberOfZonesLocated > 0) {
numberOfZonesLocatedText.text = numberOfZonesLocated.ToString ();
materialsZonesStateString = "Material Zones Located Info\n";
for (int i = 0; i < mainMaterialExtractionStationSystem.materialsZoneSystemLocatedList.Count; i++) {
materialsZonesStateString += "Station " + (i + 1).ToString () + " : ";
materialsZonesStateString += mainMaterialExtractionStationSystem.materialsZoneSystemLocatedList [i].getRemainMaterialsAmount ();
materialsZonesStateString += "\n";
}
materialsZonesStateText.text = materialsZonesStateString;
} else {
numberOfZonesLocatedText.text = noZonesLocatedString;
materialsZonesStateString = "Material Zones Located Info\n";
for (int i = 0; i < mainMaterialExtractionStationSystem.materialsZoneSystemLocatedList.Count; i++) {
materialsZonesStateString += "Station " + (i + 1).ToString () + " : EMPTY";
materialsZonesStateString += "\n";
}
materialsZonesStateText.text = materialsZonesStateString;
}
if (mainMaterialExtractionStationSystem.useEnergyToExtract) {
updateEnergyAmountText ();
}
}
void updateEnergyAmountText ()
{
currentEnergyAmount = mainMaterialExtractionStationSystem.getCurrentEnergyAmount ();
if (currentEnergyAmount <= 0) {
currentEnergyAmount = 0;
}
if (showMaxAndRemainEnergyAmount) {
stationEnergyAmountText.text = mainMaterialExtractionStationSystem.getMaxEnergyAmount ().ToString () + "/" +
currentEnergyAmount.ToString ();
} else {
stationEnergyAmountText.text = currentEnergyAmount.ToString ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: dbffb29b33112474ca78d3f10bad0a49
timeCreated: 1666141304
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/Crafting System/materialExtractionStationUISystem.cs
uploadId: 814740

View File

@@ -0,0 +1,356 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class materialsZoneSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool materialsZoneEnabled = true;
public bool materialsZoneCanChangePosition;
public int materialZoneID;
[Space]
[Header ("Extraction Settings")]
[Space]
public float materialExtractionRate;
public int materialExtractionAmount;
[Space]
[Header ("Spawn Objects Settings")]
[Space]
public float maxRadiusToInstantiate = 1;
public Transform positionToSpawnExtractedObjects;
public bool addForceToSpawnedObjects;
public ForceMode forceModeOnSpawnedObjects;
public float forceAmountOnSpawnedObjects;
public float forceRadiusOnSpawnedObjects;
[Space]
[Header ("Material Info List Settings")]
[Space]
public List<materialZoneInfo> materialZoneInfoList = new List<materialZoneInfo> ();
[Space]
[Header ("Other Settings")]
[Space]
public bool refillMaterialsZoneAfterDelayOnEmpty;
public float delayToRefillMaterialsOnEmpty;
public bool canBeExtractedByExternalElementsEnabled = true;
[Space]
[Header ("Debug")]
[Space]
public int remainMaterialsAmount;
public bool materialsZoneEmpty;
public bool materialsZoneFull = true;
public bool materialsZoneExtractionInProcess;
public int materialExtractionStationsActive;
public bool refillInProcess;
[Space]
[Header ("Event Settings")]
[Space]
public bool useEventOnZoneEmpty;
public UnityEvent eventOnZoneEmpty;
public bool useEventOnZoneRefilled;
public UnityEvent eventOnZoneRefilled;
Coroutine refillCoroutine;
inventoryListManager mainInventoryListManager;
bool mainInventoryManagerLocated;
public void setMaterialsZoneExtractionInProcessState (bool state)
{
if (state) {
materialExtractionStationsActive++;
} else {
materialExtractionStationsActive--;
}
if (materialExtractionStationsActive < 0) {
materialExtractionStationsActive = 0;
}
materialsZoneExtractionInProcess = (materialExtractionStationsActive > 0);
if (materialsZoneExtractionInProcess) {
if (materialsZoneFull) {
getRemainMaterialsAmount ();
materialsZoneFull = false;
}
}
}
public int getRemainMaterialsAmount ()
{
remainMaterialsAmount = 0;
for (int i = 0; i < materialZoneInfoList.Count; i++) {
remainMaterialsAmount += materialZoneInfoList [i].materialAmount;
}
return remainMaterialsAmount;
}
public void setMaterialsZoneFullState (bool state)
{
materialsZoneFull = state;
if (materialsZoneFull) {
refillMaterialsZone ();
}
}
void refillMaterialsZone ()
{
materialsZoneEnabled = true;
materialsZoneEmpty = false;
for (int i = 0; i < materialZoneInfoList.Count; i++) {
materialZoneInfoList [i].materialAmount = materialZoneInfoList [i].maxMaterialAmount;
}
if (useEventOnZoneRefilled) {
eventOnZoneRefilled.Invoke ();
}
}
public bool isMaterialsZoneEnabled ()
{
return materialsZoneEnabled;
}
public void setMaterialsZoneEmptyState (bool state)
{
materialsZoneEmpty = state;
for (int i = 0; i < materialZoneInfoList.Count; i++) {
if (materialZoneInfoList [i].materialAmount > 0) {
materialsZoneEmpty = false;
return;
}
}
if (materialsZoneEmpty) {
if (useEventOnZoneEmpty) {
eventOnZoneEmpty.Invoke ();
}
materialsZoneEnabled = false;
if (refillMaterialsZoneAfterDelayOnEmpty) {
stopRefillMaterialsZoneCoroutine ();
refillCoroutine = StartCoroutine (refillMaterialsZoneCoroutine ());
}
}
}
public bool isMaterialsZoneEmpty ()
{
return materialsZoneEmpty;
}
public bool isCanBeExtractedByExternalElementsEnabled ()
{
return canBeExtractedByExternalElementsEnabled;
}
public int getMaterialZoneID ()
{
return materialZoneID;
}
public void stopRefillMaterialsZoneCoroutine ()
{
if (refillCoroutine != null) {
StopCoroutine (refillCoroutine);
}
refillInProcess = false;
}
IEnumerator refillMaterialsZoneCoroutine ()
{
refillInProcess = true;
yield return new WaitForSecondsRealtime (delayToRefillMaterialsOnEmpty);
refillInProcess = false;
setMaterialsZoneFullState (true);
}
public void checkMaterialZoneToExtractExternally ()
{
bool checkMaterialZoneResult = true;
if (isMaterialsZoneEmpty ()) {
checkMaterialZoneResult = false;
}
Vector3 newPosition = Vector3.zero;
Quaternion newRotation = Quaternion.identity;
if (positionToSpawnExtractedObjects != null) {
newPosition = positionToSpawnExtractedObjects.position;
newRotation = positionToSpawnExtractedObjects.rotation;
} else {
newPosition = transform.position;
newRotation = transform.rotation;
}
if (checkMaterialZoneResult) {
bool allMaterialsOnZoneEmpty = true;
int currentExtractionAmount = 0;
for (int j = 0; j < materialZoneInfoList.Count; j++) {
materialZoneInfo currentMaterialZoneInfo = materialZoneInfoList [j];
bool canExtractMaterialResult = true;
if (currentMaterialZoneInfo.materialAmount <= 0) {
canExtractMaterialResult = false;
}
if (canExtractMaterialResult) {
currentExtractionAmount = materialExtractionAmount;
if (currentMaterialZoneInfo.useCustomMaterialExtractionAmount) {
currentExtractionAmount = currentMaterialZoneInfo.customMaterialExtractionAmount;
}
int amountToObtain = currentExtractionAmount;
currentMaterialZoneInfo.materialAmount -= amountToObtain;
if (currentMaterialZoneInfo.useInfiniteMaterialAmount) {
currentMaterialZoneInfo.materialAmount = 1;
}
if (!mainInventoryManagerLocated) {
checkGetMainInventoryManager ();
}
if (mainInventoryManagerLocated) {
GameObject newMaterialObject =
mainInventoryListManager.spawnInventoryObjectByName (currentMaterialZoneInfo.materialName,
amountToObtain, newPosition, newRotation);
if (newMaterialObject != null) {
newMaterialObject.transform.position += Random.insideUnitSphere * maxRadiusToInstantiate;
if (addForceToSpawnedObjects) {
if (newMaterialObject != null) {
Rigidbody objectRigidbody = newMaterialObject.GetComponent<Rigidbody> ();
if (objectRigidbody != null) {
objectRigidbody.AddExplosionForce (forceAmountOnSpawnedObjects,
newPosition, forceRadiusOnSpawnedObjects, 1, forceModeOnSpawnedObjects);
}
}
}
} else {
print ("not found " + currentMaterialZoneInfo.materialName);
}
}
allMaterialsOnZoneEmpty = false;
}
}
if (allMaterialsOnZoneEmpty) {
if (getRemainMaterialsAmount () <= 0) {
setMaterialsZoneEmptyState (true);
}
}
}
}
void checkGetMainInventoryManager ()
{
if (!mainInventoryManagerLocated) {
mainInventoryManagerLocated = mainInventoryListManager != null;
if (!mainInventoryManagerLocated) {
mainInventoryListManager = inventoryListManager.Instance;
mainInventoryManagerLocated = mainInventoryListManager != null;
}
if (!mainInventoryManagerLocated) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (inventoryListManager.getMainManagerName (), typeof(inventoryListManager), true);
mainInventoryListManager = inventoryListManager.Instance;
mainInventoryManagerLocated = (mainInventoryListManager != null);
}
if (!mainInventoryManagerLocated) {
mainInventoryListManager = FindObjectOfType<inventoryListManager> ();
mainInventoryManagerLocated = mainInventoryListManager != null;
}
}
}
[System.Serializable]
public class materialZoneInfo
{
[Header ("Main Settings")]
[Space]
public string materialName;
public int maxMaterialAmount;
public int materialAmount;
public bool useInfiniteMaterialAmount;
[Space]
[Header ("Other Settings")]
[Space]
public bool useCustomMaterialExtractionAmount;
public int customMaterialExtractionAmount;
// public bool useCustomExtractionRate;
// public float extractionRate;
[Space]
public int materialID;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 5a55c5b549f448641bc6d36033ce29f4
timeCreated: 1665743017
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/Crafting System/materialsZoneSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,275 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class processStationSystem : craftingStationSystem
{
[Header ("Main Settings")]
[Space]
public bool stationEnabled = true;
public List<string> materialProcessNameList = new List<string> ();
[Space]
[Header ("Process Settings")]
[Space]
public float processRate;
[Space]
[Header ("Energy Settings")]
[Space]
public bool useEnergyToExtract;
public float maxEnergyAmount;
public float currentEnergyAmount;
public float useEnergyRate;
public float energyToUseAmount;
[Space]
public bool useEnergyFromInventoryBank;
public string energyObjectName;
public bool checkEnergyObjectNameOnEnergyStation;
[Space]
[Header ("Debug")]
[Space]
public bool stationActive;
public bool energySourceLocated;
public List<materialInfo> materialInfoList = new List<materialInfo> ();
[Space]
[Header ("Components")]
[Space]
public inventoryBankSystem inventoryBankMaterialsProcessed;
public inventoryBankSystem inventoryBankMaterialsSource;
public inventoryBankSystem inventoryBankEnergySource;
float lastTimeEnergyUsed;
Coroutine updateCoroutine;
List<craftingBlueprintInfoTemplateData> craftingBlueprintInfoTemplateDataList;
float lastTimeMaterialsProcessed;
public void toggleProcessStation ()
{
setStationActiveState (!stationActive);
}
public void setStationActiveState (bool state)
{
if (!stationEnabled) {
return;
}
if (stationActive == state) {
return;
}
stationActive = state;
energySourceLocated = (!useEnergyFromInventoryBank || inventoryBankEnergySource != null);
craftingUISystem currentCraftingUISystem = FindObjectOfType<craftingUISystem> ();
if (currentCraftingUISystem != null) {
craftingBlueprintInfoTemplateDataList = currentCraftingUISystem.getCraftingBlueprintInfoTemplateDataList ();
}
stopUpdateCoroutine ();
if (stationActive) {
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
} else {
}
}
public void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
if (Time.time > processRate + lastTimeMaterialsProcessed) {
materialInfoList.Clear ();
List<inventoryInfo> inventoryList = inventoryBankMaterialsSource.getBankInventoryList ();
for (int i = 0; i < inventoryList.Count; i++) {
materialInfo newMaterialInfo = new materialInfo ();
newMaterialInfo.materialName = inventoryList [i].Name;
newMaterialInfo.materialAmount = inventoryList [i].amount;
processMaterialInfo newProcessMaterialInfo = getProcessMaterialInfoByName (newMaterialInfo.materialName);
newMaterialInfo.mainProcessMaterialInfo = newProcessMaterialInfo;
newMaterialInfo.mainProcessMaterialInfoAssigned = newProcessMaterialInfo != null;
materialInfoList.Add (newMaterialInfo);
}
if (materialInfoList.Count == 0) {
setStationActiveState (false);
return;
}
bool allObjectsProcessed = true;
for (int i = 0; i < materialInfoList.Count; i++) {
if (materialInfoList [i].mainProcessMaterialInfoAssigned) {
if (materialInfoList [i].materialAmount >= materialInfoList [i].mainProcessMaterialInfo.materialAmountNeeded) {
materialInfoList [i].materialAmount -= materialInfoList [i].mainProcessMaterialInfo.materialAmountNeeded;
inventoryBankMaterialsProcessed.addInventoryObjectByName (materialInfoList [i].mainProcessMaterialInfo.materialProcessedName, materialInfoList [i].mainProcessMaterialInfo.materialAmountToObtain);
inventoryBankMaterialsSource.removeObjectAmountFromInventory (materialInfoList [i].materialName, materialInfoList [i].mainProcessMaterialInfo.materialAmountNeeded);
allObjectsProcessed = false;
}
}
}
for (int i = materialInfoList.Count - 1; i >= 0; i--) {
if (materialInfoList [i].materialAmount < 0) {
materialInfoList.RemoveAt (i);
}
}
lastTimeMaterialsProcessed = Time.time;
if (allObjectsProcessed) {
setStationActiveState (false);
}
}
updateEnergyUsage ();
}
public processMaterialInfo getProcessMaterialInfoByName (string objectName)
{
for (int i = 0; i < craftingBlueprintInfoTemplateDataList.Count; i++) {
for (int j = 0; j < craftingBlueprintInfoTemplateDataList [i].craftingBlueprintInfoTemplateList.Count; j++) {
craftingBlueprintInfoTemplate currentCraftingBlueprintInfoTemplate = craftingBlueprintInfoTemplateDataList [i].craftingBlueprintInfoTemplateList [j];
if (currentCraftingBlueprintInfoTemplate.Name.Equals (objectName)) {
if (currentCraftingBlueprintInfoTemplate.processMaterialInfoList.Count > 0) {
for (int k = 0; k < currentCraftingBlueprintInfoTemplate.processMaterialInfoList.Count; k++) {
if (materialProcessNameList.Contains (currentCraftingBlueprintInfoTemplate.processMaterialInfoList [k].materialProcessedName)) {
return currentCraftingBlueprintInfoTemplate.processMaterialInfoList [k];
}
}
} else {
return null;
}
}
}
}
return null;
}
void updateEnergyUsage ()
{
if (useEnergyToExtract) {
if (Time.time > lastTimeEnergyUsed + useEnergyRate) {
if (useEnergyFromInventoryBank) {
if (energySourceLocated) {
currentEnergyAmount = inventoryBankEnergySource.getInventoryObjectAmountByName (energyObjectName);
if (currentEnergyAmount > 0) {
inventoryBankEnergySource.removeObjectAmountFromInventory (energyObjectName, (int)currentEnergyAmount);
}
} else {
currentEnergyAmount = 0;
}
}
if (energyStationAssigned) {
if (checkEnergyObjectNameOnEnergyStation) {
if (energyObjectName.Equals (currentEnergyStationSystem.getEnergyName ())) {
currentEnergyAmount = currentEnergyStationSystem.getCurrentEnergyAmount ();
} else {
currentEnergyAmount = 0;
}
} else {
currentEnergyAmount = currentEnergyStationSystem.getCurrentEnergyAmount ();
}
}
currentEnergyAmount -= energyToUseAmount;
if (useInfiniteEnergy) {
currentEnergyAmount = maxEnergyAmount;
}
if (currentEnergyAmount < 0) {
currentEnergyAmount = 0;
}
lastTimeEnergyUsed = Time.time;
}
if (currentEnergyAmount <= 0) {
setStationActiveState (false);
}
}
}
[System.Serializable]
public class materialInfo
{
[Header ("Main Settings")]
[Space]
public string materialName;
public int materialAmount;
[Space]
public bool mainProcessMaterialInfoAssigned;
public processMaterialInfo mainProcessMaterialInfo;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ce315b9e6ca90db4f98a9e28c12c751b
timeCreated: 1667262821
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/Crafting System/processStationSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,493 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
using UnityEngine.Events;
public class simpleBreakObject : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool breakObjectEnabled = true;
public bool canBreakWithCollisionsEnabled = true;
public float minVelocityToBreak;
public AudioClip explosionSound;
public AudioElement explosionAudioElement;
public bool breakInPieces;
public bool objectIsKinematic;
[Space]
[Header ("Disable Object Settings")]
[Space]
public bool disableMainObject;
public bool disableMainObjectMesh;
public GameObject mainObjectToDisable;
public bool removePiecesParent;
[Space]
[Header ("Fade Pieces Settings")]
[Space]
public bool fadePiecesEnabled;
public float fadePiecesSpeed = 5;
public bool destroyObjectAfterFade;
public bool destroyFadedPieces;
public float timeToRemovePieces = 3;
public Shader transparentShader;
public string defaultShaderName = "Legacy Shaders/Transparent/Diffuse";
[Space]
[Header ("Explosion Damage Settings")]
[Space]
public bool useExplosionAroundEnabled;
public float explosionDamage;
public bool ignoreShield;
public float damageRadius;
public float explosionDelay;
public bool canDamageToObjectOwner;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
[Space]
[Header ("Explosion Physics Settings")]
[Space]
public float explosionForceToPieces = 5;
public float explosionRadiusToPieces = 30;
public ForceMode forceModeToPieces = ForceMode.Impulse;
public float explosionForce = 300;
[Space]
[Header ("Damage Over Time Settings")]
[Space]
public bool damageTargetOverTime;
public float damageOverTimeDelay;
public float damageOverTimeDuration;
public float damageOverTimeAmount;
public float damageOverTimeRate;
public bool damageOverTimeToDeath;
public bool removeDamageOverTimeState;
[Space]
[Header ("Other Explosion Settings")]
[Space]
public bool pushCharacters = true;
public bool killObjectsInRadius;
public ForceMode explosionForceMode;
public bool userLayerMask;
public LayerMask layer;
public bool applyExplosionForceToVehicles = true;
public float explosionForceToVehiclesMultiplier = 0.2f;
public bool searchClosestWeakSpot;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEventOnObjectsFound;
public string remoteEventName;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnObjectBroken;
public UnityEvent eventOnObjectBroken;
[Space]
[Header ("Debug")]
[Space]
public bool canBreakStatePaused;
public bool broken;
public bool fadeInProcess;
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
[Space]
[Header ("Components")]
[Space]
public GameObject brokenObjectPiecesParent;
public bool spawnBrokenObjectPiecesEnabled;
public GameObject explosionParticles;
public Rigidbody mainRigidbody;
public GameObject objectOwner;
public AudioSource mainAudioSource;
List<Material> rendererParts = new List<Material> ();
int i, j;
List<GameObject> piecesLit = new List<GameObject> ();
int rendererPartsCount;
Material currentMaterial;
Coroutine mainUpdateCoroutine;
float currentTimeToRemovePieces;
private void Start ()
{
if (mainAudioSource != null) {
explosionAudioElement.audioSource = mainAudioSource;
}
if (explosionSound != null) {
explosionAudioElement.clip = explosionSound;
}
}
IEnumerator updateCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateState ();
yield return waitTime;
}
}
void updateState ()
{
if (fadeInProcess) {
if (fadePiecesEnabled) {
if (currentTimeToRemovePieces > 0) {
currentTimeToRemovePieces -= Time.deltaTime;
} else {
rendererPartsCount = rendererParts.Count;
bool allPiecesFaded = true;
for (i = 0; i < rendererPartsCount; i++) {
currentMaterial = rendererParts [i];
Color alpha = currentMaterial.color;
alpha.a -= Time.deltaTime / fadePiecesSpeed;
currentMaterial.color = alpha;
//once the alpha is 0, remove the gameObject
if (currentMaterial.color.a > 0) {
allPiecesFaded = false;
}
}
if (allPiecesFaded) {
if (destroyObjectAfterFade) {
Destroy (gameObject);
} else {
stopUpdateCoroutine ();
fadeInProcess = false;
}
if (destroyFadedPieces) {
for (i = 0; i < piecesLit.Count; i++) {
if (piecesLit [i] != null) {
Destroy (piecesLit [i]);
}
}
}
}
}
} else {
if (destroyObjectAfterFade) {
if (currentTimeToRemovePieces > 0) {
currentTimeToRemovePieces -= Time.deltaTime;
} else {
if (destroyObjectAfterFade) {
Destroy (gameObject);
} else {
stopUpdateCoroutine ();
fadeInProcess = false;
}
if (destroyFadedPieces) {
for (i = 0; i < piecesLit.Count; i++) {
if (piecesLit [i] != null) {
Destroy (piecesLit [i]);
}
}
}
}
}
}
}
}
public void fixBrokenObject ()
{
if (disableMainObjectMesh) {
GetComponent<Collider> ().enabled = true;
GetComponent<MeshRenderer> ().enabled = true;
} else {
if (mainObjectToDisable != null) {
mainObjectToDisable.SetActive (true);
}
}
if (mainRigidbody != null) {
mainRigidbody.isKinematic = objectIsKinematic;
}
broken = false;
}
public void activateBreakObject ()
{
if (!breakObjectEnabled) {
return;
}
if (broken) {
return;
}
if (objectOwner == null) {
objectOwner = gameObject;
}
if (disableMainObject) {
if (disableMainObjectMesh) {
GetComponent<Collider> ().enabled = false;
GetComponent<MeshRenderer> ().enabled = false;
} else {
if (mainObjectToDisable != null) {
mainObjectToDisable.SetActive (false);
}
}
}
if (!objectIsKinematic) {
if (mainRigidbody != null) {
mainRigidbody.isKinematic = true;
}
}
if (fadePiecesEnabled) {
if (transparentShader == null) {
transparentShader = Shader.Find (defaultShaderName);
}
}
if (useExplosionAroundEnabled) {
Vector3 currentPosition = transform.position;
applyDamage.setExplosion (currentPosition, damageRadius, userLayerMask, layer, objectOwner, canDamageToObjectOwner,
gameObject, killObjectsInRadius, true, false, explosionDamage, pushCharacters, applyExplosionForceToVehicles,
explosionForceToVehiclesMultiplier, explosionForce, explosionForceMode, true, objectOwner.transform, ignoreShield,
useRemoteEventOnObjectsFound, remoteEventName, damageTypeID,
damageTargetOverTime, damageOverTimeDelay, damageOverTimeDuration, damageOverTimeAmount,
damageOverTimeRate, damageOverTimeToDeath, removeDamageOverTimeState, damageCanBeBlocked, searchClosestWeakSpot);
}
//create the explosion particles
if (explosionParticles != null) {
GameObject explosionParticlesClone = (GameObject)Instantiate (explosionParticles, transform.position, transform.rotation);
explosionParticlesClone.transform.SetParent (transform);
}
if (explosionAudioElement != null) {
AudioPlayer.PlayOneShot (explosionAudioElement, gameObject);
}
piecesLit.Clear ();
//if the option break in pieces is enabled, create the barrel broken
if (breakInPieces) {
GameObject brokenObject = brokenObjectPiecesParent;
if (spawnBrokenObjectPiecesEnabled) {
brokenObject = (GameObject)Instantiate (brokenObjectPiecesParent, transform.position, transform.rotation);
if (!brokenObject.activeSelf) {
brokenObject.SetActive (true);
}
} else {
brokenObjectPiecesParent.SetActive (true);
}
if (removePiecesParent) {
brokenObject.transform.SetParent (null);
} else {
brokenObject.transform.SetParent (transform);
}
Component[] components = brokenObject.GetComponentsInChildren (typeof(MeshRenderer));
foreach (MeshRenderer child in components) {
Rigidbody currentPartRigidbody = child.gameObject.GetComponent<Rigidbody> ();
if (currentPartRigidbody == null) {
currentPartRigidbody = child.gameObject.AddComponent<Rigidbody> ();
}
if (child.gameObject.GetComponent<Collider> () == null) {
child.gameObject.AddComponent<BoxCollider> ();
}
currentPartRigidbody.AddExplosionForce (explosionForceToPieces, child.transform.position,
explosionRadiusToPieces, 1, forceModeToPieces);
if (fadePiecesEnabled) {
//change the shader of the fragments to fade them
int materialsLength = child.materials.Length;
for (j = 0; j < materialsLength; j++) {
Material temporalMaterial = child.materials [j];
temporalMaterial.shader = transparentShader;
rendererParts.Add (temporalMaterial);
}
}
piecesLit.Add (child.gameObject);
}
}
//kill the health component, to call the functions when the object health is 0
if (!applyDamage.checkIfDead (gameObject)) {
applyDamage.killCharacter (gameObject);
}
if (useEventOnObjectBroken) {
eventOnObjectBroken.Invoke ();
}
broken = true;
fadeInProcess = true;
currentTimeToRemovePieces = timeToRemovePieces;
if (fadePiecesEnabled) {
stopUpdateCoroutine ();
mainUpdateCoroutine = StartCoroutine (updateCoroutine ());
}
//if the object is being carried by the player, make him drop it
GKC_Utils.checkDropObject (gameObject);
}
void stopUpdateCoroutine ()
{
if (mainUpdateCoroutine != null) {
StopCoroutine (mainUpdateCoroutine);
}
}
public void setCanBreakStatePaused (bool state)
{
canBreakStatePaused = state;
}
public void setObjectOwner (GameObject newObject)
{
objectOwner = newObject;
}
void OnCollisionEnter (Collision col)
{
if (canBreakWithCollisionsEnabled) {
if (mainRigidbody != null) {
if (mainRigidbody.linearVelocity.magnitude > minVelocityToBreak && !canBreakStatePaused && !broken) {
activateBreakObject ();
}
}
}
}
public void waitToBreak ()
{
if (explosionDelay > 0) {
StartCoroutine (waitToBreakCorutine ());
} else {
activateBreakObject ();
}
}
IEnumerator waitToBreakCorutine ()
{
WaitForSeconds delay = new WaitForSeconds (explosionDelay);
yield return delay;
activateBreakObject ();
}
public void setExplosionValues (float force, float radius)
{
explosionForce = force;
damageRadius = radius;
}
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere (transform.position, damageRadius);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 53c2ab2239c34934e8b15b6f8a908225
timeCreated: 1663258932
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/Crafting System/simpleBreakObject.cs
uploadId: 814740

View File

@@ -0,0 +1,54 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class simpleDeviceStationSystem : craftingStationSystem
{
[Header ("Main Settings")]
[Space]
public bool stationEnabled = true;
[Space]
[Header ("Debug")]
[Space]
public bool stationActive;
[Space]
[Header ("Event Settings")]
[Space]
public UnityEvent eventOnConnectInput;
public UnityEvent eventOnDisconnectInput;
public override void checkStateOnSetInput ()
{
if (stationEnabled) {
if (stationActive) {
return;
}
stationActive = true;
eventOnConnectInput.Invoke ();
}
}
public override void checkStateOnRemoveInput ()
{
if (stationEnabled) {
if (!stationActive) {
return;
}
stationActive = false;
eventOnDisconnectInput.Invoke ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ad6070f78d5aaca499fd262cd7881fc4
timeCreated: 1667361919
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/Crafting System/simpleDeviceStationSystem.cs
uploadId: 814740