Exemplo n.º 1
0
        public WarParty SendWarParty(Faction natives)
        {
            natives.World.MakeAnnouncement(String.Format("War party from {0} has arrived!", natives.Name), null);
            natives.World.Tutorial("war");
            SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_negative_generic, 0.5f);
            Politics politics = GetPolitics(natives, natives.World.PlayerFaction);

            politics.WasAtWar = true;
            List <CreatureAI> creatures = natives.World.MonsterSpawner.Spawn(natives.World.MonsterSpawner.GenerateSpawnEvent(natives, natives.World.PlayerFaction, MathFunctions.Random.Next(5) + 1, true));
            var party = new WarParty(natives.World.Time.CurrentDate)
            {
                Creatures    = creatures,
                OtherFaction = natives.World.PlayerFaction,
                ShouldRemove = false,
                OwnerFaction = natives
            };

            natives.WarParties.Add(party);

            foreach (var creature in creatures)
            {
                if (natives.Economy == null)
                {
                    natives.Economy = new Economy(natives, (decimal)MathFunctions.Rand(1000, 9999), World, null);
                }
                if (natives.Economy.Company.Information == null)
                {
                    natives.Economy.Company.Information = new CompanyInformation();
                }

                creature.Physics.AddChild(new Flag(World.ComponentManager, Vector3.Up * 0.5f + Vector3.Backward * 0.25f, natives.Economy.Company.Information));
            }
            return(party);
        }
Exemplo n.º 2
0
 public static void RecallWarParty(WarParty party)
 {
     // TODO: do ths more naturally
     party.ExpiditionState = Expedition.State.Leaving;
     foreach (CreatureAI creature in party.Creatures)
     {
         creature.LeaveWorld();
     }
 }
Exemplo n.º 3
0
 public void RecallWarParty(WarParty party)
 {
     // TODO: do ths more naturally
     party.ShouldRemove = true;
     foreach (CreatureAI creature in party.Creatures)
     {
         creature.GetRootComponent().Delete();
     }
 }
Exemplo n.º 4
0
        public WarParty SendWarParty()
        {
            World.Tutorial("war");
            SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_negative_generic, 0.5f);
            Politics politics = World.Overworld.GetPolitics(ParentFaction, World.PlayerFaction.ParentFaction);

            politics.IsAtWar = true;
            List <CreatureAI> creatures = World.MonsterSpawner.Spawn(World.MonsterSpawner.GenerateSpawnEvent(this, World.PlayerFaction, MathFunctions.Random.Next(World.Overworld.Difficulty) + 1, false));
            var party = new WarParty(World.Time.CurrentDate)
            {
                Creatures    = creatures,
                OtherFaction = World.PlayerFaction,
                ShouldRemove = false,
                OwnerFaction = this
            };

            WarParties.Add(party);

            World.MakeAnnouncement(new Gui.Widgets.QueuedAnnouncement()
            {
                Text           = String.Format("A war party from {0} has arrived!", ParentFaction.Name),
                SecondsVisible = 60,
                ClickAction    = (gui, sender) =>
                {
                    if (party.Creatures.Count > 0)
                    {
                        party.Creatures.First().ZoomToMe();
                        World.UserInterface.MakeWorldPopup(String.Format("Warriors from {0} ({1}) have entered our territory. They will prepare for a while and then attack us.", ParentFaction.Name, Race.Name), party.Creatures.First().Physics, -10);
                    }
                },
                ShouldKeep = () =>
                {
                    return(party.ExpiditionState == Expedition.State.Arriving);
                }
            });

            SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_negative_generic, 0.15f);

            foreach (var creature in creatures)
            {
                if (Economy == null)
                {
                    Economy = new Company(this, (decimal)MathFunctions.Rand(1000, 9999), null);
                }

                if (Economy.Information == null)
                {
                    Economy.Information = new CompanyInformation();
                }

                creature.Physics.AddChild(new Flag(World.ComponentManager, Vector3.Up * 0.5f + Vector3.Backward * 0.25f, Economy.Information));
            }
            return(party);
        }
