private void OnAction(MuzzleyAppAction muzzley_event) { //participantes[muzzley_event.Participant.Id].UpdateInputs(muzzley_event.Data //print(muzzley_event.Data["c"] + " " + muzzley_event.Data["e"]); if (muzzley_event.Data["c"].ToString() == "jl") participantes[muzzley_event.Participant.Id].MuzzleyInputRotacao(muzzley_event.Data["v"].ToString(), muzzley_event.Data["e"].ToString()); if (muzzley_event.Data["c"].ToString() == "bc") participantes[muzzley_event.Participant.Id].MuzzleyInputAceleracao(muzzley_event.Data["e"].ToString()); if (muzzley_event.Data["c"].ToString() == "bb") participantes[muzzley_event.Participant.Id].MuzzleyInputRe(muzzley_event.Data["e"].ToString()); if (muzzley_event.Data["c"].ToString() == "bd") { if (fluxo == FLUXO.PLACAR) jogarNovamente = true; } }
private void OnAction(MuzzleyAppAction muzzley_event) { int id_int = int.Parse(muzzley_event.Participant.Id.ToString()); string id = muzzley_event.Participant.Id; if (muzzley_event.Data[MuzzleyConstants.Data.COMPONENT].ToString() == MuzzleyConstants.Data.Component.JOYSTICK) { // Debug.Log(MuzzleyConstants.ACTION); // // 1 // Dictionary<string, object> intensitySteps = new Dictionary<string, object>(); // intensitySteps = new Dictionary<string, object>(); // // muzzley_event.Data.TryGetValue("v", out intensitySteps); // string angle = intensitySteps["a"]; // string intensity = intensitySteps["i"]; // Debug.Log(angle); // Debug.Log(intensity); // 2 // float angle = float.Parse(muzzley_event.Data[MuzzleyConstants.ACTION].ToString()); // float intensity = float.Parse(muzzley_event.Data["i"].ToString()); //3 LitJson.JsonData jsonData = LitJson.JsonMapper.ToObject(muzzley_event.Data["v"].ToString()); int angle = int.Parse(jsonData["a"].ToString()); float intensity = float.Parse(jsonData["i"].ToString()); if (muzzley_event.Data[MuzzleyConstants.Data.EVENT].ToString() == MuzzleyConstants.Data.Events.PRESS) { gamePadListeners[id].onJoystickPress(angle, intensity); } else { gamePadListeners[id].onJoystickRelease(angle, intensity); } } else if (muzzley_event.Data[MuzzleyConstants.Data.COMPONENT].ToString() == MuzzleyConstants.Data.Component.BUTTON_A) { if (muzzley_event.Data[MuzzleyConstants.Data.EVENT].ToString() == MuzzleyConstants.Data.Events.PRESS) { gamePadListeners[id].onButonAPress(); } else if (muzzley_event.Data[MuzzleyConstants.Data.EVENT].ToString() == MuzzleyConstants.Data.Events.RELEASE) { gamePadListeners[id].onButonARelease(); } } else if (muzzley_event.Data[MuzzleyConstants.Data.COMPONENT].ToString() == MuzzleyConstants.Data.Component.BUTTON_B) { if (muzzley_event.Data[MuzzleyConstants.Data.EVENT].ToString() == MuzzleyConstants.Data.Events.PRESS) { gamePadListeners[id].onButonBPress(); } else { gamePadListeners[id].onButonBRelease(); } } else if (muzzley_event.Data[MuzzleyConstants.Data.COMPONENT].ToString() == MuzzleyConstants.Data.Component.BUTTON_C) { if (muzzley_event.Data[MuzzleyConstants.Data.EVENT].ToString() == MuzzleyConstants.Data.Events.PRESS) { gamePadListeners[id].onButonCPress(); } else { gamePadListeners[id].onButonCRelease(); } } else if (muzzley_event.Data[MuzzleyConstants.Data.COMPONENT].ToString() == MuzzleyConstants.Data.Component.BUTTON_D) { if (muzzley_event.Data[MuzzleyConstants.Data.EVENT].ToString() == MuzzleyConstants.Data.Events.PRESS) { gamePadListeners[id].onButonDPress(); } else { gamePadListeners[id].onButonDRelease(); } } }