Example #1
0
    // Update is called once per frame
    void Update()
    {
        int c = comboCount;

        for (int n = 0; c > 0; n++)
        {
            if (!storeMap[n])
            {
                continue;
            }

            ComboTabulator combo = tabulatorStore[n];
            c--;

            if (combo.InvolvementCount == 0)
            {
                FreeId(n);
            }
            else
            {
                if (combo.EliminationJustOccurred)
                {
                    // notify the score
                    Game.Score++;

                    combo.EliminationJustOccurred = false;
                }
            }
        }
    }
Example #2
0
    public void StartFalling(ComboTabulator combo = null)
    {
        if (State != BlockState.Static)
        {
            return;
        }

        // change our state
        State = BlockState.Falling;

        FallElapsed = FallDuration;

        grid.ChangeState(X, Y, this, GridElement.ElementState.Falling);

        if (combo != null)
        {
            BeginComboInvolvement(combo);
        }

        if (Y < Grid.PlayHeight - 1)
        {
            if (grid.StateAt(X, Y + 1) == GridElement.ElementState.Block)
            {
                grid.BlockAt(X, Y + 1).StartFalling(CurrentCombo);
            }
        }
    }
Example #3
0
 public void EndComboInvolvement(ComboTabulator combo)
 {
     if (CurrentCombo != null && CurrentCombo == combo)
     {
         CurrentCombo.DecrementInvolvement();
         CurrentCombo = null;
     }
 }
Example #4
0
 public void EndComboInvolvement(ComboTabulator combo)
 {
     if(CurrentCombo != null && CurrentCombo == combo)
     {
         CurrentCombo.DecrementInvolvement();
         CurrentCombo = null;
     }
 }
Example #5
0
 // Use this for initialization
 void Start()
 {
     for(int n = 0; n < comboTabulatorStoreSize; n++)
     {
         storeMap[n] = false;
         tabulatorStore[n] = new ComboTabulator();
         tabulatorStore[n].Id = n;
     }
 }
Example #6
0
 // Use this for initialization
 void Start()
 {
     for (int n = 0; n < comboTabulatorStoreSize; n++)
     {
         storeMap[n]          = false;
         tabulatorStore[n]    = new ComboTabulator();
         tabulatorStore[n].Id = n;
     }
 }
Example #7
0
    public void BeginComboInvolvement(ComboTabulator combo)
    {
        if(CurrentCombo != null)
        {
            CurrentCombo.DecrementInvolvement();
        }

        CurrentCombo = combo;
        CurrentCombo.IncrementInvolvement();
    }
Example #8
0
    public ComboTabulator NewComboTabulator()
    {
        int id = FindFreeId();

        AllocateId(id);
        ComboTabulator combo = tabulatorStore[id];

        combo.Initialize();
        return(combo);
    }
Example #9
0
    public void BeginComboInvolvement(ComboTabulator combo)
    {
        if (CurrentCombo != null)
        {
            CurrentCombo.DecrementInvolvement();
        }

        CurrentCombo = combo;
        CurrentCombo.IncrementInvolvement();
    }
Example #10
0
    public void NewBlock(int x, int y, int flavor, float popDuration, float awakenDuration, ComboTabulator combo, int popColor)
    {
        if(BlockCount == BlockStoreSize)
            return;

        int id = FindFreeId();
        AllocateId(id);
        Block block = BlockStore[id];

        block.InitializeAwakening(x, y, flavor, popDuration, awakenDuration, combo, popColor);
    }
Example #11
0
    public void StartDying(ComboTabulator combo, int sparkNumber)
    {
        // change the game state
        game.DyingCount++;

        BeginComboInvolvement(combo);

        State      = BlockState.Dying;
        DieElapsed = 0.0f;

        grid.ChangeState(X, Y, this, GridElement.ElementState.Immutable);

        DyingAxis = Random.insideUnitCircle;
    }
Example #12
0
    // Untested
    public void NewAwakeningBlock(int x, int y, float popDuration, float awakenDuration, ComboTabulator combo, int popColor)
    {
        int flavor;

        do
        {
            flavor = Random.Range(0, Block.FlavorCount);
        } while((flavor == lastFlavorCreep && lastFlavorCreep == secondToLastFlavorCreep) ||
                (flavor == LastRowCreep[x] && LastRowCreep[x] == SecondToLastRowCreep[x]));

        SecondToLastRowCreep[x] = LastRowCreep[x];
        LastRowCreep[x] = flavor;

        secondToLastFlavorCreep = lastFlavorCreep;
        lastFlavorCreep = flavor;

        NewBlock(x, y, flavor, popDuration, awakenDuration, combo, popColor);
    }
