Пример #1
0
 /// <summary>
 /// Overridden get function which returns an interface to a dictionary to the caller.
 /// </summary>
 /// <param name="type">Type of dictionary required</param>
 /// <returns>Interface to dictionary.</returns>
 public IDictionary getDataFromStorageObject(GameDataStorageLayerUtils.objectClassType type)
 {
     return(characterData);
 }
Пример #2
0
 /// <summary>
 /// Insert BaseGameDataStorageObject into a concurrent dictionary
 /// </summary>
 /// <typeparam name="TValue1">Templated value type for the first BaseGameDataStorageObject parameter</typeparam>
 /// <typeparam name="TValue2">Templated value type for the second BaseGameDataStorageObject parameter</typeparam>
 /// <param name="classType"></param>
 /// <param name="objectToStore"></param>
 /// <param name="key"></param>
 public void insertDataFromSerializedObject <TValue1, TValue2>(GameDataStorageLayerUtils.objectClassType classType, BaseGameDataStorageObject <TValue1, TValue2> objectToStore, string key)
 {
 }
Пример #3
0
        /// <summary>
        /// Return the interface BaseGameObject to the caller, based on the type of class we can recast it once returned.
        /// </summary>
        /// <typeparam name="TValue1">usually the string value (key)</typeparam>
        /// <typeparam name="TValue2">Tuple of string,int or string,string</typeparam>
        /// <param name="type">type of data to search for</param>
        /// <param name="key">key value to search for</param>
        /// <returns>Interface to a game object that will need to be recast to the original type.</returns>
        public BaseGameObject <TValue1, TValue2> getDataFromStorageObject <TValue1, TValue2>(GameDataStorageLayerUtils.objectClassType type, string key)
        {
            BaseGameObject <TValue1, TValue2> obj = null;

            switch (type)
            {
            case GameDataStorageLayerUtils.objectClassType.Attribute:
                if (characterData.ContainsKey(key))
                {
                    return((BaseGameObject <TValue1, TValue2>)characterData[key]);
                }
                break;
            }

            return(obj);
        }
