コード例 #1
0
    void DeactivateBlock(int playerNum)
    {
        ActivatedBlock curABScript = null;

        switch (playerNum)
        {
        case 1:
            curABScript = ABscript1;
            break;

        case 2:
            curABScript = ABscript2;
            break;

        case 3:
            curABScript = ABscript3;
            break;

        case 4:
            curABScript = ABscript4;
            break;
        }

        curABScript.blockActivated = false;
        curABScript.playerIndex    = 0;
        curABScript.enabled        = false;
    }
コード例 #2
0
    void ActivateBlock(GameObject block)
    {
        // Activate Block

        script         = block.transform.GetChild(0).gameObject.GetComponent <ActivatedBlock>();
        script.enabled = true;

        script.blockActivated = true;

        // Cooldown

        putActiveBlock = false;

        StartCoroutine("Cooldown");
    }
コード例 #3
0
    void ActivateBlock(int blockIndex, int playerNum)
    {
        GameObject block = blocks[blockIndex];

        // Activate Block based on blockIndex and playerNum

        switch (playerNum)
        {
        case 1:
            curNum1 = blockIndex;

            ABscript1             = block.transform.GetChild(0).gameObject.GetComponent <ActivatedBlock>();
            ABscript1.playerIndex = playerNum;
            ABscript1.colorIndex  = player1.GetComponent <PlayerController>().colorIndex;
            ABscript1.enabled     = true;

            ABscript1.blockActivated = true;
            break;

        case 2:
            curNum2 = blockIndex;

            ABscript2             = block.transform.GetChild(0).gameObject.GetComponent <ActivatedBlock>();
            ABscript2.playerIndex = playerNum;
            ABscript2.colorIndex  = player2.GetComponent <PlayerController>().colorIndex;
            ABscript2.enabled     = true;

            ABscript2.blockActivated = true;
            break;

        case 3:
            curNum3 = blockIndex;

            ABscript3             = block.transform.GetChild(0).gameObject.GetComponent <ActivatedBlock>();
            ABscript3.playerIndex = playerNum;
            ABscript3.colorIndex  = player3.GetComponent <PlayerController>().colorIndex;
            ABscript3.enabled     = true;

            ABscript3.blockActivated = true;
            break;

        case 4:
            curNum4 = blockIndex;

            ABscript4             = block.transform.GetChild(0).gameObject.GetComponent <ActivatedBlock>();
            ABscript4.playerIndex = playerNum;
            ABscript4.colorIndex  = player4.GetComponent <PlayerController>().colorIndex;
            ABscript4.enabled     = true;

            ABscript4.blockActivated = true;
            break;
        }

        switch (playerNum)
        {
        case 1:
            putActiveBlock1 = false;
            break;

        case 2:
            putActiveBlock2 = false;
            break;

        case 3:
            putActiveBlock3 = false;
            break;

        case 4:
            putActiveBlock4 = false;
            break;
        }

        // Initiate cooldown to determine when a certain player should be assigned a new block
        StartCoroutine(CooldownAB(playerNum));
    }