Exemplo n.º 1
0
    void CreateNewBlock()
    {
        // Manually create a set of new blocks in the proper location
        int i_NumToShift = 0;

        // Find the 'X' location to set the block location (2 wide)
        if(e_BlockSize == Enum_BlockSize.size_2w_2h || e_BlockSize == Enum_BlockSize.size_2w_3h)
        {
            // Finds the center of the List width
            v2_ActiveBlockLocation.x = (int)((i_ArrayWidth - 1) / 2);
        }
        else // (3 high)
        {
            // Finds the center of the List width, and shifts to the left one space
            v2_ActiveBlockLocation.x = (int)((i_ArrayWidth - 1) / 2) - 1;
        }

        // Find the 'Y' location to set the block location (2 high)
        if (e_BlockSize == Enum_BlockSize.size_2w_2h || e_BlockSize == Enum_BlockSize.size_3w_2h)
        {
            v2_ActiveBlockLocation.y = i_ArrayHeight - 2;
        }
        // (3 high)
        else v2_ActiveBlockLocation.y = i_ArrayHeight - 3;

        // Check for GameOver based on new ActiveBlockLocation information. Returns true if the game's over.
        if (GameOverCheck())
        {
            // PauseState is set to Game Over
            e_PauseEffect = Enum_PauseEffect.GameOver;

            return;
        }

        // Set the number of blocks to shift afterward
        if (e_BlockSize == Enum_BlockSize.size_2w_2h)                                                   i_NumToShift = 4;
        else if (e_BlockSize == Enum_BlockSize.size_2w_3h || e_BlockSize == Enum_BlockSize.size_3w_2h)  i_NumToShift = 6;
        else if (e_BlockSize == Enum_BlockSize.size_3w_3h)                                              i_NumToShift = 9;

        // Create temp block list
        int i_NewBlocks_Width = 2;
        int i_NewBlocks_Height = 2;

        if (e_BlockSize == Enum_BlockSize.size_3w_2h || e_BlockSize == Enum_BlockSize.size_3w_3h) i_NewBlocks_Width = 3;
        if (e_BlockSize == Enum_BlockSize.size_2w_3h || e_BlockSize == Enum_BlockSize.size_3w_3h) i_NewBlocks_Height = 3;

        // print("BLOCK SIZE: " + e_BlockSize);
        Enum_BlockType[,] e_SmallList = new Enum_BlockType[i_NewBlocks_Height, i_NewBlocks_Width];

        // No matter what, set the initial 2x2
        SetBlock(v2_ActiveBlockLocation,                                            e_NextBlockList[0]);
        e_SmallList[0, 0] = e_NextBlockList[0];

        SetBlock(new Vector2(v2_ActiveBlockLocation.x + 1, v2_ActiveBlockLocation.y + 0),   e_NextBlockList[1]);
        e_SmallList[0, 1] = e_NextBlockList[1];

        SetBlock(new Vector2(v2_ActiveBlockLocation.x + 0, v2_ActiveBlockLocation.y + 1),   e_NextBlockList[2]);
        e_SmallList[1, 0] = e_NextBlockList[2];

        SetBlock(new Vector2(v2_ActiveBlockLocation.x + 1, v2_ActiveBlockLocation.y + 1),   e_NextBlockList[3]);
        e_SmallList[1, 1] = e_NextBlockList[3];

        // If we're specifically 3x2, set those positions
        if ( e_BlockSize == Enum_BlockSize.size_3w_2h )
        {
            SetBlock(new Vector2(v2_ActiveBlockLocation.x + 2, v2_ActiveBlockLocation.y + 1), e_NextBlockList[4]);
            e_SmallList[1, 2] = e_NextBlockList[4];

            SetBlock(new Vector2(v2_ActiveBlockLocation.x + 2, v2_ActiveBlockLocation.y + 0), e_NextBlockList[5]);
            e_SmallList[0, 2] = e_NextBlockList[5];
        }
        // If we're specifically 2x3, set those positions
        else if( e_BlockSize == Enum_BlockSize.size_2w_3h)
        {
            SetBlock(new Vector2(v2_ActiveBlockLocation.x + 0, v2_ActiveBlockLocation.y + 2), e_NextBlockList[4]);
            e_SmallList[2, 0] = e_NextBlockList[4];

            SetBlock(new Vector2(v2_ActiveBlockLocation.x + 1, v2_ActiveBlockLocation.y + 2), e_NextBlockList[5]);
            e_SmallList[2, 1] = e_NextBlockList[5];
        }
        else if( e_BlockSize == Enum_BlockSize.size_3w_3h )
        {
            SetBlock(new Vector2(v2_ActiveBlockLocation.x + 2, v2_ActiveBlockLocation.y + 1), e_NextBlockList[4]);
            e_SmallList[1, 2] = e_NextBlockList[4];

            SetBlock(new Vector2(v2_ActiveBlockLocation.x + 2, v2_ActiveBlockLocation.y + 0), e_NextBlockList[5]);
            e_SmallList[0, 2] = e_NextBlockList[5];

            SetBlock(new Vector2(v2_ActiveBlockLocation.x + 0, v2_ActiveBlockLocation.y + 2), e_NextBlockList[6]);
            e_SmallList[2, 0] = e_NextBlockList[6];

            SetBlock(new Vector2(v2_ActiveBlockLocation.x + 1, v2_ActiveBlockLocation.y + 2), e_NextBlockList[7]);
            e_SmallList[2, 1] = e_NextBlockList[7];

            SetBlock(new Vector2(v2_ActiveBlockLocation.x + 2, v2_ActiveBlockLocation.y + 2), e_NextBlockList[8]);
            e_SmallList[2, 2] = e_NextBlockList[8];
        }

        #region Send e_SmallList to Board Display
        GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().Set_NewBlocks(e_SmallList, e_BlockSize, new IntVector2((int)v2_ActiveBlockLocation.x, (int)v2_ActiveBlockLocation.y));
        #endregion

        #region Send Set_ShowPotentialBlockVisual Information
        PotentialBlockVisual();
        #endregion

        ShiftNewBlockList( i_NumToShift );
    }
