Exemple #1
0
 private static void OnPing()
 {
     if (gameController != null)
     {
         gameController.OnPing();
     }
 }
        public static void ProcessSignal(string jsonString)
        {
            JSONNode json = JSON.Parse(jsonString);

            switch (json["type"].Value)
            {
            case "Hello":
                //Debug.Log("[Play->ProcessSignal] Raw="+jsonString+" --> Parsed to Settings=" + Settings.FromString(json["settings"].ToString()) + "; json[\"memory\"].ToString():" + json["memory"].ToString());
                gameController.OnHello(Settings.FromString(json["settings"].ToString()), (json["memory"].ToString() == "null") ? null : json["memory"].ToString());;
                break;

            case "Ping":
                gameController.OnPing();
                break;

            case "Suspend":
                gameController.OnSuspend();
                break;

            case "Resume":
                gameController.OnResume();
                break;

            case "Step":
                Hardware.OnStep(directionToString(json["direction"].Value));
                break;

            case "Release":
                Hardware.OnRelease(directionToString(json["direction"].Value));
                break;

            case "SensoState":
                foreach (var dir in json["state"].Keys)
                {
                    JSONNode plate = json["state"][dir];
                    Hardware.OnSensoState(directionToString(dir), plate["x"].AsFloat, plate["y"].AsFloat, plate["f"].AsFloat);
                }
                break;
            }
        }