add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,896 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class playerSkillsSystem : MonoBehaviour
|
||||
{
|
||||
public bool playerSkillsActive = true;
|
||||
|
||||
public bool initializeSkillsValuesAtStartActive = true;
|
||||
|
||||
public bool initializeSkillsOnlyWhenLoadingGame;
|
||||
|
||||
public bool saveCurrentPlayerSkillsToSaveFile;
|
||||
|
||||
public List<skillCategoryInfo> skillCategoryInfoList = new List<skillCategoryInfo> ();
|
||||
|
||||
public skillInfo currentSkillInfo;
|
||||
|
||||
public skillLevelInfo currentSkillLevelInfo;
|
||||
|
||||
public bool isLoadingGame;
|
||||
|
||||
public bool initializeValuesWhenNotLoadingFromTemplate;
|
||||
|
||||
public skillSettingsTemplate mainSkillSettingsTemplate;
|
||||
|
||||
public playerStatsSystem mainPlayerStatsSystem;
|
||||
|
||||
bool mainPlayerStatsSystemLocated;
|
||||
|
||||
|
||||
public bool isLoadingGameActive ()
|
||||
{
|
||||
return isLoadingGame;
|
||||
}
|
||||
|
||||
|
||||
public void initializeSkillsValues ()
|
||||
{
|
||||
if (!playerSkillsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool initializingValuesFromTemplate = false;
|
||||
|
||||
if (initializeSkillsValuesAtStartActive) {
|
||||
if (initializeValuesWhenNotLoadingFromTemplate && !isLoadingGame) {
|
||||
loadSettingsFromTemplate (false);
|
||||
|
||||
initializingValuesFromTemplate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (initializeSkillsValuesAtStartActive && (!initializeSkillsOnlyWhenLoadingGame || isLoadingGame || initializingValuesFromTemplate)) {
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.skillEnabled) {
|
||||
|
||||
if (initializingValuesFromTemplate) {
|
||||
if (currentSkillInfo.skillCompleteFromTemplate) {
|
||||
currentSkillInfo.currentValue = currentSkillInfo.valueToConfigure;
|
||||
|
||||
currentSkillInfo.currentBoolState = currentSkillInfo.boolStateToConfigure;
|
||||
|
||||
currentSkillInfo.skillUnlocked = true;
|
||||
|
||||
currentSkillInfo.skillActive = true;
|
||||
|
||||
currentSkillInfo.currentSkillLevel = currentSkillInfo.skillLevelInfoList.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSkillInfo.useFloatValue) {
|
||||
currentSkillInfo.eventToInitializeSkill.Invoke (currentSkillInfo.currentValue);
|
||||
}
|
||||
|
||||
if (currentSkillInfo.useBoolValue) {
|
||||
if (currentSkillInfo.useTwoEventsForActiveAndNotActive) {
|
||||
if (currentSkillInfo.currentBoolState) {
|
||||
currentSkillInfo.eventToInitializeSkillActive.Invoke ();
|
||||
} else {
|
||||
currentSkillInfo.eventToInitializeSkillNotActive.Invoke ();
|
||||
}
|
||||
|
||||
} else {
|
||||
currentSkillInfo.eventToInitializeBoolSkill.Invoke (currentSkillInfo.currentBoolState);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSkillInfo.useSkillLevel) {
|
||||
if (currentSkillInfo.skillActive) {
|
||||
|
||||
int currentSkillLevel = currentSkillInfo.currentSkillLevel;
|
||||
|
||||
if (currentSkillInfo.skillLevelInfoList.Count > currentSkillLevel) {
|
||||
currentSkillLevelInfo = currentSkillInfo.skillLevelInfoList [currentSkillLevel];
|
||||
|
||||
if (currentSkillLevelInfo.useFloatValue) {
|
||||
currentSkillLevelInfo.eventToInitializeSkill.Invoke (currentSkillLevelInfo.currentValue);
|
||||
}
|
||||
|
||||
if (currentSkillLevelInfo.useBoolValue) {
|
||||
currentSkillLevelInfo.eventToInitializeBoolSkill.Invoke (currentSkillLevelInfo.currentBoolState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsLoadingGameState (bool state)
|
||||
{
|
||||
isLoadingGame = state;
|
||||
}
|
||||
|
||||
public bool isLoadingGameState ()
|
||||
{
|
||||
return isLoadingGame;
|
||||
}
|
||||
|
||||
public void increasePlayerSkill (string skillName, float skillExtraValue)
|
||||
{
|
||||
if (!playerSkillsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
currentSkillInfo.currentValue += skillExtraValue;
|
||||
|
||||
currentSkillInfo.eventToIncreaseSkill.Invoke (skillExtraValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getSkillValue (string skillName)
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
return currentSkillInfo.currentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void updateSkillValue (string skillName, float newValue)
|
||||
{
|
||||
if (!playerSkillsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
currentSkillInfo.currentValue = newValue;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableOrDisableBoolPlayerSkill (string skillName, bool boolSkillValue)
|
||||
{
|
||||
if (!playerSkillsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
currentSkillInfo.currentBoolState = boolSkillValue;
|
||||
|
||||
currentSkillInfo.eventToActivateBoolSkill.Invoke (boolSkillValue);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool getBoolSkillValue (string skillName)
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
return currentSkillInfo.currentBoolState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateBoolSkillValue (string skillName, bool boolSkillValue)
|
||||
{
|
||||
if (!playerSkillsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
currentSkillInfo.currentBoolState = boolSkillValue;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public skillInfo getSkillInfoByIndex (int categoryIndex, int skillIndex)
|
||||
{
|
||||
if (categoryIndex < skillCategoryInfoList.Count && skillIndex < skillCategoryInfoList [categoryIndex].skillInfoList.Count) {
|
||||
return skillCategoryInfoList [categoryIndex].skillInfoList [skillIndex];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int useSkillPoints (int categoryIndex, int skillIndex, int totalSkillPoints, bool ignoreSkillPoints)
|
||||
{
|
||||
skillInfo skillInfoToUse = skillCategoryInfoList [categoryIndex].skillInfoList [skillIndex];
|
||||
|
||||
int neededSkillPoints = 0;
|
||||
|
||||
int currentSkillLevel = skillInfoToUse.currentSkillLevel;
|
||||
|
||||
if (skillInfoToUse.useSkillLevel && skillInfoToUse.skillActive) {
|
||||
if (skillInfoToUse.skillLevelInfoList.Count > currentSkillLevel) {
|
||||
neededSkillPoints = skillInfoToUse.skillLevelInfoList [currentSkillLevel].neededSkillPoints;
|
||||
|
||||
skillInfoToUse.currentSkillLevel++;
|
||||
|
||||
if (skillInfoToUse.currentSkillLevel > skillInfoToUse.skillLevelInfoList.Count - 1) {
|
||||
skillInfoToUse.currentSkillLevel = skillInfoToUse.skillLevelInfoList.Count - 1;
|
||||
}
|
||||
|
||||
if (currentSkillLevel > skillInfoToUse.skillLevelInfoList.Count - 1) {
|
||||
currentSkillLevel = skillInfoToUse.skillLevelInfoList.Count - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
neededSkillPoints = skillInfoToUse.neededSkillPoints;
|
||||
}
|
||||
|
||||
if (neededSkillPoints <= totalSkillPoints || ignoreSkillPoints) {
|
||||
|
||||
bool useRegularSkillEvent = false;
|
||||
bool useLevelSkillEvent = false;
|
||||
|
||||
if (skillInfoToUse.useSkillLevel) {
|
||||
if (skillInfoToUse.skillActive) {
|
||||
if (currentSkillLevel == skillInfoToUse.skillLevelInfoList.Count - 1) {
|
||||
skillInfoToUse.skillComplete = true;
|
||||
}
|
||||
|
||||
useLevelSkillEvent = true;
|
||||
useRegularSkillEvent = true;
|
||||
} else {
|
||||
useRegularSkillEvent = true;
|
||||
}
|
||||
} else {
|
||||
skillInfoToUse.skillComplete = true;
|
||||
|
||||
useRegularSkillEvent = true;
|
||||
}
|
||||
|
||||
if (useRegularSkillEvent) {
|
||||
if (skillInfoToUse.useFloatValue) {
|
||||
skillInfoToUse.currentValue = skillInfoToUse.valueToConfigure;
|
||||
skillInfoToUse.eventToIncreaseSkill.Invoke (skillInfoToUse.currentValue);
|
||||
}
|
||||
|
||||
if (skillInfoToUse.useBoolValue) {
|
||||
skillInfoToUse.currentBoolState = skillInfoToUse.boolStateToConfigure;
|
||||
skillInfoToUse.eventToActivateBoolSkill.Invoke (skillInfoToUse.currentBoolState);
|
||||
}
|
||||
|
||||
if (skillInfoToUse.useStatToIncrease) {
|
||||
if (!mainPlayerStatsSystemLocated) {
|
||||
mainPlayerStatsSystemLocated = mainPlayerStatsSystem != null;
|
||||
}
|
||||
|
||||
if (mainPlayerStatsSystemLocated) {
|
||||
if (skillInfoToUse.amountIsStatMultiplier) {
|
||||
mainPlayerStatsSystem.increasePlayerStatByMultiplier (skillInfoToUse.statToIncreaseName, skillInfoToUse.statToIncreaseAmount);
|
||||
} else {
|
||||
mainPlayerStatsSystem.increasePlayerStat (skillInfoToUse.statToIncreaseName, skillInfoToUse.statToIncreaseAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useLevelSkillEvent) {
|
||||
|
||||
// print ("level " + currentSkillLevel);
|
||||
|
||||
currentSkillLevelInfo = skillInfoToUse.skillLevelInfoList [currentSkillLevel];
|
||||
|
||||
if (currentSkillLevelInfo.useFloatValue) {
|
||||
currentSkillLevelInfo.eventToIncreaseSkill.Invoke (currentSkillLevelInfo.currentValue);
|
||||
}
|
||||
|
||||
if (currentSkillLevelInfo.useBoolValue) {
|
||||
currentSkillLevelInfo.eventToActivateBoolSkill.Invoke (currentSkillLevelInfo.currentBoolState);
|
||||
}
|
||||
|
||||
if (currentSkillLevelInfo.useStatToIncrease) {
|
||||
if (!mainPlayerStatsSystemLocated) {
|
||||
mainPlayerStatsSystemLocated = mainPlayerStatsSystem != null;
|
||||
}
|
||||
|
||||
if (mainPlayerStatsSystemLocated) {
|
||||
if (currentSkillLevelInfo.amountIsStatMultiplier) {
|
||||
mainPlayerStatsSystem.increasePlayerStatByMultiplier (currentSkillLevelInfo.statToIncreaseName, currentSkillLevelInfo.statToIncreaseAmount);
|
||||
} else {
|
||||
mainPlayerStatsSystem.increasePlayerStat (currentSkillLevelInfo.statToIncreaseName, currentSkillLevelInfo.statToIncreaseAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skillInfoToUse.skillActive = true;
|
||||
|
||||
// print (skillInfoToUse.Name + " " + skillInfoToUse.skillActive);
|
||||
|
||||
return neededSkillPoints;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void getSkillByName (string skillName)
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
useSkillPoints (i, k, 0, true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disableSkillByName (string skillName)
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.skillEnabled && currentSkillInfo.skillActive) {
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
currentSkillInfo.skillComplete = false;
|
||||
|
||||
if (currentSkillInfo.useFloatValue) {
|
||||
currentSkillInfo.currentValue = 0;
|
||||
}
|
||||
|
||||
if (currentSkillInfo.useBoolValue) {
|
||||
currentSkillInfo.currentBoolState = !currentSkillInfo.boolStateToConfigure;
|
||||
}
|
||||
|
||||
currentSkillInfo.skillActive = false;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disableAllSkills ()
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.skillEnabled) {
|
||||
currentSkillInfo.skillComplete = false;
|
||||
|
||||
if (currentSkillInfo.useFloatValue) {
|
||||
currentSkillInfo.currentValue = 0;
|
||||
}
|
||||
|
||||
if (currentSkillInfo.useBoolValue) {
|
||||
currentSkillInfo.currentBoolState = !currentSkillInfo.boolStateToConfigure;
|
||||
}
|
||||
|
||||
if (currentSkillInfo.useSkillLevel) {
|
||||
currentSkillInfo.currentSkillLevel = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unlockSkillSlotByName (string skillName)
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
currentSkillInfo.skillUnlocked = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getCategoryIndex (string categoryName)
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
if (skillCategoryInfoList [i].Name.Equals (categoryName)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getSkillIndex (string skillName)
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getSkillIndex (string skillCategoryName, string skillName)
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
if (currentSkillCategoryInfo.Name.Equals (skillCategoryName)) {
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.Name.Equals (skillName)) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setPlayerSkillsActiveState (bool state)
|
||||
{
|
||||
playerSkillsActive = state;
|
||||
}
|
||||
|
||||
public void saveSettingsToTemplate ()
|
||||
{
|
||||
if (mainSkillSettingsTemplate == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainSkillSettingsTemplate.skillTemplateCategoryInfoList.Clear ();
|
||||
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillTemplateCategoryInfo newSkillTemplateCategoryInfo = new skillTemplateCategoryInfo ();
|
||||
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
newSkillTemplateCategoryInfo.Name = currentSkillCategoryInfo.Name;
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
skillTemplateInfo newSkillTemplateInfo = new skillTemplateInfo ();
|
||||
|
||||
newSkillTemplateInfo.Name = currentSkillInfo.Name;
|
||||
|
||||
newSkillTemplateInfo.skillEnabled = currentSkillInfo.skillEnabled;
|
||||
|
||||
newSkillTemplateInfo.skillComplete = currentSkillInfo.skillComplete;
|
||||
|
||||
newSkillTemplateCategoryInfo.skillTemplateInfoList.Add (newSkillTemplateInfo);
|
||||
}
|
||||
|
||||
mainSkillSettingsTemplate.skillTemplateCategoryInfoList.Add (newSkillTemplateCategoryInfo);
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Save Skills Settings To Template", gameObject);
|
||||
|
||||
print ("Skills values saved to template");
|
||||
}
|
||||
|
||||
public void loadSettingsFromTemplate (bool loadingFromEditor)
|
||||
{
|
||||
if (mainSkillSettingsTemplate == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
skillCategoryInfo currentSkillCategoryInfo = skillCategoryInfoList [i];
|
||||
|
||||
int categoryIndex = mainSkillSettingsTemplate.skillTemplateCategoryInfoList.FindIndex (a => a.Name == currentSkillCategoryInfo.Name);
|
||||
|
||||
if (categoryIndex > -1) {
|
||||
|
||||
skillTemplateCategoryInfo newSkillTemplateCategoryInfo = mainSkillSettingsTemplate.skillTemplateCategoryInfoList [categoryIndex];
|
||||
|
||||
int skillInfoListCount = currentSkillCategoryInfo.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
currentSkillInfo = currentSkillCategoryInfo.skillInfoList [k];
|
||||
|
||||
int skillIndex = newSkillTemplateCategoryInfo.skillTemplateInfoList.FindIndex (a => a.Name == currentSkillInfo.Name);
|
||||
|
||||
if (skillIndex > -1) {
|
||||
skillTemplateInfo newSkillTemplateInfo = newSkillTemplateCategoryInfo.skillTemplateInfoList [skillIndex];
|
||||
|
||||
currentSkillInfo.skillEnabled = newSkillTemplateInfo.skillEnabled;
|
||||
|
||||
currentSkillInfo.skillCompleteFromTemplate = newSkillTemplateInfo.skillComplete;
|
||||
|
||||
currentSkillInfo.skillComplete = newSkillTemplateInfo.skillComplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (loadingFromEditor) {
|
||||
updateComponent ();
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Load Skills Settings From Template", gameObject);
|
||||
|
||||
print ("Skills values loaded from template");
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllSkillsCompleteStateOnTemplate (bool state)
|
||||
{
|
||||
if (mainSkillSettingsTemplate == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < mainSkillSettingsTemplate.skillTemplateCategoryInfoList.Count; i++) {
|
||||
for (int k = 0; k < mainSkillSettingsTemplate.skillTemplateCategoryInfoList [i].skillTemplateInfoList.Count; k++) {
|
||||
mainSkillSettingsTemplate.skillTemplateCategoryInfoList [i].skillTemplateInfoList [k].skillComplete = state;
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Skills Settings To Template", gameObject);
|
||||
|
||||
print ("All skills complete state configured as " + state);
|
||||
}
|
||||
|
||||
public void enableAllSkillsOnEditor ()
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
enableOrDisableSkillsOnEditor (true, i);
|
||||
}
|
||||
}
|
||||
|
||||
public void disableAllSkillsOnEditor ()
|
||||
{
|
||||
int skillCategoryInfoListCount = skillCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < skillCategoryInfoListCount; i++) {
|
||||
enableOrDisableSkillsOnEditor (false, i);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableSkillsOnEditor (int categoryIndex)
|
||||
{
|
||||
enableOrDisableSkillsOnEditor (true, categoryIndex);
|
||||
}
|
||||
|
||||
public void disableSkillsOnEditor (int categoryIndex)
|
||||
{
|
||||
enableOrDisableSkillsOnEditor (false, categoryIndex);
|
||||
}
|
||||
|
||||
public void enableOrDisableSkillsOnEditor (bool state, int categoryIndex)
|
||||
{
|
||||
skillCategoryInfo currentCategory = skillCategoryInfoList [categoryIndex];
|
||||
|
||||
int skillInfoListCount = currentCategory.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
currentCategory.skillInfoList [k].skillEnabled = state;
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void activateSkillsOnEditor (int categoryIndex)
|
||||
{
|
||||
activateOrDeactivateSkillsOnEditor (true, categoryIndex);
|
||||
}
|
||||
|
||||
public void deactivateSkillsOnEditor (int categoryIndex)
|
||||
{
|
||||
activateOrDeactivateSkillsOnEditor (false, categoryIndex);
|
||||
}
|
||||
|
||||
public void activateOrDeactivateSkillsOnEditor (bool state, int categoryIndex)
|
||||
{
|
||||
skillCategoryInfo currentCategory = skillCategoryInfoList [categoryIndex];
|
||||
|
||||
int skillInfoListCount = currentCategory.skillInfoList.Count;
|
||||
|
||||
for (int k = 0; k < skillInfoListCount; k++) {
|
||||
|
||||
currentSkillInfo = currentCategory.skillInfoList [k];
|
||||
|
||||
if (currentSkillInfo.skillEnabled) {
|
||||
|
||||
if (currentSkillInfo.useBoolValue) {
|
||||
if (state) {
|
||||
currentSkillInfo.currentBoolState = currentSkillInfo.boolStateToConfigure;
|
||||
} else {
|
||||
currentSkillInfo.currentBoolState = !currentSkillInfo.boolStateToConfigure;
|
||||
}
|
||||
} else {
|
||||
if (state) {
|
||||
currentSkillInfo.currentValue = currentSkillInfo.valueToConfigure;
|
||||
} else {
|
||||
currentSkillInfo.currentValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setPlayerSkillsActiveStateFromEditor (bool state)
|
||||
{
|
||||
setPlayerSkillsActiveState (state);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Skills Values", gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class skillCategoryInfo
|
||||
{
|
||||
public string Name;
|
||||
public List<skillInfo> skillInfoList = new List<skillInfo> ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class skillInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool skillEnabled = true;
|
||||
|
||||
[TextArea (1, 10)] public string skillDescription;
|
||||
|
||||
public int neededSkillPoints = 1;
|
||||
|
||||
public bool skillUnlocked;
|
||||
|
||||
public bool skillActive;
|
||||
|
||||
public bool skillComplete;
|
||||
|
||||
public bool useFloatValue;
|
||||
|
||||
public float currentValue;
|
||||
|
||||
public float valueToConfigure;
|
||||
|
||||
public eventParameters.eventToCallWithAmount eventToInitializeSkill;
|
||||
|
||||
public eventParameters.eventToCallWithAmount eventToIncreaseSkill;
|
||||
|
||||
public bool useBoolValue;
|
||||
|
||||
public bool currentBoolState;
|
||||
|
||||
public bool boolStateToConfigure;
|
||||
|
||||
public eventParameters.eventToCallWithBool eventToInitializeBoolSkill;
|
||||
|
||||
public eventParameters.eventToCallWithBool eventToActivateBoolSkill;
|
||||
|
||||
public bool useTwoEventsForActiveAndNotActive;
|
||||
|
||||
public UnityEvent eventToInitializeSkillActive;
|
||||
|
||||
public UnityEvent eventToInitializeSkillNotActive;
|
||||
|
||||
public bool useSkillLevel;
|
||||
|
||||
public int currentSkillLevel;
|
||||
|
||||
public List<skillLevelInfo> skillLevelInfoList = new List<skillLevelInfo> ();
|
||||
|
||||
public bool skillCompleteFromTemplate;
|
||||
|
||||
public bool useStatToIncrease;
|
||||
public string statToIncreaseName;
|
||||
public float statToIncreaseAmount;
|
||||
public bool amountIsStatMultiplier;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class skillLevelInfo
|
||||
{
|
||||
[TextArea (1, 10)] public string skillLevelDescription;
|
||||
|
||||
public int neededSkillPoints = 1;
|
||||
|
||||
public bool useFloatValue;
|
||||
public float currentValue;
|
||||
|
||||
public eventParameters.eventToCallWithAmount eventToInitializeSkill;
|
||||
|
||||
public eventParameters.eventToCallWithAmount eventToIncreaseSkill;
|
||||
|
||||
public bool useBoolValue;
|
||||
public bool currentBoolState;
|
||||
public eventParameters.eventToCallWithBool eventToInitializeBoolSkill;
|
||||
|
||||
public eventParameters.eventToCallWithBool eventToActivateBoolSkill;
|
||||
|
||||
public bool useStatToIncrease;
|
||||
public string statToIncreaseName;
|
||||
public float statToIncreaseAmount;
|
||||
public bool amountIsStatMultiplier;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class skillTemplateCategoryInfo
|
||||
{
|
||||
public string Name;
|
||||
public List<skillTemplateInfo> skillTemplateInfoList = new List<skillTemplateInfo> ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class skillTemplateInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool skillEnabled = true;
|
||||
|
||||
public bool skillComplete;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cc19c9c30b6e29488f139f94be8696b
|
||||
timeCreated: 1568428066
|
||||
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/Skills System/playerSkillsSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,566 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
using GKC.Localization;
|
||||
|
||||
public class playerSkillsUISystem : MonoBehaviour
|
||||
{
|
||||
public List<skillUICategoryInfo> skillUICategoryInfoList = new List<skillUICategoryInfo> ();
|
||||
|
||||
public bool skillsMenuOpened;
|
||||
|
||||
public bool showLockedSkillName = true;
|
||||
public string lockedSkillNameToShow = "???";
|
||||
public bool showLockedSkillDescription = true;
|
||||
public string lockedSkillDescriptionToShow = "???";
|
||||
|
||||
public bool useDoublePressToShowIncreaseSkillButtonEnabled = true;
|
||||
|
||||
public GameObject skillsMenuPanel;
|
||||
|
||||
public Text currentSkillCategoryNameText;
|
||||
public Text currentSkillNameText;
|
||||
public Text currentSkillDescriptionText;
|
||||
public Text currentSkillLevelDescriptionText;
|
||||
public Text currentSkillPointsText;
|
||||
|
||||
public Text requiredSkillPointsText;
|
||||
|
||||
public RectTransform confirmUseSkillPointsPanel;
|
||||
|
||||
public Scrollbar categoryScrollBar;
|
||||
public RectTransform categoryListContent;
|
||||
public ScrollRect categoryScrollRect;
|
||||
|
||||
public UnityEvent eventOnSkillMenuOpened;
|
||||
public UnityEvent eventOnSkillMenuClosed;
|
||||
|
||||
public UnityEvent eventOnSkillPointsUsed;
|
||||
public UnityEvent eventOnNotEnoughSkillPoints;
|
||||
|
||||
public playerExperienceSystem playerExperienceManager;
|
||||
public playerSkillsSystem playerSkillsManager;
|
||||
|
||||
public skillUICategoryInfo currentSkillUICategoryInfo;
|
||||
|
||||
public skillUIInfo currentSkillUIInfo;
|
||||
public skillUIInfo previousSkillUIInfo;
|
||||
|
||||
public skillSlotPanelInfo currentSkillSlotPanelInfo;
|
||||
|
||||
public string skillSlotsName = "Skill Slot ";
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
playerSkillsSystem.skillInfo currentSkillInfo;
|
||||
|
||||
|
||||
public void updateSkillSlots ()
|
||||
{
|
||||
for (int i = 0; i < skillUICategoryInfoList.Count; i++) {
|
||||
|
||||
currentSkillUICategoryInfo = skillUICategoryInfoList [i];
|
||||
|
||||
for (int k = 0; k < currentSkillUICategoryInfo.skillUIInfoList.Count; k++) {
|
||||
|
||||
currentSkillUIInfo = currentSkillUICategoryInfo.skillUIInfoList [k];
|
||||
|
||||
currentSkillInfo = playerSkillsManager.getSkillInfoByIndex (currentSkillUIInfo.categorySkillIndex, currentSkillUIInfo.skillIndex);
|
||||
|
||||
if (currentSkillInfo != null) {
|
||||
if (currentSkillInfo.skillUnlocked) {
|
||||
if (currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotLocked.activeSelf) {
|
||||
currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotLocked.SetActive (false);
|
||||
}
|
||||
|
||||
if (currentSkillInfo.skillActive) {
|
||||
if (!currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotActive.activeSelf) {
|
||||
currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotActive.SetActive (true);
|
||||
}
|
||||
} else {
|
||||
if (!currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotUnlocked.activeSelf) {
|
||||
currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotUnlocked.SetActive (true);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSkillInfo.useSkillLevel) {
|
||||
|
||||
if (!currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotSkillAmountText.gameObject.activeSelf) {
|
||||
currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotSkillAmountText.gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
if (currentSkillInfo.skillComplete) {
|
||||
currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotSkillAmountText.text = (currentSkillInfo.currentSkillLevel + 1) + "/" +
|
||||
currentSkillInfo.skillLevelInfoList.Count;
|
||||
} else {
|
||||
currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotSkillAmountText.text = currentSkillInfo.currentSkillLevel + "/" +
|
||||
currentSkillInfo.skillLevelInfoList.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("skill with category and index " + currentSkillUIInfo.categorySkillIndex + " " + currentSkillUIInfo.skillIndex + " not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void openOrCloseSkillsMenu (bool state)
|
||||
{
|
||||
skillsMenuOpened = state;
|
||||
|
||||
if (skillsMenuPanel.activeSelf != skillsMenuOpened) {
|
||||
skillsMenuPanel.SetActive (skillsMenuOpened);
|
||||
}
|
||||
|
||||
previousSkillUIInfo = null;
|
||||
|
||||
if (skillsMenuOpened) {
|
||||
|
||||
updateSkillSlots ();
|
||||
|
||||
checkSkillCategoryPressed (skillUICategoryInfoList [0].categorySlot);
|
||||
|
||||
eventOnSkillMenuOpened.Invoke ();
|
||||
|
||||
resetScroll (categoryScrollBar);
|
||||
|
||||
resetScrollRectTransfrom (categoryListContent, categoryScrollRect);
|
||||
} else {
|
||||
if (confirmUseSkillPointsPanel.gameObject.activeSelf) {
|
||||
confirmUseSkillPointsPanel.gameObject.SetActive (false);
|
||||
}
|
||||
|
||||
eventOnSkillMenuClosed.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkSkillPressed (GameObject skillSlot)
|
||||
{
|
||||
for (int i = 0; i < skillUICategoryInfoList.Count; i++) {
|
||||
|
||||
currentSkillUICategoryInfo = skillUICategoryInfoList [i];
|
||||
|
||||
for (int k = 0; k < currentSkillUICategoryInfo.skillUIInfoList.Count; k++) {
|
||||
|
||||
currentSkillUIInfo = currentSkillUICategoryInfo.skillUIInfoList [k];
|
||||
|
||||
if (currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.skillSlot == skillSlot) {
|
||||
|
||||
if (confirmUseSkillPointsPanel.gameObject.activeSelf) {
|
||||
confirmUseSkillPointsPanel.gameObject.SetActive (false);
|
||||
}
|
||||
|
||||
if (previousSkillUIInfo != null) {
|
||||
if (previousSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotPressedIcon.activeSelf) {
|
||||
previousSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotPressedIcon.SetActive (false);
|
||||
}
|
||||
}
|
||||
|
||||
updateCurrentSkillInfo ();
|
||||
|
||||
bool activateUseOfSkillPoints = false;
|
||||
|
||||
if (currentSkillUIInfo != previousSkillUIInfo) {
|
||||
previousSkillUIInfo = currentSkillUIInfo;
|
||||
} else {
|
||||
activateUseOfSkillPoints = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("different");
|
||||
}
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (currentSkillUIInfo.Name);
|
||||
}
|
||||
|
||||
if (!currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotPressedIcon.activeSelf) {
|
||||
currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotPressedIcon.SetActive (true);
|
||||
}
|
||||
|
||||
currentSkillInfo = playerSkillsManager.getSkillInfoByIndex (currentSkillUIInfo.categorySkillIndex, currentSkillUIInfo.skillIndex);
|
||||
|
||||
if (currentSkillInfo != null) {
|
||||
if (currentSkillInfo.skillComplete || !currentSkillInfo.skillUnlocked) {
|
||||
if (showDebugPrint) {
|
||||
print ("return");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!useDoublePressToShowIncreaseSkillButtonEnabled) {
|
||||
activateUseOfSkillPoints = true;
|
||||
}
|
||||
|
||||
if (activateUseOfSkillPoints) {
|
||||
if (!confirmUseSkillPointsPanel.gameObject.activeSelf) {
|
||||
confirmUseSkillPointsPanel.gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
confirmUseSkillPointsPanel.position = currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.confirmUseSkillPointsPanelPosition.position;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCurrentSkillInfo ()
|
||||
{
|
||||
bool isCheckLanguageActive = gameLanguageSelector.isCheckLanguageActive ();
|
||||
|
||||
string currentSkillUICategoryInfoName = currentSkillUICategoryInfo.Name;
|
||||
|
||||
string currentSkillUIInfoName = currentSkillUIInfo.Name;
|
||||
|
||||
string lockedSkillNameToShowValue = lockedSkillNameToShow;
|
||||
|
||||
string lockedSkillDescriptionToShowValue = lockedSkillDescriptionToShow;
|
||||
|
||||
|
||||
if (isCheckLanguageActive) {
|
||||
currentSkillUICategoryInfoName = skillsLocalizationManager.GetLocalizedValue (currentSkillUICategoryInfoName);
|
||||
currentSkillUIInfoName = skillsLocalizationManager.GetLocalizedValue (currentSkillUIInfoName);
|
||||
lockedSkillNameToShowValue = skillsLocalizationManager.GetLocalizedValue (lockedSkillNameToShowValue);
|
||||
lockedSkillDescriptionToShowValue = skillsLocalizationManager.GetLocalizedValue (lockedSkillDescriptionToShowValue);
|
||||
}
|
||||
|
||||
|
||||
currentSkillCategoryNameText.text = currentSkillUICategoryInfoName;
|
||||
|
||||
currentSkillInfo = playerSkillsManager.getSkillInfoByIndex (currentSkillUIInfo.categorySkillIndex, currentSkillUIInfo.skillIndex);
|
||||
|
||||
if (currentSkillInfo != null) {
|
||||
if (showLockedSkillName) {
|
||||
currentSkillNameText.text = currentSkillUIInfoName;
|
||||
} else {
|
||||
if (currentSkillInfo.skillUnlocked) {
|
||||
currentSkillNameText.text = currentSkillUIInfoName;
|
||||
} else {
|
||||
currentSkillNameText.text = lockedSkillNameToShowValue;
|
||||
}
|
||||
}
|
||||
|
||||
bool showSkilLevelDescription = true;
|
||||
|
||||
string currentSkillInfoSkillDescription = currentSkillInfo.skillDescription;
|
||||
|
||||
if (isCheckLanguageActive) {
|
||||
currentSkillInfoSkillDescription = skillsLocalizationManager.GetLocalizedValue (currentSkillInfoSkillDescription);
|
||||
}
|
||||
|
||||
if (showLockedSkillDescription) {
|
||||
currentSkillDescriptionText.text = currentSkillInfoSkillDescription;
|
||||
} else {
|
||||
if (currentSkillInfo.skillUnlocked) {
|
||||
currentSkillDescriptionText.text = currentSkillInfoSkillDescription;
|
||||
} else {
|
||||
currentSkillDescriptionText.text = lockedSkillDescriptionToShowValue;
|
||||
|
||||
showSkilLevelDescription = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (showSkilLevelDescription) {
|
||||
if (currentSkillInfo.useSkillLevel) {
|
||||
if (currentSkillInfo.skillLevelInfoList.Count > currentSkillInfo.currentSkillLevel) {
|
||||
string skillLevelDescription = currentSkillInfo.skillLevelInfoList [currentSkillInfo.currentSkillLevel].skillLevelDescription;
|
||||
|
||||
if (isCheckLanguageActive) {
|
||||
skillLevelDescription = skillsLocalizationManager.GetLocalizedValue (skillLevelDescription);
|
||||
}
|
||||
|
||||
currentSkillLevelDescriptionText.text = skillLevelDescription;
|
||||
}
|
||||
} else {
|
||||
currentSkillLevelDescriptionText.text = "";
|
||||
}
|
||||
} else {
|
||||
if (currentSkillInfo.useSkillLevel && currentSkillInfo.skillLevelInfoList.Count > currentSkillInfo.currentSkillLevel &&
|
||||
currentSkillInfo.skillLevelInfoList [currentSkillInfo.currentSkillLevel].skillLevelDescription != "") {
|
||||
currentSkillLevelDescriptionText.text = lockedSkillDescriptionToShowValue;
|
||||
} else {
|
||||
currentSkillLevelDescriptionText.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
currentSkillPointsText.text = playerExperienceManager.getSkillPointsAmount ().ToString ();
|
||||
|
||||
if (currentSkillInfo.skillComplete) {
|
||||
requiredSkillPointsText.text = "";
|
||||
} else {
|
||||
if (currentSkillInfo.useSkillLevel) {
|
||||
if (currentSkillInfo.skillLevelInfoList.Count > currentSkillInfo.currentSkillLevel) {
|
||||
requiredSkillPointsText.text = currentSkillInfo.skillLevelInfoList [currentSkillInfo.currentSkillLevel].neededSkillPoints.ToString ();
|
||||
}
|
||||
} else {
|
||||
requiredSkillPointsText.text = currentSkillInfo.neededSkillPoints.ToString ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void confirmUseSkillPointsOnCurrentSkillSlot ()
|
||||
{
|
||||
if (currentSkillUIInfo != null) {
|
||||
|
||||
int skillPointsUsed = playerSkillsManager.useSkillPoints (currentSkillUIInfo.categorySkillIndex, currentSkillUIInfo.skillIndex, playerExperienceManager.getSkillPointsAmount (), false);
|
||||
|
||||
currentSkillInfo = playerSkillsManager.getSkillInfoByIndex (currentSkillUIInfo.categorySkillIndex, currentSkillUIInfo.skillIndex);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (skillPointsUsed);
|
||||
}
|
||||
|
||||
if (currentSkillInfo != null) {
|
||||
if (skillPointsUsed > 0) {
|
||||
playerExperienceManager.useSkillPoints (skillPointsUsed);
|
||||
|
||||
currentSkillSlotPanelInfo = currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo;
|
||||
|
||||
if (!currentSkillSlotPanelInfo.slotActive.activeSelf) {
|
||||
currentSkillSlotPanelInfo.slotActive.SetActive (true);
|
||||
}
|
||||
|
||||
if (currentSkillSlotPanelInfo.slotUnlocked.activeSelf) {
|
||||
currentSkillSlotPanelInfo.slotUnlocked.SetActive (false);
|
||||
}
|
||||
|
||||
if (currentSkillInfo.useSkillLevel && currentSkillInfo.skillActive) {
|
||||
if (!currentSkillSlotPanelInfo.slotSkillAmountText.gameObject.activeSelf) {
|
||||
currentSkillSlotPanelInfo.slotSkillAmountText.gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
if (currentSkillInfo.skillComplete) {
|
||||
currentSkillSlotPanelInfo.slotSkillAmountText.text = (currentSkillInfo.currentSkillLevel + 1) + "/" + currentSkillInfo.skillLevelInfoList.Count;
|
||||
} else {
|
||||
currentSkillSlotPanelInfo.slotSkillAmountText.text = currentSkillInfo.currentSkillLevel + "/" + currentSkillInfo.skillLevelInfoList.Count;
|
||||
}
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("try unlock " + currentSkillUIInfo.unlockOtherSkillSlots);
|
||||
}
|
||||
|
||||
if (currentSkillUIInfo.unlockOtherSkillSlots && (!currentSkillUIInfo.unlockWhenCurrentSlotIsComplete || currentSkillInfo.skillComplete)) {
|
||||
|
||||
if (!currentSkillInfo.useSkillLevel || !currentSkillUIInfo.useMinSkillLevelToUnlock ||
|
||||
(currentSkillUIInfo.useMinSkillLevelToUnlock && currentSkillInfo.currentSkillLevel >= currentSkillUIInfo.minSkillLevelToUnlock)) {
|
||||
|
||||
for (int i = 0; i < currentSkillUICategoryInfo.skillUIInfoList.Count; i++) {
|
||||
if (currentSkillUIInfo.skillNameListToUnlock.Contains (currentSkillUICategoryInfo.skillUIInfoList [i].Name)) {
|
||||
unlockSkillSlot (i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateCurrentSkillInfo ();
|
||||
|
||||
eventOnSkillPointsUsed.Invoke ();
|
||||
} else {
|
||||
eventOnNotEnoughSkillPoints.Invoke ();
|
||||
}
|
||||
|
||||
if (confirmUseSkillPointsPanel.gameObject.activeSelf) {
|
||||
confirmUseSkillPointsPanel.gameObject.SetActive (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelUseSkillPointsOnCurrentSkillSlot ()
|
||||
{
|
||||
if (confirmUseSkillPointsPanel.gameObject.activeSelf) {
|
||||
confirmUseSkillPointsPanel.gameObject.SetActive (false);
|
||||
}
|
||||
}
|
||||
|
||||
public void unlockSkillSlot (int skillSlotIndex)
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("unlock " + currentSkillUICategoryInfo.skillUIInfoList [skillSlotIndex].Name);
|
||||
}
|
||||
|
||||
// currentSkillInfo = playerSkillsManager.getSkillInfoByIndex (currentSkillUIInfo.categorySkillIndex, currentSkillUIInfo.skillIndex);
|
||||
|
||||
currentSkillSlotPanelInfo = currentSkillUICategoryInfo.skillUIInfoList [skillSlotIndex].mainSkillSlotPanel.mainSkillSlotPanelInfo;
|
||||
|
||||
if (currentSkillSlotPanelInfo.slotLocked.activeSelf) {
|
||||
currentSkillSlotPanelInfo.slotLocked.SetActive (false);
|
||||
}
|
||||
|
||||
if (!currentSkillSlotPanelInfo.slotUnlocked.activeSelf) {
|
||||
currentSkillSlotPanelInfo.slotUnlocked.SetActive (true);
|
||||
}
|
||||
|
||||
playerSkillsManager.unlockSkillSlotByName (currentSkillUICategoryInfo.skillUIInfoList [skillSlotIndex].Name);
|
||||
}
|
||||
|
||||
public void checkSkillCategoryPressed (GameObject categorySlot)
|
||||
{
|
||||
previousSkillUIInfo = null;
|
||||
|
||||
for (int i = 0; i < skillUICategoryInfoList.Count; i++) {
|
||||
if (skillUICategoryInfoList [i].categorySlot == categorySlot) {
|
||||
if (!skillUICategoryInfoList [i].categorySkillPanel.activeSelf) {
|
||||
skillUICategoryInfoList [i].categorySkillPanel.SetActive (true);
|
||||
}
|
||||
|
||||
if (currentSkillUIInfo != null) {
|
||||
if (currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotPressedIcon.activeSelf) {
|
||||
currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.slotPressedIcon.SetActive (false);
|
||||
}
|
||||
}
|
||||
|
||||
checkSkillPressed (skillUICategoryInfoList [i].skillUIInfoList [0].mainSkillSlotPanel.mainSkillSlotPanelInfo.skillSlot);
|
||||
} else {
|
||||
if (skillUICategoryInfoList [i].categorySkillPanel.activeSelf) {
|
||||
skillUICategoryInfoList [i].categorySkillPanel.SetActive (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (confirmUseSkillPointsPanel.gameObject.activeSelf) {
|
||||
confirmUseSkillPointsPanel.gameObject.SetActive (false);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetScroll (Scrollbar scrollBarToReset)
|
||||
{
|
||||
StartCoroutine (resetScrollCoroutine (scrollBarToReset));
|
||||
}
|
||||
|
||||
IEnumerator resetScrollCoroutine (Scrollbar scrollBarToReset)
|
||||
{
|
||||
yield return new WaitForEndOfFrame ();
|
||||
yield return new WaitForEndOfFrame ();
|
||||
|
||||
scrollBarToReset.value = 1;
|
||||
}
|
||||
|
||||
public void resetScrollRectTransfrom (RectTransform listContent, ScrollRect scrollRectToReset)
|
||||
{
|
||||
StartCoroutine (resetScrollRectTransfromCoroutine (listContent, scrollRectToReset));
|
||||
}
|
||||
|
||||
IEnumerator resetScrollRectTransfromCoroutine (RectTransform listContent, ScrollRect scrollRectToReset)
|
||||
{
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate (listContent);
|
||||
|
||||
yield return new WaitForEndOfFrame ();
|
||||
yield return new WaitForEndOfFrame ();
|
||||
|
||||
scrollRectToReset.verticalNormalizedPosition = 1;
|
||||
}
|
||||
|
||||
public void assignSkillsToSlots ()
|
||||
{
|
||||
for (int i = 0; i < skillUICategoryInfoList.Count; i++) {
|
||||
for (int k = 0; k < skillUICategoryInfoList [i].skillUIInfoList.Count; k++) {
|
||||
|
||||
currentSkillUIInfo = skillUICategoryInfoList [i].skillUIInfoList [k];
|
||||
|
||||
currentSkillUIInfo.categorySkillIndex = playerSkillsManager.getCategoryIndex (skillUICategoryInfoList [i].Name);
|
||||
currentSkillUIInfo.skillIndex = playerSkillsManager.getSkillIndex (skillUICategoryInfoList [i].Name, currentSkillUIInfo.Name);
|
||||
|
||||
if (showDebugPrint) {
|
||||
if (currentSkillUIInfo.categorySkillIndex != -1 && currentSkillUIInfo.skillIndex != -1) {
|
||||
print ("Assigned skill " + currentSkillUIInfo.Name + " " + currentSkillUIInfo.categorySkillIndex + " " + currentSkillUIInfo.skillIndex);
|
||||
} else {
|
||||
print ("WARNING: the skill slot with the name " + currentSkillUIInfo.Name + " hasn't found the skill configured. Make sure it exists");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("All skills assigned to every slot");
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void assignSkillsNamesToSlots (int listIndex)
|
||||
{
|
||||
for (int k = 0; k < skillUICategoryInfoList [listIndex].skillUIInfoList.Count; k++) {
|
||||
|
||||
currentSkillUIInfo = skillUICategoryInfoList [listIndex].skillUIInfoList [k];
|
||||
|
||||
if (currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.skillSlot != null) {
|
||||
currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.skillSlot.name = skillSlotsName + currentSkillUIInfo.Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("All skills names assigned to every slot");
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void activateAllSkills (int listIndex)
|
||||
{
|
||||
checkSkillCategoryPressed (skillUICategoryInfoList [listIndex].categorySlot);
|
||||
|
||||
for (int k = 0; k < skillUICategoryInfoList [listIndex].skillUIInfoList.Count; k++) {
|
||||
|
||||
currentSkillUIInfo = skillUICategoryInfoList [listIndex].skillUIInfoList [k];
|
||||
|
||||
checkSkillPressed (currentSkillUIInfo.mainSkillSlotPanel.mainSkillSlotPanelInfo.skillSlot);
|
||||
|
||||
confirmUseSkillPointsOnCurrentSkillSlot ();
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("All skills on category " + skillUICategoryInfoList [listIndex].Name + " activated");
|
||||
}
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update UI Skills", gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class skillUICategoryInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public GameObject categorySlot;
|
||||
|
||||
public GameObject categorySkillPanel;
|
||||
|
||||
public List<skillUIInfo> skillUIInfoList = new List<skillUIInfo> ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class skillUIInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public skillSlotPanel mainSkillSlotPanel;
|
||||
|
||||
public int categorySkillIndex;
|
||||
public int skillIndex;
|
||||
|
||||
public bool unlockOtherSkillSlots;
|
||||
|
||||
public bool unlockWhenCurrentSlotIsComplete;
|
||||
|
||||
public bool useMinSkillLevelToUnlock;
|
||||
public int minSkillLevelToUnlock;
|
||||
|
||||
public List<string> skillNameListToUnlock = new List<string> ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4695c35fe6f8c144381671f205406190
|
||||
timeCreated: 1568510564
|
||||
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/Skills System/playerSkillsUISystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu (fileName = "Skills Settings Template", menuName = "GKC/Create Skills Template", order = 51)]
|
||||
public class skillSettingsTemplate : ScriptableObject
|
||||
{
|
||||
public int characterTemplateID = 0;
|
||||
public List<playerSkillsSystem.skillTemplateCategoryInfo> skillTemplateCategoryInfoList = new List<playerSkillsSystem.skillTemplateCategoryInfo> ();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6495758bbd7256b4281811af209cb0a5
|
||||
timeCreated: 1625712047
|
||||
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/Skills System/skillSettingsTemplate.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class skillSlotPanel : MonoBehaviour
|
||||
{
|
||||
public skillSlotPanelInfo mainSkillSlotPanelInfo;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 007b5de948df4da458b901386f4cd73b
|
||||
timeCreated: 1568483693
|
||||
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/Skills System/skillSlotPanel.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[System.Serializable]
|
||||
public class skillSlotPanelInfo
|
||||
{
|
||||
public GameObject skillSlot;
|
||||
public GameObject slotActive;
|
||||
public GameObject slotLocked;
|
||||
public GameObject slotUnlocked;
|
||||
public Text slotSkillAmountText;
|
||||
public GameObject slotPressedIcon;
|
||||
|
||||
public Transform confirmUseSkillPointsPanelPosition;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9304cdf11e4eb44f8d5d0bb304b235f
|
||||
timeCreated: 1568484879
|
||||
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/Skills System/skillSlotPanelInfo.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user