/// <summary> /// Get Event key /// </summary> /// <param name="ec">EventCollect</param> /// <param name="id">key list</param> /// <returns>event key</returns> public string GetEventKey(EventCollect ec) { string key = "0"; var event_list = PlayerRoot.Instance.evnet_list; for (int i = 0; i < ec.events.Length; i++) { foreach (var e in event_list) { if (e.all_event_id == ec.events[i].all_event_id) { if (e.is_finish) { if (i < ec.events.Length - 1) { key = ec.events[i + 1].all_event_id.ToString(); } } else { if (e.target_num == e.target_count) { key = "complete" + ec.events[i].all_event_id.ToString(); } else { key = ec.events[i].all_event_id.ToString(); } return(key); } } } } return(key); }
/// <summary> /// Get Event /// </summary> /// <param name="JsonString">Json string</param> /// <param name="id">event id</param> /// <returns>EventJson</returns> public EventJson GetEvent(string JsonString, int id = 0) { EventCollect ec = JsonUtility.FromJson <EventCollect>(JsonString); foreach (var ej in ec.events) { if (id != 0) { if (id == ej.all_event_id) { return(ej); } } else if (!ej.is_finish) { return(ej); } } return(null); }
/// <summary> /// テキストファイルを読み込む /// </summary> /// <param name="ss">Scenario Script</param> public void UpdateLines(ScenarioScript ss) { if (ss.enemy_list.Count > 0) { battelEnemyList = ss.enemy_list; } isTutorial = ss.isTutorial; if (ss.fileName != "") { string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "Scenario/" + ss.fileName + ".txt"); string scenarioText = File.ReadAllText(filePath); if (scenarioText == null) { Debug.LogError("Scenario file not found"); Debug.LogError("ScenarioManger not active"); enabled = false; return; } string key = "0"; if (ss.event_file != "") { string js = EventManager.Instance.ReadFile(ss.event_file); EventCollect ec = EventManager.Instance.GetAllEvent(js); key = EventManager.Instance.GetEventKey(ec); } string[] scenarios = scenarioText.Split(new string[] { "\n" }, System.StringSplitOptions.None); m_scenarios = getNowScenario(scenarios, key); m_currentLine = 0; isScenario = true; if (ss.autoDestory) { Destroy(ss.gameObject); } ItweenMoveTo(hukidasi, new Vector3(0, -300, 0), 0.5f, "easeInOutBack", "RequestNextLine", this.gameObject); } }
/// <summary> /// Get All Event /// </summary> /// <param name="JsonString">Json String</param> /// <returns>Even tCollect</returns> public EventCollect GetAllEvent(string JsonString) { EventCollect ec = JsonUtility.FromJson <EventCollect>(JsonString); return(ec); }