Пример #1
0
 void OnEnable()
 {
     systemConfigurationManager = GameObject.FindObjectOfType <SystemConfigurationManager>();
     if (systemConfigurationManager != null)
     {
         gameName = systemConfigurationManager.GameName;
     }
 }
Пример #2
0
        private void MakeGameManagerPrefabVariant(GameObject goToMakeVariantOf, string newPath)
        {
            // instantiate original
            GameObject instantiatedGO = (GameObject)PrefabUtility.InstantiatePrefab(goToMakeVariantOf);

            instantiatedGO.name = fileSystemGameName + instantiatedGO.name;

            // Set the properties of the GameManager for this game
            EditorUtility.DisplayProgressBar("New Game Wizard", "Configuration Game Settings...", 0.91f);
            SystemConfigurationManager systemConfigurationManager = instantiatedGO.GetComponent <SystemConfigurationManager>();

            systemConfigurationManager.GameName            = gameName;
            systemConfigurationManager.GameVersion         = gameVersion;
            systemConfigurationManager.InitializationScene = fileSystemGameName;
            systemConfigurationManager.MainMenuScene       = "MainMenu";
            systemConfigurationManager.DefaultStartingZone = fileSystemFirstSceneName;

            if (useThirdPartyController == true)
            {
                systemConfigurationManager.UseThirdPartyMovementControl = true;
                systemConfigurationManager.AllowAutoAttack              = false;
                systemConfigurationManager.UseThirdPartyCameraControl   = true;
                systemConfigurationManager.DefaultPlayerUnitProfileName = "Invector UMA Player";
                if (thirdPartyCameraPrefab != null)
                {
                    systemConfigurationManager.ThirdPartyCamera = thirdPartyCameraPrefab;
                }
                //systemConfigurationManager.CharacterCreatorProfileNames = new List<string>() { "Invector UMA Player" };
            }

            EditorUtility.DisplayProgressBar("New Game Wizard", "Copying resources...", 0.92f);
            // Create a Resources folder and point the game manager to it
            if (systemConfigurationManager.LoadResourcesFolders == null)
            {
                systemConfigurationManager.LoadResourcesFolders = new List <string>();
            }

            string newResourcesFolderName = fileSystemGameName;

            systemConfigurationManager.LoadResourcesFolders.Add(newResourcesFolderName);

            // make variant on disk
            Debug.Log("saving " + newPath);
            GameObject variant = PrefabUtility.SaveAsPrefabAsset(instantiatedGO, newPath);

            // remove original from scene
            GameObject.DestroyImmediate(instantiatedGO);

            // instantiate new variant in scene
            //PrefabUtility.InstantiatePrefab(variant);
            GameObject sceneVariant = (GameObject)PrefabUtility.InstantiatePrefab(variant);

            sceneVariant.name = goToMakeVariantOf.name;
        }
Пример #3
0
        void GenericLoadList <T>(string folder) where T : ResourceProfile
        {
            masterList.Add(Resources.LoadAll <T>(folder));
            SystemConfigurationManager systemConfigurationManager = GameObject.FindObjectOfType <SystemConfigurationManager>();

            if (systemConfigurationManager != null)
            {
                foreach (string resourceFolderName in systemConfigurationManager.LoadResourcesFolders)
                {
                    masterList.Add(Resources.LoadAll <T>(resourceFolderName + "/" + folder));
                }
            }
        }
Пример #4
0
        private void MakeGameManagerPrefabVariant(GameObject goToMakeVariantOf, string newPath)
        {
            // instantiate original
            GameObject instantiatedGO = (GameObject)PrefabUtility.InstantiatePrefab(goToMakeVariantOf);

            instantiatedGO.name = fileSystemGameName + instantiatedGO.name;

            // Set the properties of the GameManager for this game
            EditorUtility.DisplayProgressBar("New Game Wizard", "Configuration Game Settings...", 0.75f);
            SystemConfigurationManager systemConfigurationManager = instantiatedGO.GetComponent <SystemConfigurationManager>();

            systemConfigurationManager.GameName            = gameName;
            systemConfigurationManager.GameVersion         = gameVersion;
            systemConfigurationManager.InitializationScene = fileSystemGameName;
            systemConfigurationManager.MainMenuScene       = "MainMenu";
            systemConfigurationManager.DefaultStartingZone = fileSystemFirstSceneName;

            EditorUtility.DisplayProgressBar("New Game Wizard", "Copying resources...", 0.8f);
            // Create a Resources folder and point the game manager to it
            if (systemConfigurationManager.LoadResourcesFolders == null)
            {
                systemConfigurationManager.LoadResourcesFolders = new List <string>();
            }

            string newResourcesFolderName = fileSystemGameName;

            systemConfigurationManager.LoadResourcesFolders.Add(newResourcesFolderName);

            // make variant on disk
            GameObject variant = PrefabUtility.SaveAsPrefabAsset(instantiatedGO, newPath);

            // remove original from scene
            GameObject.DestroyImmediate(instantiatedGO);

            // instantiate new variant in scene
            //PrefabUtility.InstantiatePrefab(variant);
            GameObject sceneVariant = (GameObject)PrefabUtility.InstantiatePrefab(variant);

            sceneVariant.name = goToMakeVariantOf.name;
        }
