private void Combo(GridScript g, ComboData c) { // Send blocks! if (players.Count > 1) { GenerateGarbage(g, c); } }
private void GenerateGarbage(GridScript g, ComboData c) { // Every action send garbages, but not always a lot of it. int width = 0; int count = 1; if (c.isChain == false) { // 3 blocs = 1x1 every 3 combos if (c.blockCount == 3 && c.multiplier % 3 == 0) { width = 1; count = 1; } // 4 blocs = 1x1 else if (c.blockCount == 4) { width = 1; count = 1; } // 5 blocks else if (c.blockCount == 5) { width = 3; count = 1; } // L-shaped block = wow else if (c.blockCount > 5) { width = 5; count = 1; } } else { width = players[0].grid.settings.width; } // Factors if (settings.garbagesType == GarbagesType.None) { return; } if (settings.garbagesType == GarbagesType.Low) { if (width == 5) { count = 2; } width = 1; } if (width > 0) { var si = g.player.index; var sender = players.First(p => p.player.index == si); if (sender.lastPlayerTarget < 0) { sender.lastPlayerTarget = sender.player.index; } sender.lastPlayerTarget++; if (sender.lastPlayerTarget >= players.Count) { sender.lastPlayerTarget = 0; } var alivePlayers = players.Where(p => p.player.GameOver == false).ToArray(); foreach (var p in alivePlayers) { int pi = p.player.index; if ( // Target the other player (alivePlayers.Length <= 2 && pi != si) || // Target rotation (pi >= sender.lastPlayerTarget && pi != si && p.player.GameOver == false)) { sender.lastPlayerTarget = pi; width = Mathf.Clamp(width, 1, settings.gridSettings.width); for (int i = 0; i < count; i++) { p.grid.AddGarbage(width, c.isChain, sender, c.comboLocation, c.definition.color); } break; } } } }