private SimpleDrone() { Rats.AddPriorityTargets(); Rats.AddNPCs(); Rats.AddTargetingMe(); Rats.Ordering = new RatComparer(); }
/// <summary> /// Apply a move and update the map with the new state. /// </summary> /// <param name="source"></param> /// <param name="destination"></param> public void ApplyMove(Coordinates source, Coordinates destination) { Tile sourceTile = GetTileByCoordinates(source); Tile destinationTile = GetTileByCoordinates(destination); switch (destinationTile.Content) { case TileContent.Cheese: Cheese.RemoveAll(tile => tile.Position.Equals(destination)); // Removes the cheese eaten break; case TileContent.Rat: Rats.RemoveAll(tile => tile.Position.Equals(destination)); // Removes the rat captured break; } switch (sourceTile.Content) { case TileContent.Cat: Cats[Cats.FindIndex(tile => tile.Equals(sourceTile))] = destinationTile; // Change the cat position break; case TileContent.Rat: Rats[Rats.FindIndex(tile => tile.Position.Equals(sourceTile.Position))] = destinationTile; // Change the rat position break; } // Move the source's content to the destination's content destinationTile.Content = sourceTile.Content; sourceTile.Content = TileContent.Empty; if (Exits.Contains(destinationTile) && destinationTile.Content == TileContent.Rat) { // A rat reached the exit Rats.RemoveAll(tile => tile.Position.Equals(destination)); // Removes the escaped rat destinationTile.Content = TileContent.Empty; // Empty the tile } }
/// <summary> /// moze sie zdarzyc ze enemy zaatakuje, to jest wlasnie po to /// </summary> private void PossibleEnemy() { Random r = new Random(); int randomNum = r.Next(100); if (randomNum > 70) { Rats rats = new Rats("Brunatne szczury!", 2); rats.DoDamage(this.tavern); MessageBox.Show(rats.GetName() + " atakuja! Tracisz zywnosc!"); } else if (randomNum < 5) { Bandits bandits = new Bandits("Szkarłatna zgraja!"); bandits.DoDamage(this.tavern); MessageBox.Show(bandits.GetName() + " atakuja! Tracisz piwo i monety!!!"); } UpdateResources(); ListViewChanged(); }
public void Handover(ICall call, ISession session, IMobileTerminal mobileTerminal, IRat source) { if (call == null) { throw new VerticalHandoverPredictionException($"{nameof(call)} is invalid"); } if (session == null) { throw new VerticalHandoverPredictionException($"{nameof(session)} is invalid"); } if (mobileTerminal == null) { throw new VerticalHandoverPredictionException($"{nameof(mobileTerminal)} is invalid"); } if (source == null) { throw new VerticalHandoverPredictionException($"{nameof(source)} is invalid"); } var callsToHandedOverToTargetRat = session.ActiveCalls.Select(x => x.Service).ToList(); callsToHandedOverToTargetRat.Add(call.Service); var rats = Rats .Where(x => x.RatId != session.RatId && x.Services.ToHashSet().IsSupersetOf(callsToHandedOverToTargetRat)) .OrderBy(x => x.Services.Count()) .ToList(); var requiredNetworkResouces = 0; foreach (var service in callsToHandedOverToTargetRat) { requiredNetworkResouces += service.ComputeRequiredNetworkResources(); } foreach (var target in rats) { if (requiredNetworkResouces <= target.AvailableNetworkResources()) { UpdateHandovers(call.Service); source.RealeaseNetworkResources(requiredNetworkResouces - call.Service.ComputeRequiredNetworkResources()); source.RemoveSession(session); session.SetRatId(target.RatId); target.TakeNetworkResources(requiredNetworkResouces); session.AddToActiveCalls(call); var state = mobileTerminal.UpdateMobileTerminalState(session); session.AddToSessionSequence(state); target.AddSession(session); return; } } //If call cannot be handed over then the incoming call is blocked BlockedCalls++; }