Exemplo n.º 5
0
        public WarParty SendWarParty()
        {
            World.Tutorial("war");
            SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_negative_generic, 0.5f);
            var politics = World.Overworld.GetPolitics(ParentFaction, World.PlayerFaction.ParentFaction);

            politics.IsAtWar = true;

            var creatures = World.MonsterSpawner.Spawn(World.MonsterSpawner.GenerateSpawnEvent(this, World.PlayerFaction, MathFunctions.Random.Next(World.Overworld.Difficulty.CombatModifier) + 1, false));

            var party = new WarParty(World.Time.CurrentDate)
            {
                Creatures    = creatures,
                OtherFaction = World.PlayerFaction,
                ShouldRemove = false,
                OwnerFaction = this
            };

            WarParties.Add(party);

            World.MakeAnnouncement(new Gui.Widgets.QueuedAnnouncement()
            {
                Text           = String.Format("A war party from {0} has arrived!", ParentFaction.Name),
                SecondsVisible = 60,
                ClickAction    = (gui, sender) =>
                {
                    if (party.Creatures.Count > 0)
                    {
                        party.Creatures.First().ZoomToMe();
                        World.UserInterface.MakeWorldPopup(String.Format("Warriors from {0} ({1}) have entered our territory. They will prepare for a while and then attack us.", ParentFaction.Name, (Race.HasValue(out var race) ? race.Name : "???")), party.Creatures.First().Physics, -10);
                    }
                },
                ShouldKeep = () =>
                {
                    return(party.ExpiditionState == Expedition.State.Arriving);
                }
            });
Exemplo n.º 6
0
        public void Update(DwarfTime time, DateTime currentDate, WorldManager world)
        {
            World = world;
#if UPTIME_TEST
            return;
#endif
            var timeSinceLastTrade = world.Time.CurrentDate - TimeOfLastTrade;
            foreach (var mypolitics in FactionPolitics)
            {
                Pair <string> pair = mypolitics.Key;
                if (!pair.IsSelfPair() && pair.Contains(world.PlayerFaction.Name))
                {
                    Faction otherFaction = null;

                    otherFaction = pair.First.Equals(world.PlayerFaction.Name) ? Factions.Factions[pair.Second] : Factions.Factions[pair.First];
                    UpdateTradeEnvoys(otherFaction);
                    UpdateWarParties(otherFaction);
                    Politics relation = mypolitics.Value;

                    bool needsNewTradeEnvoy = true;

                    if (CurrentTradeEnvoy != null)
                    {
                        needsNewTradeEnvoy = CurrentTradeEnvoy.Creatures.Count == 0 ||
                                             CurrentTradeEnvoy.Creatures.All(creature => creature.IsDead);
                    }

                    if (needsNewTradeEnvoy)
                    {
                        CurrentTradeEnvoy = null;
                    }

                    bool needsNewWarparty = true;

                    if (CurrentWarParty != null)
                    {
                        needsNewWarparty = CurrentWarParty.Creatures.Count == 0 ||
                                           CurrentWarParty.Creatures.All(creature => creature.IsDead);
                    }

                    if (needsNewWarparty)
                    {
                        CurrentWarParty = null;
                    }


                    if (needsNewTradeEnvoy && otherFaction.Race.IsIntelligent && !otherFaction.IsRaceFaction &&
                        relation.GetCurrentRelationship() != Relationship.Hateful)
                    {
                        if (otherFaction.TradeEnvoys.Count == 0)
                        {
                            relation.TradePartyTimer.Update(currentDate);

                            if (relation.TradePartyTimer.HasTriggered && timeSinceLastTrade.TotalDays > 1.0 && LastTradeEmpire != otherFaction.Name)
                            {
                                relation.TradePartyTimer.Reset(World.Time.CurrentDate);
                                CurrentTradeEnvoy = SendTradeEnvoy(otherFaction, world);
                                TimeOfLastTrade   = world.Time.CurrentDate;
                                LastTradeEmpire   = otherFaction.Name;
                            }
                        }
                        else if (otherFaction.TradeEnvoys.Count == 0)
                        {
                            relation.DispatchNewTradeEnvoy(world.Time.CurrentDate);
                        }
                    }
                    else if (needsNewWarparty &&
                             otherFaction.Race.IsIntelligent && !otherFaction.IsRaceFaction &&
                             relation.GetCurrentRelationship() == Relationship.Hateful)
                    {
                        if (otherFaction.WarParties.Count == 0 && !relation.WarPartyTimer.HasTriggered)
                        {
                            relation.WarPartyTimer.Update(currentDate);

                            if (relation.WarPartyTimer.HasTriggered)
                            {
                                CurrentWarParty = SendWarParty(otherFaction);
                            }
                        }
                        else if (otherFaction.WarParties.Count == 0)
                        {
                            relation.DispatchNewWarParty(world.Time.CurrentDate);
                        }
                    }
                }
                mypolitics.Value.UpdateEvents(currentDate);
            }
        }