예제 #1
0
        private void _sendInit(GameObject obj, string name)
        {
            var jsonObject = new JSONObject($"{{\"type\":\"Instantiate\"}}");

            jsonObject["args"] = new JSONObject($"{{\"uuid\":\"{obj.GetComponent<UuidObject>().uuid.ToString()}\",\"parent\":null,\"prefab\":\"{name}\"}}");
            jsonObject["args"]["transform"]             = new JSONObject();
            jsonObject["args"]["transform"]["position"] = Jsonify.VectortoJson(obj.transform.position);
            jsonObject["args"]["transform"]["rotation"] = Jsonify.VectortoJson(obj.transform.rotation.eulerAngles);
            _network.Emit("updateEntity", jsonObject);
        }
예제 #2
0
        private IEnumerator _sendMovement()
        {
            while (true)
            {
                yield return(new WaitForSeconds(_emitSpeed));

                foreach (var obj in _data.Values)
                {
                    if (!(obj is IPlatform) && !(obj is Player))
                    {
                        continue;
                    }

                    var jsonObject = new JSONObject($"{{\"type\":\"Translate\"}}");
                    jsonObject["args"]             = new JSONObject("{\"uuid\":\"a\"}");
                    jsonObject["args"]["position"] = Jsonify.VectortoJson(obj.transform.position);
                    jsonObject["args"]["rotation"] = Jsonify.VectortoJson(obj.transform.rotation.eulerAngles);
                    jsonObject["args"]["uuid"].str = obj.uuid.ToString();
                    _network.Emit("updateEntity", jsonObject);
                }
            }
        }