private IEnumerator LoadMetaData()
        {
            Debug.Log(string.Format("Loading Mission Metadata for mission {0}", ParticipantBehavior.Participant.CurrentMission));

            var form = new WWWForm();

            form.AddField("mission_number",
                          ParticipantBehavior.Participant.CurrentMission);
            using (var www = UnityWebRequest.Post(ServerURL.LOAD_MISSION, form))
            {
                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    var result = JSON.Parse(www.downloadHandler.text);
                    if (result["failed"].AsBool)
                    {
                        Debug.Log("Could not load Mission Metadata.");
                    }

                    var data = result["data"][0];

                    var missionId     = data["mission_id"].AsInt;
                    var missionLength = data["mission_length"].AsFloat;
                    var missionBrief  = data["mission_brief"];

                    EventManager.OnMetaDataLoaded(missionId, missionLength,
                                                  missionBrief);
                }
            }
        }
Пример #2
0
 public static void CompleteMission()
 {
     EventManager.OnCompleted();
 }