Пример #1
0
        public T RunOnServer <T>(BaseGameObject caller, string functionName, IDictionary <string, object> args = null)
        {
            IDictionary <string, object> serialized = null;

            if (args != null)
            {
                serialized = new Dictionary <string, object>();
                foreach (string key in args.Keys)
                {
                    serialized.Add(key, Client.Instance.GameManager.SerializeSafe(args[key]));
                }
            }

            this.Send("run", new ServerMessages.RunMessage()
            {
                caller       = this.GameManager.SerializeGameObject(caller),
                functionName = functionName,
                args         = serialized
            }
                      );

            var runData = (JToken)this.WaitForEvent("ran");

            return(this.GameManager.GetValueFromJToken <T>(runData));
        }
Пример #2
0
 public Dictionary <string, string> SerializeGameObject(BaseGameObject baseGameObject)
 {
     return(new Dictionary <string, string>()
     {
         { "id", baseGameObject.Id }
     });
 }
Пример #3
0
        private void AutoHandleDelta(JObject data)
        {
            try
            {
                this.GameManager.DeltaUpdate(data);
            }
            catch (Exception exception)
            {
                ErrorHandler.HandleError(ErrorHandler.ErrorCode.DELTA_MERGE_FAILURE, exception, "Could not delta update");
            }

            if (this.AIsPlayer == null)
            {
                try
                {
                    this.AIsPlayer = (BaseGameObject)this.AI.GetType().GetField("Player").GetValue(this.AI);
                }
                catch (Exception exception)
                {
                    ErrorHandler.HandleError(ErrorHandler.ErrorCode.REFLECTION_FAILED, exception, "Could not get ai's player via reflection.");
                }
            }

            if (this.AIsPlayer != null)
            {
                try
                {
                    this.AI.GameUpdated();
                }
                catch (Exception exception)
                {
                    ErrorHandler.HandleError(ErrorHandler.ErrorCode.AI_ERRORED, exception, "AI threw unhandled exception during GameUpdated()");
                }
            }
        }