private void AddNewLookupLocation(LocationList location)
        {
            var feedeeLocationTable = new Dictionary <string, FeedeeEntry>();

            nodeFeedeeLookup = new Dictionary <TownNodeList, SaveableClone>();
            saveableClones   = new List <SaveableClone>();

            foreach (TownNodeList townNode in nodeManager.GetLocationMainNodes(location))
            {
                for (int i = 0; i < nodeManager.GetNodeMenuCount(location, townNode); i++)
                {
                    if (nodeManager.HasNPCSpawn(location, townNode, i))
                    {
                        TownNodeList  feedeeNode     = nodeManager.GetConnectedNode(location, townNode, i);
                        FeedeeClass   newFeedeeClass = ChooseFeedeeClass(feedeeNode);
                        FeedeeEntry   newFeedee      = CreateNewFeedee(newFeedeeClass, feedeeNode);
                        SaveableClone feedeeSaveable = feedeeSpawner.SpawnNewNPC(newFeedee.feedeeClass, newFeedee.identifier);

                        NPCInfo info = feedeeSaveable.GetComponent <NPCInfo>();
                        info.SetCharacterInfo("name", newFeedee.name);
                        info.SetCharacterInfo("rank", newFeedeeClass.ToString());

                        saveableClones.Add(feedeeSaveable);
                        feedeeLocationTable[newFeedee.identifier] = newFeedee;
                        AssignNPCToNode(feedeeSaveable, feedeeNode);
                    }
                }
                feedeeLookup[location] = feedeeLocationTable;
            }
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
        private IEnumerator RestoreNPCsToLocation()
        {
            yield return(null);

            LocationList currentLocation = locationManager.GetCurrentLocation();

            nodeFeedeeLookup = new Dictionary <TownNodeList, SaveableClone>();
            saveableClones   = new List <SaveableClone>();

            if (feedeeLookup.ContainsKey(currentLocation))
            {
                foreach (FeedeeEntry feedee in feedeeLookup[currentLocation].Values)
                {
                    SaveableClone clone = feedeeSpawner.SpawnNewNPC(feedee.feedeeClass, feedee.identifier, feedee.state);
                    saveableClones.Add(clone);
                    AssignNPCToNode(clone, feedee.activeNode);
                }
            }
            else if (nodeManager != null)
            {
                AddNewLookupLocation(currentLocation);
            }
        }
Beispiel #5
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);
        }
Beispiel #6
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++;
                }
            }
        }
 private void AssignNPCToNode(SaveableClone feedee, TownNodeList node)
 {
     nodeFeedeeLookup[node] = feedee;
 }