// 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; } } } }
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); } } }
public void EndComboInvolvement(ComboTabulator combo) { if (CurrentCombo != null && CurrentCombo == combo) { CurrentCombo.DecrementInvolvement(); CurrentCombo = null; } }
public void EndComboInvolvement(ComboTabulator combo) { if(CurrentCombo != null && CurrentCombo == combo) { CurrentCombo.DecrementInvolvement(); CurrentCombo = null; } }
// Use this for initialization void Start() { for(int n = 0; n < comboTabulatorStoreSize; n++) { storeMap[n] = false; tabulatorStore[n] = new ComboTabulator(); tabulatorStore[n].Id = n; } }
// Use this for initialization void Start() { for (int n = 0; n < comboTabulatorStoreSize; n++) { storeMap[n] = false; tabulatorStore[n] = new ComboTabulator(); tabulatorStore[n].Id = n; } }
public void BeginComboInvolvement(ComboTabulator combo) { if(CurrentCombo != null) { CurrentCombo.DecrementInvolvement(); } CurrentCombo = combo; CurrentCombo.IncrementInvolvement(); }
public ComboTabulator NewComboTabulator() { int id = FindFreeId(); AllocateId(id); ComboTabulator combo = tabulatorStore[id]; combo.Initialize(); return(combo); }
public void BeginComboInvolvement(ComboTabulator combo) { if (CurrentCombo != null) { CurrentCombo.DecrementInvolvement(); } CurrentCombo = combo; CurrentCombo.IncrementInvolvement(); }
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); }
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; }
// 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); }
// 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); }
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); }
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); }
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); }
public void RequestEliminationCheck(Block block, ComboTabulator combo = null) { checkRegistry[block.Id].Mark = true; checkRegistry[block.Id].Combo = combo; checkCount++; }
public void DeleteComboTabulator(ComboTabulator combo) { FreeId(combo.Id); }
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); } }