Exemplo n.º 2
0
    bool Load_ScoreLine()
    {
        // Reset v2_ScoreLine
        iv2_ScoreLine = new List<IntVector2>();

        // Reset storage of current block color
        e_CurrBlockType = Enum_BlockType.Empty;

        int i_LeftBound = 1;
        int i_RightBound = i_ArrayWidth - 1;

        // Begin checking for a scoreline only if the left-most column (X = 1) has a block in it
        for(int y_ = 0; y_ < i_ArrayHeight; ++y_)
        {
            //print("Checking: " + i_LeftBound + ", " + y_);
            //print("Curr Block: " + e_CurrBlockType);
            //print("New Block: " + GetBlock(i_LeftBound, y_));

            // If the previous checked block differs than the current block && isn't empty && isn't Block 3
            if( e_CurrBlockType != GetBlock(i_LeftBound, y_) &&
                GetBlock(i_LeftBound, y_) != Enum_BlockType.Empty &&
                GetBlock(i_LeftBound, y_) != Enum_BlockType.Block_3_Static)
            {

                // Store the new block
                e_CurrBlockType = GetBlock(i_LeftBound, y_);

                #region Check each column for this blocktype
                // Initiate a check to ensure every column has at least one block in it of the current block type
                for(int x = i_LeftBound; x < i_RightBound; ++x)
                {
                    // Reset the bool at the beginning of each column loop
                    bool b_RowHasBlockType = false;

                    // Check each column from the bottom up
                    for(int y = 0; y < i_ArrayHeight; ++y)
                    {
                        // If this column has the specific block type, move to the next column
                        if (GetBlock(x, y) == e_CurrBlockType)
                        {
                            b_RowHasBlockType = true;

                            // Move to the next column
                            continue;
                        }
                    }

                    // If we didn't find the specific block in this column, we can't have a completed line. Break out.
                    if (!b_RowHasBlockType)
                    {
                        // print("FAILED");

                        // Continue since we need to check the other blocks in the column, regardless of the outcome of this one
                        continue;
                    }
                }
                #endregion

                // Clear the list since this is a new attempt to find a line
                iv2_PathfindLine = new List<IntVector2>();

                if( GetBlock(1, y_) == Enum_BlockType.Block_1_Static ||
                    GetBlock(1, y_) == Enum_BlockType.Block_2_Static ||
                    GetBlock(1, y_) == Enum_BlockType.Block_3_Static  )
                {
                    // Push findings into the i_PathfindLine
                    iv2_PathfindLine.Add(new IntVector2(1, y_));

                    // Begins the iterative check
                    if(ScoreLine(Enum_Direction.Right))
                    {
                        GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().Set_ClearBackdrops();

                        return true;
                    }
                }
            }
        }

        return false;
    }
