コード例 #1
0
ファイル: Location.cs プロジェクト: arpond/longRoadHome
        /// <summary>
        /// Generates a custom sublocation
        /// </summary>
        /// <param name="id">ID of the sublocation</param>
        /// <param name="keys">Types of sublocations available</param>
        /// <param name="maxItems">Max items to be found at sublocation</param>
        /// <param name="maxAmount">Max amount of each item to be found at sublocation</param>
        /// <returns></returns>
        private Sublocation GenerateRandomSublocation(int id, List <String> keys, int maxItems, int maxAmount)
        {
            int    nextType = rnd.Next(keys.Count);
            String tempType = keys[nextType];

            return(SubLocationFactory.CreateSubLocation(tempType, id, maxItems, maxAmount));
        }
コード例 #2
0
ファイル: Location.cs プロジェクト: arpond/longRoadHome
        /// <summary>
        /// Generates a standard sublocation
        /// </summary>
        /// <param name="id">ID of the sublocation</param>
        /// <param name="keys">Types of sublocations available</param>
        /// <returns></returns>
        private Sublocation GenerateRandomSublocation(int id, List <String> keys)
        {
            int    nextType = rnd.Next(keys.Count);
            String tempType = keys[nextType];

            return(SubLocationFactory.CreateSubLocation(tempType, id, STD_MAX_ITEMS, STD_MAX_AMOUNT));
        }
コード例 #3
0
ファイル: Location.cs プロジェクト: arpond/longRoadHome
        public Location(String toParse)
        {
            visited      = true;
            sublocations = new Dictionary <int, Sublocation>();
            String[] lElems = toParse.Split(',');
            foreach (String elem in lElems)
            {
                String[] locElem = elem.Split(':');
                switch (locElem[0])
                {
                case "ID":
                    int tempID;
                    int.TryParse(locElem[1], out tempID);
                    locationID = tempID;
                    break;

                case "Visited":
                    bool tempVis;
                    bool.TryParse(locElem[1], out tempVis);
                    visited = tempVis;
                    break;

                case "Sublocations":
                    if (locElem.Length > 1)
                    {
                        for (int i = 1; i < locElem.Length; i = i + 6)
                        {
                            Sublocation temp = SubLocationFactory.CreateSubLocation(locElem[i] + ":" + locElem[i + 1] + ":" + locElem[i + 2] + ":" + locElem[i + 3] + ":" + locElem[i + 4] + ":" + locElem[i + 5]);
                            int         id;
                            if (int.TryParse(locElem[i + 1], out id))
                            {
                                sublocations.Add(id, temp);
                            }
                        }
                    }
                    break;

                case "CurrentSublocation":
                    int currID;
                    if (locElem.Length > 1)
                    {
                        int.TryParse(locElem[1], out currID);
                        sublocations.TryGetValue(currID, out currentSubLocation);
                    }
                    break;
                }
            }
        }
コード例 #4
0
ファイル: Location.cs プロジェクト: arpond/longRoadHome
 /// <summary>
 /// Parses a sublocation from a string
 /// </summary>
 /// <param name="toParse">The string to parse to a sublocation</param>
 /// <returns>The sublocation parsed</returns>
 private Sublocation ParseSublocationFromString(String toParse)
 {
     return(SubLocationFactory.CreateSubLocation(toParse));
 }