Esempio n. 1
0
        private void handleNotifyMapAttrClearOnClient(Packet pkt)
        {
            string   entityID = pkt.ReadEntityID();
            ListAttr path     = pkt.ReadData() as ListAttr;

            EntityManager.Instance.OnMapAttrClear(entityID, path);
        }
Esempio n. 2
0
        private void handleNotifyMapAttrDelOnClient(Packet pkt)
        {
            string   entityID = pkt.ReadEntityID();
            ListAttr path     = pkt.ReadData() as ListAttr;
            string   key      = pkt.ReadVarStr();

            EntityManager.Instance.OnMapAttrDel(entityID, path, key);
        }
Esempio n. 3
0
        static ListAttr convertFromMsgPackObjectList(IList <MsgPack.MessagePackObject> mpobj)
        {
            ListAttr list = new ListAttr();
            IEnumerator <MsgPack.MessagePackObject> e = mpobj.GetEnumerator();

            while (e.MoveNext())
            {
                list.append(convertFromMsgPackObject(e.Current));
            }
            return(list);
        }
Esempio n. 4
0
        internal void OnListAttrChange(ListAttr path, int index, object val)
        {
            ListAttr l = getAttrByPath(path) as ListAttr;

            l.set(index, val);
            string rootkey = (string)path.get(0);

            System.Reflection.MethodInfo callback = this.GetType().GetMethod("OnAttrChange_" + rootkey);
            if (callback != null)
            {
                callback.Invoke(this, new object[0]);
            }
        }
Esempio n. 5
0
        internal void OnMapAttrChange(ListAttr path, string key, object val)
        {
            MapAttr t = this.getAttrByPath(path) as MapAttr;

            t.put(key, val);
            string rootkey = path != null && path.Count > 0 ? (string)path.get(0) : key;

            System.Reflection.MethodInfo callback = this.GetType().GetMethod("OnAttrChange_" + rootkey);
            if (callback != null)
            {
                callback.Invoke(this, new object[0]);
            }
        }
Esempio n. 6
0
        internal void OnMapAttrClear(ListAttr path)
        {
            System.Diagnostics.Debug.Assert(path != null && path.Count > 0);
            MapAttr t = this.getAttrByPath(path) as MapAttr;

            t.Clear();
            string rootkey = (string)path.get(0);

            System.Reflection.MethodInfo callback = this.GetType().GetMethod("OnAttrChange_" + rootkey);
            if (callback != null)
            {
                callback.Invoke(this, new object[0]);
            }
        }
Esempio n. 7
0
        internal void OnMapAttrDel(ListAttr path, string key)
        {
            MapAttr t = this.getAttrByPath(path) as MapAttr;

            if (t.ContainsKey(key))
            {
                t.Remove(key);
            }
            string rootkey = path != null && path.Count > 0 ? (string)path.get(0) : key;

            System.Reflection.MethodInfo callback = this.GetType().GetMethod("OnAttrChange_" + rootkey);
            if (callback != null)
            {
                callback.Invoke(this, new object[0]);
            }
        }
Esempio n. 8
0
        internal void OnMapAttrClear(string entityID, ListAttr path)
        {
            ClientEntity entity;

            try
            {
                entity = this.entities[entityID];
            }
            catch (KeyNotFoundException)
            {
                GoWorldLogger.Warn("EntityManager", "Entity {0} Sync Entity Info Failed: Entity Not Found", entityID);
                return;
            }

            entity.OnMapAttrClear(path);
        }
Esempio n. 9
0
        static MsgPack.MessagePackObject convertToMsgPackObject(object v)
        {
            Type t = v.GetType();

            if (t.Equals(typeof(MapAttr)))
            {
                MapAttr ht = v as MapAttr;
                IDictionaryEnumerator e = ht.GetEnumerator();
                MsgPack.MessagePackObjectDictionary d = new MsgPack.MessagePackObjectDictionary();
                while (e.MoveNext())
                {
                    d.Add(new MsgPack.MessagePackObject(e.Key as string), convertToMsgPackObject(e.Value));
                }
                return(new MsgPack.MessagePackObject(d));
            }
            else if (t.Equals(typeof(ListAttr)))
            {
                ListAttr    al = v as ListAttr;
                IEnumerator e  = al.GetEnumerator();
                System.Collections.Generic.IList <MsgPack.MessagePackObject> l = new System.Collections.Generic.List <MsgPack.MessagePackObject>();
                while (e.MoveNext())
                {
                    l.Add(convertToMsgPackObject(e.Current));
                }
                return(new MsgPack.MessagePackObject(l));
            }
            else if (t.Equals(typeof(bool)))
            {
                return(new MsgPack.MessagePackObject((bool)v));
            }
            else if (t.Equals(typeof(string)))
            {
                return(new MsgPack.MessagePackObject((string)v));
            }
            else
            {
                Debug.Assert(false, "Unknwon type: " + t.Name);
                return(new MsgPack.MessagePackObject());
            }
        }
Esempio n. 10
0
        internal object getAttrByPath(ListAttr path)
        {
            object attr = this.Attrs;

            if (path == null)
            {
                return(attr);
            }

            foreach (object key in path)
            {
                if (key.GetType() == typeof(string))
                {
                    attr = (attr as MapAttr).get((string)key);
                }
                else
                {
                    attr = (attr as ListAttr).get((int)key);
                }
            }

            GoWorldLogger.Debug(this.ToString(), "Get Attr By Path: {0} = {1}", path.ToString(), attr);
            return(attr);
        }