add ckg
plantilla base para movimiento básico
This commit is contained in:
22
Assets/Game Kit Controller/Scripts/Stats System/Istat.cs
Normal file
22
Assets/Game Kit Controller/Scripts/Stats System/Istat.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface Istat
|
||||
{
|
||||
void eventToInitializeStat (float newValue);
|
||||
|
||||
void eventToIncreaseStat (float newValue);
|
||||
|
||||
void eventToUseStat (float newValue);
|
||||
|
||||
void eventToAddAmount (float newValue);
|
||||
|
||||
void eventToInitializeBoolStat (bool newValue);
|
||||
|
||||
void eventToActivateBoolStat (bool newValue);
|
||||
|
||||
void eventToInitializeStatOnComponent ();
|
||||
|
||||
void eventToInitializeBoolStatOnComponent ();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65c6896b25254f144aad0f7003f17881
|
||||
timeCreated: 1586865549
|
||||
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/Stats System/Istat.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4796ae7c63b3a7742b7b8f43b1718f02
|
||||
folderAsset: yes
|
||||
timeCreated: 1677812931
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[System.Serializable]
|
||||
public class objectStatButtonInfo : MonoBehaviour
|
||||
{
|
||||
public string objectCategoryName;
|
||||
|
||||
public string objectName;
|
||||
|
||||
[Space]
|
||||
|
||||
public GameObject buttonGameObject;
|
||||
|
||||
public Text statNameText;
|
||||
|
||||
public RawImage statImage;
|
||||
|
||||
public Text statValueText;
|
||||
|
||||
public Text extraStatValueText;
|
||||
|
||||
public Slider statSlider;
|
||||
|
||||
public Toggle statToggle;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool objectAssigned;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d766f471afc38f4992d58b35b7d89cb
|
||||
timeCreated: 1664495191
|
||||
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/Stats System/Objects Stats/objectStatButtonInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class objectStatsInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<objectStatInfo> objectStatInfoList = new List<objectStatInfo> ();
|
||||
|
||||
[Space]
|
||||
|
||||
public bool usedOnObject;
|
||||
|
||||
public List<string> usableObjectList = new List<string> ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class objectStatInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool statIsAmount = true;
|
||||
|
||||
public Texture statIcon;
|
||||
|
||||
[Space]
|
||||
|
||||
public float currentFloatValue;
|
||||
|
||||
public float maxFloatValue;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool currentBoolState;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0d1fae7324b4ed47bbe2e5080ee8787
|
||||
timeCreated: 1664244096
|
||||
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/Stats System/Objects Stats/objectStatsInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu (fileName = "Object Stats Template", menuName = "GKC/Create Object Stats Template", order = 51)]
|
||||
public class objectStatsInfoTemplate : ScriptableObject
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID = 0;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool usedOnObject;
|
||||
|
||||
public List<string> usableObjectList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Object Stats Settings")]
|
||||
[Space]
|
||||
|
||||
public List<objectStatInfo> objectStatInfoList = new List<objectStatInfo> ();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aab22c978bb5e0c4a938f068b8128925
|
||||
timeCreated: 1664354883
|
||||
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/Stats System/Objects Stats/objectStatsInfoTemplate.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu (fileName = "Object Stats Template List", menuName = "GKC/Create Object Stats Template List", order = 51)]
|
||||
public class objectStatsInfoTemplateData : ScriptableObject
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID = 0;
|
||||
|
||||
[Space]
|
||||
|
||||
[TextArea (3, 5)] public string description;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public List<objectStatsInfoTemplate> objectStatsInfoTemplateList = new List<objectStatsInfoTemplate> ();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d957663987b8c8347af28e31ca66e1ed
|
||||
timeCreated: 1664355062
|
||||
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/Stats System/Objects Stats/objectStatsInfoTemplateData.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,199 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class objectStatsSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Stats Settings")]
|
||||
[Space]
|
||||
|
||||
public string objectName;
|
||||
|
||||
public bool useStats;
|
||||
|
||||
public float loadStatsDelay;
|
||||
|
||||
public List<statInfo> statInfoList = new List<statInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public bool characterLocated;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public GameObject mainCharacterGameObject;
|
||||
|
||||
public objectStatsInfoTemplate mainObjectStatsInfoTemplate;
|
||||
|
||||
|
||||
string currentStatNameToCheck;
|
||||
|
||||
public void addObjectStatsToMainManager ()
|
||||
{
|
||||
checkMainCharacterGameObject ();
|
||||
|
||||
if (characterLocated) {
|
||||
playerComponentsManager currentPlayerComponentsManager = mainCharacterGameObject.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
objectsStatsSystem currentobjectsStatsSystem = currentPlayerComponentsManager.getObjectsStatsSystem ();
|
||||
|
||||
if (currentobjectsStatsSystem != null) {
|
||||
currentobjectsStatsSystem.addObjectStatsSystem (this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMainCharacterGameObject (GameObject newObject)
|
||||
{
|
||||
mainCharacterGameObject = newObject;
|
||||
}
|
||||
|
||||
public void checkMainCharacterGameObject ()
|
||||
{
|
||||
if (characterLocated) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainCharacterGameObject == null) {
|
||||
getMainCharacterGameObject ();
|
||||
}
|
||||
|
||||
characterLocated = mainCharacterGameObject != null;
|
||||
}
|
||||
|
||||
public virtual void getMainCharacterGameObject ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void checkStatsStateOnLoad ()
|
||||
{
|
||||
if (useStats) {
|
||||
if (loadStatsDelay > 0) {
|
||||
setStatsOnLoadWithDelay ();
|
||||
} else {
|
||||
setStatsOnLoad ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setStatsOnLoadWithDelay ()
|
||||
{
|
||||
StartCoroutine (setStatsOnLoadCoroutine ());
|
||||
}
|
||||
|
||||
IEnumerator setStatsOnLoadCoroutine ()
|
||||
{
|
||||
yield return new WaitForSeconds (loadStatsDelay);
|
||||
|
||||
setStatsOnLoad ();
|
||||
}
|
||||
|
||||
public void setStatsOnLoad ()
|
||||
{
|
||||
if (useStats) {
|
||||
if (showDebugPrint) {
|
||||
print ("\n");
|
||||
print ("SETTING STATS INFO ON " + gameObject.name);
|
||||
|
||||
print ("\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < statInfoList.Count; i++) {
|
||||
statInfo currentStatInfo = statInfoList [i];
|
||||
|
||||
if (currentStatInfo.statIsAmount) {
|
||||
currentStatInfo.eventToInitializeFloatStat.Invoke (currentStatInfo.currentFloatValue);
|
||||
} else {
|
||||
currentStatInfo.eventToInitializeBoolStat.Invoke (currentStatInfo.currentBoolState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentStatNameToSave (string newValue)
|
||||
{
|
||||
currentStatNameToCheck = newValue;
|
||||
}
|
||||
|
||||
public void setCurrentFloatValueToSave (float newValue)
|
||||
{
|
||||
if (useStats) {
|
||||
for (int i = 0; i < statInfoList.Count; i++) {
|
||||
statInfo currentStatInfo = statInfoList [i];
|
||||
|
||||
if (currentStatInfo.Name.Equals (currentStatNameToCheck)) {
|
||||
currentStatInfo.currentFloatValue = newValue;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentBoolValueToSave (bool newValue)
|
||||
{
|
||||
if (useStats) {
|
||||
for (int i = 0; i < statInfoList.Count; i++) {
|
||||
statInfo currentStatInfo = statInfoList [i];
|
||||
|
||||
if (currentStatInfo.Name.Equals (currentStatNameToCheck)) {
|
||||
currentStatInfo.currentBoolState = newValue;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnStatsSave ()
|
||||
{
|
||||
if (useStats) {
|
||||
for (int i = 0; i < statInfoList.Count; i++) {
|
||||
statInfo currentStatInfo = statInfoList [i];
|
||||
|
||||
currentStatNameToCheck = currentStatInfo.Name;
|
||||
|
||||
if (currentStatInfo.statIsAmount) {
|
||||
currentStatInfo.eventToGetFloatStat.Invoke ();
|
||||
} else {
|
||||
currentStatInfo.eventToGetBoolStat.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class statInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool statIsAmount = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public float currentFloatValue;
|
||||
|
||||
public eventParameters.eventToCallWithAmount eventToInitializeFloatStat;
|
||||
|
||||
public UnityEvent eventToGetFloatStat;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool currentBoolState;
|
||||
|
||||
public eventParameters.eventToCallWithBool eventToInitializeBoolStat;
|
||||
|
||||
public UnityEvent eventToGetBoolStat;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 367d190aa6e56f146bbbda45db2d2f51
|
||||
timeCreated: 1664245089
|
||||
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/Stats System/Objects Stats/objectStatsSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class objectStatsSystemOnMeleeWeapons : objectStatsSystem
|
||||
{
|
||||
|
||||
|
||||
public override void getMainCharacterGameObject ()
|
||||
{
|
||||
grabPhysicalObjectMeleeAttackSystem currentGrabPhysicalObjectMeleeAttackSystem = GetComponent<grabPhysicalObjectMeleeAttackSystem> ();
|
||||
|
||||
if (currentGrabPhysicalObjectMeleeAttackSystem != null) {
|
||||
mainCharacterGameObject = currentGrabPhysicalObjectMeleeAttackSystem.getCurrentCharacter ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d057aecd26832244282fc0d0707d2203
|
||||
timeCreated: 1664355556
|
||||
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/Stats System/Objects Stats/objectStatsSystemOnMeleeWeapons.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,115 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class objectsStatsSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool objectsStatsSystemEnabled = true;
|
||||
|
||||
public List<objectStatsSystem> objectStatsSystemList = new List<objectStatsSystem> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Object Stats Template Settings")]
|
||||
[Space]
|
||||
|
||||
public List<objectStatsInfoTemplateData> objectStatsInfoTemplateDataList = new List<objectStatsInfoTemplateData> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Object Stats List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<objectStatsInfo> objectStatsInfoList = new List<objectStatsInfo> ();
|
||||
|
||||
|
||||
|
||||
public List<objectStatsInfoTemplateData> getObjectStatsInfoTemplateDataList ()
|
||||
{
|
||||
return objectStatsInfoTemplateDataList;
|
||||
}
|
||||
|
||||
public void addObjectStatsSystem (objectStatsSystem newObjectStatsSystem)
|
||||
{
|
||||
if (!objectsStatsSystemEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!objectStatsSystemList.Contains (newObjectStatsSystem)) {
|
||||
objectStatsSystemList.Add (newObjectStatsSystem);
|
||||
}
|
||||
}
|
||||
|
||||
public List<objectStatInfo> getStatsFromObjectByName (string objectName)
|
||||
{
|
||||
if (!objectsStatsSystemEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int currentObjectIndex = objectStatsSystemList.FindIndex (s => s.objectName.Equals (objectName));
|
||||
|
||||
if (currentObjectIndex > -1) {
|
||||
return objectStatsSystemList [currentObjectIndex].mainObjectStatsInfoTemplate.objectStatInfoList;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool objectCanBeUpgraded (string objectName)
|
||||
{
|
||||
if (!objectsStatsSystemEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int currentObjectIndex = objectStatsSystemList.FindIndex (s => s.objectName.Equals (objectName));
|
||||
|
||||
if (currentObjectIndex > -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void increaseStat (string statName, float statExtraValue)
|
||||
{
|
||||
if (!objectsStatsSystemEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// statInfo currentStatInfo = null;
|
||||
//
|
||||
// int statInfoListCount = statInfoList.Count;
|
||||
//
|
||||
// for (int k = 0; k < statInfoListCount; k++) {
|
||||
// currentStatInfo = statInfoList [k];
|
||||
//
|
||||
// if (currentStatInfo.Name.Equals (statName)) {
|
||||
// currentStatInfo.currentValue += statExtraValue;
|
||||
//
|
||||
// if (currentStatInfo.useMaxAmount) {
|
||||
// currentStatInfo.currentValue = Mathf.Clamp (currentStatInfo.currentValue, 0, getStatMaxAmountByIndex (k));
|
||||
// }
|
||||
//
|
||||
// if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
// currentStatInfo.customStatType.eventToIncreaseStat (statExtraValue);
|
||||
// } else {
|
||||
// currentStatInfo.eventToIncreaseStat.Invoke (statExtraValue);
|
||||
// }
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
public void setObjectsStatsSystemEnabledState (bool state)
|
||||
{
|
||||
objectsStatsSystemEnabled = state;
|
||||
}
|
||||
|
||||
public void setObjectsStatsSystemEnabledStateFromEditor (bool state)
|
||||
{
|
||||
setObjectsStatsSystemEnabledState (state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89fbb176551b85249a455c25d471396e
|
||||
timeCreated: 1664246635
|
||||
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/Stats System/Objects Stats/objectsStatsSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class externalStatsManager : MonoBehaviour
|
||||
{
|
||||
public playerStatsSystem mainPlayerStatsSystem;
|
||||
|
||||
public bool statsManagerEnabled = true;
|
||||
|
||||
string temporalStatName;
|
||||
|
||||
public void setTemporalStatName (string statName)
|
||||
{
|
||||
if (statsManagerEnabled) {
|
||||
temporalStatName = statName;
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlayerStateOfTemporalStat (float statExtraValue)
|
||||
{
|
||||
if (statsManagerEnabled) {
|
||||
if (temporalStatName != "") {
|
||||
updateStatValueExternally (temporalStatName, statExtraValue);
|
||||
|
||||
temporalStatName = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatValueExternally (string statName, float newValue)
|
||||
{
|
||||
if (statsManagerEnabled) {
|
||||
mainPlayerStatsSystem.updateStatValueExternally (statName, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatValueExternally (int statIndex, float newValue)
|
||||
{
|
||||
if (statsManagerEnabled) {
|
||||
mainPlayerStatsSystem.updateStatValueExternally (statIndex, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac88e212d6675ef4aa3a4f3743698bb7
|
||||
timeCreated: 1673192805
|
||||
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/Stats System/externalStatsManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class generalStatComponent : statType
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public int currentStatAmount;
|
||||
|
||||
|
||||
public override void eventToInitializeStat (float newValue)
|
||||
{
|
||||
currentStatAmount = (int)newValue;
|
||||
}
|
||||
|
||||
public override void eventToIncreaseStat (float newValue)
|
||||
{
|
||||
currentStatAmount += (int)newValue;
|
||||
}
|
||||
|
||||
public override void eventToUseStat (float newValue)
|
||||
{
|
||||
currentStatAmount -= (int)newValue;
|
||||
}
|
||||
|
||||
public override void eventToAddAmount (float newValue)
|
||||
{
|
||||
currentStatAmount += (int)newValue;
|
||||
}
|
||||
|
||||
public override void eventToInitializeBoolStat (bool newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void eventToActivateBoolStat (bool newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void eventToInitializeStatOnComponent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void eventToInitializeBoolStatOnComponent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void updateStatAmountWithoutUpdatingStatManager (int statId, float amount)
|
||||
{
|
||||
currentStatAmount = (int)amount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e5c1a4fc0ceb7d4698ea680a97da384
|
||||
timeCreated: 1665176359
|
||||
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/Stats System/generalStatComponent.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class persuasionSystem : statType
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public int currentPersuasionAmount;
|
||||
|
||||
|
||||
public override void eventToInitializeStat (float newValue)
|
||||
{
|
||||
currentPersuasionAmount = (int)newValue;
|
||||
}
|
||||
|
||||
public override void eventToIncreaseStat (float newValue)
|
||||
{
|
||||
currentPersuasionAmount += (int)newValue;
|
||||
}
|
||||
|
||||
public override void eventToUseStat (float newValue)
|
||||
{
|
||||
currentPersuasionAmount -= (int)newValue;
|
||||
}
|
||||
|
||||
public override void eventToAddAmount (float newValue)
|
||||
{
|
||||
currentPersuasionAmount += (int)newValue;
|
||||
}
|
||||
|
||||
public override void eventToInitializeBoolStat (bool newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void eventToActivateBoolStat (bool newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void eventToInitializeStatOnComponent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void eventToInitializeBoolStatOnComponent ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a25e9f7bc6da4141bace7196181d95a
|
||||
timeCreated: 1586870684
|
||||
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/Stats System/persuasionSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,795 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class playerStatsSystem : MonoBehaviour
|
||||
{
|
||||
public bool playerStatsActive = true;
|
||||
|
||||
public bool initializeStatsValuesAtStartActive = true;
|
||||
|
||||
public bool initializeStatsOnlyWhenLoadingGame;
|
||||
|
||||
public bool saveCurrentPlayerStatsToSaveFile;
|
||||
|
||||
public List<statInfo> statInfoList = new List<statInfo> ();
|
||||
|
||||
public bool isLoadingGame;
|
||||
|
||||
public bool initializeValuesWhenNotLoadingFromTemplate;
|
||||
|
||||
public statsSettingsTemplate mainStatsSettingsTemplate;
|
||||
|
||||
public bool useByAI;
|
||||
|
||||
|
||||
float currentMaxAmount;
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
if (useByAI) {
|
||||
initializeStatsValues ();
|
||||
}
|
||||
}
|
||||
|
||||
public void initializeStatsValues ()
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool initializingValuesFromTemplate = false;
|
||||
|
||||
if (initializeStatsValuesAtStartActive) {
|
||||
if (initializeValuesWhenNotLoadingFromTemplate && !isLoadingGame) {
|
||||
loadSettingsFromTemplate (false);
|
||||
|
||||
initializingValuesFromTemplate = true;
|
||||
}
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
if (initializeStatsValuesAtStartActive && (!initializeStatsOnlyWhenLoadingGame || isLoadingGame || initializingValuesFromTemplate)) {
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.initializeStatWithThisValue) {
|
||||
if (currentStatInfo.statIsAmount) {
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToInitializeStat (currentStatInfo.currentValue);
|
||||
} else {
|
||||
currentStatInfo.eventToInitializeStat.Invoke (currentStatInfo.currentValue);
|
||||
}
|
||||
} else {
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToInitializeBoolStat (currentStatInfo.currentBoolState);
|
||||
} else {
|
||||
currentStatInfo.eventToInitializeBoolStat.Invoke (currentStatInfo.currentBoolState);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentStatInfo.statIsAmount) {
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToInitializeStatOnComponent ();
|
||||
} else {
|
||||
currentStatInfo.eventToInitializeStatOnComponent.Invoke ();
|
||||
}
|
||||
} else {
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToInitializeBoolStatOnComponent ();
|
||||
} else {
|
||||
currentStatInfo.eventToInitializeBoolStatOnComponent.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsLoadingGameState (bool state)
|
||||
{
|
||||
isLoadingGame = state;
|
||||
}
|
||||
|
||||
public bool isLoadingGameState ()
|
||||
{
|
||||
return isLoadingGame;
|
||||
}
|
||||
|
||||
public float getStatMaxAmountByIndex (int statIndex)
|
||||
{
|
||||
statInfo currentStatInfo = statInfoList [statIndex];
|
||||
|
||||
currentMaxAmount = currentStatInfo.maxAmount;
|
||||
|
||||
if (currentStatInfo.useOtherStatAsMaxAmount) {
|
||||
currentMaxAmount = getStatValue (currentStatInfo.otherStatAsMaxAmountName);
|
||||
|
||||
if (currentMaxAmount < 0) {
|
||||
currentMaxAmount = currentStatInfo.currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
return currentMaxAmount;
|
||||
}
|
||||
|
||||
public float getStatMaxAmountByName (string statName)
|
||||
{
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
if (currentStatInfo.useMaxAmount) {
|
||||
currentMaxAmount = currentStatInfo.maxAmount;
|
||||
|
||||
if (currentStatInfo.useOtherStatAsMaxAmount) {
|
||||
currentMaxAmount = getStatValue (currentStatInfo.otherStatAsMaxAmountName);
|
||||
|
||||
if (currentMaxAmount < 0) {
|
||||
currentMaxAmount = currentStatInfo.currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
return currentMaxAmount;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool isStatOnMaxAmount (string statName)
|
||||
{
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
if (currentStatInfo.useMaxAmount) {
|
||||
currentMaxAmount = currentStatInfo.maxAmount;
|
||||
|
||||
if (currentStatInfo.useOtherStatAsMaxAmount) {
|
||||
currentMaxAmount = getStatValue (currentStatInfo.otherStatAsMaxAmountName);
|
||||
|
||||
if (currentMaxAmount < 0) {
|
||||
currentMaxAmount = currentStatInfo.currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentStatInfo.currentValue >= currentMaxAmount) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
string temporalStatName;
|
||||
|
||||
public void increasePlayerStatWithNameAndAmount (string statNameAndAmountString)
|
||||
{
|
||||
bool splitSymbolLocated = statNameAndAmountString.Contains (";");
|
||||
|
||||
if (splitSymbolLocated) {
|
||||
string [] nameAndAmount = statNameAndAmountString.Split (';');
|
||||
|
||||
if (nameAndAmount.Length > 1) {
|
||||
string nameValue = nameAndAmount [0];
|
||||
|
||||
float amountValue = float.Parse (nameAndAmount [1]);
|
||||
|
||||
if (amountValue > 0) {
|
||||
increasePlayerStat (nameValue, amountValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTemporalStatName (string statName)
|
||||
{
|
||||
temporalStatName = statName;
|
||||
}
|
||||
|
||||
public void increasePlayerStateOfTemporalStat (float statExtraValue)
|
||||
{
|
||||
if (temporalStatName != "") {
|
||||
increasePlayerStat (temporalStatName, statExtraValue);
|
||||
|
||||
temporalStatName = "";
|
||||
}
|
||||
}
|
||||
|
||||
public void increasePlayerStatByMultiplier (string statName, float statMultiplier)
|
||||
{
|
||||
float temporalValue = getStatValue (statName);
|
||||
|
||||
if (temporalValue > 0) {
|
||||
float amountToIncrease = (statMultiplier * temporalValue) / 100;
|
||||
|
||||
increasePlayerStat (statName, amountToIncrease);
|
||||
}
|
||||
}
|
||||
|
||||
public void increasePlayerStat (string statName, float statExtraValue)
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
currentStatInfo.currentValue += statExtraValue;
|
||||
|
||||
if (currentStatInfo.useMaxAmount) {
|
||||
currentStatInfo.currentValue = Mathf.Clamp (currentStatInfo.currentValue, 0, getStatMaxAmountByIndex (k));
|
||||
}
|
||||
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToIncreaseStat (statExtraValue);
|
||||
} else {
|
||||
currentStatInfo.eventToIncreaseStat.Invoke (statExtraValue);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void increaseExtraPlayerStat (string statName, float statExtraValue)
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
currentStatInfo.currentValue += statExtraValue;
|
||||
|
||||
currentStatInfo.extraCurrentValue += statExtraValue;
|
||||
|
||||
if (currentStatInfo.useMaxAmount) {
|
||||
currentStatInfo.currentValue = Mathf.Clamp (currentStatInfo.currentValue, 0, getStatMaxAmountByIndex (k));
|
||||
}
|
||||
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToIncreaseStat (statExtraValue);
|
||||
} else {
|
||||
currentStatInfo.eventToIncreaseStat.Invoke (statExtraValue);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void usePlayerStat (string statName, float statValueToUse)
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
currentStatInfo.currentValue -= statValueToUse;
|
||||
|
||||
if (currentStatInfo.currentValue < 0) {
|
||||
currentStatInfo.currentValue = 0;
|
||||
}
|
||||
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToUseStat (statValueToUse);
|
||||
} else {
|
||||
currentStatInfo.eventToUseStat.Invoke (statValueToUse);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void usePlayerStatByIndex (int statIndex, float statValueToUse)
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (statIndex < 0 || statIndex >= statInfoList.Count) {
|
||||
return;
|
||||
}
|
||||
|
||||
usePlayerStat (statInfoList [statIndex].Name, statValueToUse);
|
||||
}
|
||||
|
||||
public void addOrRemovePlayerStatAmount (string statName, float amountToUse)
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
currentStatInfo.currentValue += amountToUse;
|
||||
|
||||
if (currentStatInfo.currentValue < 0) {
|
||||
currentStatInfo.currentValue = 0;
|
||||
} else {
|
||||
if (currentStatInfo.useMaxAmount) {
|
||||
currentStatInfo.currentValue = Mathf.Clamp (currentStatInfo.currentValue, 0, getStatMaxAmountByIndex (k));
|
||||
}
|
||||
}
|
||||
|
||||
if (amountToUse > 0) {
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToAddAmount (amountToUse);
|
||||
} else {
|
||||
currentStatInfo.eventToAddAmount.Invoke (amountToUse);
|
||||
}
|
||||
} else {
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToUseStat (-amountToUse);
|
||||
} else {
|
||||
currentStatInfo.eventToUseStat.Invoke (-amountToUse);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string getStatName (int index)
|
||||
{
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (k == index) {
|
||||
return currentStatInfo.Name;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public List<string> getStatsNames ()
|
||||
{
|
||||
List<string> names = new List<string> ();
|
||||
|
||||
for (int k = 0; k < statInfoList.Count; k++) {
|
||||
names.Add (statInfoList [k].Name);
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
public float getStatValue (string statName)
|
||||
{
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
return currentStatInfo.currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool checkIfStatValueAvailable (string statName, int statAmount)
|
||||
{
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
return currentStatInfo.currentValue >= statAmount;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getStatValueByIndex (int statIndex)
|
||||
{
|
||||
if (statIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return statInfoList [statIndex].currentValue;
|
||||
}
|
||||
|
||||
public int getStatValueIndex (string statName)
|
||||
{
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void updateStatValue (string statName, float newValue)
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
currentStatInfo.currentValue = newValue;
|
||||
|
||||
if (currentStatInfo.useMaxAmount) {
|
||||
currentStatInfo.currentValue = Mathf.Clamp (currentStatInfo.currentValue, 0, getStatMaxAmountByIndex (k));
|
||||
}
|
||||
|
||||
if (currentStatInfo.useEventToSendValueOnUpdateStat) {
|
||||
currentStatInfo.eventToSendValueOnUpdateStat.Invoke (k, currentStatInfo.currentValue);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatValueExternally (int statIndex, float newValue)
|
||||
{
|
||||
updateStatValueExternally (getStatName (statIndex), newValue);
|
||||
}
|
||||
|
||||
public void updateStatValueExternally (string statName, float newValue)
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
currentStatInfo.currentValue = newValue;
|
||||
|
||||
if (currentStatInfo.useMaxAmount) {
|
||||
currentStatInfo.currentValue = Mathf.Clamp (currentStatInfo.currentValue, 0, getStatMaxAmountByIndex (k));
|
||||
}
|
||||
|
||||
if (currentStatInfo.useEventToSendValueOnUpdateStatExternally) {
|
||||
currentStatInfo.eventToSendValueOnUpdateStatExternally.Invoke (k, currentStatInfo.currentValue);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatValue (int statIndex, float newValue)
|
||||
{
|
||||
updateStatValue (getStatName (statIndex), newValue);
|
||||
}
|
||||
|
||||
public void enableOrDisableBoolPlayerStat (string statName, bool boolStateValue)
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
currentStatInfo.currentBoolState = boolStateValue;
|
||||
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToActivateBoolStat (boolStateValue);
|
||||
} else {
|
||||
currentStatInfo.eventToActivateBoolStat.Invoke (boolStateValue);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool getBoolStatValue (string statName)
|
||||
{
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
return currentStatInfo.currentBoolState;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateBoolStatValue (string statName, bool boolStateValue)
|
||||
{
|
||||
if (!playerStatsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
currentStatInfo = statInfoList [k];
|
||||
|
||||
if (currentStatInfo.Name.Equals (statName)) {
|
||||
currentStatInfo.currentBoolState = boolStateValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerStatsActiveState (bool state)
|
||||
{
|
||||
playerStatsActive = state;
|
||||
}
|
||||
|
||||
public void saveSettingsToTemplate ()
|
||||
{
|
||||
if (mainStatsSettingsTemplate == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainStatsSettingsTemplate.statTemplateInfoList.Clear ();
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int i = 0; i < statInfoListCount; i++) {
|
||||
statTemplateInfo newStatTemplateInfo = new statTemplateInfo ();
|
||||
|
||||
newStatTemplateInfo.Name = statInfoList [i].Name;
|
||||
|
||||
newStatTemplateInfo.currentValue = statInfoList [i].currentValue;
|
||||
|
||||
newStatTemplateInfo.currentBoolState = statInfoList [i].currentBoolState;
|
||||
|
||||
mainStatsSettingsTemplate.statTemplateInfoList.Add (newStatTemplateInfo);
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Save Stats Settings To Template", gameObject);
|
||||
|
||||
print ("States values saved to template");
|
||||
}
|
||||
|
||||
public void loadSettingsFromTemplate (bool loadingFromEditor)
|
||||
{
|
||||
if (mainStatsSettingsTemplate == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
statInfo currentStatInfo = null;
|
||||
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int i = 0; i < statInfoListCount; i++) {
|
||||
int statIndex = mainStatsSettingsTemplate.statTemplateInfoList.FindIndex (a => a.Name == statInfoList [i].Name);
|
||||
|
||||
if (statIndex > -1) {
|
||||
|
||||
statTemplateInfo newStatTemplateInfo = mainStatsSettingsTemplate.statTemplateInfoList [statIndex];
|
||||
|
||||
currentStatInfo = statInfoList [i];
|
||||
|
||||
currentStatInfo.currentBoolState = newStatTemplateInfo.currentBoolState;
|
||||
currentStatInfo.currentValue = newStatTemplateInfo.currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (loadingFromEditor) {
|
||||
updateComponent ();
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Load Stats Settings From Template", gameObject);
|
||||
|
||||
print ("Stats values loaded from template");
|
||||
}
|
||||
}
|
||||
|
||||
public void initializeAllStatValuesFromEditor ()
|
||||
{
|
||||
int statInfoListCount = statInfoList.Count;
|
||||
|
||||
for (int k = 0; k < statInfoListCount; k++) {
|
||||
initializeStatValueFromEditor (statInfoList [k].Name, false);
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Initialize All Stat Values From Editor", gameObject);
|
||||
}
|
||||
|
||||
public void initializeStatValueFromEditor (string statName, bool updateComponentValue)
|
||||
{
|
||||
int statIndex = statInfoList.FindIndex (a => a.Name.Equals (statName));
|
||||
|
||||
if (statIndex > -1) {
|
||||
statInfo currentStatInfo = statInfoList [statIndex];
|
||||
|
||||
if (currentStatInfo.statIsAmount) {
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToInitializeStat (currentStatInfo.currentValue);
|
||||
} else {
|
||||
currentStatInfo.eventToInitializeStat.Invoke (currentStatInfo.currentValue);
|
||||
}
|
||||
} else {
|
||||
if (currentStatInfo.useCustomStatTypeForEvents) {
|
||||
currentStatInfo.customStatType.eventToInitializeBoolStat (currentStatInfo.currentBoolState);
|
||||
} else {
|
||||
currentStatInfo.eventToInitializeBoolStat.Invoke (currentStatInfo.currentBoolState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateComponentValue) {
|
||||
updateComponent ();
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Initialize Stat Value From Editor", gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatValueFromEditor (string statName, float newValue)
|
||||
{
|
||||
updateStatValue (statName, newValue);
|
||||
|
||||
updateComponent ();
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Stat Value From Editor", gameObject);
|
||||
}
|
||||
|
||||
public void setPlayerStatsActiveStateFromEditor (bool state)
|
||||
{
|
||||
setPlayerStatsActiveState (state);
|
||||
|
||||
updateComponent ();
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Stats System", gameObject);
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class statInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool statIsAmount = true;
|
||||
|
||||
public float currentValue;
|
||||
|
||||
public float extraCurrentValue;
|
||||
|
||||
public eventParameters.eventToCallWithAmount eventToInitializeStat;
|
||||
|
||||
public eventParameters.eventToCallWithAmount eventToIncreaseStat;
|
||||
|
||||
public eventParameters.eventToCallWithAmount eventToUseStat;
|
||||
|
||||
public eventParameters.eventToCallWithAmount eventToAddAmount;
|
||||
|
||||
[FormerlySerializedAs ("useEventToSendValueOnUpdateState")]
|
||||
public bool useEventToSendValueOnUpdateStat;
|
||||
|
||||
[FormerlySerializedAs ("eventToSendValueOnUpdateState")]
|
||||
public eventParameters.eventToCallWithIntAndFloat eventToSendValueOnUpdateStat;
|
||||
|
||||
public bool currentBoolState;
|
||||
|
||||
public eventParameters.eventToCallWithBool eventToInitializeBoolStat;
|
||||
|
||||
public eventParameters.eventToCallWithBool eventToActivateBoolStat;
|
||||
|
||||
public bool initializeStatWithThisValue = true;
|
||||
public UnityEvent eventToInitializeStatOnComponent;
|
||||
public UnityEvent eventToInitializeBoolStatOnComponent;
|
||||
|
||||
public bool useCustomStatTypeForEvents;
|
||||
public statType customStatType;
|
||||
|
||||
public bool useMaxAmount;
|
||||
public float maxAmount;
|
||||
public bool useOtherStatAsMaxAmount;
|
||||
public string otherStatAsMaxAmountName;
|
||||
|
||||
public bool useEventToSendValueOnUpdateStatExternally;
|
||||
|
||||
public eventParameters.eventToCallWithIntAndFloat eventToSendValueOnUpdateStatExternally;
|
||||
|
||||
public bool ignoreStatInitializationOnLoadGame;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class statTemplateInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public float currentValue;
|
||||
|
||||
public bool currentBoolState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5429c70e4eb60434181af41846a8f5cb
|
||||
timeCreated: 1564469533
|
||||
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/Stats System/playerStatsSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,123 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class showValuesOnScreenSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool showValueEnabled = true;
|
||||
|
||||
public bool addExtraString;
|
||||
public string extraString;
|
||||
public bool addExtraStringAtStart;
|
||||
|
||||
[Space]
|
||||
[Header ("Stats Settings")]
|
||||
[Space]
|
||||
|
||||
public string statNameToShow;
|
||||
public bool showStatValueOnStart;
|
||||
|
||||
[Space]
|
||||
[Header ("Inventory Settings")]
|
||||
[Space]
|
||||
|
||||
public string inventoryObjectNameToShow;
|
||||
public bool showInventoryObjectAmountOnStart;
|
||||
|
||||
[Space]
|
||||
[Header ("HUD Settings")]
|
||||
[Space]
|
||||
|
||||
public GameObject valueTextPanel;
|
||||
public Text valueText;
|
||||
|
||||
public GameObject playerGameObject;
|
||||
|
||||
bool panelActive;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (!showValueEnabled) {
|
||||
if (valueTextPanel.activeSelf) {
|
||||
valueTextPanel.SetActive (false);
|
||||
}
|
||||
}
|
||||
|
||||
if (showStatValueOnStart || showInventoryObjectAmountOnStart) {
|
||||
StartCoroutine (showValueOnStartCoroutine ());
|
||||
}
|
||||
}
|
||||
|
||||
public void showInventoryObjectAmountByName ()
|
||||
{
|
||||
if (inventoryObjectNameToShow != "") {
|
||||
float newValue = GKC_Utils.getInventoryObjectAmountByName (inventoryObjectNameToShow, playerGameObject);
|
||||
|
||||
if (newValue > -1) {
|
||||
updateValueAmount (newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showStatByName ()
|
||||
{
|
||||
if (statNameToShow != "") {
|
||||
float newValue = GKC_Utils.getStateValueByName (statNameToShow, playerGameObject);
|
||||
|
||||
if (newValue > -1) {
|
||||
updateValueAmount (newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateValueAmount (int IDValue, float newValue)
|
||||
{
|
||||
updateValueAmount (newValue);
|
||||
}
|
||||
|
||||
public void updateValueAmount (float newValue)
|
||||
{
|
||||
if (!showValueEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!panelActive) {
|
||||
if (!valueTextPanel.activeSelf) {
|
||||
valueTextPanel.SetActive (true);
|
||||
}
|
||||
|
||||
panelActive = true;
|
||||
}
|
||||
|
||||
string valueString = newValue.ToString ();
|
||||
|
||||
if (addExtraString) {
|
||||
if (addExtraStringAtStart) {
|
||||
valueString = extraString + valueString;
|
||||
} else {
|
||||
valueString += extraString;
|
||||
}
|
||||
}
|
||||
|
||||
valueText.text = valueString;
|
||||
}
|
||||
|
||||
IEnumerator showValueOnStartCoroutine ()
|
||||
{
|
||||
WaitForSeconds delay = new WaitForSeconds (0.3f);
|
||||
|
||||
yield return delay;
|
||||
|
||||
if (showInventoryObjectAmountOnStart) {
|
||||
showInventoryObjectAmountByName ();
|
||||
}
|
||||
|
||||
if (showStatValueOnStart) {
|
||||
showStatByName ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60ed666c0e27e3f4d90646c15beb1632
|
||||
timeCreated: 1635815085
|
||||
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/Stats System/showValuesOnScreenSystem.cs
|
||||
uploadId: 814740
|
||||
51
Assets/Game Kit Controller/Scripts/Stats System/statType.cs
Normal file
51
Assets/Game Kit Controller/Scripts/Stats System/statType.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class statType : MonoBehaviour
|
||||
{
|
||||
public virtual void eventToInitializeStat (float newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void eventToIncreaseStat (float newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void eventToUseStat (float newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void eventToAddAmount (float newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void eventToInitializeBoolStat (bool newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void eventToActivateBoolStat (bool newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void eventToInitializeStatOnComponent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void eventToInitializeBoolStatOnComponent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void updateStatAmountWithoutUpdatingStatManager (int statId, float amount)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4411305d8d31b044a54f421c817b9f6
|
||||
timeCreated: 1586863703
|
||||
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/Stats System/statType.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu (fileName = "Stats Settings Template", menuName = "GKC/Create Stats Template", order = 51)]
|
||||
public class statsSettingsTemplate : ScriptableObject
|
||||
{
|
||||
public int characterTemplateID = 0;
|
||||
public List<playerStatsSystem.statTemplateInfo> statTemplateInfoList = new List<playerStatsSystem.statTemplateInfo> ();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80ab432db80e26144ae44149495e4d8b
|
||||
timeCreated: 1625717225
|
||||
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/Stats System/statsSettingsTemplate.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class templateStatTypeComponent : statType
|
||||
{
|
||||
public float currentStatAmount;
|
||||
|
||||
public bool currentStateBoolValue;
|
||||
|
||||
public override void eventToInitializeStat (float newValue)
|
||||
{
|
||||
currentStatAmount = newValue;
|
||||
}
|
||||
|
||||
public override void eventToIncreaseStat (float newValue)
|
||||
{
|
||||
currentStatAmount += newValue;
|
||||
}
|
||||
|
||||
public override void eventToUseStat (float newValue)
|
||||
{
|
||||
currentStatAmount -= newValue;
|
||||
}
|
||||
|
||||
public override void eventToAddAmount (float newValue)
|
||||
{
|
||||
currentStatAmount += newValue;
|
||||
}
|
||||
|
||||
public override void eventToInitializeBoolStat (bool newValue)
|
||||
{
|
||||
currentStateBoolValue = newValue;
|
||||
}
|
||||
|
||||
public override void eventToActivateBoolStat (bool newValue)
|
||||
{
|
||||
currentStateBoolValue = newValue;
|
||||
}
|
||||
|
||||
public override void eventToInitializeStatOnComponent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void eventToInitializeBoolStatOnComponent ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void updateStatAmountWithoutUpdatingStatManager (int statId, float amount)
|
||||
{
|
||||
currentStatAmount = amount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da7381abdfb4722418123c76821fe7b5
|
||||
timeCreated: 1586871757
|
||||
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/Stats System/templateStatTypeComponent.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user