Beispiel #1
0
            public static string MarkerTypeToString(MarkerTypes MType)
            {
                string str1      = MType.ToString();
                string newstring = "";

                for (int i = 0; i < str1.Length; i++)
                {
                    if (i > 0 && char.IsUpper(str1[i]))
                    {
                        newstring += " ";
                    }
                    newstring += str1[i].ToString();
                }
                return(newstring);
            }
Beispiel #2
0
        /// <summary>
        /// Assigns a quest resource to this Place site.
        /// Supports Persons, Foes, Items from within same quest as Place.
        /// Quest must have previously created SiteLink for layout builders to discover assigned resources.
        /// </summary>
        /// <param name="targetSymbol">Resource symbol of Person, Item, or Foe to assign.</param>
        public void AssignQuestResource(Symbol targetSymbol)
        {
            // Site must have at least one marker of each type
            if (!ValidateQuestMarkers(siteDetails.questSpawnMarkers, siteDetails.questItemMarkers))
            {
                throw new Exception(string.Format("Tried to assign resource {0} to Place without at least 1x spawn and 1x item marker.", targetSymbol.Name));
            }

            // Attempt to get resource from symbol
            QuestResource resource = ParentQuest.GetResource(targetSymbol);

            if (resource == null)
            {
                throw new Exception(string.Format("Could not locate quest resource with symbol {0}", targetSymbol.Name));
            }

            // Must be a supported resource type
            MarkerTypes requiredMarkerType = MarkerTypes.None;

            if (resource is Person || resource is Foe)
            {
                requiredMarkerType = MarkerTypes.QuestSpawn;
            }
            else if (resource is Item)
            {
                requiredMarkerType = MarkerTypes.QuestItem;
            }
            else
            {
                throw new Exception(string.Format("Tried to assign incompatible resource symbol {0} to Place", targetSymbol.Name));
            }

            // Assign target resource to marker selected for this quest
            if (requiredMarkerType == MarkerTypes.QuestSpawn)
            {
                AssignResourceToMarker(targetSymbol, ref siteDetails.questSpawnMarkers[siteDetails.selectedQuestSpawnMarker]);
            }
            else if (requiredMarkerType == MarkerTypes.QuestItem)
            {
                AssignResourceToMarker(targetSymbol, ref siteDetails.questItemMarkers[siteDetails.selectedQuestItemMarker]);
            }
            else
            {
                throw new Exception(string.Format("Tried to assign resource symbol _{0}_ to Place {1} but it has an unknown MarkerType {2}", targetSymbol.Name, Symbol.Name, requiredMarkerType.ToString()));
            }

            // Output debug information
            if (resource is Person)
            {
                if (siteDetails.siteType == SiteTypes.Building)
                {
                    if (requiredMarkerType == MarkerTypes.QuestSpawn)
                    {
                        Debug.LogFormat("Assigned Person {0} to Building {1}", (resource as Person).DisplayName, SiteDetails.buildingName);
                    }
                }
                else if (siteDetails.siteType == SiteTypes.Dungeon)
                {
                    if (requiredMarkerType == MarkerTypes.QuestSpawn)
                    {
                        Debug.LogFormat("Assigned Person {0} to Dungeon {1}", (resource as Person).DisplayName, SiteDetails.locationName);
                    }
                }
            }
            else if (resource is Foe)
            {
                if (siteDetails.siteType == SiteTypes.Building)
                {
                    if (requiredMarkerType == MarkerTypes.QuestSpawn)
                    {
                        Debug.LogFormat("Assigned Foe _{0}_ to Building {1}", resource.Symbol.Name, SiteDetails.buildingName);
                    }
                }
                else if (siteDetails.siteType == SiteTypes.Dungeon)
                {
                    if (requiredMarkerType == MarkerTypes.QuestSpawn)
                    {
                        Debug.LogFormat("Assigned Foe _{0}_ to Dungeon {1}", resource.Symbol.Name, SiteDetails.locationName);
                    }
                }
            }
            else if (resource is Item)
            {
                if (siteDetails.siteType == SiteTypes.Building)
                {
                    if (requiredMarkerType == MarkerTypes.QuestItem)
                    {
                        Debug.LogFormat("Assigned Item _{0}_ to Building {1}", resource.Symbol.Name, SiteDetails.buildingName);
                    }
                }
                else if (siteDetails.siteType == SiteTypes.Dungeon)
                {
                    if (requiredMarkerType == MarkerTypes.QuestItem)
                    {
                        Debug.LogFormat("Assigned Item _{0}_ to Dungeon {1}", resource.Symbol.Name, SiteDetails.locationName);
                    }
                }
            }
        }