private void _instantiateObject(JSONObject jsonObject) { var guid = Guid.Parse(jsonObject["uuid"].str); var position = Jsonify.JsontoVector(jsonObject["transform"]["position"]); var rotation = Jsonify.JsontoVector(jsonObject["transform"]["rotation"]); var prefab = jsonObject["prefab"].str; switch (prefab) { case "Player": UnityMainThread.Worker.AddJob(() => { _playerCount++; var pref = PrefabManager.GetInstance().GetGameObject($"P{_playerCount}Sprite"); var obj = Object.Instantiate(pref, position, Quaternion.Euler(rotation)); obj.transform.localScale = Vector3.one * 0.4f; obj.GetComponent <UuidObject>().ModifySelfId(guid); }); break; default: UnityMainThread.Worker.AddJob(() => { var pref = PrefabManager.GetInstance().GetGameObject(prefab); var obj = Object.Instantiate(pref, position, Quaternion.Euler(rotation)); obj.GetComponent <UuidObject>().ModifySelfId(guid); }); break; } }
public void Project_ToJson_Success(string relativePath, int referenceCount, int compileCount, string projectName) { var path = GetResourcePath(relativePath); var project = ProjectHelpers.LoadProject(path, new Dictionary <string, string>()); var json = Jsonify.ToJson(project); Assert.AreEqual(referenceCount, json[projectName]["Reference"].Count()); Assert.AreEqual(compileCount, json[projectName]["Compile"].Count()); Assert.AreEqual(projectName, json[projectName]["Properties"]["MSBuildProjectName"].Value <String>()); }
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); }
public void Project_Parameters_AreApplied() { var path = GetResourcePath("Resources/dummy.csproj"); var args = new Dictionary <string, string>(); args["Configuration"] = "Release"; var project = ProjectHelpers.LoadProject(path, args); var json = Jsonify.ToJson(project); Assert.AreEqual("Release", json["dummy"]["Properties"]["Configuration"].Value <String>()); }
private void OnDiscard(Player player, JToken data) { if (player.Hand.Count <= 12) { this.UpdateHand(player); return; } List <string> cardNames = Jsonify.ArrayToList <string>(data["cards"]); player.Discard(player.Hand.GetCards <Card>(cardNames)); }
public void Solution_Parameters_AreApplied() { var path = GetResourcePath("Resources/dummy.sln"); var args = new Dictionary <string, string>(); args["Configuration"] = "Release"; args["Platform"] = "x86"; var projects = ProjectHelpers.GetProjects(SolutionFile.Parse(path), args); var json = Jsonify.ToJson(projects); Assert.AreEqual("Release", json["dummy"]["Properties"]["Configuration"].Value <String>()); Assert.AreEqual("AnyCPU", json["dummy"]["Properties"]["Platform"].Value <String>()); }
public void Solution_ToJson_Success(string relativePath, string[] projects) { var path = GetResourcePath(relativePath); SolutionFile solution = SolutionFile.Parse(path); var json = Jsonify.ToJson(ProjectHelpers.GetProjects(solution, new Dictionary <string, string>())); int i = 0; foreach (var project in json) { Assert.AreEqual(projects[i++], project.Key); } }
private void _translateObject(JSONObject jsonObject) { var uuid = Guid.Parse(jsonObject["uuid"].str); if (!_data.ContainsKey(uuid)) { Debug.Log($"{uuid} is not in uuid dictionary"); return; } var obj = _data[uuid]; obj.transform.position = Jsonify.JsontoVector(jsonObject["position"]); obj.transform.rotation = Quaternion.Euler(Jsonify.JsontoVector(jsonObject["rotation"])); }
public void Project_NugetDependencies_AreParsed() { var path = GetResourcePath("Resources/dummy.csproj"); var args = new Dictionary <string, string>(); args["Configuration"] = "Release"; var project = ProjectHelpers.LoadProject(path, args); var json = Jsonify.ToJson(project); var dependencies = ((JArray)json["dummy"]["NugetDependencies"]); Assert.AreEqual(5, dependencies.Count); AssertDependency(dependencies, 0, "Microsoft.Web.Xdt", "2.1.1"); AssertDependency(dependencies, 1, "MSBuild", "0.1.2"); AssertDependency(dependencies, 2, "Newtonsoft.Json", "8.0.2"); AssertDependency(dependencies, 3, "NuGet.Core", "2.14.0"); AssertDependency(dependencies, 4, "FooBar", "0.2.3.0-gerrit96533-SNAPSHOT", true); }
private void OnPlayCardStage(Player player, JToken data) { QuestCard quest = this.matches[player].CurrentStory as QuestCard; QuestArea area = quest.StageBuilder; List <string> cardNames = Jsonify.ArrayToList <string>(data["cards"]); List <FoeCard> foe = player.Hand.GetCards <FoeCard>(cardNames); List <WeaponCard> weapons = player.Hand.GetCards <WeaponCard>(cardNames); List <TestCard> test = player.Hand.GetCards <TestCard>(cardNames); player.Hand.Transfer(area, test.Cast <Card>().ToList()); player.Hand.Transfer(area, foe.Cast <Card>().ToList()); player.Hand.Transfer(area, weapons.Cast <Card>().ToList()); this.UpdateHand(player); this.UpdateOtherArea(player, area.Cards); this.UpdatePlayerArea(player); }
public async void UpdateGames(Player player) { List <int> ids = new List <int>(); foreach (QuestMatch match in this.matches.Values) { if (!ids.Contains(match.Id)) { ids.Add(match.Id); } } JObject data = new JObject(); data["game_ids"] = Jsonify.ListToArray(ids); EventData evn = new EventData("update_games", data); await this.messageHandler.SendToPlayerAsync(player, evn.ToString()); }
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); } } }
private void OnPlayCards(Player player, JToken data) { List <string> cardNames = Jsonify.ArrayToList <string>(data["cards"]); player.Play(player.Hand.GetCards <BattleCard>(cardNames)); }