void OnRequestNewCarRecv(JSONObject json) { tk.JsonTcpClient client = null; //TODO where to get client? //We get this callback in a worker thread, but need to make mainthread calls. //so use this handy utility dispatcher from // https://github.com/PimDeWitte/UnityMainThreadDispatcher UnityMainThreadDispatcher.Instance().Enqueue(SpawnNewCar(client)); }
public void Init(tk.JsonTcpClient _client) { client = _client; _client.dispatchInMainThread = false; //too slow to wait. _client.dispatcher.Register("verify", new tk.Delegates.OnMsgRecv(OnVerify)); _client.dispatcher.Register("set_random_seed", new tk.Delegates.OnMsgRecv(OnSetRandomSeed)); _client.dispatcher.Register("reset_challenges", new tk.Delegates.OnMsgRecv(OnResetChallenges)); }
IEnumerator SpawnNewCar(tk.JsonTcpClient client) { CarSpawner spawner = GameObject.FindObjectOfType <CarSpawner>(); if (spawner != null) { spawner.Spawn(client); } yield return(null); }
public void Init(tk.JsonTcpClient _client) { _client.dispatchInMainThread = true; client = _client; client.dispatcher.Register("load_scene", new tk.Delegates.OnMsgRecv(OnLoadScene)); client.dispatcher.Register("get_protocol_version", new tk.Delegates.OnMsgRecv(OnProtocolVersion)); client.dispatcher.Register("get_scene_names", new tk.Delegates.OnMsgRecv(OnGetSceneNames)); client.dispatcher.Register("quit_app", new tk.Delegates.OnMsgRecv(OnQuitApp)); client.dispatcher.Register("connected", new tk.Delegates.OnMsgRecv(OnConnected)); }
void Awake() { car = carObj.GetComponent <ICar>(); client = GetComponent <tk.JsonTcpClient>(); pm = GameObject.FindObjectOfType <PathManager>(); Canvas canvas = GameObject.FindObjectOfType <Canvas>(); GameObject go = CarSpawner.getChildGameObject(canvas.gameObject, "AISteering"); if (go != null) { ai_text = go.GetComponent <Text>(); } }
public void Init(tk.JsonTcpClient _client) { client = _client; if (client == null) { return; } client.dispatchInMainThread = false; //too slow to wait. client.dispatcher.Register("control", new tk.Delegates.OnMsgRecv(OnControlsRecv)); client.dispatcher.Register("exit_scene", new tk.Delegates.OnMsgRecv(OnExitSceneRecv)); client.dispatcher.Register("reset_car", new tk.Delegates.OnMsgRecv(OnResetCarRecv)); client.dispatcher.Register("step_mode", new tk.Delegates.OnMsgRecv(OnStepModeRecv)); client.dispatcher.Register("quit_app", new tk.Delegates.OnMsgRecv(OnQuitApp)); client.dispatcher.Register("regen_road", new tk.Delegates.OnMsgRecv(OnRegenRoad)); client.dispatcher.Register("car_config", new tk.Delegates.OnMsgRecv(OnCarConfig)); client.dispatcher.Register("cam_config", new tk.Delegates.OnMsgRecv(OnCamConfig)); }
void Awake() { client = GetComponent <tk.JsonTcpClient>(); }