public void Send(GameMsg msg) { if (parentSystem != null) { parentSystem.Receive(msg); } }
/// <summary> /// 点击进入游戏 /// </summary> public void ClickEnterBtn() { audioSvc.PlayUIAudio(Constants.UILoginBtn); string _acct = iptAcct.text; string _pass = iptPass.text; if (_acct != "" && _pass != "") { //更新本地存储的账号密码 PlayerPrefs.SetString("Acct", _acct); PlayerPrefs.SetString("Pass", _pass); //发送网络消息,请求登录 GameMsg msg = new GameMsg { cmd = (int)CMD.ReqLogin, reqLogin = new ReqLogin { acct = _acct, pass = _pass } }; netSvc.SendMsg(msg); } else { GameRoot.AddTips("账号或密码为空"); } }
void OnClientReady(ClientReady ready, Connection conn) { if (conn.state == ConnState.WaitForReady) { conn.state = ConnState.InGame; Player p = lm.AddPlayer(ControllerType.Remote, NewPlayerId(), conn.playerName); conn.playerId = p.id; //发送游戏状态 InitServerGameInfo info = new InitServerGameInfo(); //此客户端的玩家信息 info.clientLocalPlayer = p.AchievePlayerInfo(); //其他玩家的信息 info.elsePlayers = new PlayerInfo[lm.playerCount - 1]; lm.AchievePlayerInfo(info.elsePlayers, p.id); Server.SendMessage(new GameMsg(GameMsg.MsgType.InitServerGameInfo, info), conn.connId, UnityEngine.Networking.QosType.ReliableSequenced); //通知其他玩家 PlayerJoin join = new PlayerJoin(); join.info = info.clientLocalPlayer; GameMsg msg = new GameMsg(GameMsg.MsgType.PlayerJoin, join); SendToAllClientsInGame(msg, conn.connId, UnityEngine.Networking.QosType.ReliableSequenced); } }
void OnClientQuit(QuitGameReq req, Connection conn) { Server.Disconnect(conn.connId); //从dict中移出这个连接 connDict.Remove(conn.connId); if (conn.state == ConnState.InGame) { //游戏玩家-1,并通知其他玩家 inGameClientPlayerCount--; LevelManager lm = UnityHelper.GetLevelManager(); lm.RemovePlayer(conn.playerId); UIManager um = UnityHelper.GetUIManager(); um.AddScrollMessage(string.Format("{0}离开游戏", conn.playerName)); Protocol.PlayerQuit quit = new PlayerQuit(); quit.ids = new int[1]; quit.ids[0] = conn.playerId; GameMsg msg = new GameMsg(GameMsg.MsgType.PlayerQuit, quit); SendToAllClientsInGame(msg, UnityEngine.Networking.QosType.ReliableSequenced); } else if (conn.state == ConnState.WaitForReady) { //游戏玩家-1, inGameClientPlayerCount--; } else if (conn.state == ConnState.Connected) { //不用做什么 } }
private void ProcessMsg(GameMsg msg) { Debug.Log("处理数据"); if (msg.err != (int)ERR.None) { switch ((ERR)msg.err) { case ERR.None: Debug.Log("没有错误码"); break; } return; } switch ((CMD)msg.cmd) { case CMD.HeartBeat: //接收到心跳包 刷新 if (ackMgr != null) { ackMgr.UpdateOneHeat(session.Client); } break; case CMD.RspLogin: Debug.Log($"接收到服务端消息:{msg.Chatdata}"); break; } }
public void ReqFBFightEnd(MsgPack pack) { ReqFBFightEnd data = pack.msg.reqFBFightEnd; GameMsg msg = new GameMsg { cmd = (int)CMD.RspFBFightEnd }; // 校验战斗是否合法 if (data.win == true) { if (data.costtime > 0 && data.resthp > 0) { // 根据对应副本ID获取奖励 MapCfg rd = cfgSvc.GetMapCfg(data.fbId); PlayerData pd = cacheSvc.GetPlayerDataBySession(pack.session); // 任务进度更新 TaskSys.Instance.CalcTaskPrgs(pd, 2); pd.coin += rd.coin; pd.crystal += rd.exp; Common.CalcExp(pd, rd.exp); if (pd.fuben == data.fbId) { pd.fuben += 1; } // 更新数据库 if (cacheSvc.UpdatePlayerData(pd.id, pd) == false) { msg.err = (int)ErrorCode.UpdateDBError; } else { RspFBFightEnd rspFBFightEnd = new RspFBFightEnd { win = data.win, fbId = data.fbId, resthp = data.resthp, costtime = data.costtime, coin = pd.coin, lv = pd.lv, exp = pd.exp, crystal = pd.crystal, fuben = pd.fuben }; msg.rspFBFightEnd = rspFBFightEnd; } } } else { msg.err = (int)ErrorCode.ClientDataError; } pack.session.SendMsg(msg); }
public override void PutMessage(GameMsg msg) { base.PutMessage(msg); InteractStatusMsg imsg = msg as InteractStatusMsg; if (imsg != null) { /* Now that scripts are launching this dialog, this handler, and the Procedure Resident class, are no longer needed. if (imsg.InteractName == "TASK:FAST:GET:COMPLETE") { FASTdelay = Time.time + 6.0f; } */ /* moved to Provider class where stethoscope is declared. if (imsg.InteractName == "PROCEDURERESIDENT:STETHOSCOPE:ON") { if(stethoscope != null) { stethoscope.GetComponent<MeshToggle>().Toggle(true); } } if (imsg.InteractName == "PROCEDURERESIDENT:STETHOSCOPE:OFF") { if(stethoscope != null) { stethoscope.GetComponent<MeshToggle>().Toggle(false); } } */ } }
public void AddMsgQue(ServerSession session, GameMsg msg) { lock (obj) //异步 锁住 数据安全 { msgPackQue.Enqueue(new MsgPack(session, msg)); } }
public void ReqRename(MsgPack pack) { ReqRename data = pack.msg.reqRename; GameMsg msg = new GameMsg { cmd = (int)CMD.RspRename }; if (cacheSvc.IsNameExist(data.name)) { //名字是否已经存在 //存在:返回错误码 msg.err = (int)ErrorCode.NameIsExist; } else { //不存在:更新缓存,以及数据库,再返回给客户端 PlayerData playerData = cacheSvc.GetPlayerDataBySession(pack.session); playerData.name = data.name; if (!cacheSvc.UpdatePlayerData(playerData.id, playerData)) { msg.err = (int)ErrorCode.UpdateDBError; } else { msg.rspRename = new RspRename { name = data.name }; } } pack.session.SendMsg(msg); }
public void SndChat(MsgPack pack) { SndChat data = pack.msg.sndChat; PlayerData pd = CacheSvc.Instance.GetPlayerDataBySession(pack.session); GameMsg msg = new GameMsg { cmd = (int)CMD.PshChat, pshChat = new PshChat { name = pd.name, Chat = data.Chat } }; //广播 List <ServerSession> list = CacheSvc.Instance.GetOnlineServerSession(); byte[] bytes = PENet.PETool.PackNetMsg(msg); for (int i = 0; i < list.Count; i++) { list[i].SendMsg(bytes); } TaskSys.Instance.CalcTaskPrgs(pd, 6);//更新任务进度数据 }
//点击登录 public void BtnLoginEnter() { audioService.PlayUIAudio(Constants.uiLoginBtn); string account = accText.text; string passWord = pwdText.text; if (account != "" && passWord != "") { // 更新本地的存储 PlayerPrefs.SetString("Account", account); PlayerPrefs.SetString("PassWord", passWord); //todo发送网络消息 请求登录 GameMsg msg = new GameMsg { cmd = (int)CMD.ReqLogin, reqLogin = new ReqLogin { account = account, password = passWord } }; netService.SendMsg(msg); } else { GameRoot.AddTips("账号密码为空"); } }
public void ReqLogin(MsgPack pack) { ReqLogin data = pack.msg.reqLogin; GameMsg msg = new GameMsg() { cmd = (int)CMD.RspLogin, }; //如果账号已经登入 if (cacheSvc.IsAcctOnline(data.acct)) { msg.err = (int)ErrorCode.AcctIsOnline; } else { PlayerData pd = cacheSvc.GetPlayerData(data.acct, data.pass); if (pd == null) { //存在,密码错误 msg.err = (int)ErrorCode.WrongPass; } else { //登入成功 //计算体力最大值 int power = pd.power; int powerMax = PECommon.GetPowerLimit(pd.lv); if (pd.power < powerMax) { long nowTime = timerSvc.GetNowTime(); long millisecendsCount = nowTime - pd.time; //计算玩家离线时间回复体力值 int addPower = (int)(millisecendsCount / (1000 * 60 * PECommon.PowerAddSpace)) * PECommon.PowerAddCount; if (addPower > 0) { pd.power += addPower; if (pd.power > powerMax) { pd.power = powerMax; } } } if (pd.power != power) { cacheSvc.UpdataPlayerData(pd.id, pd); } msg.rspLogin = new RspLogin() { playerData = pd }; cacheSvc.AcctOnline(data.acct, pack.session, pd); } } pack.session.SendMsg(msg); }
/// <summary> /// 进入游戏按钮点击事件 /// </summary> public void OnEnterButtonClick() { //播放按钮点击音效 audioSvc.PlayUIAudio(Constant.UILoginEnter); string acct = idInput.text; string passwd = pwInput.text; if (acct != "" && passwd != "") { PlayerPrefs.SetString("Acct", acct); PlayerPrefs.SetString("PW", passwd); //发送网络消息 请求登录 GameMsg msg = new GameMsg { cmd = (int)CMD.ReqLogin, reqLogin = new ReqLogin { acct = acct, pwd = passwd } }; netSvc.SendMsg(msg); //LoginSys.Instance.RspLogin(); } else { GameRoot.AddTipsToQueue("账号或 密码为空"); } }
public void SndChat(MsgPack pack) { SndChat data = pack.msg.sndChat; PlayerData pd = cacheSvc.GetPlayerDataBySession(pack.session); // 任务进度数据更新 PshTaskPrgs pshTaskPrgs = TaskSys.Instance.GetTaskPrgs(pd, 6); GameMsg msg = new GameMsg { cmd = (int)CMD.PshChat, pshChat = new PshChat { name = pd.name, chat = data.chat }, pshTaskPrgs = pshTaskPrgs }; // 广播所有在线客户端 List <ServerSession> lst = cacheSvc.GetOnlineServerSessions(); // 重点优化,因为要给很多个客户端发送相同的数据,如果重复地序列化成二进制发送会重复浪费cpu,所以可以先序列化成二进制再重复发送 byte[] bytes = PENet.PETool.PackNetMsg(msg); for (int i = 0; i < lst.Count; i++) { lst[i].SendMsg(bytes); } }
/// <summary> /// 创建角色,重命名 /// </summary> /// <param name="pack"></param> public void ReqRename(MsgPack pack) { ReqRename data = pack.msg.reqRename; GameMsg msg = new GameMsg { cmd = (int)CMD.RspRename }; if (cacheSvc.IsNameExit(data.name) == true) { // 名字已存在,返回错误码 msg.err = (int)ErrorCode.NameIsExist; } else { // 名字未使用,更新缓存,数据库,返回给客户端 PlayerData playerData = cacheSvc.GetPlayerDataBySession(pack.session); playerData.name = data.name; if (cacheSvc.UpdatePlayerData(playerData.id, playerData) == false) { msg.err = (int)ErrorCode.UpdateDBError; } else { msg.rspRename = new RspRename { name = data.name }; } } pack.session.SendMsg(msg); }
public void OnTaskBtnClick(int fbid) { audioSvc.PlayUIAudio(Constant.UICommonClick); //检查体力是否足够TODO int costStamina = resSvc.GetMapCfg(fbid).costStamina; if (playerData.stamina < costStamina) { GameRoot.AddTipsToQueue("体力不足"); } else { //向服务器发送数据,请求进入战斗场景 GameMsg msg = new GameMsg { cmd = (int)CMD.ReqFBFight, reqFBFight = new ReqFBFight { fbid = fbid, } }; netSvc.SendMsg(msg); } SetWindowState(false); }
public void EndBattle(bool isWin, int restHp) { playerCtrlWnd.SetWndState(false); GameRoot.Instance.dynamicWnd.RmvAllHpItemInfo(); if (isWin == true) { double endFightTime = timerSvc.GetNowTime(); // 发送数据到服务器结算 GameMsg gameMsg = new GameMsg { cmd = (int)CMD.ReqFBFightEnd, reqFBFightEnd = new ReqFBFightEnd { fbId = fbid, win = isWin, resthp = restHp, costtime = (int)(endFightTime - startFightTime) } }; netSvc.SendMsg(gameMsg); } else { SetBattleEndWndState(FBEndType.Lose); } }
public void RspDungeonFight(GameMsg msg) { GameRoot.Instance.SetPlayerDataByDungeonStart(msg.rspDungeonFight); MainCitySys.Instance.mainCityWnd.SetWndState(false); SetDungeonWndState(false); BattleSys.Instance.StartBattle(msg.rspDungeonFight.dungeonId); }
public void RspFBFight(GameMsg msg) { GameRoot.Instance.SetPlayerDataByFBStart(msg.rspFBFight); MainCitySys.Instance.maincityWnd.SetWndState(false); SetFubenWndState(false); BattleSys.Instance.StartBattle(msg.rspFBFight.fbid); }
/// <summary> /// 点击进入游戏 /// </summary> public void ClickEnterBtn() { audioSvc.PlayUIAudio(Constants.UILoginBtn); string account = iptAcct.text; string password = iptPass.text; if (account != "" && password != "") { //更新本地存储的账号密码 PlayerPrefs.SetString("Acct", account); PlayerPrefs.SetString("Pass", password); //TODO 发送网络消息,请求登录 GameMsg msg = new GameMsg { cmd = (int)CMD.ReqLogin, reqLogin = new ReqLogin { Acct = account, Pass = password, } }; netSvc.SendMsg(msg); } else { GameRoot.AddTips("账号或密码为空"); } }
public void AddMsgQue(GameMsg msg) { lock (obj) { msgQueue.Enqueue(msg); } }
public void ClickNextBtn() { audioSvc.PlayUIAudio(Constants.UIClickBtn); index += 1; if (index == dialogArr.Length) { //TODO发送任务引导完成信息 GameMsg msg = new GameMsg { cmd = (int)CMD.ReqGuide, reqGuide = new ReqGuide { guideid = curtTaskData.ID } }; netSvc.SendMsg(msg); SetWndState(false); } else { SetTalk(); } }
public void EndBattle(bool isWin, int restHP) { playerCtrlWnd.SetWndState(false); GameRoot.Instance.dynamicWnd.RemoveAllHpItemInfo(); if (isWin) { double endTime = timerSvc.GetNowTime(); //发送结算战斗请求 GameMsg msg = new GameMsg { cmd = (int)CMD.ReqFBFightEnd, reqFBFightEnd = new ReqFBFightEnd { win = isWin, fbid = fbid, resthp = restHP, costtime = (int)((endTime - startTime) / 1000), } }; netSvc.SendMsg(msg); } else { SetBattleEndWndState(FBEndType.Lose); } }
public void ReqRename(MsgPack pack) { ReqRename rename = pack.msg.reqRename; GameMsg msg = new GameMsg() { cmd = (int)CMD.RspRename, }; if (cacheSvc.IsNameExist(rename.name)) { msg.err = (int)ErrorCode.NameIsExist; } else { PlayerData playerData = cacheSvc.GetPlayerDataBySession(pack.session); playerData.name = rename.name; if (!cacheSvc.UpdataPlayerData(playerData.id, playerData)) { msg.err = (int)ErrorCode.UpdateDBError; } else { msg.rspRename = new RspRename() { name = rename.name }; } } pack.session.SendMsg(msg); }
private void ProcessMsg(GameMsg msg) { if (msg.err != (int)ErrorCode.Node) { switch ((ErrorCode)msg.err) { //case ErrorCode.Node: // break; case ErrorCode.AcctisOnline: GameRoot.AddTips("当前账号已上线"); break; case ErrorCode.WrongPass: GameRoot.AddTips("密码错误"); break; } return; } switch ((CMD)msg.cmd) { //case CMD.None: // break; //case CMD.ReqLogin: // break; case CMD.RspLogin: LoginSys.Instance.RspLogin(msg); break; } }
private void ProcessMsg(GameMsg msg) { NetLogger.LogMsg("处理数据:" + msg.chatMsg); if (msg.err != (int)ERR.None) { switch ((ERR)msg.err) { case ERR.None: NetLogger.LogMsg("err 111"); break; } return; } switch ((CMD)msg.cmd) { case CMD.HelloWorld: //接收到心跳包 刷新 if (ackMgr != null) { ackMgr.UpdateOneHeat(client.Client); } break; case CMD.Chat: NetLogger.LogMsg($"接收到聊天信息{msg.chatMsg}"); break; } }
public void SndChat(MsgPack msgPack) { SndChat data = msgPack.msg.sndChat; PlayerData pd = cacheSvc.GetPlayerDataBySettion(msgPack.session); GameMsg msg = new GameMsg { cmd = (int)CMD.PshChat, pshChat = new PshChat { name = pd.name, chat = data.chat, }, }; //任务进度更新 TaskSys.Instance.CalcTaskPrgs(pd, 6);//?需要更新吗 //广播消息 var lst = cacheSvc.GetOnlineSvrSessions(); byte[] msgData = PENet.PETool.PackNetMsg(msg);//广播前提前序列化,减少次数 foreach (var svrsin in lst) { svrsin.SendMsg(msgData); } }
/// <summary> /// 点击进入游戏按钮 /// </summary> public void ClickEnterButton() { audioSvc.PlayUIAudio(Constants.UILoginBtn); string mAcct = iptAcct.text; string mPwd = iptPwd.text; // 输入合法 if (mAcct != "" && mPwd != "") { //更新本地存储的账号和密码 PlayerPrefs.SetString("Acct", mAcct); PlayerPrefs.SetString("Pwd", mPwd); // 发送网络消息,请求登录 GameMsg msg = new GameMsg { cmd = (int)CMD.ReqLogin, reqLogin = new ReqLogin { acct = mAcct, pwd = mPwd } }; // 发送消息给服务器 netSvc.SendMsg(msg); } // 输入不合法 else { GameRoot.AddTips("输入不合法"); } }
public void RspGuide(GameMsg msg) { RspGuide data = msg.rspGuide; GameRoot.AddTips(Constants.Color("任务奖励 金币+" + curtTaskData.coin + " 经验+" + curtTaskData.exp, TxtColor.Blue)); switch (curtTaskData.actID) { case 0: break; case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; } GameRoot.Instance.SetPlayerDataByGuide(data); mainCityWnd.RefreshUI(); }
public void SndChat(PackMsg pack) { SndChat data = pack.msg.sndChat; PlayerData pd = cacheSvc.GetPlayerDataCache(pack.session); PshTaskProgs pshTaskProgs = null; //更新任务进度 pshTaskProgs = TaskSys.Instance.CalcTaskProgs(pd, 6); GameMsg msg = new GameMsg { cmd = (int)CMD.PshChat, pshChat = new PshChat { name = pd.name, msg = data.msg } }; if (pshTaskProgs != null) { msg.pshTaskProgs = pshTaskProgs; } //广播所有在线客户端 List <ServerSession> sessionList = cacheSvc.GetOnLineServerSessions(); foreach (ServerSession session in sessionList) { session.SendMsg(msg); } }
/// <summary> /// 处理请求升级逻辑 /// </summary> /// <param name="pack"></param> public void ReqStrong(MsgPack pack) { ReqStrong data = pack.msg.reqStrong; GameMsg msg = new GameMsg { cmd = (int)CMD.RspStrong, }; PlayerData pd = cacheSvc.GetPlayerDataBySettion(pack.session); int curtStartLv = pd.strongArr[data.pos];//请求升级的武器 StrongCfg nextSd = cfgSvc.GetStrongCfg(data.pos, curtStartLv + 1); //数据校验(这是必须的,如果客户端均已校验,则此校验结果可以作为玩家是否作弊的依据) if (pd.lv < nextSd.minlv) { msg.err = (int)ErrorCode.LackLevel; } else if (pd.coin < nextSd.coin) { msg.err = (int)ErrorCode.LackCoin; } else if (pd.crystal < nextSd.crystal) { msg.err = (int)ErrorCode.LackCrystal; } else//校验通过 { //资产变化 pd.coin -= nextSd.coin; pd.crystal -= nextSd.crystal; pd.strongArr[data.pos] += 1; //属性变化 pd.hp += nextSd.addhp; pd.ad += nextSd.addhurt; pd.ap += nextSd.addhurt; pd.addef += nextSd.adddef; pd.apdef += nextSd.adddef; //任务进度更新 TaskSys.Instance.CalcTaskPrgs(pd, 3); //数据库更新 if (cacheSvc.UpdatePlayerData(pd.id, pd)) { msg.rspStrong = new RspStrong { coin = pd.coin, crystal = pd.crystal, hp = pd.hp, ad = pd.ad, ap = pd.ap, addef = pd.addef, apdef = pd.apdef, strongArr = pd.strongArr }; } else { msg.err = (int)ErrorCode.UpdateDbError; } } pack.session.SendMsg(msg); }
public override void PutMessage(GameMsg msg) { base.PutMessage(msg); InteractStatusMsg ismsg = msg as InteractStatusMsg; if (ismsg != null) { if (ismsg.InteractName == "TASK:TABLE:PUTHOME") { State = TableState.NotInPlace; UnityEngine.Debug.Log("IntubationTable.PutMessage() : " + ismsg.InteractName + ", tray is not in place = <" + InPlace + ">"); } if (ismsg.InteractName == "TASK:TABLE:PUTBEDSIDE:COMPLETE") { State = TableState.InPlace; UnityEngine.Debug.Log("IntubationTable.PutMessage() : " + ismsg.InteractName + ", tray is in place = <" + InPlace + ">"); } } TaskRequestedMsg trmsg = msg as TaskRequestedMsg; if (trmsg != null) { if (trmsg.Request == "TASK:TABLE:PUTBEDSIDE") { UnityEngine.Debug.Log("IntubationTable.PutMessage() : TaskRequestMsg=<" + trmsg.Name + "," + trmsg.Request + ">"); } } }
override public void PutMessage(GameMsg msg) { // call base base.PutMessage(msg); InteractMsg interactMsg = msg as InteractMsg; if (interactMsg != null) { // if (interactMsg.map.item == "PHONE:CALL:ATTENDING") // { // // see if the cuff is enabled (anywhere). we should change this so there is // // only one cuff object! // /* - CHECK CUFF ENABLED // bool cuffEnabled = false; // PatientBloodPressureCuff[] cuffs = GameObject.FindObjectsOfType(typeof(PatientBloodPressureCuff)) as PatientBloodPressureCuff[]; // if (cuffs != null) // { // foreach (PatientBloodPressureCuff cuff in cuffs) // if (cuff.enabled && cuff.gameObject.active) // { // if (cuff.Visible == true) // cuffEnabled = true; // } // } // * */ // string dialog = EFMScenario.GetInstance().GetCurrentTurn().PhoneDialogAttending; // if (dialog == null || dialog == "" ) // dialog = "MissingPhone"; // // CHECK CUFF ENABLED // //if (cuffEnabled == false) // // dialog = "DefaultNoBP"; // DialogueTree.Instance.GoToDialogue(dialog, true); // } // else if (interactMsg.map.item == "PHONE:CALL:NURSE") // { // string dialog = EFMScenario.GetInstance().GetCurrentTurn().PhoneDialogNurse; // if (dialog == null || dialog == "") // dialog = "MissingPhoneNurse"; // DialogueTree.Instance.GoToDialogue(dialog, true); // } // else if (interactMsg.map.item == "PHONE:CALL:ANESTH") // { // string dialog = EFMScenario.GetInstance().GetCurrentTurn().PhoneDialogAnesth; // if (dialog == null || dialog == "" ) // dialog = "MissingPhoneAnesth"; // DialogueTree.Instance.GoToDialogue(dialog, true); // } // special HandleResponse(interactMsg); } }
public override void PutMessage(GameMsg msg) { //InfoDialogMsg idmsg = msg as InfoDialogMsg; //if (idmsg != null) //{ // idmsg.screenName = "dialogGeneric"; // idmsg.xmlName = "InfoDialog"; // idmsg.screenType = "InfoDialogGUI"; // idmsg.modal = false; // GUIManager.GetInstance().PutMessage(idmsg); //} }
override public void PutMessage(GameMsg msg) { if (IsActive() == false) return; ResizeDialogMsg dialogmsg = msg as ResizeDialogMsg; if (dialogmsg != null) { // only call base if this message is for us base.PutMessage(msg); textbox = dialogmsg.text; } }
override public void PutMessage(GameMsg msg) { if (IsActive() == false) return; ModalDialogMsg dialogmsg = msg as ModalDialogMsg; if (dialogmsg != null) { // only call base if this message is for us base.PutMessage(msg); textbox = dialogmsg.text; // set the color on the open command if ( dialogmsg.command == DialogMsg.Cmd.open ) color = RenderSettings.ambientLight; } }
public override void PutMessage(GameMsg msg) { base.PutMessage(msg); InteractStatusMsg imsg = msg as InteractStatusMsg; if (imsg != null) { if (imsg.InteractName == "TASK:XRAY:SHOOT:COMPLETE") { //UnityEngine.Debug.Log("XRayTech : Got TASK:XRAY:SHOOT:COMPLETE MSG!"); //PUT THE DIALOG HERE DialogLoader dl = GetComponent<DialogLoader>(); if (dl != null) { dl.LoadXML("dialog.xray.template"); } } } }
public override void PutMessage(GameMsg msg) { base.PutMessage(msg); InteractStatusMsg ismsg = msg as InteractStatusMsg; if (ismsg != null) { if (ismsg.InteractName == "PREP:INTUBATION:COMPLETE") { State = TrayState.TrayInPlace; UnityEngine.Debug.Log("IntubationTray.PutMessage() : PREP:INTUBATION:COMPLETE, tray in place = <" + InPlace + ">"); } } TaskRequestedMsg trmsg = msg as TaskRequestedMsg; if (trmsg != null) { UnityEngine.Debug.Log("IntubationTray.PutMessage() : TaskRequestMsg=<" + trmsg.Name + "," + trmsg.Request + ">"); } }
override public void PutMessage(GameMsg msg) { QuickInfoMsg dialogmsg = msg as QuickInfoMsg; if (dialogmsg != null) { // only call base if this message is for us base.PutMessage(msg); switch ( dialogmsg.command ) { case DialogMsg.Cmd.open: { if (dialogmsg.timeout == 0.0f) timeout = 0.0f; else timeout = Time.time + dialogmsg.timeout; DialogLoader dl = DialogLoader.GetInstance(); if (dl != null) { DialogMsg dmsg = new DialogMsg(); dmsg.className = "GUIDialog"; dmsg.xmlName = "dialog.quickinfo.template"; dmsg.modal = false; Screen = GUIManager.GetInstance().LoadDialog(dmsg); Screen.SetLabelText("titleBarText", dialogmsg.title); Screen.SetLabelText("contentText", dialogmsg.text); } LogMgr.GetInstance().Add(new ParamLogItem(Time.time, "QuickInfoMsg", dialogmsg.text)); } break; case DialogMsg.Cmd.close: GUIManager.GetInstance().Remove(Screen.Parent); Screen = null; break; } } }
public override void PutMessage(GameMsg msg) { AssessmentScenarioMsg asmsg = msg as AssessmentScenarioMsg; if (asmsg != null) { QuickInfoMsg qimsg = new QuickInfoMsg(); qimsg.text = asmsg.PrettyPrint(); QuickInfoDialog.GetInstance().PutMessage(qimsg); } AssessmentListMsg almsg = msg as AssessmentListMsg; if (almsg != null) { #if DEBUG_ASSESSMENT_LIST QuickInfoMsg qimsg = new QuickInfoMsg(); qimsg.text = almsg.PrettyPrint(); QuickInfoDialog.GetInstance().PutMessage(qimsg); #endif } AssessmentItemMsg aimsg = msg as AssessmentItemMsg; if (aimsg != null) { if (aimsg.Item.Fatal == true) { QuickInfoMsg qimsg = new QuickInfoMsg(); qimsg.title = "FATAL"; qimsg.text = aimsg.PrettyPrint(); QuickInfoDialog.GetInstance().PutMessage(qimsg); } } }
public override void PutMessage(GameMsg msg) { UnityEngine.Debug.Log("Assessment : PutMessage"); }
public void PutMessage( GameMsg msg ) { }
public override void PutMessage(GameMsg msg) { // check for correct person, not busy, etc. if (CheckValidInteraction(msg) == false) return; TaskCompleteMsg complete = msg as TaskCompleteMsg; if ( complete != null ) { if (InteractionList != null) { #if DEBUG_INTERACTIONLIST UnityEngine.Debug.Log("Character.PutMessage() : TaskCompleteMsg, Name=" + Name + " : InteractionList=" + InteractionList.Name + " : task=" + InteractionList.Current.Name); #endif InteractionList.TaskComplete(complete.TaskName); } else { #if DEBUG_INTERACTIONLIST UnityEngine.Debug.Log("Character.PutMessage() : TaskCompleteMsg, Name=" + Name + " : InteractionList=null"); #endif } } // handle base message base.PutMessage(msg); }
override public void PutMessage(GameMsg msg) { PopupMsg dialogmsg = msg as PopupMsg; if (dialogmsg != null) { // only call base if this message is for us base.PutMessage(msg); textbox = dialogmsg.text; x = dialogmsg.x; y = dialogmsg.y; w = dialogmsg.w; h = dialogmsg.h; visible = true; this.hasCancel = dialogmsg.hasCancel; this.commandString = dialogmsg.commandString; title = dialogmsg.title; } }
public void PutMessage(GameMsg msg) { MedAdministerMsg medmsg = msg as MedAdministerMsg; if (medmsg != null) { // check inventory (make sure med has been ordered) if (CheckInventory(medmsg.Med) == false) { // put up QI dialog, med is not ready return; } // save as administered Administered.Add(medmsg.Med); // log interaction MedAdministerLogItem logitem = new MedAdministerLogItem(Time.time, medmsg.Med, medmsg.Type, medmsg.Who, medmsg.Dosage); LogMgr.GetInstance().Add(logitem); // broadcast ObjectManager.GetInstance().PutMessage(medmsg); } // add order MedOrderMsg ordermsg = msg as MedOrderMsg; if (ordermsg != null) { Ordered.Add(ordermsg); // log interaction MedOrderItem logitem = new MedOrderItem(Time.time, ordermsg.Med, ordermsg.Who); LogMgr.GetInstance().Add(logitem); } }
public override void PutMessage(GameMsg msg) { AssessmentMgrDialogMsg dmsg = msg as AssessmentMgrDialogMsg; if (dmsg != null) { if (dmsg.List != null) List = dmsg.List; if ( dmsg.Report != null ) Report = dmsg.Report; // close info dialog InfoDialogMsg idmsg = new InfoDialogMsg(); idmsg.command = DialogMsg.Cmd.close; InfoDialogLoader.GetInstance().PutMessage(idmsg); // put up assessment dialog if (Screen != null) { GUIManager.GetInstance().Remove(Screen.Parent); Screen = null; } DialogLoader dl = DialogLoader.GetInstance(); if (dl != null) { dl.LoadXML("dialog.assessment"); GUIScreen dp = Screen = dl.ScreenInfo.FindScreen("AssessmentScreen"); dp.SetLabelText("titleBarText", "Scenario Assessment"); GUIContainer guiobj = dp.Find("scrollBox") as GUIContainer; if (guiobj != null) { GUIReportObject reportObj = new GUIReportObject(Report); reportObj.SetSkin(gSkin); guiobj.Elements.Add(reportObj); } } } //base.PutMessage(msg); }
public override void PutMessage( GameMsg msg ) { // speech SpeechMsg speechmsg = msg as SpeechMsg; if (speechmsg != null) { HandleSpeech(speechmsg); return; } // log it InteractMsg interactMsg = msg as InteractMsg; if (interactMsg != null) { HandleInteractMsg(interactMsg); HandleResponse(interactMsg); if (IsActive() == true) { Brain.GetInstance().PutMessage(msg); } } // let our scriptedObject see this msg I admit this isn't very clean yet. if (GetComponent<ScriptedObject>() != null) GetComponent<ScriptedObject>().PutMessage(msg); }
public virtual void HandleResponse(GameMsg msg) { ObjectInteractionMgr.GetInstance().HandleResponse(msg); }
public override void PutMessage(GameMsg msg) { if (GUIManager.GetInstance() != null) GUIManager.GetInstance().Fade = false; // this doesn't belong here at all. but it needs to happen. InteractStatusMsg ismsg = msg as InteractStatusMsg; if (ismsg != null) { if (ismsg.InteractName == "GO:TO:ASSESSMENT") { MenuLoader loader = new GameObject("tmp").AddComponent<MenuLoader>() as MenuLoader; if ( loader != null ) loader.GotoAssessment(); } } base.PutMessage(msg); // let assessment manager chew on this msg AssessmentMgr.GetInstance().PutMessage(msg); // InteractionMgr.GetInstance().EvaluateInteractionSet(msg); #if DEBUG_ASSESSMENT_ITEM AssessmentItemMsg aimsg = msg as AssessmentItemMsg; if (aimsg != null) { // do a quickinfo dialog for the 1st list item QuickInfoMsg qimsg = new QuickInfoMsg(); qimsg.timeout = 3.0f; qimsg.title = "Assessment Item"; qimsg.text = aimsg.PrettyPrint(); QuickInfoDialog.GetInstance().PutMessage(qimsg); } #endif #if DEBUG_ASSESSMENT_LIST AssessmentListMsg almsg = msg as AssessmentListMsg; if (almsg != null) { // do a quickinfo dialog for the 1st list item QuickInfoMsg qimsg = new QuickInfoMsg(); qimsg.timeout = 3.0f; qimsg.title = "Assessment List"; qimsg.text = almsg.PrettyPrint(); QuickInfoDialog.GetInstance().PutMessage(qimsg); } #endif // send to MedLabMgr //MedLabMgr.GetInstance().PutMessage(msg); }
public void PutMessage(GameMsg msg) { InteractStatusMsg ismsg = msg as InteractStatusMsg; if (ismsg != null) { #if CHECK_VALID_INTERACTION // check for valid map if (ismsg.InteractMap == null) { // can't find it, look it up ismsg.InteractMap = InteractionMgr.GetInstance().Get(ismsg.InteractName); if (ismsg.InteractMap == null) { #if DEBUG_DECISION_ENGINE UnityEngine.Debug.Log("DecisionMgr.PutMessage() : InteractMap = null. InteractName=" + ismsg.InteractName); #endif return; } } #endif #if DEBUG_DECISION_ENGINE UnityEngine.Debug.Log("DecisionMgr.PutMessage(" + ismsg.InteractName + ")"); #endif // add msg Interactions.Add(ismsg); // evaluate immediately EvaluateMaps(); } }
virtual public void PutMessage(GameMsg msg) { // handlers HandleChangeState(msg); HandleInteractStatusMsg(msg); HandleCallbacks(msg); // pass messages to current state if (current != null) { // send to brain states current.PutMessage(msg); } }
public void HandleInteractStatusMsg(GameMsg msg) { // first try making this a InteractStatusMsg InteractStatusMsg ismsg = msg as InteractStatusMsg; if (ismsg == null) { // nope, try InteractMsg InteractMsg imsg = msg as InteractMsg; if (imsg == null) { #if DEBUG_BRAIN UnityEngine.Debug.Log("Brain.HandleInteractStatusMsg() : not InteractMsg!!"); #endif // not the right msg, hangup return; } ismsg = new InteractStatusMsg(imsg); } if (ismsg != null) { #if DEBUG_BRAIN UnityEngine.Debug.Log("Brain.HandleInteractStatusMsg(" + ismsg.InteractName + ")"); #endif // log it LogMgr.GetInstance().GetCurrent().Add(new InteractStatusItem(ismsg)); // send interact status message to everyone ObjectManager.GetInstance().PutMessage(ismsg); // pass to the GUI manager if (GUIManager.GetInstance() != null) GUIManager.GetInstance().PutMessage(ismsg); // pass to decision mgr DecisionMgr.GetInstance().PutMessage(ismsg); } }
public override void PutMessage(GameMsg msg) { MedAdministrationDialogMsg dmsg = msg as MedAdministrationDialogMsg; if (dmsg != null) { UnityEngine.Debug.Log("MedAdministrationDialog.PutMessage(" + msg + ") : Provider=" + dmsg.provider); } base.PutMessage(msg); }
public void HandleChangeState(GameMsg msg) { // swap states ChangeStateMsg statemsg = msg as ChangeStateMsg; if (statemsg != null) { #if BRAIN_DEBUG Debug.Log("Got ChangeStateMsg = " + statemsg.state); #endif // convert string to classname Type type = brainStates.GetType(); if (type == null) return; PropertyInfo state = type.GetProperty(statemsg.state); if (state == null) { Debug.Log("Brain : HandleChangeState(" + statemsg.state + ") Can't find state!"); return; } BrainState next = state.GetValue(brainStates, null) as BrainState; if (next != null) { // save name next.Name = statemsg.state; next.Args = statemsg.args; // cleanup old state if (current != null) current.Cleanup(); // set current = next; // init new state if (current != null) current.Init(); } else { Debug.LogWarning("ChangeStateMsg: unknown state - " + statemsg.state); } } }
public virtual bool CheckValidInteraction( GameMsg msg) { // don't worry about InteractListMsgs if (msg.GetType() == typeof(InteractListMsg)) { //UnityEngine.Debug.LogWarning("Character.CheckValidInteraction(" + msg.GetType() + ") : ignoring type InteractListMsg"); return true; } // check InteractMsg InteractMsg imsg = msg as InteractMsg; if (imsg != null && imsg.map != null ) { // check prereq if (imsg.map.prereq != null && imsg.map.prereq.Count() > 0) { foreach (string item in imsg.map.prereq) { if (GetInteractionCount(item) < 1) { HandleInteractionError(imsg, "VOICE:MISSING:PREREQ"); return false; } } } // check for exceeding max commands if (imsg.map.max != 0) { if (GetInteractionCount(imsg.map.item) >= imsg.map.max) { HandleInteractionError(imsg, "VOICE:EXCEEDED:MAX:INTERACTION"); // we're done! return false; } } if (IsValidInteraction(imsg.map.item) == false) { HandleInteractionError(imsg, "VOICE:WRONG:PERSON"); // we're done! return false; } /* go ahead and queue this, let the dispatcher handle it.. // check if we're busy if (IsDone() == false) { // Let everyone know we are busy but will get to it later ... // HandleInteractionError(imsg, "VOICE:BUSY"); // this happens too often with the scripting system, lets revisit. // Queue QueueInteractMsg(imsg); return false; } */ } return true; }
public void HandleCallbacks( GameMsg msg ) { if ( putMessageCallback != null ) putMessageCallback(msg); }
virtual public void PutMessage(GameMsg msg) { // check to see if we're active if (IsActive() == false) return; DialogMsg dialogmsg = msg as DialogMsg; if (dialogmsg != null) { //Debug.Log("Dialog: DialogMsg - " + dialogmsg.command); if (dialogmsg.command == DialogMsg.Cmd.open) { modal = dialogmsg.modal; SetModal(dialogmsg.modal); SetVisible(true); } if (dialogmsg.command == DialogMsg.Cmd.close) { SetVisible(false); } if (dialogmsg.command == DialogMsg.Cmd.position) { x = dialogmsg.x; y = dialogmsg.y; } if (dialogmsg.command == DialogMsg.Cmd.size) { w = dialogmsg.w; h = dialogmsg.h; } if (dialogmsg.title != "") { title = dialogmsg.title; } // handle time time = dialogmsg.time; if (dialogmsg.time != 0.0f) { timeout = elapsedTime + time; } } }
public override void PutMessage(GameMsg msg) { UnityEngine.Debug.Log("EndScenario : PutMessage"); }
public void PutMessage( GameMsg msg ) { InteractMsg imsg = msg as InteractMsg; if (imsg != null) // handle special messages to abort or flush script queue { if (imsg.map != null){ if (imsg.map.item == "SCRIPT:ABORT"){ if (scriptStack.Count > 0){ scriptStack.Peek().script.Abort(); } return; } if (imsg.map.item == "SCRIPT:QUEUE:FLUSH"){ if (scriptStack.Count > 0){ scriptStack.Peek().script.Abort(); } //The OnComplete from this abort is likely to start up any stacked or queued scripts. // this really isn't very clean, as there might be stacked scripts which will not get a clean // shutdown opportunity, we should probably abort at each level of the stack before clearing all. // for now, just clear everything after aborting the current script. That should get Zoll going. scriptStack.Clear(); scriptArray.Clear (); currentScript = null; if ( myOI != null ) myOI.actingInScript = null; return; } } //UnityEngine.Debug.Log("Scripted Object "+name+" received interact message "+imsg.map.item); // see if this message should trigger any of our scripts... InteractionScript s = TriggeredScript(imsg.map.item,myOI as BaseObject); if (s != null){ string args = "trigger="+imsg.map.item; int priority=s.startPriority; if (imsg.map.param != null){ for (int i=0;i<imsg.map.param.Count; i++){ if (imsg.map.param[i].Contains("priority")){ string[] kv = imsg.map.param[i].Split('='); int.TryParse(kv[1],out priority); } else { args += " "+imsg.map.param[i]; } } } QueueScript( s,args, gameObject,priority); } return; } InteractStatusMsg ismsg = msg as InteractStatusMsg; if (ismsg != null) { // see if this message should trigger any of our scripts... InteractionScript s = TriggeredScript(ismsg.InteractName,null); if (s != null){ string args = "trigger="+ismsg.InteractName; int priority=4; if (ismsg.Params != null){ foreach (string p in ismsg.Params){ if (p.Contains("priority")){ string[] kv = p.Split('='); int.TryParse(kv[1],out priority); } else { args += " "+p; } } } QueueScript( s,args, gameObject,priority); } //UnityEngine.Debug.Log("Scripted Object "+name+" received interact status message "+ismsg.InteractName); } }
public virtual void HandleResponse(GameMsg msg) { InteractMsg interactmsg = msg as InteractMsg; if (interactmsg == null || interactmsg.map == null) return; //UnityEngine.Debug.Log("ObjectInteractionMgr.HandleResponse(" + interactmsg.map.item + ") : name=<" + interactmsg.gameObject + "> : sound=<" + interactmsg.map.sound + ">"); //interactmsg.map.Debug(); // play audio Brain.GetInstance().PlayAudio(interactmsg.map.sound); // send interaction to the voice manager VoiceMgr.GetInstance().Play(interactmsg); // check for a response string str = interactmsg.map.response; if (str != null && str != "" && str.Length != 0) { // this translates any snapshot specific text string text = Translate(str); // check special case, option to display dialog if (text.Contains("DIALOGUE:")) { // remove the tag string text = text.Replace("DIALOGUE:", ""); // load dialog, if ok then return if (DialogueTree.GetInstance().GoToDialogue(text, true) == true) { return; } } // default to normal dialog InfoDialogMsg infomsg1 = new InfoDialogMsg(); // grab title from map otherwise just use object's prettyname if (interactmsg.map.response_title != null && interactmsg.map.response_title != "") infomsg1.title = StringMgr.GetInstance().Get(interactmsg.map.response_title); else infomsg1.title = "response_title"; if (InfoDialogLoader.GetInstance() != null) { infomsg1.command = DialogMsg.Cmd.open; infomsg1.text = text; // InfoDialogLoader.GetInstance().PutMessage(infomsg1); } } }