void LoadNpcs() { var npcs = FindObjectsOfType <NpcSystem>(); foreach (var runtime in saveGame.npcRuntimes) { NpcRuntime foundRuntime = null; NpcSystem foundSystem = null; foreach (var npc in npcs) { var npcSaveGameId = npc.GetComponent <SaveGameIdSystem>().SaveGameId; if (npcSaveGameId == runtime.saveGameId) { foundRuntime = runtime; foundSystem = npc.GetComponent <NpcSystem>(); break; } } if (foundRuntime == null) { var spawned = Instantiate(runtimePrefabSettings.npcCharacterPrefab, runtime.position, runtime.rotation); spawned.transform.localScale = runtime.scale; spawned.GetComponent <SaveGameIdSystem>().SaveGameId = runtime.saveGameId; spawned.GetComponent <NpcSystem>().OnLoad(saveGame); } else { foundSystem.OnLoad(saveGame); } } }
/// <summary> /// 构造方法 /// </summary> public SynopsisSystem(InGameSystem _inGame) : base(_inGame) { _inGameSystem = _inGame; EventCenter.AddListener(EventDefine.ShowUIC, ShowUI); EventCenter.AddListener(EventDefine.ShowTalkTextC, ShowTalk); EventCenter.AddListener(EventDefine.ChangeNpcState, SetNpcState); EventCenter.AddListener(EventDefine.ShowTaskButtonC, ShowButton); EventCenter.AddListener(EventDefine.SetTaskPanelC, ShowTaskPanel); EventCenter.AddListener(EventDefine.MiniTaskShowC, ShowMiniTaskPanel); EventCenter.AddListener(EventDefine.Test, ShowProgress); taskSystem = new TaskSystem(this); npcSystem = new NpcSystem(this); talkSystem = new TalkSystem(this); currentTask = new Task(); //currentTask.taskState = TaskState.PickUp; }
/// <summary> /// 展示header状态以及button文本 /// </summary> /// <param name="header"></param> /// <param name="button"></param> public void ShowHeaderAndButton(Text header, Button button, Task currentTask, NpcSystem npcSystem, TalkSystem talkSystem) { //如果没到npc处 if (talkSystem.sy.currentNpc == null) { if (button.interactable) { button.interactable = false; } } //到了npc处 else { //Debug.Log(currentTask.taskType); //如果是对话类型的任务 if (currentTask.taskType == TaskType.Dialogue) { //拿到对话人的npc脚本 for (int i = 0; i < npcSystem.list.Count; i++) { //Debug.Log(npcSystem.list[i].npcName); //Debug.Log(currentTask.prop[0]); if (npcSystem.list[i].npcName == currentTask.prop[0]) { _npc = npcSystem.list[i]; break; } } //如果是对话人且对话结束 if (_npc.npcID == talkSystem.sy.currentNpc.GetComponent <Npc>().npcID&¤tTask.taskState == TaskState.UnSubmit) { SetButton(button, true); } //如果是发布任务的时候 else if (currentTask.npcID == talkSystem.sy.currentNpc.GetComponent <Npc>().npcID&& currentTask.taskState == TaskState.PickUp && talkSystem.sy.TalkState == TalkState.EndTalk) { //Debug.Log(3); SetButton(button, true); } else { SetButton(button, false); } } //其他任务 else { //Debug.Log(5); //如果进入的人和发布任务的人一致 if (currentTask.npcID == talkSystem.sy.currentNpc.GetComponent <Npc>().npcID&&(currentTask.taskState == TaskState.PickUp || currentTask.taskState == TaskState.UnSubmit) && talkSystem.sy.TalkState == TalkState.EndTalk) { SetButton(button, true); } else { SetButton(button, false); } } } //当 ShowText(header, button, currentTask); }
/// <summary> /// 展示button的状态和按钮文字 /// </summary> /// <param name="taskSystem"></param> /// <param name="npcSystem"></param> /// <param name="talkSystem"></param> public void ShowButtonAndState(TaskSystem taskSystem, NpcSystem npcSystem, TalkSystem talkSystem) { showUI.ShowHeaderAndButton(header, button, taskSystem.sy.currentTask, npcSystem, talkSystem); }
private void ThreadLaunch(Timeline timeline, TimelineHandler handler) { try { _log.Trace($"Attempting new thread for: {handler.HandlerType}"); Thread t = null; ThreadJob threadJob = new ThreadJob { Id = Guid.NewGuid().ToString(), Handler = handler }; switch (handler.HandlerType) { case HandlerType.NpcSystem: NpcSystem npc = new NpcSystem(handler); break; case HandlerType.Command: t = new Thread(() => { Cmd o = new Cmd(handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); threadJob.ProcessName = ProcessManager.ProcessNames.Command; break; case HandlerType.Word: _log.Trace("Launching thread for word"); if (_isWordInstalled) { var pids = ProcessManager.GetPids(ProcessManager.ProcessNames.Word).ToList(); if (pids.Count > timeline.TimeLineHandlers.Count(o => o.HandlerType == HandlerType.Word)) { return; } t = new Thread(() => { WordHandler o = new WordHandler(timeline, handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); threadJob.ProcessName = ProcessManager.ProcessNames.Word; } break; case HandlerType.Excel: _log.Trace("Launching thread for excel"); if (_isExcelInstalled) { var pids = ProcessManager.GetPids(ProcessManager.ProcessNames.Excel).ToList(); if (pids.Count > timeline.TimeLineHandlers.Count(o => o.HandlerType == HandlerType.Excel)) { return; } t = new Thread(() => { ExcelHandler o = new ExcelHandler(timeline, handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); threadJob.ProcessName = ProcessManager.ProcessNames.Excel; } break; case HandlerType.Clicks: _log.Trace("Launching thread to handle clicks"); t = new Thread(() => { Clicks o = new Clicks(handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); break; case HandlerType.Reboot: _log.Trace("Launching thread to handle reboot"); t = new Thread(() => { Reboot o = new Reboot(handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); break; case HandlerType.PowerPoint: _log.Trace("Launching thread for powerpoint"); if (_isPowerPointInstalled) { var pids = ProcessManager.GetPids(ProcessManager.ProcessNames.PowerPoint).ToList(); if (pids.Count > timeline.TimeLineHandlers.Count(o => o.HandlerType == HandlerType.PowerPoint)) { return; } t = new Thread(() => { PowerPointHandler o = new PowerPointHandler(timeline, handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); threadJob.ProcessName = ProcessManager.ProcessNames.PowerPoint; } break; case HandlerType.Outlook: _log.Trace("Launching thread for outlook - note we're not checking if outlook installed, just going for it"); //if (this.IsOutlookInstalled) //{ t = new Thread(() => { Outlook o = new Outlook(handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); threadJob.ProcessName = ProcessManager.ProcessNames.Outlook; //} break; case HandlerType.BrowserIE: //IE demands COM apartmentstate be STA so diff thread creation required t = new Thread(() => { BrowserIE o = new BrowserIE(handler); }); t.SetApartmentState(ApartmentState.STA); t.IsBackground = true; t.Name = threadJob.Id; t.Start(); break; case HandlerType.Notepad: //TODO t = new Thread(() => { Notepad o = new Notepad(handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); break; case HandlerType.BrowserChrome: t = new Thread(() => { BrowserChrome o = new BrowserChrome(handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); threadJob.ProcessName = ProcessManager.ProcessNames.Chrome; break; case HandlerType.BrowserFirefox: t = new Thread(() => { BrowserFirefox o = new BrowserFirefox(handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); threadJob.ProcessName = ProcessManager.ProcessNames.Firefox; break; case HandlerType.Watcher: t = new Thread(() => { Watcher o = new Watcher(handler); }) { IsBackground = true, Name = threadJob.Id }; t.Start(); //threadJob.ProcessName = ProcessManager.ProcessNames.Watcher; break; } if (threadJob.ProcessName != null) { _threadJobs.Add(threadJob); } if (t != null) { _threads.Add(t); } } catch (Exception e) { _log.Error(e); } }