Пример #1
0
        public SaveableClone SpawnNewNPC(FeedeeClass feedeeClass, string feedeeUUID, object state = null)
        {
            foreach (var prefab in feedeePrefabs)
            {
                if (prefab.GetClass() == feedeeClass)
                {
                    BaseFeedeeStats feedee        = Instantiate(prefab, parentTransform);
                    SaveableClone   saveableClone = feedee.GetComponent <SaveableClone>();
                    saveableClone.SetUniqueIdentifier(feedeeUUID);
                    if (state != null)
                    {
                        saveableClone.RestoreState(state);
                    }

                    return(saveableClone);
                }
            }
            return(null);
        }
Пример #2
0
        public SaveableClone SpawnActiveFollower(CharacterClass followerClass, string followerUUID, object state = null)
        {
            foreach (var prefab in followerPrefabs)
            {
                if (prefab.GetClass() == followerClass)
                {
                    Transform     followerTransform = Instantiate(prefab, parentTransform).transform;
                    SaveableClone saveableClone     = followerTransform.GetComponent <SaveableClone>();
                    saveableClone.SetUniqueIdentifier(followerUUID);
                    if (state != null)
                    {
                        saveableClone.RestoreState(state);
                    }
                    followerTransform.SetSiblingIndex(siblingIndex);

                    return(saveableClone);
                }
            }
            return(null);
        }
Пример #3
0
        public SaveableClone SpawnBackgroundFollower(CharacterClass followerClass, string followerUUID, object state = null)
        {
            if (isCombat)
            {
                return(null);
            }

            foreach (var prefab in nonCombatPrefabs)
            {
                if (prefab.GetClass() == followerClass)
                {
                    BaseStats     followerBase  = Instantiate(prefab, parentTransformBackground);
                    SaveableClone saveableClone = followerBase.GetComponent <SaveableClone>();
                    saveableClone.SetUniqueIdentifier(followerUUID);
                    if (state != null)
                    {
                        saveableClone.RestoreState(state);
                    }

                    return(saveableClone);
                }
            }
            return(null);
        }
Пример #4
0
        private void SpawnCharacters()
        {
            // Check scene location against character location
            string curScene = SceneManager.GetActiveScene().name;

            saveables = new List <SaveableClone>();

            foreach (string girl in characterLookup.Keys)
            {
                // Get schedule from save
                string scheduleName = "ProjectQuimbly.Schedules." + girl + "Schedule";
                string girlLocation;
                Dictionary <string, object> stateDict = (Dictionary <string, object>)characterLookup[girl].state;
                if (stateDict == null)
                {
                    Scheduler defaultScheduler = characterDB.GetBasePrefab(girl).GetComponent <Scheduler>();
                    girlLocation = defaultScheduler.GetLocation();
                }
                else
                {
                    Scheduler scheduler = new Scheduler();
                    scheduler.RestoreState(stateDict[scheduleName]);
                    girlLocation = scheduler.GetLocation();
                }

                if (curScene == girlLocation)
                {
                    // Spawn from prefab
                    GameObject characterGO = null;
                    switch (curScene)
                    {
                    case "Dates":
                        characterGO = characterDB.GetDatePrefab(girl);
                        break;

                    case "Feeding Minigame":
                        characterGO = characterDB.GetFeedingPrefab(girl);
                        break;

                    case "Inflation Minigame":
                        characterGO = characterDB.GetInflationPrefab(girl);
                        break;

                    default:
                        characterGO = characterDB.GetBasePrefab(girl);
                        break;
                    }
                    GameObject charInstance = Instantiate(characterGO, transform);

                    // Offset position if multiple
                    if (charactersInScene > 0)
                    {
                        Vector3 charPosition = charInstance.transform.GetChild(0).position;
                        int     xOffset      = -590 * charactersInScene;
                        charPosition += new Vector3(xOffset, 0, 0);
                        charInstance.transform.GetChild(0).position = charPosition;
                    }

                    // Restore saved variables
                    SaveableClone saveableClone = charInstance.GetComponent <SaveableClone>();
                    saveables.Add(saveableClone);
                    if (characterLookup[girl].state != null)
                    {
                        saveableClone.RestoreState(characterLookup[girl].state);
                    }

                    charactersInScene++;
                }
            }
        }