Exemple #1
0
        public void LoadHashTable()
        {
            if (!isProxyValid())
            {
                return;
            }

            string _tag = uniqueTag.Value;

            if (string.IsNullOrEmpty(_tag))
            {
                _tag = Fsm.GameObjectName + "/" + Fsm.Name + "/hashTable/" + reference;
            }

            ES2Settings loadSettings = new ES2Settings();

            if (loadFromResources.Value)
            {
                loadSettings.saveLocation = ES2Settings.SaveLocation.Resources;
            }

            Dictionary <string, string> _dict = ES2.LoadDictionary <string, string>(saveFile.Value + "?tag=" + _tag);

            Log("Loaded from " + saveFile.Value + "?tag=" + _tag);

            proxy.hashTable.Clear();


            foreach (string key in _dict.Keys)
            {
                proxy.hashTable[key] = PlayMakerUtils.ParseValueFromString(_dict[key]);
            }

            Finish();
        }
Exemple #2
0
        public override void OnUpdate()
        {
            if (web.isError)
            {
                errorMessage.Value = web.error;
                errorCode.Value    = web.errorCode;
                Fsm.Event(isError);
                Finish();
            }
            else if (web.isDone)
            {
                Fsm.Event(isDownloaded);

                List <string> source = web.LoadList <string>(_tag);

                if (localFile.Value != "")
                {
                    web.SaveToFile(localFile.Value);
                }


                Log("Loaded from " + saveFile.Value + "?tag=" + uniqueTag);

                proxy.arrayList.Clear();

                foreach (string element in source)
                {
                    proxy.arrayList.Add(PlayMakerUtils.ParseValueFromString(element));
                }


                Finish();
            }
        }
Exemple #3
0
        public void LoadArrayList()
        {
            if (!isProxyValid())
            {
                return;
            }

            string _tag = uniqueTag.Value;

            if (string.IsNullOrEmpty(_tag))
            {
                _tag = Fsm.GameObjectName + "/" + Fsm.Name + "/arraylist/" + reference.Value;
            }

            ES2Settings loadSettings = new ES2Settings();

            if (loadFromResources.Value)
            {
                loadSettings.saveLocation = ES2Settings.SaveLocation.Resources;
            }

            List <string> source = ES2.LoadList <string>(saveFile.Value + "?tag=" + _tag);

            Log("Loaded from " + saveFile.Value + "?tag=" + uniqueTag);

            proxy.arrayList.Clear();

            foreach (string element in source)
            {
                proxy.arrayList.Add(PlayMakerUtils.ParseValueFromString(element));
            }

            Finish();
        }
        public override void OnUpdate()
        {
            if (web.isError)
            {
                errorMessage.Value = web.error;
                errorCode.Value    = web.errorCode;
                Fsm.Event(isError);
                Finish();
            }
            else if (web.isDone)
            {
                Fsm.Event(isDownloaded);

                Dictionary <string, string> _dict = web.LoadDictionary <string, string>(_tag);

                if (localFile.Value != "")
                {
                    web.SaveToFile(localFile.Value);
                }

                Log("DownLoaded from " + saveFile.Value + "?tag=" + _tag);

                proxy.hashTable.Clear();

                foreach (string key in _dict.Keys)
                {
                    proxy.hashTable[key] = PlayMakerUtils.ParseValueFromString(_dict[key]);
                }

                Finish();
            }
        }
        public bool ParseNode()
        {
            if (!isProxyValid())
            {
                return(false);
            }


            if (xmlSource.Value == null)
            {
                Debug.LogWarning("XMl source is empty, or likely invalid");
                return(false);
            }

            // I am not clearing to allow for default values, could be handy, else you can always clear before using this action.
            //proxy.hashTable.Clear();

            // get attributes first:
            XmlAttributeCollection attCol = xmlSource.Value.Attributes;

            foreach (XmlAttribute _att in attCol)
            {
                proxy.hashTable["@" + _att.Name] = PlayMakerUtils.ParseValueFromString(_att.InnerText, propertiesTypes.GetPropertyType("@" + _att.Name));
            }

            // get the node properties
            foreach (XmlNode _childNode in xmlSource.Value.ChildNodes)
            {
                proxy.hashTable[_childNode.Name] = PlayMakerUtils.ParseValueFromString(_childNode.InnerText, propertiesTypes.GetPropertyType(_childNode.Name));
            }

            return(true);
        }
Exemple #6
0
    public static void StoreNodeProperties(Fsm fsm, XmlNode node, FsmXmlProperty[] properties)
    {
        int prop_i = 0;

        foreach (FsmXmlProperty prop in properties)
        {
            string _property = DataMakerXmlActions.GetNodeProperty(node, prop.property.Value);

            PlayMakerUtils.ApplyValueToFsmVar(
                fsm,
                prop.variable,
                PlayMakerUtils.ParseValueFromString(_property, prop.variable.Type)
                );

            prop_i++;
        }
    }
Exemple #7
0
    static public bool GetParsePropertyToFsmVar(ParseObject _object, string property, Fsm fsm, FsmVar fsmVar)
    {
        if (_object == null || string.IsNullOrEmpty(property))
        {
            return(false);
        }

        if (!_object.ContainsKey(property))
        {
            return(false);
        }


        if (fsmVar.Type == VariableType.Bool)
        {
            PlayMakerUtils.ApplyValueToFsmVar(fsm, fsmVar, _object[property]);
        }
        else if (fsmVar.Type == VariableType.Float)
        {
            PlayMakerUtils.ApplyValueToFsmVar(fsm, fsmVar, _object[property]);
        }
        else if (fsmVar.Type == VariableType.Int)
        {
            PlayMakerUtils.ApplyValueToFsmVar(fsm, fsmVar, _object[property]);
        }
        else if (fsmVar.Type == VariableType.String)
        {
            PlayMakerUtils.ApplyValueToFsmVar(fsm, fsmVar, _object[property]);
        }
        else if (fsmVar.Type == VariableType.Color)
        {
            fsmVar.colorValue = (Color)PlayMakerUtils.ParseValueFromString((string)_object[property]);
        }
        else if (fsmVar.Type == VariableType.GameObject)
        {
            fsmVar.gameObjectValue = (GameObject)PlayMakerUtils.ParseValueFromString((string)_object[property]);
        }
        else if (fsmVar.Type == VariableType.Material)
        {
            fsmVar.materialValue = (Material)PlayMakerUtils.ParseValueFromString((string)_object[property]);
        }
        else if (fsmVar.Type == VariableType.Quaternion)
        {
            fsmVar.quaternionValue = (Quaternion)PlayMakerUtils.ParseValueFromString((string)_object[property]);
        }
        else if (fsmVar.Type == VariableType.Rect)
        {
            fsmVar.rectValue = (Rect)PlayMakerUtils.ParseValueFromString((string)_object[property]);
        }
        else if (fsmVar.Type == VariableType.Texture)
        {
            fsmVar.textureValue = (Texture2D)PlayMakerUtils.ParseValueFromString((string)_object[property]);
        }
        else if (fsmVar.Type == VariableType.Vector2)
        {
            fsmVar.vector2Value = (Vector2)PlayMakerUtils.ParseValueFromString((string)_object[property]);
        }
        else if (fsmVar.Type == VariableType.Vector3)
        {
            fsmVar.vector3Value = (Vector3)PlayMakerUtils.ParseValueFromString((string)_object[property]);
        }

        return(true);
    }