public void Update() { if (msgPackQue.Count > 0) { PECommon.Log("PackCount:" + msgPackQue.Count); lock (obj) { MsgPack pack = msgPackQue.Dequeue(); //TODO可优化 锁不用锁完 HandOutMsg(pack); } } }
public void Init() { resSvc = ResSvc.Instance; timeSvc = TimerSvc.Instance; Dictionary <int, SkillCfg> skillDicts = resSvc.skillCfgDicts; foreach (var skill in skillDicts.Values) { skillCdDicts.Add(skill.ID, true); } PECommon.Log("SkillMgr Init Done"); }
public void Update() { if (msgPackQue.Count > 0) { PECommon.Log("PackCount" + msgPackQue.Count); //取数据的时候也要加锁 lock (obj) { MsgPack msgPack = msgPackQue.Dequeue(); HandOutMsg(msgPack); } } }
public void Update() { //取出数据 if (msgPackQue.Count > 0) { PECommon.Log("PackCount : " + msgPackQue.Count); lock (obj) { MsgPack pack = msgPackQue.Dequeue(); HadOutMsg(pack); } } }
public void InitSvc() { Instance = this; //实例化计时类 pt = new PETimer(); //日志工具接口 pt.SetLog((string info) => { PECommon.Log(info); }); PECommon.Log("Init TimerSvc..."); }
//发送消息 public void SendMsg(GameMsg msg) { if (client.session != null) { client.session.SendMsg(msg); } else { GameRoot.AddTips("服务器未连接"); PECommon.Log("服务器未连接"); InitSvc(); } }
public void Process(EntityBase entity, params object[] args) { if (entity.GetDirInput() != Vector2.zero) { entity.Move(); entity.SetDir(entity.GetDirInput()); } else { entity.SetBlend(Constants.BlendIdle); } PECommon.Log("Process StateIdle."); }
public void StartBattle(GameMsg msg) { audioSvc.PlayAudioInUI(audioSvc.uiAudio); StartBattle startBattle = msg.startBattle; //传递玩家数据 PECommon.Log("跳转场景,进入战斗。"); resSvc.AsyncLoadScene(Constants.SceneBattle, () => { BattleSys.Instance.EnterBattle(startBattle.battlePropDic); }); //TODO多人再做。 }
public void InitSvc() { Instance = this; InitRDNameCfg(PathDefine.RDNameCfg); InitMapCfg(PathDefine.MapCfg); InitGuideCfg(PathDefine.GuideCfg); InitStrongCfg(PathDefine.StrongCfg); InitTaskRewardCfg(PathDefine.TaskRewardCfg); InitSkillCfg(PathDefine.SkillCfg); InitSkillMoveCfg(PathDefine.SkillMoveCfg); PECommon.Log("Init ResSvc..."); }
public void InitSvc() { Instance = this; pt = new PETimer(); // 设置日志输出 pt.SetLog((string info) => { PECommon.Log(info); }); PECommon.Log("Init TimeSvc..."); }
//分发消息 private void ProcessMsg(GameMsg msg) { if (msg.err != (int)ErrorCode.None) { switch ((ErrorCode)msg.err) { case ErrorCode.AcctIsOnline: GameRoot.AddTips("账号已在线"); break; case ErrorCode.WrongPass: GameRoot.AddTips("密码错误"); break; case ErrorCode.NameRepeat: GameRoot.AddTips("用户名已存在"); break; case ErrorCode.UpdateDbError: GameRoot.AddTips("网络连接异常"); PECommon.Log("数据库更新日常", LogType.Error); break; case ErrorCode.ServerDataError: GameRoot.AddTips("数据异常"); PECommon.Log("服务器数据不一致", LogType.Error); break; } } else { switch ((CMD)msg.cmd) { case CMD.RspLogin: LoginSyc.Instance.RspLogin(msg); break; case CMD.ReName: LoginSyc.Instance.ReName(msg); break; case CMD.ResGuied: MainCitySyc.Instance.ResGuide(msg); break; case CMD.PshChat: MainCitySyc.Instance.PshChat(msg); break; } } }
public void ClearOfflineData(ServerSession serverSession) { PlayerData playerData = cacheSvc.GetPlayerDataCache(serverSession); if (playerData != null) { playerData.time = timeSvc.GetNowTime(); if (!cacheSvc.UpdatePlayerData(playerData.id, playerData)) { PECommon.Log("Update OffLine Time Error", LogType.Error); } cacheSvc.ClearOffLineData(serverSession); } }
public void AcctOffLine(ServerSession session) { foreach (var item in onLineAcctDic) { if (item.Value == session) { onLineAcctDic.Remove(item.Key); break; } } bool succ = onLineSessionDic.Remove(session); PECommon.Log($"Offline Result: SessionID:{session.sessionID} {succ}"); }
public void Init() { conn = new MySqlConnection("server=localhost;User Id = root;password=;Database=darkgod;Charset=utf8"); try { conn.Open(); } catch (Exception e) { } PECommon.Log("DBMgr Init Done."); QueryPlayerData("xxx", "000"); }
public void Enter(EntityBase entityBase, params object[] para) { entityBase.currentAniState = AniState.Jump; //移动跳跃 if (entityBase.currentAniState == AniState.Move) { entityBase.controller.DirJump(); } else { entityBase.controller.CharacterJump(); } PECommon.Log("EnterJump"); }
public void AcctOffLine(ServerSession serverSession) { foreach (var item in onLineAcct) { if (item.Value == serverSession) { onLineAcct.Remove(item.Key); break; } } bool succ = onLineSessionDic.Remove(serverSession); PECommon.Log("账号下线,Session:" + serverSession.session); }
private int InsertNewAcctData(string acct, string pass, PlayerData pd) { int id = -1; try { MySqlCommand cmd = new MySqlCommand ("insert into account set acct=@acct,pass=@pass,name=@name,lv=@lv,power=@power,coin=@coin,diamond=@diamond,exp=@exp," + "crystal=@crystal,hp=@hp,ad=@ad,ap=@ap,addef=@addef,apdef=@apdef,dodge=@dodge,pierce=@pierce,critical=@critical,guideid=@guideid," + "strong=@strong", conn); cmd.Parameters.AddWithValue("id", id); cmd.Parameters.AddWithValue("acct", acct); cmd.Parameters.AddWithValue("pass", pass); cmd.Parameters.AddWithValue("name", pd.name); cmd.Parameters.AddWithValue("lv", pd.lv); cmd.Parameters.AddWithValue("exp", pd.exp); cmd.Parameters.AddWithValue("power", pd.power); cmd.Parameters.AddWithValue("coin", pd.coin); cmd.Parameters.AddWithValue("diamond", pd.diamond); cmd.Parameters.AddWithValue("hp", pd.hp); cmd.Parameters.AddWithValue("ad", pd.ad); cmd.Parameters.AddWithValue("ap", pd.ap); cmd.Parameters.AddWithValue("addef", pd.addef); cmd.Parameters.AddWithValue("apdef", pd.apdef); cmd.Parameters.AddWithValue("dodge", pd.dodge); cmd.Parameters.AddWithValue("pierce", pd.pierce); cmd.Parameters.AddWithValue("critical", pd.critical); cmd.Parameters.AddWithValue("guideid", pd.guideid); cmd.Parameters.AddWithValue("crystal", pd.crystal); string strongInfo = ""; for (int i = 0; i < pd.strengthArray.Length; i++) { strongInfo += pd.strengthArray[i]; strongInfo += "#"; } cmd.Parameters.AddWithValue("strong", strongInfo); cmd.ExecuteNonQuery(); id = (int)cmd.LastInsertedId; } catch (Exception e) { PECommon.Log("Insert playerdata Error:" + e, LogType.Error); } return(id); }
public void Init(BattleMgr battle) { waveIndex = 1; battleMgr = battle; for (int i = 0; i < triggerArr.Length; i++) { BoxCollider co = triggerArr[i].GetComponent <BoxCollider>(); co.isTrigger = false; } //实例化第一批怪物 battleMgr.LoadMonsterByWaveID(waveIndex); PECommon.Log("Init MapMgr Done."); }
public void AccOffLine(ServerSession session) { foreach (var item in onLineAccDic) { if (item.Value == session) { onLineAccDic.Remove(item.Key); break; } } bool succ = onlineSessionDic.Remove(session); PECommon.Log("ID:" + session.sessionID + "的客户端移除结果:" + succ); }
private void InitSkillActionCfg(string assetName, object asset, float duration, object userData) { TextAsset xml = asset as TextAsset; if (!xml) { PECommon.Log("xml file:" + assetName + " not exist", LogType.Error); } else { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml.text); XmlNodeList nodLst = doc.SelectSingleNode("root").ChildNodes; for (int i = 0; i < nodLst.Count; i++) { XmlElement ele = nodLst[i] as XmlElement; if (ele.GetAttributeNode("ID") == null) { continue; } int ID = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText); SkillActionCfg sac = new SkillActionCfg { ID = ID }; foreach (XmlElement e in nodLst[i].ChildNodes) { switch (e.Name) { case "delayTime": sac.delayTime = int.Parse(e.InnerText); break; case "radius": sac.radius = float.Parse(e.InnerText); break; case "angle": sac.angle = int.Parse(e.InnerText); break; } } skillActionDic.Add(ID, sac); } } GameEntry.Resource.UnloadAsset(asset); }
public void Init() { PECommon.Log("TimerSvc Init Done!"); timer = new PETimer(0);//表征100ms调用一次事件的计时器 timer.SetLog(info => PECommon.Log(info)); //设置Handle的逻辑体,即驱动函数在驱动至一个满足条件的回调时,不再执行回调,而是将回调加入队列当中 timer.SetHandle((cb, tid) => { lock (tpQueLock) { tpQue.Enqueue(new TaskPack(tid, cb)); } }); }
public void ClearOffline(ServerSession session) { PlayerData pd = CacheSvc.Instance.GetPlayerDataBySession(session); if (pd != null) { pd.time = TimeSvc.Instance.GetNowTime(); if (!CacheSvc.Instance.UpdatePlayerData(pd.id, pd, session)) { PECommon.Log("Update offline time Error"); } CacheSvc.Instance.AcctOffline(session); } }
/// <summary> /// 更新单个玩家数据 /// </summary> /// <param name="id"></param> /// <param name="data"></param> /// <returns></returns> public bool UpdatePlayerData(int id, PlayerData data) { bool isSuccess = true; MySqlDataReader reader = null; try { MySqlCommand cmd = new MySqlCommand ("update account set name=@name,lv=@lv,exp=@exp,power=@power,coin=@coin,diamond=@diamond " + ",hp=@hp,ad=@ad,ap=@ap,addef=@addef,apdef=@apdef,dodge=@dodge,pierce=@pierce,critical=@critical " + ",guideid=@guideid " + "where id=@id ", conct); cmd.Parameters.AddWithValue("name", data.name); cmd.Parameters.AddWithValue("lv", data.lv); cmd.Parameters.AddWithValue("exp", data.exp); cmd.Parameters.AddWithValue("power", data.power); cmd.Parameters.AddWithValue("coin", data.coin); cmd.Parameters.AddWithValue("diamond", data.diamond); cmd.Parameters.AddWithValue("id", data.id); cmd.Parameters.AddWithValue("hp", data.hp); cmd.Parameters.AddWithValue("ad", data.ad); cmd.Parameters.AddWithValue("addef", data.addef); cmd.Parameters.AddWithValue("ap", data.ap); cmd.Parameters.AddWithValue("apdef", data.apdef); cmd.Parameters.AddWithValue("dodge", data.dodge); cmd.Parameters.AddWithValue("pierce", data.pierce); cmd.Parameters.AddWithValue("critical", data.critical); cmd.Parameters.AddWithValue("guideid", data.guideid); reader = cmd.ExecuteReader(); } catch (Exception e) { PECommon.Log("Update Data Error" + e, LogType.Error); isSuccess = false; } finally { if (reader != null) { reader.Close(); } } return(isSuccess); }
private void InitSkillMoveCfg(string path) { TextAsset xml = Resources.Load <TextAsset>(path); if (!xml) { PECommon.Log("xml file:" + path + " not exist", LogType.Error); } else { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml.text); XmlNodeList nodLst = doc.SelectSingleNode("root").ChildNodes; for (int i = 0; i < nodLst.Count; i++) { XmlElement ele = nodLst[i] as XmlElement; if (ele.GetAttributeNode("ID") == null) { continue; } int ID = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText); SkillMoveCfg smc = new SkillMoveCfg { ID = ID }; foreach (XmlElement e in nodLst[i].ChildNodes) { switch (e.Name) { case "delayTime": smc.delayTime = int.Parse(e.InnerText); break; case "moveTime": smc.moveTime = int.Parse(e.InnerText); break; case "moveDis": smc.moveDis = float.Parse(e.InnerText); break; } } skillMoveDic.Add(ID, smc); } } }
public override void InitSys() { base.InitSys(); loader = ResLoader.Allocate(); loader.Add2Load(QAssetBundle.Scenelogin_unity.SCENELOGIN); loader.LoadAsync(() => { Log.I("加载场景成功"); SceneManager.LoadScene("SceneLogin"); }); // loader.LoadSync(QAssetBundle.Scenelogin_unity.SCENELOGIN); PECommon.Log("Init LoginSys..."); }
public void ReqReadyBattle() { isReady = !isReady; GameMsg gameMsg = new GameMsg { cmd = (int)CMD.ReqReadyBattle, reqReadyBattle = new ReqReadyBattle { isReady = isReady, } }; PECommon.Log("发送准备请求:" + isReady); netSvc.SendMsg(gameMsg); }
public void InitSvc() { InitRandomNameCfgs(PathDefine.nameCfgs); InitMonsterCfgs(PathDefine.monsterCfgs); InitMapCfgs(PathDefine.mapCfgs); InitAutoGuideCfgs(PathDefine.autoGuideCfgs); InitStrongCfg(PathDefine.strongCfgs); InitTaskRewardCfgs(PathDefine.taskRewardCfgs); InitSkillCfgs(PathDefine.skillCfgs); InitSkillMoveCfgs(PathDefine.skillMoveCfgs); InitSkilActionCfgs(PathDefine.skillActionCfgs); PECommon.Log("Init ResSvc...."); }
public void OnGuideBtnClick() { audioSvc.PlayUIAudio(Constant.UICommonClick); if (curTaskCfg != null) { //执行引导任务 MainCitySys.Instance.RunTask(curTaskCfg); } else { //弹出tips PECommon.Log("任务已完成,更多任务正在开发中....."); } //TODO }
public void InitSvc() { // InitRDNameCfg(PathDefine.RDNameCfg); // InitMonsterCfg(PathDefine.MonsterCfg); // InitMapCfg(PathDefine.MapCfg); // InitGuideCfg(PathDefine.GuideCfg); // InitStrongCfg(PathDefine.StrongCfg); // InitTaskRewardCfg(PathDefine.TaskRewardCfg); // InitSkillCfg(PathDefine.SkillCfg); // InitSkillMoveCfg(PathDefine.SkillMoveCfg); // InitSkillActionCfg(PathDefine.SkillActionCfg); PECommon.Log("Init ResSvc..."); }
//下线 public void ClearOfflineData(ServerSession session) { //写入离线时间 PlayerData pd = cacheSvc.GetPlayerDataBySession(session); if (pd != null) { pd.time = timerSvc.GetNowTime(); if (!cacheSvc.UpdataPlayerData(pd.id, pd)) { PECommon.Log("Update offline time error!", LogType.Error); } } cacheSvc.AcctOffLine(session); }