コード例 #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;
                }
            }
        }
    }
コード例 #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);
            }
        }
    }
コード例 #3
0
 public void EndComboInvolvement(ComboTabulator combo)
 {
     if (CurrentCombo != null && CurrentCombo == combo)
     {
         CurrentCombo.DecrementInvolvement();
         CurrentCombo = null;
     }
 }
コード例 #4
0
ファイル: Block.cs プロジェクト: ronforbes/TetrisAttack
 public void EndComboInvolvement(ComboTabulator combo)
 {
     if(CurrentCombo != null && CurrentCombo == combo)
     {
         CurrentCombo.DecrementInvolvement();
         CurrentCombo = null;
     }
 }
コード例 #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;
     }
 }
コード例 #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;
     }
 }
コード例 #7
0
ファイル: Block.cs プロジェクト: ronforbes/TetrisAttack
    public void BeginComboInvolvement(ComboTabulator combo)
    {
        if(CurrentCombo != null)
        {
            CurrentCombo.DecrementInvolvement();
        }

        CurrentCombo = combo;
        CurrentCombo.IncrementInvolvement();
    }
コード例 #8
0
    public ComboTabulator NewComboTabulator()
    {
        int id = FindFreeId();

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

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

        CurrentCombo = combo;
        CurrentCombo.IncrementInvolvement();
    }
コード例 #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);
    }
コード例 #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;
    }
コード例 #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);
    }
コード例 #13
0
ファイル: Block.cs プロジェクト: ronforbes/TetrisAttack
    // 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);
    }
コード例 #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);
    }
コード例 #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);
    }
コード例 #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);
    }
コード例 #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);
    }
コード例 #18
0
ファイル: Grid.cs プロジェクト: ronforbes/TetrisAttack
    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);
    }
コード例 #19
0
 public void RequestEliminationCheck(Block block, ComboTabulator combo = null)
 {
     checkRegistry[block.Id].Mark  = true;
     checkRegistry[block.Id].Combo = combo;
     checkCount++;
 }
コード例 #20
0
ファイル: Grid.cs プロジェクト: ronforbes/TetrisAttack
 public void RequestEliminationCheck(Block block, ComboTabulator combo = null)
 {
     checkRegistry[block.Id].Mark = true;
     checkRegistry[block.Id].Combo = combo;
     checkCount++;
 }
コード例 #21
0
ファイル: Block.cs プロジェクト: ronforbes/TetrisAttack
    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;
    }
コード例 #22
0
 public void DeleteComboTabulator(ComboTabulator combo)
 {
     FreeId(combo.Id);
 }
コード例 #23
0
ファイル: Block.cs プロジェクト: ronforbes/TetrisAttack
    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);
        }
    }
コード例 #24
0
 public void DeleteComboTabulator(ComboTabulator combo)
 {
     FreeId(combo.Id);
 }