Exemplo n.º 3
0
 void SetBlock(Vector2 blockPos_, Enum_BlockType blockType_)
 {
     SetBlock((int)blockPos_.x, (int)blockPos_.y, blockType_);
 }
Exemplo n.º 4
0
    void Update()
    {
        if(Input.GetKeyDown(KeyCode.P))
        {
            Cheat_SetDoubleLine();
        }

        if(e_PauseEffect == Enum_PauseEffect.Unpause)
        {
            if(b_DemoGame_InputReceived)
            {
                #region Drop Block timer
            // Decrement timer for next time to move blocks down
            if (i_TimeToDrop_Max > 0)
            {
                f_TimeToDrop += Time.deltaTime;

                if(f_TimeToDrop > i_TimeToDrop_Max)
                {
                    // Reset timer
                    f_TimeToDrop = 0;

                    // Drop blocks down manually
                    MoveActiveBlocks_Down(v2_ActiveBlockLocation, e_BlockSize);
                }
            }
            #endregion
            }
        }
        else if(e_PauseEffect == Enum_PauseEffect.ScoreLine)
        {
            #region Scoreline Pause
            // Run through the Scoreline array and have them destroy themselves
            f_ScoreLine_Timer += Time.deltaTime;

            if(f_ScoreLine_Timer > f_ScoreLine_Timer_Max)
            {
                if(i_ScoreLine_Counter < iv2_ScoreLine.Count)
                {
                    // Set the block in BlockArray to empty
                    SetBlock(iv2_ScoreLine[i_ScoreLine_Counter].x, iv2_ScoreLine[i_ScoreLine_Counter].y, Enum_BlockType.Empty);

                    // Score the block model on the screen
                    GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().ScoreBlockAt(iv2_ScoreLine[i_ScoreLine_Counter]);

                    #region Play sound effect
                    // Store previous pitch
                    float f_Pitch_Prev = go_SFX.GetComponent<AudioSource>().pitch;

                    // Find pitch
                    float f_Pitch = 0.4f + ((iv2_ScoreLine[i_ScoreLine_Counter].x / 3f) * 0.2f) + ((iv2_ScoreLine[i_ScoreLine_Counter].y / 3f) * 0.05f);
                    print("Setting pitch: " + f_Pitch);
                    go_SFX.GetComponent<AudioSource>().clip = sfx_ScoreEffect;
                    go_SFX.GetComponent<AudioSource>().pitch = f_Pitch;
                    go_SFX.GetComponent<AudioSource>().time = 0.09f;
                    go_SFX.GetComponent<AudioSource>().Play();

                    // Set previous pitch
                    // go_SFX.GetComponent<AudioSource>().pitch = f_Pitch_Prev;
                    #endregion

                    // Increment i_ScoreLine_Counter
                    ++i_ScoreLine_Counter;
                }
                // Scoreline is finished, reset and move on
                else
                {
                    // f_ScoreLine_Timer_Max gets added here cause I'm lazy. This line doesn't hit until the above timer breaches f_ScoreLine_Timer_Max.
                    f_ScoreLine_Timer_Conclusion += Time.deltaTime + f_ScoreLine_Timer_Max;

                    if(f_ScoreLine_Timer_Conclusion > f_ScoreLine_Timer_Conclusion_Max)
                    {
                        if (Load_ScoreLine())
                        {
                            CheckScoreLineLeftWall();

                            b_RunAgain = true;

                            e_PauseEffect = Enum_PauseEffect.ScoreLine;

                            GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().Set_ScoreTextIncrease(iv2_ScoreLine.Count);

                            i_ScoreLine_Counter = 0;

                            f_ScoreLine_Timer_Conclusion = 0.0f;

                            return;
                        }
                        else
                        {
                            f_ScoreLine_Timer_Conclusion = 0.0f;

                            // Reset the counter for the next cycle
                            i_ScoreLine_Counter = 0;

                            b_RunAgain = true;

                            // Clear the ScoreLine list
                            iv2_ScoreLine = new List<IntVector2>();

                            // 'PullBlocksDown' to update the board
                            PullBlocksDown();

                            if(Load_ScoreLine())
                            {
                                CheckScoreLineLeftWall();

                                b_RunAgain = true;

                                e_PauseEffect = Enum_PauseEffect.ScoreLine;

                                GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().Set_ScoreTextIncrease(iv2_ScoreLine.Count);

                                i_ScoreLine_Counter = 0;

                                f_ScoreLine_Timer_Conclusion = 0.0f;

                                return;
                            }

                            // Make a new block
                            CreateNewBlock();

                            // Gameplay resumes
                            e_PauseEffect = Enum_PauseEffect.Unpause;
                        }

                        // Reset the ScoreLine timer
                    }
                }

                // Reset the float timer
                f_ScoreLine_Timer = 0.0f;
            }
            #endregion
        }
        else if(e_PauseEffect == Enum_PauseEffect.StartGame)
        {
            #region Start Game
            // Creates a new block after a couple seconds at the beginning of the game
            if (f_StartGameTimer > 0)
            {
                f_StartGameTimer -= Time.deltaTime;

                if (f_StartGameTimer < 0)
                {
                    // GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().Set_ClearBackdrops();
                    CreateNewBlock();
                    e_PauseEffect = Enum_PauseEffect.Unpause;
                }
            }
            #endregion
        }
        else if(e_PauseEffect == Enum_PauseEffect.GameOver)
        {
            #region End Game
            f_GameOver_Timer += Time.deltaTime;

            if(f_GameOver_Timer > f_GameOver_Timer_Max)
            {
                // Set block position
                if( i_GameOver_X < i_ArrayWidth - 1 &&
                    i_GameOver_Y < i_ArrayHeight )
                {
                    // Destroy the old. Set the new. All visual, no board array manipulation.
                    GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().DestroyBlockAt(new IntVector2(i_GameOver_X, i_GameOver_Y));
                    GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().Set_GameOverBlock( i_GameOver_X, i_GameOver_Y, e_GameOverBlock );
                }

                // Set next block type
                #region Next Block Type
                // Ensure that we're an odd number. Forces a checkerboard pattern.
                if(i_GameOver_X < i_ArrayWidth - 1)
                {
                    if (e_GameOverBlock == Enum_BlockType.Block_1_Active)
                    {
                        e_GameOverBlock = Enum_BlockType.Block_2_Active;
                    }
                    else if (e_GameOverBlock == Enum_BlockType.Block_2_Active)
                    {
                        if (b_ThreeBlockColors)
                        {
                            e_GameOverBlock = Enum_BlockType.Block_3_Active;
                        }
                        else
                        {
                            e_GameOverBlock = Enum_BlockType.Block_1_Active;
                        }
                    }
                    else // Block 3
                    {
                        e_GameOverBlock = Enum_BlockType.Block_1_Active;
                    }
                }
                else
                {
                    if (i_ArrayWidth % 2 == 0)
                    {
                        if (e_GameOverBlock == Enum_BlockType.Block_1_Active)
                        {
                            e_GameOverBlock = Enum_BlockType.Block_2_Active;
                        }
                        else if (e_GameOverBlock == Enum_BlockType.Block_2_Active)
                        {
                            if (b_ThreeBlockColors)
                            {
                                e_GameOverBlock = Enum_BlockType.Block_3_Active;
                            }
                            else
                            {
                                e_GameOverBlock = Enum_BlockType.Block_1_Active;
                            }
                        }
                        else
                        {
                            e_GameOverBlock = Enum_BlockType.Block_1_Active;
                        }
                    }
                }

                #endregion

                // Reset timer
                f_GameOver_Timer = 0f;

                // Increment X/Y
                ++i_GameOver_X;

                // When the GameOver_X position is greater than the inner walls...
                if(i_GameOver_X > i_ArrayWidth - 1)
                {
                    // Reset the X position
                    i_GameOver_X = 1;

                    // Increments the Y.
                    ++i_GameOver_Y;
                }
            }
            else
            {
                if (i_GameOver_X >= i_ArrayWidth - 1 && i_GameOver_Y >= i_ArrayHeight - 1)
                {
                    f_GameOver_FadeOut_Timer += Time.deltaTime;
                }
            }
            #endregion

            if(f_GameOver_FadeOut_Timer > 0f)
            {
                // Fade to black & return to main menu
                f_GameOver_FadeOut_Timer += Time.deltaTime;

                print(f_GameOver_FadeOut_Timer);

                if (f_GameOver_FadeOut_Timer > 5.0f)
                {
                    // Fade out the screen slowly
                    Color clr_CurrAlpha = go_FadeOut.GetComponent<Image>().color;

                    clr_CurrAlpha.a += Time.deltaTime / 3f;
                    float f_Perc = 1f - clr_CurrAlpha.a;
                    go_FadeOut.GetComponent<Image>().color = clr_CurrAlpha;

                    // Reduce volume to match
                    GameObject.Find("AudioSource_Music").GetComponent<AudioSource>().volume = f_Perc / 2.0f;
                }

                if (f_GameOver_FadeOut_Timer > 10f)
                {
                    SceneManager.LoadScene(2);
                }
            }
        }
    }
