Ejemplo n.º 1
0
    // 暫時不用
    public void setDir(int dir, int mode)
    {
        if (mode == 1)
        {
            this.JocDir = dir;
        }
        if (dir == 0)
        {
            dir = this.JocDir;
        }
        if (LastDir == dir)
        {
            return;
        }
//		Debug.Log (LastDir+","+dir);
        if (mapCreate.Mode == MapMode.Level || mapCreate.Mode == MapMode.Unlimited)
        {
            this.Dir = dir;
        }
        else
        {
            this.Dir = dir;
            // 发送
            CSMove move = new CSMove();
//			move.Dir = dir;
            move.PosX = transform.localPosition.x;
            move.PosY = transform.localPosition.y;
            Debug.Log("send:" + move.PosX + "," + move.PosY);
            move.Speed = 10;
            byte[] data = CSMove.SerializeToBytes(move);
            SocketManager.SendMessageAsyc((int)MiGongOpcode.CSMove, data, delegate(int opcode, byte[] reData) {
            });
        }
        LastDir = dir;
    }
Ejemplo n.º 2
0
 public void setMovePosiNorm(Vector3 movePosiNorm)
 {
     if (lastMovePosiNorm == movePosiNorm)
     {
         return;
     }
     changePos(movePosiNorm);
     // 位置
     if (mapCreate.Mode == MapMode.Level || mapCreate.Mode == MapMode.Unlimited)
     {
         this.MovePosiNorm = movePosiNorm;
     }
     else
     {
         this.MovePosiNorm = movePosiNorm;
         // 发送
         CSMove move = new CSMove();
         move.DirX = movePosiNorm.x;
         move.DirY = movePosiNorm.y;
         move.PosX = transform.localPosition.x;
         move.PosY = transform.localPosition.y;
         //Debug.Log ("send:"+move.PosX+","+move.PosY);
         move.Speed = 10;
         byte[] data = CSMove.SerializeToBytes(move);
         SocketManager.SendMessageAsyc((int)MiGongOpcode.CSMove, data, delegate(int opcode, byte[] reData) {
         });
     }
     lastMovePosiNorm = movePosiNorm;
 }
Ejemplo n.º 3
0
    CSMove GetCSMove(Vector3 direction)
    {
        CSMove msg = new CSMove();

        msg.playerId    = MSShare.mainPlayerId;
        msg.curPos      = new BVector3();
        msg.curPos.x    = go.transform.position.x;
        msg.curPos.y    = go.transform.position.y;
        msg.curPos.z    = go.transform.position.z;
        msg.direction   = new BVector3();
        msg.direction.x = direction.x;
        msg.direction.y = direction.y;
        msg.direction.z = direction.z;
        msg.timeStamp   = Utils.GetTimeMilli();
        return(msg);
    }
Ejemplo n.º 4
0
    public static MSMessageBase GetEmptyMessageById(int id)
    {
        MSMessageBase msg = null;

        switch (id)
        {
        case 102:
            msg = new BVector2();
            break;

        case 103:
            msg = new BVector3();
            break;

        case 101:
            msg = new BPlayer();
            break;

        case 1001:
            msg = new CSLogin();
            break;

        case 1003:
            msg = new SCJoinGame();
            break;

        case 1004:
            msg = new SCLogin();
            break;

        case 1005:
            msg = new SCGameSync();
            break;

        case 2001:
            msg = new CSMove();
            break;

        case 2002:
            msg = new SCMove();
            break;

        case 2003:
            msg = new CSJump();
            break;

        case 2004:
            msg = new SCJump();
            break;

        case 2005:
            msg = new CSDash();
            break;

        case 2006:
            msg = new SCDashStart();
            break;

        case 2007:
            msg = new SCDashStop();
            break;


        default:
            break;
        }
        return(msg);
    }