Пример #4
0
 /// <summary>
 /// Searches through the concurrent dictionaries for the object specified and then modifies it on the fly.
 /// </summary>
 /// <param name="type">Type of dictionary we should address.</param>
 /// <param name="obj">Object data to modify</param>
 /// <returns>True for success, false on failure</returns>
 public bool modifyData(GameDataStorageLayerUtils.objectClassType type, BaseGameDataStorageObject <string, Tuple <string, int> > obj)
 {
     return(true);
 }
 public BaseGameDataStorageObject(GameDataStorageLayerUtils.objectClassType typeOfObject, int sizeOfList)
 {
     dataList       = new List <Tuple <DataType1, DataType2> >(sizeOfList);
     this.classType = typeOfObject;
 }
        //public static BaseGameDataStorageObject<DataType1,DataType2> Create<DataType1,DataType2>(GameDataStorageLayerUtils.objectClassType typeOfObject, Tuple<DataType1, DataType2> dt)
        //{
        //   return new BaseGameDataStorageObject<DataType1,DataType2>(typeOfObject);
        //}

        public BaseGameDataStorageObject(GameDataStorageLayerUtils.objectClassType typeOfObject)
        {
            this.classType = typeOfObject;
            dataList       = new List <Tuple <DataType1, DataType2> >();
        }
        /// <summary>
        /// Most other data objects are defined using string,Tuple<string,string> instead of string, Tuple<string,int>
        /// We can leverage filling out the rest by implementing this function and passing a type param
        /// </summary>
        /// <returns>Returns a concurrent dict with the filled out data</returns>
        public static ConcurrentDictionary <string, BaseGameDataStorageObject <string, Tuple <string, string> > > fillOtherDataObjectsWithData(GameDataStorageLayerUtils.objectClassType typeOfObjectToFill)
        {
            ConcurrentDictionary <string, BaseGameDataStorageObject <string, Tuple <string, string> > > dataDict = new ConcurrentDictionary <string, BaseGameDataStorageObject <string, Tuple <string, string> > >();
            string path = "";
            Tuple <string, Tuple <string, string> > testData  = null;
            Tuple <string, Tuple <string, string> > testData1 = null;
            Tuple <string, Tuple <string, string> > testData2 = null;
            Tuple <string, Tuple <string, string> > testData3 = null;
            BaseGameDataStorageObject <string, Tuple <string, string> > tObject = null;

            switch (typeOfObjectToFill)
            {
            case GameDataStorageLayerUtils.objectClassType.Descriptor:
                string[] descriptorLabels = new string[4] {
                    "Angel", "Ghostly", "Demon", "Monster"
                };
                path      = "testChar/descriptorData";
                testData  = new Tuple <string, Tuple <string, string> >("testChar:descriptorData:Angel", new Tuple <string, string>(path + "/" + descriptorLabels[0], "Angelic Being"));
                testData1 = new Tuple <string, Tuple <string, string> >("testChar:descriptorData:Ghostly", new Tuple <string, string>(path + "/" + descriptorLabels[1], "Ghostly Being"));
                testData2 = new Tuple <string, Tuple <string, string> >("testChar:descriptorData:Demon", new Tuple <string, string>(path + "/" + descriptorLabels[2], "Demonic Being"));
                testData3 = new Tuple <string, Tuple <string, string> >("testChar:descriptorData:Monster", new Tuple <string, string>(path + "/" + descriptorLabels[3], "Monster HD:24"));
                tObject   = new BaseGameDataStorageObject <string, Tuple <string, string> >(GameDataStorageLayerUtils.objectClassType.Descriptor);
                break;

            case GameDataStorageLayerUtils.objectClassType.Extra:
                string[] extraLabels = new string[4] {
                    "Note", "Always Fail", "Secret Note", "Extra Item"
                };
                path      = "testChar/extraData";
                testData  = new Tuple <string, Tuple <string, string> >("testChar:extraData:Note", new Tuple <string, string>(path + "/" + extraLabels[0], "Note: this character has a note!"));
                testData1 = new Tuple <string, Tuple <string, string> >("testChar:extraData:Always Fail", new Tuple <string, string>(path + "/" + extraLabels[1], "Always fail a critical hit."));
                testData2 = new Tuple <string, Tuple <string, string> >("testChar:extraData:Secret Note", new Tuple <string, string>(path + "/" + extraLabels[2], "Secret note: this character has a secret."));
                testData3 = new Tuple <string, Tuple <string, string> >("testChar:extraData:Extra Item", new Tuple <string, string>(path + "/" + extraLabels[3], "Extra item: this character always gets two potions."));
                tObject   = new BaseGameDataStorageObject <string, Tuple <string, string> >(GameDataStorageLayerUtils.objectClassType.Extra);
                break;

            case GameDataStorageLayerUtils.objectClassType.Modified:
                string[] modifiedLabels = new string[4] {
                    "Extra Strength", "Haste", "Flying", "Dancing"
                };
                path      = "testChar/modifiedData";
                testData  = new Tuple <string, Tuple <string, string> >("testChar:modifiedData:Extra Strength", new Tuple <string, string>(path + "/" + modifiedLabels[0], "This creature has extra stength of 8."));
                testData1 = new Tuple <string, Tuple <string, string> >("testChar:modifiedData:Haste", new Tuple <string, string>(path + "/" + modifiedLabels[1], "This creature is hasted."));
                testData2 = new Tuple <string, Tuple <string, string> >("testChar:modifiedData:Flying", new Tuple <string, string>(path + "/" + modifiedLabels[2], "This creature is flying."));
                testData3 = new Tuple <string, Tuple <string, string> >("testChar:modifiedData:Dancing", new Tuple <string, string>(path + "/" + modifiedLabels[3], "This creature is dancing."));
                tObject   = new BaseGameDataStorageObject <string, Tuple <string, string> >(GameDataStorageLayerUtils.objectClassType.Modified);
                break;

            default:
                descriptorLabels = new string[4] {
                    "Angel", "Ghostly", "Demon", "Monster"
                };
                path      = "testChar/descriptorData";
                testData  = new Tuple <string, Tuple <string, string> >("testChar:descriptorData:Angel", new Tuple <string, string>(path + "/" + descriptorLabels[0], "Angelic Being"));
                testData1 = new Tuple <string, Tuple <string, string> >("testChar:descriptorData:Ghostly", new Tuple <string, string>(path + "/" + descriptorLabels[0], "Ghostly Being"));
                testData2 = new Tuple <string, Tuple <string, string> >("testChar:descriptorData:Demon", new Tuple <string, string>(path + "/" + descriptorLabels[0], "Demonic Being"));
                testData3 = new Tuple <string, Tuple <string, string> >("testChar:descriptorData:Monster", new Tuple <string, string>(path + "/" + descriptorLabels[0], "Monster HD:24"));
                tObject   = new BaseGameDataStorageObject <string, Tuple <string, string> >(GameDataStorageLayerUtils.objectClassType.Descriptor);
                break;
            }

            tObject.addTupleToList(testData);
            tObject.addTupleToList(testData1);
            tObject.addTupleToList(testData2);
            tObject.addTupleToList(testData3);
            string tPath = path.Replace("/", ":");

            dataDict.TryAdd(tPath, tObject);
            return(dataDict);
        }