Exemplo n.º 5
0
    void PotentialBlockVisual()
    {
        // Clear Backdrops before positioning new stuff
        // GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().Set_ClearBackdrops();

        // Reset SmallList_Vert
        int i_BlockHeight = 2;
        if (e_BlockSize == Enum_BlockSize.size_2w_3h || e_BlockSize == Enum_BlockSize.size_3w_3h) i_BlockHeight = 3;

        int i_BlockWidth = 2;
        if (e_BlockSize == Enum_BlockSize.size_3w_2h || e_BlockSize == Enum_BlockSize.size_3w_3h) i_BlockWidth = 3;

        Enum_BlockType[] e_SmallList_Vert = new Enum_BlockType[i_BlockHeight];

        // Start with the ActiveBlockLocation bottom left and cycle upward
        for(int x_ = 0; x_ < i_BlockWidth; ++x_)
        {
            for(int y_ = 0; y_ < i_BlockHeight; ++y_)
            {
                // When the active blocks reach the bottom, the blocks used to apply the visual blocks above the active blocks. This prevents that.
                if((int)v2_ActiveBlockLocation.y > 0)
                {
                    e_SmallList_Vert[y_] = GetBlock((int)v2_ActiveBlockLocation.x + x_, (int)v2_ActiveBlockLocation.y + y_);
                }
            }

            // Send to Set_ShowPotentialBlockVisual
            GameObject.Find("BoardDisplay").GetComponent<Cs_BoardDisplay>().Set_ShowPotentialBlockVisual((int)v2_ActiveBlockLocation.x + x_, (int)v2_ActiveBlockLocation.y, e_SmallList_Vert);
        }
    }
