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; } }
private FeedeeClass ChooseFeedeeClass(TownNodeList nodeList) { switch (nodeList) { case TownNodeList.Bakery: return(FeedeeClass.Baker); case TownNodeList.Bar: return(FeedeeClass.Bartender); case TownNodeList.Blacksmith: case TownNodeList.Furnishings: case TownNodeList.Tailor: return(FeedeeClass.TradeProfession); case TownNodeList.BountyCounter: case TownNodeList.QuestCounter: return(FeedeeClass.GuildMember); case TownNodeList.Cafe: case TownNodeList.Restaurant: return(FeedeeClass.Waitress); case TownNodeList.FoodVendor: return(FeedeeClass.Cook); default: return(FeedeeClass.Default); } }
public void OpenMenu(LocationMenuBuilderDB locationMenuBuilder, TownNodeList townNode) { // Activate menu background.enabled = true; menuPanel.gameObject.SetActive(true); // Cache current menu info menuBuilderDB = locationMenuBuilder; node = townNode; currentTab = 0; // Pull shopkeeper data GameObject _feedeeGO = feedeeManager.GetFeedeeAtNode(townNode); if (_feedeeGO != null) { npcSlotUI.SlotSetup(_feedeeGO, townNode.ToString()); npcInfoDescription.SetCharacterInfo(_feedeeGO); npcSlotButton.onClick.AddListener(() => npcInfoDescription.SetCharacterInfo(_feedeeGO)); NPCInfo npcInfo = _feedeeGO.GetComponent <NPCInfo>(); choiceButtons[0].onClick.AddListener(() => npcInfo.TalkToNPC()); choiceButtons[1].interactable = false; choiceButtons[2].interactable = false; choiceButtons[3].interactable = false; } // Label tabs and populate menu items SetupMenuTabs(); slotCoroutine = StartCoroutine(SetupMenuSlots(currentTab)); }
public GameObject GetFeedeeAtNode(TownNodeList nodeQuery) { if (nodeFeedeeLookup.ContainsKey(nodeQuery)) { return(nodeFeedeeLookup[nodeQuery].gameObject); } return(null); }
public IEnumerable <InventoryItem> GetInventoryItems(TownNodeList townNode, int tabIndex) { BuildLookup(); foreach (InventoryItem item in nodeMenuLookup[townNode][tabIndex].menuContents) { yield return(item); } }
public IEnumerable <string> GetCategories(TownNodeList townNode) { BuildLookup(); foreach (MenuCategory menuCategory in nodeMenuLookup[townNode]) { yield return(menuCategory.category); } }
// Set // Comes from SceneChangeObj, which is on buttons that change scene (Save Slots/Travel Buttons) public void SetCurrentLocation(string locName) { previousLocation = currentLocation; if (!Enum.TryParse <LocationList>(locName, out currentLocation)) { Debug.LogError("Location not found."); return; } // SceneChangeObj gets data from PlayerInfo (for Save Slots), so update location in it playerInfo.SetPlayerInfo("location", GetLocationName(currentLocation)); currentNode = TownNodeList.Main; }
private FeedeeEntry CreateNewFeedee(FeedeeClass newClass, TownNodeList node = TownNodeList.None) { BuildLookup(); FeedeeEntry newFeedee = new FeedeeEntry(); SaveableEntity saveable = GetComponent <SaveableEntity>(); newFeedee.feedeeClass = newClass; newFeedee.activeNode = node; newFeedee.identifier = saveable.GenerateNewUniqueIdentifier(""); newFeedee.name = newFeedee.identifier; return(newFeedee); }
public int GetMenuCount(LocationList location, TownNodeList townNode) { BuildLookup(); var townNodeLookup = new Dictionary <TownNodeList, TownNodeMenuInformation[]>(); if (nodeMenuLookup.TryGetValue(location, out townNodeLookup)) { if (townNodeLookup.TryGetValue(townNode, out nodeMenus)) { return(nodeMenus.Length); } nodeMenus = null; } return(-1); }
public void RestoreState(object state) { LocationState locationState = (LocationState)state; locationLookup = locationState.locationLookup; currentLocation = locationState.currentLocation; previousLocation = locationState.previousLocation; travelDestination = locationState.travelDestination; distanceRemaining = locationState.distanceRemaining; currentNode = TownNodeList.Main; foreach (Location location in locationDB.GetLocations()) { if (locationLookup.ContainsKey(location.location)) { continue; } Location newLocation = new Location(); newLocation.location = location.location; newLocation.name = location.name; newLocation.description = location.description; newLocation.distance = location.distance; newLocation.isAvailable = location.isAvailable; newLocation.isCombatArea = location.isCombatArea; newLocation.hasTraveled = location.hasTraveled; locationLookup[newLocation.location] = newLocation; } BuildAvailableList(); CheckIfTraveled(); if (!locationLookup[currentLocation].isCombatArea) { menuManager.MakeMainMenu(currentLocation); } }
public TownNodeList GetConnectedNode(LocationList locationQuery, TownNodeList nodeQuery, int nodeIndex) { return(locationMenuDB.GetConnectedNode(locationQuery, nodeQuery, nodeIndex)); }
public bool HasNPCSpawn(LocationList locationQuery, TownNodeList nodeQuery, int index) { return(nodeMenuLookup[locationQuery][nodeQuery][index].hasNPCSpawn); }
public TownNodeList GetConnectedNode(LocationList locationQuery, TownNodeList nodeQuery, int index) { return(nodeMenuLookup[locationQuery][nodeQuery][index].connectedNode); }
private void AssignNPCToNode(SaveableClone feedee, TownNodeList node) { nodeFeedeeLookup[node] = feedee; }
public bool GetIsMerchant(TownNodeList townNode) { return(nodeIsMenuLookup[townNode]); }
public bool HasNPCSpawn(LocationList locationQuery, TownNodeList nodeQuery, int nodeIndex) { return(locationMenuDB.HasNPCSpawn(locationQuery, nodeQuery, nodeIndex)); }
public int GetNodeMenuCount(LocationList locationQuery, TownNodeList nodeQuery) { return(locationMenuDB.GetMenuCount(locationQuery, nodeQuery)); }
public void SetActiveNode(TownNodeList newNode) { activeNode = newNode; }
private void MakeNodeMenu(TownNodeList newNode) { int nodeMenuCount = locationMenuDB.GetMenuCount(currentLocation, newNode); SetupMenuSlots(nodeMenuCount); }