private void RemoveUnitFromPlayerQueue(PlayerQueue player, UnitModelScript unitToRemove) { for (int i = 0; i < player.UnitsQueue.Count; i++) { var u = player.UnitsQueue.Dequeue(); if (u != unitToRemove) { player.UnitsQueue.Enqueue(u); } } }
public void RemoveUnit(UnitModelScript unitToRemove) { if (_model.CurrentPlayerQueue != null && _model.CurrentPlayerQueue.UnitsQueue.Contains(unitToRemove)) { RemoveUnitFromPlayerQueue(_model.CurrentPlayerQueue, unitToRemove); } else { foreach (var playerQueue in _model.PlayersQueue) { RemoveUnitFromPlayerQueue(playerQueue, unitToRemove); } for (int i = 0; i < _model.PlayersQueue.Count; i++) { var p = _model.PlayersQueue.Dequeue(); if (p.Player.HasAliveUnits()) { _model.PlayersQueue.Enqueue(p); } } } }
public void SetCurrentUnit(UnitModelScript unit) { _model.CurrentUnit = unit; _model.PlayersQueue.Enqueue(_model.CurrentPlayerQueue); _model.CurrentPlayerQueue = _model.PlayersQueue.First(p => p.Player.Color == unit.Color); }