Exemplo n.º 6
0
    void SetBlock(int x_Pos_, int y_Pos_, Enum_BlockType blockType_)
    {
        if (x_Pos_ < 0 || x_Pos_ >= i_ArrayWidth)  return;
        if (y_Pos_ < 0 || y_Pos_ >= i_ArrayHeight) return;

        BlockArray[y_Pos_, x_Pos_] = blockType_;
    }
    public void Set_NextBlockArray( Enum_BlockType[,] e_BlockType_, Enum_BlockSize e_BlockSize_, IntVector2 iv2_BottomLeft_ )
    {
        if(e_BlockSize_ == Enum_BlockSize.size_2w_2h)
        {

        }

        //float f_LeftColumn = f_BlockScale_ + f_Buffer_;
        //float f_CenterColumn = f_LeftColumn + f_BlockScale_ + f_Buffer_;
        //float f_RightColumn = f_CenterColumn + f_BlockScale_ + f_Buffer_;

        //float f_MiddleRow = Screen.height / 2f;
        //float f_TopRow = f_MiddleRow + f_BlockScale_ + f_Buffer_;
        //float f_BottomRow = f_MiddleRow - f_BlockScale_ - f_Buffer_;

        /*
        // Find Height/Width of block array
        int i_BlockWidth = 2;
        int i_BlockHeight = 2;

        // 3 Wide
        if (e_BlockSize_ == Enum_BlockSize.size_3w_2h || e_BlockSize_ == Enum_BlockSize.size_3w_3h) i_BlockWidth = 3;
        // 3 High
        if (e_BlockSize_ == Enum_BlockSize.size_2w_3h || e_BlockSize_ == Enum_BlockSize.size_3w_3h) i_BlockHeight = 3;

        // Run through the list of NewBlockTypeArray
        for (int y_ = 0; y_ < i_BlockHeight; ++y_)
        {
            for (int x_ = 0; x_ < i_BlockWidth; ++x_)
            {
                GameObject go_BlockTemp;

                // Create a new block based on the position within NewBlockTypeArray
                if (e_BlockType_[y_, x_] == Enum_BlockType.Block_1_Active)
                {
                    // go_BlockTemp is Instantiated as above by default
                    go_BlockTemp = Instantiate(go_Block_A);
                    go_BlockTemp.transform.SetParent(GameObject.Find("DisplayBlockList").transform);
                }
                else if (e_BlockType_[y_, x_] == Enum_BlockType.Block_2_Active)
                {
                    go_BlockTemp = Instantiate(go_Block_B);
                    go_BlockTemp.transform.SetParent(GameObject.Find("DisplayBlockList").transform);
                }
                else if (e_BlockType_[y_, x_] == Enum_BlockType.Block_3_Active)
                {
                    go_BlockTemp = Instantiate(go_Block_C);
                    go_BlockTemp.transform.SetParent(GameObject.Find("DisplayBlockList").transform);
                }
                else
                {
                    print("INVALID BLOCK ADDED TO CS_BOARDDISPLAY");
                    go_BlockTemp = Instantiate(go_Empty);
                    go_BlockTemp.transform.SetParent(GameObject.Find("EmptyBlocks").transform);
                }

                // Initialize this block
                int i_NewX = x_ + iv2_BottomLeft_.x;
                int i_NewY = y_ + iv2_BottomLeft_.y;
                if (go_BlockTemp.GetComponent<Cs_BlockOnBoardLogic>())
                {
                    go_BlockTemp.GetComponent<Cs_BlockOnBoardLogic>().Init_BlockModel(i_NewX, i_NewY, 3.0f, 0.75f, i_Width);
                }

                // Set the Backdrop Color
                // Set_BackdropColor(e_NewBlockTypeArray_[y_, x_], new IntVector2(i_NewX, i_NewY));

                // Add this block type to the proper position within Display Array
                DisplayArray[i_NewY, i_NewX] = e_NewBlockTypeArray_[y_, x_];

                DisplayArray_Blocks[i_NewY, i_NewX] = go_BlockTemp;
            }
        }
        */
    }