Пример #5
0
        public static int GetXPAmountForQuest(int sourceLevel, Quest quest, SystemConfigurationManager systemConfigurationManager)
        {
            float multiplierValue = 1f;

            if (systemConfigurationManager.UseQuestXPLevelMultiplierDemoninator == true)
            {
                multiplierValue = 1f / Mathf.Clamp(sourceLevel, 0, (systemConfigurationManager.QuestXPMultiplierLevelCap > 0 ? systemConfigurationManager.QuestXPMultiplierLevelCap : Mathf.Infinity));
            }

            int experiencePerLevel = systemConfigurationManager.QuestXPPerLevel + quest.ExperienceRewardPerLevel;
            int baseExperience     = systemConfigurationManager.BaseQuestXP + quest.BaseExperienceReward;

            int baseXP = (int)(((quest.ExperienceLevel * experiencePerLevel) * multiplierValue) + baseExperience);

            if (sourceLevel <= quest.ExperienceLevel + 5)
            {
                return(baseXP);
            }
            if (sourceLevel == quest.ExperienceLevel + 6)
            {
                return((int)(baseXP * 0.8));
            }
            if (sourceLevel == quest.ExperienceLevel + 7)
            {
                return((int)(baseXP * 0.6));
            }
            if (sourceLevel == quest.ExperienceLevel + 8)
            {
                return((int)(baseXP * 0.4));
            }
            if (sourceLevel == quest.ExperienceLevel + 9)
            {
                return((int)(baseXP * 0.2));
            }
            if (sourceLevel == quest.ExperienceLevel + 10)
            {
                return((int)(baseXP * 0.1));
            }
            return(0);
        }
Пример #6
0
        public static int GetXPAmountForKill(int sourceLevel, BaseCharacter targetCharacter, SystemConfigurationManager systemConfigurationManager)
        {
            float multiplierValue          = 1f;
            float toughnessMultiplierValue = 1f;

            if (systemConfigurationManager.UseKillXPLevelMultiplierDemoninator == true)
            {
                multiplierValue = 1f / Mathf.Clamp(sourceLevel, 0, (systemConfigurationManager.KillXPMultiplierLevelCap > 0 ? systemConfigurationManager.KillXPMultiplierLevelCap : Mathf.Infinity));
            }
            if (targetCharacter.CharacterStats.Toughness != null)
            {
                toughnessMultiplierValue = targetCharacter.CharacterStats.Toughness.ExperienceMultiplier;
            }

            int baseXP = (int)((((sourceLevel * systemConfigurationManager.KillXPPerLevel) * multiplierValue) + systemConfigurationManager.BaseKillXP) * toughnessMultiplierValue);

            int totalXP = 0;

            if (sourceLevel < targetCharacter.CharacterStats.Level)
            {
                // higher level mob
                totalXP = (int)(baseXP * (1 + 0.05 * (targetCharacter.CharacterStats.Level - sourceLevel)));
            }
            else if (sourceLevel == targetCharacter.CharacterStats.Level)
            {
                totalXP = baseXP;
            }
            else if (targetCharacter.CharacterStats.Level > GetGrayLevel(sourceLevel))
            {
                totalXP = baseXP * (1 - (sourceLevel - targetCharacter.CharacterStats.Level) / ZeroDifference(sourceLevel));
            }
            return(totalXP);
        }
Пример #7
0
 public static int GetXPNeededForLevel(int _level, SystemConfigurationManager systemConfigurationManager)
 {
     return(_level * systemConfigurationManager.XpRequiredPerLevel);
 }
Пример #8
0
        public static float GetPrimaryStatForLevel(string statName, int level, BaseCharacter baseCharacter, SystemConfigurationManager systemConfigurationManager)
        {
            float extraStatPerLevel = 0;

            if (baseCharacter != null)
            {
                foreach (IStatProvider statProvider in baseCharacter.StatProviders)
                {
                    if (statProvider != null)
                    {
                        foreach (StatScalingNode statScalingNode in statProvider.PrimaryStats)
                        {
                            if (statScalingNode.StatName == statName)
                            {
                                extraStatPerLevel += statScalingNode.BudgetPerLevel;
                                break;
                            }
                        }
                    }
                }
            }

            // not needed because it should be part of stat providers already ?

            /*
             * foreach (StatScalingNode statScalingNode in systemConfigurationManager.PrimaryStats) {
             *  if (statScalingNode.StatName == statName) {
             *      extraStatPerLevel += statScalingNode.BudgetPerLevel;
             *      break;
             *  }
             * }
             */

            return(systemConfigurationManager.StatBudgetPerLevel + extraStatPerLevel);
        }
 public virtual void SetGameManagerReferences()
 {
     systemConfigurationManager = systemGameManager.SystemConfigurationManager;
 }
