示例#1
0
        PsScript(PsScriptMgr mgr)
        {
            mMgr    = mgr;
            mVarMgr = new VariableMgr();

            Result = EResult.Max;
        }
示例#2
0
        public static byte[] Serialize(PsScriptMgr mgr)
        {
            MemoryStream sm = new MemoryStream(1024 * 10);

            using (BinaryWriter w = new BinaryWriter(sm))
            {
                byte[] data = VariableMgr.Export(mgr.mVarMgr);
                w.Write(data.Length);
                w.Write(data);

                w.Write(mgr.mScriptList.Count);

                foreach (PsScript q in mgr.mScriptList)
                {
                    w.Write(q.Id);

                    q.Store(w);
                }

                SerializeList(mgr.mScriptLoadList, w);
                SerializeList(mgr.mScriptRemoveList, w);
            }

            return(sm.ToArray());
        }
示例#3
0
        public static PsScriptMgr Create(Factory factory)
        {
            factory.Init();

            PsScriptMgr scriptMgr = new PsScriptMgr(factory);

            scriptMgr.mVarMgr = new VariableMgr();

            scriptMgr.LoadEntry();

            return(scriptMgr);
        }
示例#4
0
        public static PsScriptMgr Deserialize(Factory factory, byte[] data)
        {
            if (null == data)
            {
                return(null);
            }

            factory.Init();

            PsScriptMgr scriptMgr = new PsScriptMgr(factory);

            MemoryStream sm = new MemoryStream(data, false);

            using (BinaryReader r = new BinaryReader(sm))
            {
                int    varDatalength = r.ReadInt32();
                byte[] varData       = r.ReadBytes(varDatalength);

                scriptMgr.mVarMgr = VariableMgr.Import(varData);

                int count = r.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    int id = r.ReadInt32();

                    PsScript script = PsScript.Load(scriptMgr, id);
                    if (null == script)
                    {
                        continue;
                    }

                    if (!script.Init())
                    {
                        continue;
                    }

                    scriptMgr.mScriptList.Add(script);

                    script.Restore(r);
                }

                DeserializeList(scriptMgr.mScriptLoadList, r);
                DeserializeList(scriptMgr.mScriptRemoveList, r);
            }

            return(scriptMgr);
        }
示例#5
0
        public static PsScript Load(PsScriptMgr mgr, int id)
        {
            string path = mgr.Factory.GetScriptPath(id);

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(path);
                XmlNode scriptNode = doc.SelectSingleNode("//MISSION");

                if (scriptNode == null)
                {
                    return(null);
                }

                PsScript script = new PsScript(mgr);

                script.Id = id;

                script.Name = Util.GetString(scriptNode, "name");

                TriggerGroup triggerGroup = new TriggerGroup(script);
                triggerGroup.SetInfo(mgr.Factory, scriptNode);
                if (false == triggerGroup.Parse())
                {
                    return(null);
                }
                else
                {
                    script.mTriggerGroup = triggerGroup;
                }

                return(script);
            }
            catch (System.Exception e)
            {
                Debug.LogError(e.ToString());
                return(null);
            }
        }
示例#6
0
 public EventProxyMgr(PsScriptMgr scriptMgr)
 {
     mScriptMgr = scriptMgr;
 }