Exemplo n.º 1
0
    public void syncPosition(long gameId,
                             string objectName,
                             int objectType,
                             int objectId,
                             bool visible,
                             double x,
                             double y,
                             double z
                             )
    {
        if (!appAccessed)
        {
            return;
        }
        var position = EzyEntityFactory.newObject();

        position.put("x", x);
        position.put("y", y);
        position.put("z", z);
        var request = EzyEntityFactory.newObject();

        request.put("gameName", GAME_NAME);
        request.put("gameId", gameId);
        request.put("objectId", objectId);
        request.put("objectName", objectName);
        request.put("objectType", objectType);
        request.put("visible", visible);
        request.put("position", position);
        var app = socketClient.getApp();

        if (app != null)
        {
            app.udpSend("syncPosition", request);
        }
    }
Exemplo n.º 2
0
    protected override void postHandle(EzyApp app, EzyArray data)
    {
        var request = EzyEntityFactory.newObject();

        request.put("gameName", SocketClientProxy.GAME_NAME);
        app.send("reconnect", request);
    }
Exemplo n.º 3
0
    public void getGameId()
    {
        var request = EzyEntityFactory.newObject();

        request.put("gameName", GAME_NAME);
        socketClient.getApp().send("getGameId", request);
    }
Exemplo n.º 4
0
        protected override EzyObject objectToMap(T obj, EzyMarshaller marshaller)
        {
            EzyObject map = EzyEntityFactory.newObject();

            foreach (PropertyInfo property in objectType.GetProperties())
            {
                string   key  = null;
                EzyValue anno = property.GetCustomAttribute <EzyValue>();
                if (anno != null)
                {
                    key = anno.name;
                }
                else
                {
                    key = property.Name.Length <= 1
                        ? char.ToLower(property.Name[0]).ToString()
                        : char.ToLower(property.Name[0]) + property.Name.Substring(1);
                }
                object rawValue = property.GetValue(obj);
                object value    = rawValue != null?marshaller.marshall <object>(rawValue) : null;

                map.put(key, value);
            }
            return(map);
        }
Exemplo n.º 5
0
    public void finishGame(long gameId)
    {
        var request = EzyEntityFactory.newObject();

        request.put("gameName", GAME_NAME);
        request.put("gameId", gameId);
        socketClient.getApp().send("finishGame", request);
    }
Exemplo n.º 6
0
    public void deleteGameObject(long gameId, int objectId)
    {
        var request = EzyEntityFactory.newObject();

        request.put("gameName", GAME_NAME);
        request.put("gameId", gameId);
        request.put("objectId", objectId);
        socketClient.getApp().send("deleteGameObject", request);
    }
Exemplo n.º 7
0
    public void syncScore(long gameId, long score)
    {
        var request = EzyEntityFactory.newObject();

        request.put("gameName", GAME_NAME);
        request.put("gameId", gameId);
        request.put("score", score);
        socketClient.getApp().send("updateScore", request);
    }
Exemplo n.º 8
0
 public object marshallByInType(object input, Type inType)
 {
     if (input == null)
     {
         return(null);
     }
     if (writerByInType.ContainsKey(inType))
     {
         IEzyWriter writer = writerByInType[inType];
         return(writer.write(input, this));
     }
     if (typeof(IDictionary).IsAssignableFrom(inType))
     {
         EzyObject   answer    = EzyEntityFactory.newObject();
         IDictionary dict      = (IDictionary)(input);
         Type        keyType   = inType.GetGenericArguments()[0];
         Type        valueType = inType.GetGenericArguments()[1];
         foreach (DictionaryEntry entry in dict)
         {
             answer.put(
                 marshallByInType(entry.Key, keyType),
                 marshallByInType(entry.Value, valueType));
         }
         return(answer);
     }
     else if (typeof(IList).IsAssignableFrom(inType))
     {
         EzyArray answer    = EzyEntityFactory.newArray();
         IList    list      = (IList)(input);
         Type     valueType = inType.GetGenericArguments()[0];
         foreach (Object value in list)
         {
             answer.add(marshallByInType(value, valueType));
         }
         return(answer);
     }
     return(input);
 }
Exemplo n.º 9
0
 protected Object transformNonNullValue(Object value)
 {
     if (value is IDictionary)
     {
         IDictionary dictionary = (IDictionary)value;
         EzyObject   obj        = EzyEntityFactory.newObject();
         foreach (DictionaryEntry entry in dictionary)
         {
             obj.put(transform(entry.Key), transform(entry.Value));
         }
         return(obj);
     }
     if (value is ICollection)
     {
         IEnumerable collection = (IEnumerable)value;
         EzyArray    array      = EzyEntityFactory.newArray();
         foreach (Object item in collection)
         {
             array.add(transform(item));
         }
         return(array);
     }
     return(value);
 }