public Gem GetRandomGem() { Gem gem = new Gem { Bonus = pu.GetRandomBonus() }; // Some specific colors are needed for some bonuses if (gem.Bonus != (int)ParamUnit.Bonus.NONE) { switch (gem.Bonus) { case (int)ParamUnit.Bonus.COLORLESS: gem.Color = 8; break; case (int)ParamUnit.Bonus.OBSTACLE: gem.Color = 9; break; default: gem.Color = pu.GetRandomColor(); break; } } else { gem.Color = pu.GetRandomColor(); } return(gem); }
public void BonusGem(GameObject gem) { for (int x = 0; x < gSizeX; x++) { for (int y = 0; y < gSizeY; y++) { if (gem.Equals(grid[x, y])) { bool wasBonused = false; if (bonusSelector.currentSelected == 0) { if (lu.grid[x, y].Gem.Bonus != (int)ParamUnit.Bonus.NONE) { wasBonused = true; if (lu.grid[x, y].Gem.Bonus == (int)ParamUnit.Bonus.COLORLESS || lu.grid[x, y].Gem.Bonus == (int)ParamUnit.Bonus.OBSTACLE) { lu.grid[x, y].Gem.Color = pu.GetRandomColor(); } lu.grid[x, y].Gem.Bonus = (int)ParamUnit.Bonus.NONE; } } else if (bonusSelector.currentSelected == 1) { if (lu.grid[x, y].Gem.Bonus != (int)ParamUnit.Bonus.ENERGY) { wasBonused = true; if (lu.grid[x, y].Gem.Bonus == (int)ParamUnit.Bonus.COLORLESS || lu.grid[x, y].Gem.Bonus == (int)ParamUnit.Bonus.OBSTACLE) { lu.grid[x, y].Gem.Color = pu.GetRandomColor(); } lu.grid[x, y].Gem.Bonus = (int)ParamUnit.Bonus.ENERGY; } } else { switch (pu.permittedBonuses[bonusSelector.currentSelected - 2]) { case (int)ParamUnit.Bonus.COLORLESS: lu.grid[x, y].Gem.Color = 8; break; case (int)ParamUnit.Bonus.OBSTACLE: lu.grid[x, y].Gem.Color = 9; break; default: if (lu.grid[x, y].Gem.Bonus == (int)ParamUnit.Bonus.COLORLESS || lu.grid[x, y].Gem.Bonus == (int)ParamUnit.Bonus.OBSTACLE) { lu.grid[x, y].Gem.Color = pu.GetRandomColor(); } break; } if (lu.grid[x, y].Gem.Bonus != pu.permittedBonuses[bonusSelector.currentSelected - 2]) { wasBonused = true; lu.grid[x, y].Gem.Bonus = pu.permittedBonuses[bonusSelector.currentSelected - 2]; } } if (wasBonused) { EditorParams.isSaved = false; DestroyGem(x, y, lu.grid[x, y].Gem.Color); SpawnGem(x, y, lu.grid[x, y].Gem.Color, lu.grid[x, y].Gem.Bonus, 0); } } } } }