public IEnumerable <Territory> GetContinent(Territory territory) { var l = territory.Location; var neighborLocations = new[] { new Location(l.Row + 1, l.Column), new Location(l.Row, l.Column - 1), new Location(l.Row, l.Column + 1), new Location(l.Row - 1, l.Column), }; return(Territories.Where(t => neighborLocations.Contains(t.Location))); }
private static void Start_RandomiseRemainingTerritories() { Debug.Log("Start rand remaining"); var remaining = Territories.Where(x => x.Owner == null || x.Owner.Name == NotOwned.Name).ToList(); while (remaining.Count > 0) { foreach (var player in Players) { var terr = remaining.First(); remaining.RemoveAt(0); terr.SetOwner(player); } remaining = Territories.Where(x => x.Owner == null || x.Owner.Name == NotOwned.Name).ToList(); } }
private IEnumerable <PossibleAttack> WeightAttacks() { var weightedNeighbors = WeightNeighbors(); //build all possible attacks List <PossibleAttack> ret = Territories .Where(o => o.OwnerPlayerID == this.PlayerID) .SelectMany(us => this.Map.Territories[us.ID].ConnectedTo .Select(k => this.Standing.Territories[k]) .Where(k => k.OwnerPlayerID != TerritoryStanding.NeutralPlayerID && !this.IsTeammateOrUs(k.OwnerPlayerID)) .Select(k => new PossibleAttack(this, us.ID, k.ID))).ToList(); //foreach (PossibleAttack a in ret) //WeightAttack(a, weightedNeighbors); //NormalizeWeights(ret); return(ret); }