Example #13
0
    // Untested
    public void InitializeAwakening(int x, int y, int flavor, float popDuration, float awakenDuration, ComboTabulator combo, int popColor)
    {
        X = x;
        Y = y;
        Flavor = flavor;

        State = BlockState.Awakening;
        AwakenDuration = awakenDuration;
        this.popDuration = popDuration;
        //popDirection = BlockManager.GeneratePopDirection();
        //this.popColor = popColor;
        CurrentCombo = combo;

        CurrentCombo.IncrementInvolvement();

        //Game.AwakeningCount++;

        grid.AddBlock(x, y, this, GridElement.ElementState.Immutable);
    }
Example #14
0
    // Untested
    public void InitializeAwakening(int x, int y, int flavor, float popDuration, float awakenDuration, ComboTabulator combo, int popColor)
    {
        X      = x;
        Y      = y;
        Flavor = flavor;

        State            = BlockState.Awakening;
        AwakenDuration   = awakenDuration;
        this.popDuration = popDuration;
        //popDirection = BlockManager.GeneratePopDirection();
        //this.popColor = popColor;
        CurrentCombo = combo;

        CurrentCombo.IncrementInvolvement();

        //Game.AwakeningCount++;

        grid.AddBlock(x, y, this, GridElement.ElementState.Immutable);
    }
Example #15
0
    // Untested
    public void NewAwakeningBlock(int x, int y, float popDuration, float awakenDuration, ComboTabulator combo, int popColor)
    {
        int flavor;

        do
        {
            flavor = Random.Range(0, Block.FlavorCount);
        } while((flavor == lastFlavorCreep && lastFlavorCreep == secondToLastFlavorCreep) ||
                (flavor == LastRowCreep[x] && LastRowCreep[x] == SecondToLastRowCreep[x]));

        SecondToLastRowCreep[x] = LastRowCreep[x];
        LastRowCreep[x]         = flavor;

        secondToLastFlavorCreep = lastFlavorCreep;
        lastFlavorCreep         = flavor;

        NewBlock(x, y, flavor, popDuration, awakenDuration, combo, popColor);
    }
Example #16
0
    void HandleEliminationCheckRequest(Block block, ComboTabulator combo)
    {
        int x = block.X;
        int y = block.Y;

        // look in four directions for matching lines

        int left = x;

        while (left > 0)
        {
            if (StateAt(left - 1, y) != GridElement.ElementState.Block)
            {
                break;
            }
            if (!MatchAt(left - 1, y, block))
            {
                break;
            }
            left--;
        }

        int right = x + 1;

        while (right < PlayWidth)
        {
            if (StateAt(right, y) != GridElement.ElementState.Block)
            {
                break;
            }
            if (!MatchAt(right, y, block))
            {
                break;
            }
            right++;
        }

        int bottom = y;

        while (bottom > 1)
        {
            if (StateAt(x, bottom - 1) != GridElement.ElementState.Block)
            {
                break;
            }
            if (!MatchAt(x, bottom - 1, block))
            {
                break;
            }
            bottom--;
        }

        int top = y + 1;

        while (top < PlayHeight)
        {
            if (StateAt(x, top) != GridElement.ElementState.Block)
            {
                break;
            }
            if (!MatchAt(x, top, block))
            {
                break;
            }
            top++;
        }

        int  width             = right - left;
        int  height            = top - bottom;
        int  magnitude         = 0;
        bool horizontalPattern = false;
        bool verticalPattern   = false;

        if (width >= MinimumPatternLength)
        {
            horizontalPattern = true;
            magnitude        += width;
        }

        if (height >= MinimumPatternLength)
        {
            verticalPattern = true;
            magnitude      += height;
        }

        if (!horizontalPattern && !verticalPattern)
        {
            block.EndComboInvolvement(combo);
            return;
        }

        if (combo == null)
        {
            combo = ComboManager.NewComboTabulator();
        }

        // if pattern matches both directions
        if (horizontalPattern && verticalPattern)
        {
            magnitude--;
        }

        // kill the pattern's blocks and look for touching garbage
        block.StartDying(combo, magnitude);

        if (horizontalPattern)
        {
            // kill the pattern's blocks
            for (int killX = left; killX < right; killX++)
            {
                if (killX != x)
                {
                    BlockAt(killX, y).StartDying(combo, magnitude);
                }
            }
        }

        if (verticalPattern)
        {
            // kill the pattern's blocks
            for (int killY = bottom; killY < top; killY++)
            {
                if (killY != y)
                {
                    BlockAt(x, killY).StartDying(combo, magnitude);
                }
            }
        }

        combo.ReportElimination(magnitude, block);
    }
