protected override bool ExecCommand(StoryInstance instance, StoryValueParam <int, float, float> _params, long delta) { object us; if (instance.GlobalVariables.TryGetValue("EntityInfo", out us)) { EntityInfo user = us as EntityInfo; if (null != user) { int objId = _params.Param1Value; float x = _params.Param2Value; float z = _params.Param3Value; EntityInfo charObj = user.SceneContext.GetEntityById(objId); if (null != charObj) { MovementStateInfo msi = charObj.GetMovementStateInfo(); msi.SetPosition2D(x, z); Scene scene = user.SceneContext.CustomData as Scene; if (null != scene) { GameFrameworkMessage.Msg_RC_AdjustPosition adjustPos = new GameFrameworkMessage.Msg_RC_AdjustPosition(); adjustPos.role_id = objId; adjustPos.face_dir = ProtoHelper.EncodeFloat(msi.GetFaceDir()); adjustPos.x = ProtoHelper.EncodeFloat(x); adjustPos.z = ProtoHelper.EncodeFloat(z); scene.NotifyAllUser(RoomMessageDefine.Msg_RC_AdjustPosition, adjustPos); } } } } return(false); }
public virtual void ResponseLogin(byte[] buffer) { try { ProtoGameServer.Login responseLogin = ProtoHelper.ToProto <ProtoGameServer.Login>(buffer); mErrorCode = responseLogin.err; if (mErrorCode == ProtoGameServer.ERROR_CODE.ERR_NONE) { mGUID = responseLogin.guid; mFlags = (uint)ProtoGameServer.FLAGS_CODE.PLAYER_FLAGS_LOGIN; if (onResponseLogin != null) { onResponseLogin(); } } else { if (onResponseError != null) { onResponseError(mErrorCode); } } } catch (Exception) { } }
private void InitV1(object serializedSet) { ObjectsFromLocal = new List <FreeItemSelected>(); var saved = serializedSet as IEnumerable <string>; if (saved != null) { try { foreach (var item in saved) { if (_versionNumber == 1) { ObjectsFromLocal.Add(ProtoHelper.ProtoDeserializeFromString <FreeItemSelected>(item)); } else { ObjectsFromLocal.Add(CommonEx.DeserializeFromString <FreeItemSelected>(item)); } } } catch (Exception ex) { ex.ShowMessage(); } } }
public virtual void ResponseCreateGame(byte[] buffer) { try { ProtoGameServer.CreateGame responseCreateGame = ProtoHelper.ToProto <ProtoGameServer.CreateGame>(buffer); mErrorCode = responseCreateGame.err; if (mErrorCode == ProtoGameServer.ERROR_CODE.ERR_NONE) { mGameID = responseCreateGame.gameid; mHostGUID = responseCreateGame.host; DisableFlag(ProtoGameServer.FLAGS_CODE.PLAYER_FLAGS_READY); DisableFlag(ProtoGameServer.FLAGS_CODE.PLAYER_FLAGS_GAMING); if (onResponseCreateGame != null) { onResponseCreateGame(); } } else { if (onResponseError != null) { onResponseError(mErrorCode); } } } catch (Exception) { } }
public virtual void ResponseListGame(byte[] buffer) { try { ProtoGameServer.ListGame responseListGame = ProtoHelper.ToProto <ProtoGameServer.ListGame>(buffer); mErrorCode = responseListGame.err; if (mErrorCode == ProtoGameServer.ERROR_CODE.ERR_NONE) { if (onResponseListGame != null) { onResponseListGame(responseListGame); } } else { if (onResponseError != null) { onResponseError(mErrorCode); } } } catch (Exception) { } }
public virtual void ResponseMatch(byte[] buffer) { try { ProtoGateServer.Match responseMatch = ProtoHelper.ToProto <ProtoGateServer.Match>(buffer); mErrorCode = responseMatch.err; if (mErrorCode == ProtoGateServer.ERROR_CODE.ERR_NONE) { if (onResponseMatch != null) { onResponseMatch(responseMatch.ip, responseMatch.port, responseMatch.gameid); } } else { if (onResponseError != null) { onResponseError(mErrorCode); } } } catch (Exception) { } }
public static void Serialize <T>(Session session, MemoryStream destination, T packet) where T : Packet { byte[] idBytes = ConvertHelper.GetBytes(packet.GetPacketId()); destination.Write(idBytes, 0, idBytes.Length); packet.Serialize(destination); ProtoHelper.ReturnPacket(packet); }
public void OnClick() { buttonSubmit.enabled = false; string inputNicknameValue = inputNickname.value; if (inputNicknameValue == null || "".Equals(inputNicknameValue)) { ShowMessage(ErrorCode.EC_UC_NO_NICKNAME); buttonSubmit.enabled = true; return; } if (inputNicknameValue.Length > 16) { ShowMessage(ErrorCode.EC_UC_NICKNAME_TOO_LONG); buttonSubmit.enabled = true; return; } UpdateNickNameReq req = new UpdateNickNameReq { nickName = inputNicknameValue }; HttpPost(Constants.API_UPDATE_NICKNAME, ProtoHelper.Proto2Bytes(req)); }
internal static void Execute(object msg, NetConnection conn) { Msg_RC_NpcFace face_msg = msg as Msg_RC_NpcFace; if (null == face_msg) { return; } EntityInfo npc = PluginFramework.Instance.GetEntityById(face_msg.npc_id); if (npc == null) { return; } if (npc.HaveState(CharacterPropertyEnum.x3002_昏睡)) { return; } float dir = ProtoHelper.DecodeFloat(face_msg.face_direction); npc.GetMovementStateInfo().SetFaceDir(dir); UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId()); actor.transform.localRotation = UnityEngine.Quaternion.Euler(0, Utility.RadianToDegree(dir), 0); }
public virtual void ResponseLogin(byte[] buffer) { try { ProtoGateServer.Login responseLogin = ProtoHelper.ToProto <ProtoGateServer.Login>(buffer); mErrorCode = responseLogin.err; if (mErrorCode == ProtoGateServer.ERROR_CODE.ERR_NONE) { mGUID = responseLogin.guid; mbLogin = true; if (onResponseLogin != null) { onResponseLogin(); } } else { if (onResponseError != null) { onResponseError(mErrorCode); } } } catch (Exception) { } }
/// <summary> /// 点击离开房间后处理服务器返回的消息 /// </summary> /// <param name="msg">服务器返回的离开房间消息</param> private void LeaveRoomHandle(object msg) { var leaveRoomMsg = msg as mmopb.leaveRoom_ack; if (leaveRoomMsg.isSuc) { //打开房间列表 roomsView.rooms.SetActive(true); //关闭进入的房间 roomView.room_boot.SetActive(false); //删除原来有的列表 GameObject[] rooms = GameObject.FindGameObjectsWithTag("ROOM"); foreach (GameObject room in rooms) { Destroy(room); } //删除聊天消息 GameObject[] messages = GameObject.FindGameObjectsWithTag("ROOMMSG"); foreach (GameObject message in messages) { Destroy(message); } //请求房间列表数据 var rooms_req = new mmopb.roomList_req(); ClientNet.Instance.Send(ProtoHelper.EncodeWithName(rooms_req)); } else { Debug.Log(leaveRoomMsg.error); } }
internal static void Execute(object msg, NetConnection conn) { Msg_RC_AdjustPosition _msg = msg as Msg_RC_AdjustPosition; if (null == _msg) { return; } EntityInfo npc = PluginFramework.Instance.GetEntityById(_msg.role_id); if (null != npc) { float x = ProtoHelper.DecodeFloat(_msg.x); float z = ProtoHelper.DecodeFloat(_msg.z); float faceDir = ProtoHelper.DecodeFloat(_msg.face_dir); MovementStateInfo msi = npc.GetMovementStateInfo(); msi.SetPosition2D(x, z); msi.SetFaceDir(faceDir); UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId()); GameFramework.Skill.Trigers.TriggerUtil.MoveObjTo(actor, new UnityEngine.Vector3(x, 0, z)); actor.transform.localRotation = UnityEngine.Quaternion.Euler(0, Utility.RadianToDegree(faceDir), 0); } }
public void Handle(byte[] message) { string msgName; var msg = ProtoHelper.DecodeWithName(message, out msgName); //派发事件 EventDispacher.Instance.DispachEvent(msgName, msg, m_role); }
/// <summary> /// 在房间里面点击退出房间退出房间 /// </summary> /// <param name="param"></param> private void OnClickBtnQuitRoom(object param) { button.clip = common; button.Play(); var leaveRoomMsg = new mmopb.leaveRoom_req(); ClientNet.Instance.Send(ProtoHelper.EncodeWithName(leaveRoomMsg)); }
/// <summary> /// 在房间里面点击开始游戏,向服务器发出开始游戏请求 /// </summary> /// <param name="param"></param> private void OnClickBtnStartGame(object param) { button.clip = common; button.Play(); var startGameMsg = new mmopb.startBattle_req(); ClientNet.Instance.Send(ProtoHelper.EncodeWithName(startGameMsg)); }
public static void RoleMove(Vector3 dest) { ReqCharacterMove req = new ReqCharacterMove(); req.dest = ProtoHelper.UV2PV(dest); Net.instance.Send((int)MsgID.ReqCharacterMove, req); }
/// <summary> /// 角色移动应答 /// </summary> /// <param name="data"></param> private void OnCharacterMove(SocketModel model) { NotifyCharacterMove notify = SerializeUtil.Deserialize <NotifyCharacterMove>(model.message); Character role = Battle.instance.GetRole(notify.characterid); role.Move(ProtoHelper.PV2UV(notify.position)); }
public void Handle(byte[] message) { string msgName; var msg = ProtoHelper.DecodeWithName(message, out msgName); Debug.Log("CActor->" + msgName); NetDispacher.Instance.DispachEvent(msgName, msg); }
/// <summary> /// 在房间里面点击邀请按钮 /// </summary> /// <param name="param"></param> private void OnClickBtnInviteFriend(object param) { button.clip = common; button.Play(); roomView.friendList.SetActive(true); var friendsReq = new mmopb.friendsList_req(); ClientNet.Instance.Send(ProtoHelper.EncodeWithName(friendsReq)); }
internal static void Execute(object msg, NetConnection conn) { Msg_RC_NpcSkill targetmsg = msg as Msg_RC_NpcSkill; if (null == targetmsg) { return; } EntityInfo npc = PluginFramework.Instance.GetEntityById(targetmsg.npc_id); if (null == npc) { return; } float x = 0.0f; float z = 0.0f; ProtoHelper.DecodePosition2D(targetmsg.stand_pos, out x, out z); float faceDir = ProtoHelper.DecodeFloat(targetmsg.face_direction); int skillId = targetmsg.skill_id; LogSystem.Info("Receive Msg_RC_NpcSkill, EntityId={0}, SkillId={1}", targetmsg.npc_id, skillId); MovementStateInfo msi = npc.GetMovementStateInfo(); if (targetmsg.target_id <= 0) { msi.SetPosition2D(x, z); msi.SetFaceDir(faceDir); npc.GetAiStateInfo().Target = 0; UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId()); GameFramework.Skill.Trigers.TriggerUtil.MoveObjTo(actor, new UnityEngine.Vector3(x, actor.transform.position.y, z)); actor.transform.localRotation = UnityEngine.Quaternion.Euler(0, Utility.RadianToDegree(faceDir), 0); } else { npc.GetAiStateInfo().Target = targetmsg.target_id; } SkillInfo skillInfo = npc.GetSkillStateInfo().GetSkillInfoById(skillId); if (null != skillInfo) { if (skillInfo.ConfigData.skillData.canmove == 0) { EntityViewModel viewModel = EntityViewModelManager.Instance.GetEntityViewById(targetmsg.npc_id); if (null != viewModel) { viewModel.StopMove(); } } if (GfxSkillSystem.Instance.StartSkill(npc.GetId(), skillInfo.ConfigData, 0)) { Utility.EventSystem.Publish("ui_skill_cooldown", "ui", npc.GetId(), skillId, skillInfo.ConfigData.skillData.cooldown / 1000.0f); } } }
/// <summary> /// 通知移动 /// </summary> /// <param name="characterid">角色全局ID</param> /// <param name="position">目标点</param> /// <param name="accounts">所有账号</param> public static void NotifyMove(uint characterid, Vector3 position, Dictionary <string, Account> accounts) { NotifyCharacterMove notify = new NotifyCharacterMove(); notify.characterid = characterid; notify.position = ProtoHelper.LV2PV(position); MsgSender.BroadCast(accounts, MsgID.NotifyCharacterMove, notify); }
public override void LoadContent() { ProtoHelper.OnChatRecieve += OnChatRecive; _ = ProtoHelper.JoinToChatAsync(); var camera = new OrthographicCamera(_sceneHandler._graphicsDevice); mouseSystem = new MouseSystem(); MouseSystem.OnMouseLeftClick += mouseClick; spriteBatch = new SpriteBatch(_sceneHandler._graphicsDevice); world = new WorldBuilder() .AddSystem(new RenderSystem(spriteBatch, camera)) .AddSystem(mouseSystem) .Build(); _sceneHandler._gameComponents.Add(world); entityFactory = new EntityFactory(world, _sceneHandler._content, _sceneHandler._graphicsDevice); text = entityFactory.CreateText(new Vector2(100, 100), ProtoHelper.nickname, 100); playerReadyButtom = entityFactory.CreateReadySign(new Vector2(500, 110)); readyText = entityFactory.CreateText(new Vector2(530, 102), "Not ready", 0); enemyText = entityFactory.CreateText(new Vector2(100, 200), "", 100); enemyReadyButtom = entityFactory.CreateReadySign(new Vector2(500, 210)); enemyReadyText = entityFactory.CreateText(new Vector2(530, 202), "Not ready", 0); LoadGui(); while (!ProtoHelper.IsChatLive) { Thread.Sleep(10); } Thread.Sleep(500); ProtoHelper.WriteToChat("!live"); while (live == null) { Thread.Sleep(10); } if ((bool)live == true) { ChangeStateToGame(); } var player = _sceneHandler._content.Load <Texture2D>("MiniHead1"); var upArrow = _sceneHandler._content.Load <Texture2D>("MiniHead1"); playerSprite = new Sprite(player); enemySprite = new Sprite(player); upArrowSprite = new Sprite(_sceneHandler._content.Load <Texture2D>("upArrow")); downArrowSprite = new Sprite(_sceneHandler._content.Load <Texture2D>("downArrow")); }
private void OnConnected(Session session, SessionParam args) { LogHelper.Print("[NetMgr]Session Connected."); ProtoHelper.Register(); if (!GameMgr.singleton.CheckUpdateState) { GameMgr.singleton.CheckUpdateState = true; _checkUpdateState = true; } }
public void OnConnected(SocketError err) { if (err == SocketError.Success) { Debug.Log("连接"); var msg = new mmopb.login_ack(); msg.error = "Hello!"; tcpConnection.Send(ProtoHelper.EncodeWithName(msg)); } }
/// <summary> /// 通知攻击事件 /// </summary> /// <param name="globalRoleID">攻击者的全局ID</param> /// <param name="skillID">技能ID</param> /// <param name="targetid">目标的全局ID</param> /// <param name="position">坐标</param> /// <param name="accounts">所有账号</param> public static void NotifyAttack(uint characterid, uint skillID, uint targetid, Vector3 position, Dictionary <string, Account> accounts) { NotifyCharacterAttack notify = new NotifyCharacterAttack(); notify.characterid = characterid; notify.skillid = skillID; notify.pos = ProtoHelper.LV2PV(position); notify.targetid = targetid; MsgSender.BroadCast(accounts, MsgID.NotifyCharacterAttack, notify); }
private void OnConnected(Session session, SessionParam args) { LogHelper.Print(string.Format("[NetMgr]Session Connected!")); ProtoHelper.Register(); if (!GameMgr.Instance.CheckUpdateState) { GameMgr.Instance.CheckUpdateState = true; _checkUpdateState = true; } }
/// <summary> /// 点击好友界面的添加好友按钮 /// </summary> /// <param name="param"></param> private void ClickAddFriend(object param) { button.clip = common; button.Play(); var addFriendMsg = new mmopb.addFriend_req(); string friendName = friendView.friendNameAdd.text; addFriendMsg.nickName = friendName; ClientNet.Instance.Send(ProtoHelper.EncodeWithName(addFriendMsg)); }
public virtual void ResponseFlags(byte[] buffer) { try { ProtoGameServer.Flags responseFlags = ProtoHelper.ToProto <ProtoGameServer.Flags>(buffer); mFlags = (mFlags & 0xffff0000) | (responseFlags.flags & 0x0000ffff); } catch (Exception) { } }
/// <summary> /// 点击邀请通知的拒绝按钮 /// </summary> /// <param name="param"></param> private void ClickNoNewInvite(object param) { button.clip = common; button.Play(); var inviteMsg = new mmopb.noticeInviteFriend_ack(); inviteMsg.isSuc = false; inviteMsg.roleId = roleId_invite; ClientNet.Instance.Send(ProtoHelper.EncodeWithName(inviteMsg)); roomsView.newInvite.SetActive(false); }
/// <summary> /// 点击邀请好友列表界面的邀请按钮(对勾) /// </summary> /// <param name="param"></param> private void ClickInviteTargetFriend(object param) { button.clip = sendMsg; button.Play(); var inviteFriendMsg = new mmopb.inviteFriend_req(); GameObject friend = (GameObject)param; FriendInviteDetail friendInviteDetail = friend.GetComponent <FriendInviteDetail>(); inviteFriendMsg.roleId = friendInviteDetail.friendId; ClientNet.Instance.Send(ProtoHelper.EncodeWithName(inviteFriendMsg)); }