Пример #10
0
 public FactoryData(string resourceClassName, SystemGameManager systemGameManager)
 {
     this.resourceClassName     = resourceClassName;
     systemConfigurationManager = systemGameManager.SystemConfigurationManager;
 }
Пример #11
0
        void OnWizardCreate()
        {
            EditorUtility.DisplayProgressBar("New Character Wizard", "Checking parameters...", 0.1f);

            SetUnitPrefab();

            EditorUtility.DisplayProgressBar("New Character Wizard", "Creating Resources Subfolder...", 0.2f);
            // Create root game folder
            string newGameFolder   = GetNewGameFolder();
            string resourcesFolder = newGameFolder + "/Resources/" + fileSystemGameName + "/UnitProfile";

            // create resources folder
            CreateFolderIfNotExists(resourcesFolder);

            AssetDatabase.Refresh();

            EditorUtility.DisplayProgressBar("New Character Wizard", "Creating Unit Profile...", 0.3f);
            UnitProfile asset = ScriptableObject.CreateInstance("UnitProfile") as UnitProfile;

            EditorUtility.DisplayProgressBar("New Character Wizard", "Configuring Unit Profile...", 0.4f);
            // setup unit profile properties
            asset.ResourceName           = characterName;
            asset.CharacterName          = characterName;
            asset.AutomaticPrefabProfile = false;
            asset.UseInlinePrefabProps   = true;

            // setup unit prefab properties
            asset.UnitPrefabProps.UnitPrefab              = unitPrefab;
            asset.UnitPrefabProps.ModelPrefab             = characterModel;
            asset.UnitPrefabProps.RotateModel             = true;
            asset.UnitPrefabProps.UseInlineAnimationProps = true;

            // setup animation properties
            asset.UnitPrefabProps.AnimationProps = animations;

            // setup nameplate properties
            asset.UnitPrefabProps.NamePlateProps.UnitFrameTarget           = headBone;
            asset.UnitPrefabProps.NamePlateProps.OverrideNameplatePosition = true;
            asset.UnitPrefabProps.NamePlateProps.NameplatePosition         = new Vector3(0f, highestYTransform + namePlateHeightAdd, 0f);
            // set the look position at half the height
            asset.UnitPrefabProps.NamePlateProps.UnitPreviewCameraLookOffset = new Vector3(0f, highestYTransform / 2f, 0f);
            // zoom out to 1.25 times the height
            asset.UnitPrefabProps.NamePlateProps.UnitPreviewCameraPositionOffset = new Vector3(0f, highestYTransform / 2f, highestYTransform * 1.25f);

            // setup foootstep properties
            asset.MovementAudioProfileNames.Add(defaultFootstepLoop);

            EditorUtility.DisplayProgressBar("New Character Wizard", "Saving Unit Profile...", 0.5f);

            scriptableObjectPath = "Assets" + newGameParentFolder + fileSystemGameName + "/Resources/" + fileSystemGameName + "/UnitProfile/" + GetFileSystemCharactername(characterName) + "Unit.asset";
            AssetDatabase.CreateAsset(asset, scriptableObjectPath);

            AssetDatabase.Refresh();

            EditorUtility.DisplayProgressBar("New Character Wizard", "Checking Default Player Unit Setting...", 0.6f);
            if (setAsDefaultPlayerCharacter == true && systemConfigurationManager != null)
            {
                SystemConfigurationManager diskSystemConfigurationManager = PrefabUtility.GetCorrespondingObjectFromSource <SystemConfigurationManager>(systemConfigurationManager);
                if (diskSystemConfigurationManager != null)
                {
                    diskSystemConfigurationManager.DefaultPlayerUnitProfileName = characterName;
                    EditorUtility.SetDirty(diskSystemConfigurationManager);
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();

                    // this next bit is due to a unity bug? where scene objects are not reimported when modified through script

                    /*
                     * Object realGO = PrefabUtility.GetCorrespondingObjectFromSource(systemConfigurationManager);
                     * string selectedPath = AssetDatabase.GetAssetPath(realGO);
                     * Debug.Log(selectedPath);
                     * AssetDatabase.ImportAsset(selectedPath);
                     */

                    //EditorApplication.RepaintHierarchyWindow();
                    //SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene().buildIndex);
                    //Resources.UnloadUnusedAssets();
                    //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single);
                }
            }

            EditorUtility.ClearProgressBar();
            EditorUtility.DisplayDialog("New Character Wizard", "New Character Wizard Complete! The character UnitProfile can be found at " + scriptableObjectPath, "OK");
        }
Пример #12
0
 public virtual void SetGameManagerReferences()
 {
     //Debug.Log("ConfiguredClass.SetGameManagerReferences() systemGameManager = " + (systemGameManager == null ? "null" : systemGameManager.gameObject.name));
     systemConfigurationManager = systemGameManager.SystemConfigurationManager;
 }