コード例 #1
0
    public void FillSlot(BColour colour)
    {
        isEmpty           = false;
        sRenderer.enabled = true;

        switch (colour)
        {
        case BColour.Red:
            holdingColour    = BColour.Red;
            sRenderer.sprite = redBlock;
            return;

        case BColour.Green:
            holdingColour    = BColour.Green;
            sRenderer.sprite = greenBlock;
            return;

        case BColour.Blue:
            holdingColour    = BColour.Blue;
            sRenderer.sprite = blueBlock;
            return;

        default:
            isEmpty           = true;
            sRenderer.enabled = false;
            return;
        }
    }
コード例 #2
0
    void SetBombType()
    {
        int random = Random.Range(0, 4);

        switch (random)
        {
        case 0:
            type = BColour.Red;
            transform.parent.GetComponentInChildren <SpriteRenderer>().sprite = redBomb;
            break;

        case 1:
            type = BColour.Blue;
            transform.parent.GetComponentInChildren <SpriteRenderer>().sprite = blueBomb;
            break;

        case 2:
            type = BColour.Green;
            transform.parent.GetComponentInChildren <SpriteRenderer>().sprite = greenBomb;
            break;

        case 3:
            transform.parent.GetComponentInChildren <SpriteRenderer>().sprite = deleteBomb;
            type = BColour.Delete;
            break;
        }
    }
コード例 #3
0
ファイル: Block.cs プロジェクト: JasonMars1/BlockPuzzleGame
 //Applying the best distance slot
 public virtual void ApplyBlock(BColour colour)
 {
     if (Check())
     {
         game.AddToScore(1);
         GridManager.instance.ReturnSlotFromCoords(GetSquareOn()).FillSlot(colour);
     }
 }
コード例 #4
0
 public override void ApplyBlock(BColour colour)
 {
     foreach (Slot x in GridManager.instance.returnSlots())
     {
         if (col.bounds.Contains(x.transform.position))
         {
             if (type == BColour.Delete)
             {
                 x.EmptySlot();
                 game.AddToScore(1);
             }
             else
             {
                 x.FillSlot(type);
                 game.AddToScore(1);
             }
         }
     }
 }
コード例 #5
0
    public void CheckForLines()
    {
        bool    checkFlag   = true;
        bool    colourFlag  = true;
        BColour bColourFlag = new BColour();

        List <LineRemove> coords = new List <LineRemove>();

        for (int x = 0; x < 10; x++) //Vertical Check for Lines
        {
            bColourFlag = slots[x, 0].holdingColour;
            checkFlag   = true;          // reset the flag to true
            colourFlag  = true;          // reset colour flag
            for (int y = 0; y < 10; y++) //Check to see if row has any empties
            {
                if (slots[x, y].isEmpty)
                {
                    checkFlag = false; // turn off the flag
                    break;             //no need to carry on looking
                }
                else if (slots[x, y].holdingColour != bColourFlag)
                {
                    colourFlag = false;
                }
            }
            if (checkFlag == true) // if the row is all full
            {
                for (int y = 0; y < 10; y++)
                {
                    if (colourFlag == true)                     //all same colours
                    {
                        coords.Add(new LineRemove(x, y, true)); //add that coord to the list to be removed at the end
                    }
                    else // not same
                    {
                        coords.Add(new LineRemove(x, y, false));
                    }
                }

                List <Sprite> colours = new List <Sprite>();
                int           count   = 0;

                foreach (LineRemove current in coords)
                {
                    count++;
                    colours.Add(slots[current.coords[0], current.coords[1]].GetComponent <SpriteRenderer>().sprite);
                    print("Added colour y");

                    if (count % 10 == 0) //for each set of 10 colours to avoid a line crash
                    {
                        FadeControl.instance.FadeOnLineY(x, colours);
                        count   = 0;
                        colours = new List <Sprite>();
                    }
                }
            }
        }

        for (int y = 0; y < 10; y++) //Horizontal Check for Lines
        {
            bColourFlag = slots[0, y].holdingColour;
            checkFlag   = true;          // reset the flag to true
            colourFlag  = true;          // reset colour flag

            for (int x = 0; x < 10; x++) //Check to see if row has any empties
            {
                if (slots[x, y].isEmpty)
                {
                    checkFlag = false; // turn off the flag
                    break;             // no need to carry on down
                }
                else if (slots[x, y].holdingColour != bColourFlag)
                {
                    colourFlag = false;
                }
            }
            if (checkFlag == true) // if the row is all full
            {
                for (int x = 0; x < 10; x++)
                {
                    if (colourFlag == true)
                    {
                        coords.Add(new LineRemove(x, y, true)); //add that coord to the list to be removed at the end
                    }
                    else
                    {
                        coords.Add(new LineRemove(x, y, false));
                    }
                }

                List <Sprite> colours = new List <Sprite>();
                int           count   = 0;//count to reset the colours list

                foreach (LineRemove current in coords)
                {
                    count++;
                    colours.Add(slots[current.coords[0], current.coords[1]].GetComponent <SpriteRenderer>().sprite);
                    print("Added colour");

                    if (count % 10 == 0)
                    {
                        FadeControl.instance.FadeOnLineX(y, colours);
                        count   = 0;
                        colours = new List <Sprite>();
                    }
                }
                // do a  for loop for every 10, problem is that the colours arent reset on second line check i think
            }
        }

        foreach (LineRemove current in coords) //remove them
        {
            slots[current.coords[0], current.coords[1]].EmptySlot();

            if (current.sameColour)
            {
                game.AddToScore(2);
                print("x2");
            }
            else
            {
                game.AddToScore(1);
            }
        }
    }