예제 #1
0
        // called from game thread
        public void IncrementEvent(string eventId, int steps, Action <bool> callback)
        {
            Logger.d("AndroidClient.IncrementEvent: " + eventId + ", steps " + steps);

            CallClientApi("increment event " + eventId, () => {
                mGHManager.CallGmsApi("games.Games", "Events", "increment",
                                      eventId, steps);
            }, callback);

            // update local cache
            Event e = GetEvent(eventId);

            if (e != null)
            {
                e.Value += steps;
            }
        }
예제 #2
0
        internal void ProcessBuffer(AndroidJavaObject eveBuffer)
        {
            int i, count;

            Logger.d("EventBank: processing event buffer given as Java object.");

            if (eveBuffer == null)
            {
                Logger.w("EventBank: given buffer was null. Ignoring.");
                return;
            }

            count = eveBuffer.Call <int>("getCount");
            Logger.d("EventBank: buffer contains " + count + " events.");

            for (i = 0; i < count; ++i)
            {
                Logger.d("EventBank: processing event #" + i);
                Event             eve    = new Event();
                AndroidJavaObject eveObj = eveBuffer.Call <AndroidJavaObject>("get", i);

                if (eveObj == null)
                {
                    Logger.w("Event #" + i + " was null. Ignoring.");
                    continue;
                }

                eve.Id          = eveObj.Call <string>("getEventId");
                eve.Value       = eveObj.Call <long>("getValue");
                eve.IsVisible   = eveObj.Call <bool>("isVisible");
                eve.Name        = eveObj.Call <string>("getName");
                eve.Description = eveObj.Call <string>("getDescription");

                Logger.d("EventBank: processed: " + eve.ToString());
                if (eve.Id != null && eve.Id.Length > 0)
                {
                    mEvents[eve.Id] = eve;
                }
                else
                {
                    Logger.w("Event w/ missing ID received. Ignoring.");
                }
            }

            Logger.d("EventBank: bank now contains " + mEvents.Count + " entries.");
        }