Exemplo n.º 8
0
    // Set the x Position of the array to run through, and find the first open position. Stack blocks vertically from there.
    public void Set_ShowPotentialBlockVisual(int i_xPos_, int i_CurrY_, Enum_BlockType[] e_VertBlockArray_ )
    {
        // Initialize the yPosition to start from
        int i_yPos = 0;

        // Search for the first open position.
        for( int y_ = 0; y_ < i_Height; ++y_ )
        {
            // When we find the first open block position, step out.
            if( DisplayArray[y_, i_xPos_] == Enum_BlockType.Empty &&
                y_ <= i_CurrY_ )
            {
                i_yPos = y_;

                break;
            }
        }

        // Begin setting the new positions vertically
        for( int i_ = 0; i_ < e_VertBlockArray_.Length; ++i_ )
        {
            Set_BackdropColor( e_VertBlockArray_[i_], new IntVector2(i_xPos_, i_yPos + i_), true );
        }
    }
Exemplo n.º 9
0
    // Used for cheating.
    public void Set_OneBlock( int i_xPos_, int i_yPos_, Enum_BlockType e_BlockType_ )
    {
        // Clear prior block first
        ScoreBlockAt(new IntVector2(i_xPos_, i_yPos_));

        // Set new Temp Block
        GameObject go_BlockTemp;

        // Create a new block based on the position within NewBlockTypeArray
        if (e_BlockType_ == Enum_BlockType.Block_1_Static)
        {
            // go_BlockTemp is Instantiated as above by default
            go_BlockTemp = Instantiate(go_Block_A);
            go_BlockTemp.transform.SetParent(GameObject.Find("DisplayBlockList").transform);
        }
        else if (e_BlockType_ == Enum_BlockType.Block_2_Static)
        {
            go_BlockTemp = Instantiate(go_Block_B);
            go_BlockTemp.transform.SetParent(GameObject.Find("DisplayBlockList").transform);
        }
        else if (e_BlockType_ == Enum_BlockType.Block_3_Static)
        {
            go_BlockTemp = Instantiate(go_Block_C);
            go_BlockTemp.transform.SetParent(GameObject.Find("DisplayBlockList").transform);
        }
        else
        {
            print("INVALID BLOCK ADDED TO CS_BOARDDISPLAY");
            go_BlockTemp = Instantiate(go_Empty);
            go_BlockTemp.transform.SetParent(GameObject.Find("EmptyBlocks").transform);
        }

        // Initialize this block
        if (go_BlockTemp.GetComponent<Cs_BlockOnBoardLogic>())
        {
            go_BlockTemp.GetComponent<Cs_BlockOnBoardLogic>().Init_BlockModel(i_xPos_, i_yPos_, 3.0f, 0.75f, i_Width);
        }

        // Set the Backdrop Color
        Set_BackdropColor(e_BlockType_, new IntVector2(i_xPos_, i_yPos_));

        // Add this block type to the proper position within Display Array
        DisplayArray[i_yPos_, i_xPos_] = e_BlockType_;

        DisplayArray_Blocks[i_yPos_, i_xPos_] = go_BlockTemp;
    }
