0
点赞
收藏
分享

微信扫一扫

verilog 从入门到看得懂---verilog 的基本语法数据和运算

北邮郭大宝 2024-03-18 阅读 8

1.点击开始游戏界面触发如下函数

public void beginGame()
{
    //nowPlayer = null;
    //Enter
    if (nowPlayer != null)//选了角色才能开始,playerModel数据结构
    {
        //EnterMapDTO edto = new EnterMapDTO();
        //edto.map = nowPlayer.map;
        //edto.point = nowPlayer.point;
        //edto.rotation = nowPlayer.rotation;
        //string m=As
        string message = Coding<StringDTO>.encode(new StringDTO(nowPlayer.id));
        NetWorkScript.getInstance().sendMessage(Protocol.USER,0,UserProtocol.SELECT_CREQ,message);//按部就班的选择请求
    }

收到服务器的返回包如下:

2.在SocketModel.cs的minna命名空间内新增地图相关的command(第三个参数)

public class MapProtocol
{
	public const int ENTER_CREQ = 0;
	public const int ENTER_SRES = 1;
	public const int ENTER_BRO = 2;
	public const int MOVE_CREQ = 3;
	public const int MOVE_BRO = 4;
	public const int LEAVE_CREQ = 5;
	public const int LEAVE_BRO = 6;
	public const int TALK_CREQ = 7;
	public const int TALK_BRO = 8;
	public const int ATTACK_CREQ = 9;
	public const int ATTACK_BRO = 10;
	public const int MONSTER_INIT_SRES = 11;
	public const int BE_ATTACK_CREQ = 12;
	public const int BE_ATTACE_BRO = 13;
	public const int MONSTER_DIE_BRO = 14;
	public const int EXP_UP_SRES = 15;
	public const int LEVEL_UP_BRO = 16;
	public const int MONSTER_RELIVE_BRO = 17;
	
	//public const int SKILL_CREQ = 18;
	//public const int SKILL_BRO = 19;
}


 3.在socketModel.cs中增加一个新的dto结构体EnterMapDTO

public class EnterMapDTO
{
	public int map;
	public Assets.Model.Vector3 point {get; set;}
	public Assets.Model.Vector4 rotation {get; set;}
}

4.MessageManager.cs中对从服务器收到返回的数据包进行解析

case UserProtocol.SELECT_SRES:
    //selectPlayer(model.message);
    Debug.Log("SELECT_SRES");
    EnterMapDTO edto = new EnterMapDTO();
    edto.map = SelectMenu.nowPlayer.map;//static 用返回回来的model信息也是可以的
    edto.point = SelectMenu.nowPlayer.point;
    edto.rotation = SelectMenu.nowPlayer.rotation;
    string m1 = Coding<EnterMapDTO>.encode(edto);
    Debug.Log("MessageManager申请进入地图");
    NetWorkScript.getInstance().sendMessage(Protocol.MAP, edto.map, MapProtocol.ENTER_CREQ,m1);//第二个参数是进哪张地图
    break;

5.MessageManager.cs增加MapHandler函数,用来分类处理来自服务器的包!

实测可以进入MapHandler,但是之后还有许多包,看起来是想要保持连接的架势

举报

相关推荐

0 条评论