Example #17
0
    public void NewBlock(int x, int y, int flavor, float popDuration, float awakenDuration, ComboTabulator combo, int popColor)
    {
        if (BlockCount == BlockStoreSize)
        {
            return;
        }

        int id = FindFreeId();

        AllocateId(id);
        Block block = BlockStore[id];

        block.InitializeAwakening(x, y, flavor, popDuration, awakenDuration, combo, popColor);
    }
Example #18
0
    void HandleEliminationCheckRequest(Block block, ComboTabulator combo)
    {
        int x = block.X;
        int y = block.Y;

        // look in four directions for matching lines

        int left = x;
        while(left > 0)
        {
            if(StateAt(left - 1, y) != GridElement.ElementState.Block)
                break;
            if(!MatchAt(left - 1, y, block))
                break;
            left--;
        }

        int right = x + 1;
        while(right < PlayWidth)
        {
            if(StateAt(right, y) != GridElement.ElementState.Block)
                break;
            if(!MatchAt(right, y, block))
                break;
            right++;
        }

        int bottom = y;
        while(bottom > 1)
        {
            if(StateAt(x, bottom - 1) != GridElement.ElementState.Block)
                break;
            if(!MatchAt(x, bottom - 1, block))
                break;
            bottom--;
        }

        int top = y + 1;
        while(top < PlayHeight)
        {
            if(StateAt (x, top) != GridElement.ElementState.Block)
                break;
            if(!MatchAt(x, top, block))
                break;
            top++;
        }

        int width = right - left;
        int height = top - bottom;
        int magnitude = 0;
        bool horizontalPattern = false;
        bool verticalPattern = false;

        if(width >= MinimumPatternLength)
        {
            horizontalPattern = true;
            magnitude += width;
        }

        if(height >= MinimumPatternLength)
        {
            verticalPattern = true;
            magnitude += height;
        }

        if(!horizontalPattern && !verticalPattern)
        {
            block.EndComboInvolvement(combo);
            return;
        }

        if(combo == null)
        {
            combo = ComboManager.NewComboTabulator();
        }

        // if pattern matches both directions
        if(horizontalPattern && verticalPattern)
            magnitude--;

        // kill the pattern's blocks and look for touching garbage
        block.StartDying(combo, magnitude);

        if(horizontalPattern)
        {
            // kill the pattern's blocks
            for(int killX = left; killX < right; killX++)
            {
                if(killX != x)
                {
                    BlockAt(killX, y).StartDying(combo, magnitude);
                }
            }
        }

        if(verticalPattern)
        {
            // kill the pattern's blocks
            for(int killY = bottom; killY < top; killY++)
            {
                if(killY != y)
                {
                    BlockAt(x, killY).StartDying(combo, magnitude);
                }
            }
        }

        combo.ReportElimination(magnitude, block);
    }
Example #19
0
 public void RequestEliminationCheck(Block block, ComboTabulator combo = null)
 {
     checkRegistry[block.Id].Mark  = true;
     checkRegistry[block.Id].Combo = combo;
     checkCount++;
 }
Example #20
0
 public void RequestEliminationCheck(Block block, ComboTabulator combo = null)
 {
     checkRegistry[block.Id].Mark = true;
     checkRegistry[block.Id].Combo = combo;
     checkCount++;
 }
Example #21
0
    public void StartDying(ComboTabulator combo, int sparkNumber)
    {
        // change the game state
        game.DyingCount++;

        BeginComboInvolvement(combo);

        State = BlockState.Dying;
        DieElapsed = 0.0f;

        grid.ChangeState(X, Y, this, GridElement.ElementState.Immutable);

        DyingAxis = Random.insideUnitCircle;
    }
Example #22
0
 public void DeleteComboTabulator(ComboTabulator combo)
 {
     FreeId(combo.Id);
 }
Example #23
0
    public void StartFalling(ComboTabulator combo = null)
    {
        if(State != BlockState.Static)
            return;

        // change our state
        State = BlockState.Falling;

        FallElapsed = FallDuration;

        grid.ChangeState(X, Y, this, GridElement.ElementState.Falling);

        if(combo != null)
        {
            BeginComboInvolvement(combo);
        }

        if(Y < Grid.PlayHeight - 1)
        {
            if(grid.StateAt(X, Y + 1) == GridElement.ElementState.Block)
                grid.BlockAt(X, Y + 1).StartFalling(CurrentCombo);
        }
    }
Example #24
0
 public void DeleteComboTabulator(ComboTabulator combo)
 {
     FreeId(combo.Id);
 }