Beispiel #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;
        }
    }
Beispiel #2
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;
        }
    }