Example #1
0
    public void Spawn(int indexX, int indexY, GameObject[] prefabs, Transform parent)
    {
        Vector3 ppos = new Vector3(indexX, indexY, 0);

        switch (indexY)
        {
        case 0:
            PlayerPeices(indexX, indexY, ppos, prefabs, parent);
            break;

        case 1:
            currentType = PeiceType.POND;
            mySelf      = DesktopInput.Instantiate(prefabs[0], ppos, Quaternion.identity, parent);
            break;

        case 6:
            currentType = PeiceType.POND;
            isWhite     = false;
            mySelf      = DesktopInput.Instantiate(prefabs[0], ppos, Quaternion.identity, parent);
            mySelf.GetComponent <SpriteRenderer>().color = Color.gray;
            break;

        case 7:
            isWhite = false;
            PlayerPeices(indexX, indexY, ppos, prefabs, parent);
            break;

        default:
            break;
        }
    }
Example #2
0
        protected override void WndProc(ref Message message)
        {
            const int WM_KEYDOWN = 0x0100;
            const int WM_KEYUP   = 0x0101;

            switch (message.Msg)
            {
            case WM_KEYDOWN:
            {
                uint         scancode = (((uint)message.LParam) >> 16) & 0x1FF;
                DesktopInput input    = ToTTKeyCode(scancode, DesktopKeyState.DESKTOPKEYSTATE_DOWN);
                ttclient.SendDesktopInput(userid, ToTTKey(input));
                break;
            }

            case WM_KEYUP:
            {
                uint         scancode = (((uint)message.LParam) >> 16) & 0x1FF;
                DesktopInput input    = ToTTKeyCode(scancode, DesktopKeyState.DESKTOPKEYSTATE_UP);
                ttclient.SendDesktopInput(userid, ToTTKey(input));
                break;
            }
            }
            base.WndProc(ref message);
        }
Example #3
0
 DesktopInput[] ToTTKey(DesktopInput input)
 {
     DesktopInput[] inputs = new DesktopInput[1];
     inputs[0] = input;
     DesktopInput[] translated;
     WindowsHelper.DesktopInputKeyTranslate(TTKeyTranslate.TTKEY_WINKEYCODE_TO_TTKEYCODE,
                                            inputs, out translated);
     return(translated);
 }
Example #4
0
    private void PlayerPeices(int indexX, int indexY, Vector3 ppos, GameObject[] prefabs, Transform parent)
    {
        switch (indexX)
        {
        case 0:     //Right Side Rooks
            currentType = PeiceType.ROOK;
            mySelf      = DesktopInput.Instantiate(prefabs[1], ppos, Quaternion.identity, parent);
            break;

        case 7:     // Left Side Rooks
            currentType = PeiceType.ROOK;
            mySelf      = DesktopInput.Instantiate(prefabs[1], ppos, Quaternion.identity, parent);
            break;

        case 1:
            currentType = PeiceType.KNIGHT;
            mySelf      = DesktopInput.Instantiate(prefabs[2], ppos, Quaternion.identity, parent);
            break;

        case 6:
            currentType = PeiceType.KNIGHT;
            mySelf      = DesktopInput.Instantiate(prefabs[2], ppos, Quaternion.identity, parent);
            break;

        case 2:
            currentType = PeiceType.BISHOB;
            mySelf      = DesktopInput.Instantiate(prefabs[3], ppos, Quaternion.identity, parent);
            break;

        case 5:
            currentType = PeiceType.BISHOB;
            mySelf      = DesktopInput.Instantiate(prefabs[3], ppos, Quaternion.identity, parent);
            break;

        case 3:
            currentType = PeiceType.QUEEN;
            mySelf      = DesktopInput.Instantiate(prefabs[4], ppos, Quaternion.identity, parent);
            break;

        case 4:
            currentType = PeiceType.KING;
            mySelf      = DesktopInput.Instantiate(prefabs[5], ppos, Quaternion.identity, parent);
            break;

        default:
            break;
        }
        if (!isWhite)
        {
            mySelf.GetComponent <SpriteRenderer>().color = Color.gray;
        }
    }
Example #5
0
    public Peice[,] Move(Vector2Int currentPos, Vector2Int movePos, Peice[,] arr)
    {
        _boardState = arr;
        if (LegalMove(currentPos, movePos))
        {
            mySelf.transform.position = new Vector3(movePos.x, movePos.y, 0);
            firstMove = false;

            if (_boardState[movePos.x, movePos.y].mySelf != null)
            {
                DesktopInput.Destroy(_boardState[movePos.x, movePos.y].mySelf);
            }

            _boardState[movePos.x, movePos.y]       = _boardState[currentPos.x, currentPos.y];
            _boardState[currentPos.x, currentPos.y] = new Peice();
            return(_boardState);
        }
        else
        {
            return(null);
        }
    }
Example #6
0
        private void DesktopDlg_MouseUp(object sender, MouseEventArgs e)
        {
            DesktopInput input = ToTTKeyCode(e, DesktopKeyState.DESKTOPKEYSTATE_UP);

            ttclient.SendDesktopInput(userid, ToTTKey(input));
        }
Example #7
0
 private void Awake()
 {
     _desktopInput = transform.root.GetComponent <DesktopInput>();
 }