Exemplo n.º 10
0
    public void Set_GameOverBlock( int i_xPos_, int i_yPos_, Enum_BlockType e_BlockType_ )
    {
        GameObject go_BlockTemp;

        // Create a new block based on the position within NewBlockTypeArray
        if (e_BlockType_ == Enum_BlockType.Block_1_Active)
        {
            // go_BlockTemp is Instantiated as above by default
            go_BlockTemp = Instantiate(go_Block_A);
            go_BlockTemp.transform.SetParent(GameObject.Find("DisplayBlockList").transform);
        }
        else if (e_BlockType_ == Enum_BlockType.Block_2_Active)
        {
            go_BlockTemp = Instantiate(go_Block_B);
            go_BlockTemp.transform.SetParent(GameObject.Find("DisplayBlockList").transform);
        }
        else if (e_BlockType_ == Enum_BlockType.Block_3_Active)
        {
            go_BlockTemp = Instantiate(go_Block_C);
            go_BlockTemp.transform.SetParent(GameObject.Find("DisplayBlockList").transform);
        }
        else
        {
            go_BlockTemp = Instantiate(go_Empty);
            go_BlockTemp.transform.SetParent(GameObject.Find("EmptyBlocks").transform);
        }

        // Initialize this block
        if (go_BlockTemp.GetComponent<Cs_BlockOnBoardLogic>())
        {
            go_BlockTemp.GetComponent<Cs_BlockOnBoardLogic>().Init_BlockModel(i_xPos_, i_yPos_, 3.0f, 0.001f, i_Width);
            go_BlockTemp.GetComponent<Cs_BlockOnBoardLogic>().Set_GameOverBlock();
        }

        // Set the Backdrop Color
        Set_BackdropColor(e_BlockType_, new IntVector2(i_xPos_, i_yPos_));
    }
Exemplo n.º 11
0
 void Set_BackdropColor( Enum_BlockType e_BlockType_, IntVector2 iv2_Pos_, bool b_IsInstant_ = false )
 {
     // Set Grid_Backdrop Color
     if (e_BlockType_ == Enum_BlockType.Block_1_Active)
     {
         Grid_Columns[iv2_Pos_.y][iv2_Pos_.x].GetComponent<Cs_GridBlockLogic>().Set_ColorState(Enum_ColorState.Red, b_IsInstant_);
     }
     else if (e_BlockType_ == Enum_BlockType.Block_2_Active)
     {
         Grid_Columns[iv2_Pos_.y][iv2_Pos_.x].GetComponent<Cs_GridBlockLogic>().Set_ColorState(Enum_ColorState.Blue, b_IsInstant_);
     }
     else if (e_BlockType_ == Enum_BlockType.Block_3_Active)
     {
         // TODO: Block 3
         Grid_Columns[iv2_Pos_.y][iv2_Pos_.x].GetComponent<Cs_GridBlockLogic>().Set_ColorState(Enum_ColorState.White, b_IsInstant_);
     }
     else if( e_BlockType_ == Enum_BlockType.Empty )
     {
         Grid_Columns[iv2_Pos_.y][iv2_Pos_.x].GetComponent<Cs_GridBlockLogic>().Set_ColorState(Enum_ColorState.Original, b_IsInstant_);
     }
 }