Beispiel #1
0
 public Pair(Pair <T> other) :
     this(other.First, other.Second)
 {
 }
Beispiel #2
0
 public bool Equals(Pair <T> other)
 {
     return((other.First.Equals(First) && other.Second.Equals(Second)) ||
            (other.First.Equals(Second) && other.Second.Equals(First)));
 }
Beispiel #3
0
        public void InitializeFactionPolitics(Faction New, DateTime Now)
        {
            TimeSpan forever = new TimeSpan(999999, 0, 0, 0);

            foreach (var faction in Factions.Factions)
            {
                Pair <string> pair = new Pair <string>(faction.Value.Name, New.Name);

                if (FactionPolitics.ContainsKey(pair))
                {
                    continue;
                }

                if (faction.Key == New.Name)
                {
                    FactionPolitics[pair] = new Politics(Now, new TimeSpan(0, 0, 0))
                    {
                        Faction      = faction.Value,
                        HasMet       = true,
                        RecentEvents = new List <PoliticalEvent>()
                        {
                            new PoliticalEvent()
                            {
                                Change      = 1.0f,
                                Description = "we are of the same faction",
                                Duration    = forever,
                                Time        = Now
                            }
                        }
                    };
                }
                else
                {
                    Point  c1   = faction.Value.Center;
                    Point  c2   = New.Center;
                    double dist = Math.Sqrt(Math.Pow(c1.X - c2.X, 2) + Math.Pow(c1.Y - c2.Y, 2));
                    // Time always takes between 1 and 4 days of travel.
                    double timeInMinutes = Math.Min(Math.Max(dist * 2.0f, 1440), 1440 * 4) + MathFunctions.RandInt(0, 250);

                    Politics politics = new Politics(Now, new TimeSpan(0, (int)(timeInMinutes), 0))
                    {
                        Faction      = New,
                        HasMet       = false,
                        RecentEvents = new List <PoliticalEvent>(),
                    };

                    if (faction.Value.Race == New.Race)
                    {
                        politics.RecentEvents.Add(new PoliticalEvent()
                        {
                            Change      = 0.5f,
                            Description = "we are of the same people",
                            Duration    = forever,
                            Time        = Now
                        });
                    }

                    if (faction.Value.Race.NaturalEnemies.Any(name => name == New.Race.Name))
                    {
                        if (!politics.HasEvent("we are taught to hate your kind"))
                        {
                            politics.RecentEvents.Add(new PoliticalEvent()
                            {
                                Change      = -10.0f, // Make this negative and we get an instant war party rush.
                                Description = "we are taught to hate your kind",
                                Duration    = forever,
                                Time        = Now
                            });
                        }
                    }

                    if (faction.Value.Race.IsIntelligent && New.Race.IsIntelligent)
                    {
                        float trustingness = faction.Value.GoodWill;

                        if (trustingness < -0.8f)
                        {
                            if (!politics.HasEvent("we just don't trust you"))
                            {
                                politics.RecentEvents.Add(new PoliticalEvent()
                                {
                                    Change      = -10.0f, // Make this negative and we get an instant war party rush.
                                    Description = "we just don't trust you",
                                    Duration    = forever,
                                    Time        = Now
                                });
                                politics.WasAtWar = true;
                            }
                            if (!politics.HasEvent("you stole our land"))
                            {
                                politics.RecentEvents.Add(new PoliticalEvent()
                                {
                                    Change      = -1.0f,
                                    Description = "you stole our land",
                                    Duration    = forever,
                                    Time        = Now
                                });
                            }
                        }
                        else if (trustingness > 0.8f)
                        {
                            if (!politics.HasEvent("we just trust you"))
                            {
                                politics.RecentEvents.Add(new PoliticalEvent()
                                {
                                    Change      = 10.0f,
                                    Description = "we just trust you",
                                    Duration    = forever,
                                    Time        = Now
                                });
                            }
                        }
                        else if (faction.Value.ClaimsColony && !faction.Value.IsMotherland)
                        {
                            if (!politics.HasEvent("you stole our land"))
                            {
                                politics.RecentEvents.Add(new PoliticalEvent()
                                {
                                    Change      = -0.1f,
                                    Description = "you stole our land",
                                    Duration    = forever,
                                    Time        = Now
                                });
                            }
                        }
                    }
                    FactionPolitics[pair] = politics;
                }
            }

            FactionPolitics[new Pair <string>("Undead", "Player")].RecentEvents.Add(new PoliticalEvent()
            {
                Change      = -10.0f,
                Description = "Test hate",
                Duration    = forever,
                Time        = Now
            });
        }