public MiniMapWindow(Route route, Region region)
        {
            InitializeComponent();
            Region = region;

            var waypoints = new List<Waypoint>();
            var connections = new List<Connection>();

            foreach (var conn in route.Path)
            {
                if (conn.Source.Region == region)
                    waypoints.Add(conn.Source);

                if (conn.Target.Region == region)
                    waypoints.Add(conn.Target);

                if (conn.Source.Region == region && conn.Target.Region == region)
                    connections.Add(conn);
            }

            Waypoints = new ReadOnlyObservableCollection<Waypoint>(new ObservableCollection<Waypoint>(waypoints));
            Connections = new ReadOnlyObservableCollection<Connection>(new ObservableCollection<Connection>(connections));

            DataContext = this;
        }
示例#2
0
        public Trade(Transportation transport, Route route, Load load, TradingPost source, TradingPost destination, List<Modifier> modifiers)
        {
            Destination = destination;
            Load = load;
            Route = route;
            Transport = transport;
            Modifiers = modifiers;

            BaseDuration = TimeSpan.FromSeconds(route.Duration.TotalSeconds / Transport.SpeedFactor);
            BaseCost = load.Slots.Sum(i => i.Key.Price * i.Value);
            BaseProfit = BaseGold = BaseMerchantRating = load.CalculateProfit(destination);
            BaseExperience = load.CalculateExperience(destination);

            Cost = BaseCost;
            Profit = (int)(BaseProfit * (1 + modifiers.Sum(m => m.ProfitBonus)));
            Gold = (int)(BaseGold * (1 + modifiers.Sum(m => m.GoldBonus)));
            MerchantRating = (int)(BaseMerchantRating * (1 + modifiers.Sum(m => m.MerchantRatingBonus)));
            Experience = (int)(BaseExperience * (1 + modifiers.Sum(m => m.ExpBonus)));
            Duration =
                TimeSpan.FromSeconds(route.Duration.TotalSeconds / (Transport.SpeedFactor + modifiers.Sum(m => m.SpeedBonus)));

            Gold = Math.Max(0, Gold);
            MerchantRating = Math.Max(0, MerchantRating);
            Experience = Math.Max(0, Experience);

            AddedCost = Cost - BaseCost;
            AddedProfit = Profit - BaseProfit;
            AddedGold = Gold - BaseGold;
            AddedMerchantRating = MerchantRating - BaseMerchantRating;
            AddedExperience = Experience - BaseExperience;
            AddedDuration = Duration - BaseDuration;

            ProfitPerSecond = Profit / Duration.TotalSeconds;

            if (source.NoProfits.Contains(destination.Id))
                Flags |= TradeFlags.NoProfit;

            if (route.Path.Select(w => w.Target.Region).Any(r => r.ChokePoint))
                Flags |= TradeFlags.ChokePoint;

            ModifierNames = string.Join(", ", Modifiers.Select(m => m.Name));
        }
 public ColoredRegion(Region region, Route route, Brush color)
 {
     Route = route;
     Color = color;
     Region = region;
 }