private void genTaskNameButton() { // Debug.Log("task numis " + taskMananger.getRegisitedTasks().Count); if (taskMananger.getStoryTask() != null) { GameObject newDi = Instantiate(TaskNameButtonPrefab) as GameObject; newDi.GetComponent <RectTransform>().SetParent(TaskUI.transform); newDi.GetComponent <RectTransform>().localPosition = new Vector3(-100, 330, 0); Text text = newDi.GetComponentInChildren <Text>(); // Debug.Log("i is " + text.text); text.text = taskMananger.getStoryTask().getTaskName(); buttionList.Add(newDi); Button button = newDi.GetComponent <Button>(); button.onClick.AddListener( delegate() { loadTaskInfo(this.taskMananger.getStoryTask()); }); } Vector3 temPos = new Vector3(-100, 330, 0); foreach (TaskInterface i in taskMananger.getRegisitedTasks()) { temPos.y -= 100; GameObject newDi = Instantiate(TaskNameButtonPrefab) as GameObject; newDi.GetComponent <RectTransform>().SetParent(TaskUI.transform); newDi.GetComponent <RectTransform>().localPosition = temPos; Text text = newDi.GetComponentInChildren <Text>(); // Debug.Log("i is " + text.text); text.text = i.getTaskName(); buttionList.Add(newDi); Button button = newDi.GetComponent <Button>(); button.onClick.AddListener( delegate() { this.clickTaskNameButton(i.getTaskCode()); } ); } if (taskMananger.getRegisitedTasks().Count > 0) { loadTaskInfo(taskMananger.getRegisitedTasks()[0]); } }
public void save() { //定义存档路径 string dirpath = Application.persistentDataPath + "/Save"; //创建存档文件夹 IOHelper.CreateDirectory(dirpath); //定义存档文件路径 filename = dirpath + "/SaveData0.sav"; filename1 = dirpath + "/SaveData1.sav"; filename2 = dirpath + "/SaveData2.sav"; filename3 = dirpath + "/SaveData3.sav"; filename4 = dirpath + "/SaveData4.sav"; filename5 = dirpath + "/SaveData5.sav"; List <Character> charas = roundController.getAllCharaFromMap(); SaveData data = new SaveData(); foreach (Character chara in charas) { saveCharInfo(data, chara); } foreach (Character chara in roundController.getAllChara()) { data.CharaNames.Add(chara.getName()); } data.StoryInfo.IsStoryStart = storyController.getIsStartStory(); if (storyController.getIsStartStory()) { data.StoryInfo.StoryCode = storyController.getStory().getStoryCode(); } data.RoundCount = roundController.getRoundCount(); // Debug.Log("save filename" + filename); foreach (ThingInfo ti in thingController.getEmptyThings()) { data.Things.Add(ti); } foreach (EventInfo ei in eventController.getStayEventList()) { data.EffectedList.Add(ei); } foreach (TaskInterface ti in this.taskMananger.getRegisitedTasks()) { saveRegisitedTask(data, ti); } if (taskMananger.getStoryTask() != null) { saveRegisitedTask(data, taskMananger.getStoryTask()); } data.HistoryTasks = taskMananger.getHistoryTask(); IOHelper.SetData(filename, data); data.CharaNames.Clear(); //保存地图数据 Dictionary <int[], RoomInterface> roomsInfo = roomContraller.getAllRoom(); IOHelper.SetData(filename1, getStringMap(initMapObject.getMapUpInfo())); stringMap.Clear(); IOHelper.SetData(filename2, getStringMap(initMapObject.getMapGroundInfo())); stringMap.Clear(); IOHelper.SetData(filename3, getStringMap(initMapObject.getMapDownInfo())); stringMap.Clear(); IOHelper.SetData(filename4, getStringMap(initMapObject.getMapHiddenInfo())); stringMap.Clear(); }