Ejemplo n.º 1
0
    void UpdatePosition()
    {
        var direction = new Vector3(0, 0, 0);

        // move directions
        if (MSShare.modControl.TryExecuteCommand(ModControl.Command.MOVE_FORWARD))
        {
            // not dashing, then move
            if (dashEnd == 0)
            {
                direction += forward;
            }
        }
        if (MSShare.modControl.TryExecuteCommand(ModControl.Command.MOVE_BACKWARD))
        {
            if (dashEnd == 0)
            {
                direction += back;
            }
        }
        if (MSShare.modControl.TryExecuteCommand(ModControl.Command.MOVE_LEFT))
        {
            if (dashEnd == 0)
            {
                direction += left;
            }
        }
        if (MSShare.modControl.TryExecuteCommand(ModControl.Command.MOVE_RIGHT))
        {
            if (dashEnd == 0)
            {
                direction += right;
            }
        }
        // dash directions
        if (MSShare.modControl.TryExecuteCommand(ModControl.Command.DASH_FORWARD))
        {
            direction = new Vector3(0, 0, 0);
            StartDash(forward);
        }
        if (MSShare.modControl.TryExecuteCommand(ModControl.Command.DASH_BACKWARD))
        {
            direction = new Vector3(0, 0, 0);
            StartDash(back);
        }
        if (MSShare.modControl.TryExecuteCommand(ModControl.Command.DASH_LEFT))
        {
            direction = new Vector3(0, 0, 0);
            StartDash(left);
        }
        if (MSShare.modControl.TryExecuteCommand(ModControl.Command.DASH_RIGHT))
        {
            direction = new Vector3(0, 0, 0);
            StartDash(right);
        }

        if (direction.x != 0.0f || direction.y != 0.0f || direction.z != 0.0f)
        {
            if (lastErrorCode != -1)
            {
                go.transform.Translate(direction * moveSpeed * Time.deltaTime);
            }
            MSShare.func_SendMsg(GetCSMove(direction));
        }

        if (MSShare.modControl.TryExecuteCommand(ModControl.Command.JUMP))
        {
            CSJump csjump = new CSJump();
            csjump.playerId = MSShare.mainPlayerId;
            MSShare.func_SendMsg(csjump);
            StartJump();
        }
    }
Ejemplo n.º 2
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);
    }