public bool IsContacted(Empire empire)
 {
     foreach (Contact contact in contacts)
     {
         if (contact.EmpireInContact == empire)
         {
             return contact.Contacted;
         }
     }
     return false;
 }
 public void EstablishContact(Empire empireContacted, SitRepManager sitRepManager)
 {
     foreach (Contact contact in contacts)
     {
         if (contact.EmpireInContact == empireContacted && !contact.Contacted)
         {
             //Need to add some fudge factor
             contact.RelationshipStatus = (int)(thisEmpire.EmpireRace.CharismaMultipler * empireContacted.EmpireRace.CharismaMultipler * 500);
             contact.Contacted = true;
             contact.OutgoingMessage = MessageType.NONE;
             contact.IncomingMessage = MessageType.NONE;
             sitRepManager.AddItem(new SitRepItem(Screen.Diplomacy, null, null, new Point(-1, -1), "You have established contact with " + empireContacted.EmpireName + " empire."));
             return;
         }
     }
 }
 public ContactManager(Empire currentEmpire, List<Empire> allEmpires)
 {
     thisEmpire = currentEmpire;
     contacts = new List<Contact>();
     /*foreach (Empire empire in allEmpires)
     {
         if (empire != currentEmpire)
         {
             Contact newContact = new Contact();
             newContact.EmpireInContact = empire;
             newContact.Contacted = true;
             newContact.RelationshipStatus = 100;
             newContact.OutgoingMessage = MessageType.NONE;
             newContact.IncomingMessage = MessageType.NONE;
             contacts.Add(newContact);
         }
     }*/
 }
        public async Task <AccountModel> GetActiveAccountAsync()
        {
            if (Storage.Exists(AccountFile))
            {
                var accounts = await LoadAccountsAsync();

                if (accounts != null)
                {
                    foreach (var a in accounts.AccountList)
                    {
                        //a.ActiveAccount = true;
                        if (a.ActiveAccount)
                        {
                            if (a.SessionRenewed < DateTime.Now.AddHours(-2))
                            {
                                var    oldAccount = a;
                                string json       = Empire.Login(1, a.EmpireName, a.Password);
                                var    s          = new Server();
                                var    response   = await s.GetHttpResultAsync(a.Server, Empire.url, json);

                                s                = null;
                                a.SessionID      = response.result.session_id;
                                a.SessionRenewed = DateTime.Now;
                                ModifyAccountAsync(a, oldAccount);
                            }
                            return(a);
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }

            return(null);
        }
Exemple #5
0
 public Seeker(Sector sector, Empire owner, ICombatant attacker, Component launcher, ICombatant target)
 {
     Sector = sector;
     Owner  = owner;
     if (launcher.Template.ComponentTemplate.WeaponInfo is SeekingWeaponInfo)
     {
         LaunchingComponent = launcher;
     }
     else
     {
         throw new Exception(launcher + " cannot launch seekers.");
     }
     Name = Owner.Name + " " + launcher.Name;
     if (WeaponInfo.Targets.HasFlag(target.WeaponTargetType))
     {
         Target = target;
     }
     else
     {
         throw new Exception(launcher + " cannot target a " + target.WeaponTargetType + ".");
     }
     Hitpoints   = WeaponInfo.SeekerDurability;           // TODO - can mounts affect seeker durability?
     CombatSpeed = WeaponInfo.SeekerSpeed;
 }
Exemple #6
0
    void DiscoverAlienEmpireOrBeDiscovered(Empire discoveredByEmpire, bool discoveredPlayer)
    {
        // TODO - record who discovered empire

        GameObject tempEmpireObject = Instantiate(GameManager.Instance.alienEmpire);
        Empire     discoveredEmpire;

        discoveredEmpire = tempEmpireObject.GetComponent <Empire>();
        if (discoveredPlayer)
        {
            discoveredEmpire.initiatedContactWithPlayer = true;
        }
        discoveredEmpire.discoveredBy      = discoveredByEmpire;
        discoveredEmpire.degreesFromPlayer = (discoveredByEmpire.degreesFromPlayer + 1);
        discoveredByEmpire.encounteredEmpires.Add(discoveredEmpire);
        GameManager.Instance.allEmpires.Add(discoveredEmpire);
        if (LogManager.Instance.logsEnabled)
        {
            if (LogManager.Instance.empireDiscovered)
            {
                Debug.Log($"An alien empire was discovered by {discoveredByEmpire.name} in {GameManager.Instance.spaceYear}.");
            }
        }
    }
Exemple #7
0
    protected override State Execute(QuestBehaviour questBehaviour, EventDiplomaticContractStateChange e, params object[] parameters)
    {
        Empire empireWhichInitiated = e.DiplomaticContract.EmpireWhichInitiated;
        Empire empireWhichReceives  = e.DiplomaticContract.EmpireWhichReceives;

        if (base.CheckAgainstQuestInitiatorFilter(questBehaviour, empireWhichInitiated, base.QuestInitiatorFilter) || (this.IsMutual && base.CheckAgainstQuestInitiatorFilter(questBehaviour, empireWhichReceives, base.QuestInitiatorFilter)))
        {
            if (this.State != QuestBehaviourTreeNode_Decorator_DiplomaticContract.QuestDiplomaticContractState.Any && !e.DiplomaticContract.State.ToString().Equals(this.State.ToString()))
            {
                return(Amplitude.Unity.AI.BehaviourTree.State.Running);
            }
            if (!string.IsNullOrEmpty(this.TargetEmpireVarName) || this.TargetEmpireIndex != -1)
            {
                if (this.TargetEmpireIndex == -1)
                {
                    MajorEmpire majorEmpire;
                    if (questBehaviour.TryGetQuestVariableValueByName <MajorEmpire>(this.TargetEmpireVarName, out majorEmpire) && ((!this.IsMutual && empireWhichReceives != majorEmpire) || (this.IsMutual && empireWhichReceives != majorEmpire && empireWhichInitiated != majorEmpire)))
                    {
                        return(Amplitude.Unity.AI.BehaviourTree.State.Running);
                    }
                }
                else if ((!this.IsMutual && empireWhichReceives.Index != this.TargetEmpireIndex) || (this.IsMutual && empireWhichReceives.Index != this.TargetEmpireIndex && empireWhichInitiated.Index != this.TargetEmpireIndex))
                {
                    return(Amplitude.Unity.AI.BehaviourTree.State.Running);
                }
            }
            for (int i = 0; i < e.DiplomaticContract.Terms.Count; i++)
            {
                if (e.DiplomaticContract.Terms[i].Definition.Name == this.DiplomaticTermDefinitionName)
                {
                    return(Amplitude.Unity.AI.BehaviourTree.State.Success);
                }
            }
        }
        return(Amplitude.Unity.AI.BehaviourTree.State.Running);
    }
Exemple #8
0
    /// <summary>
    /// Store the stats from its file
    /// </summary>
    public void StatInitializer(string cName)
    {
        CompName = cName;
        StreamReader read = new StreamReader(path + "Stats/" + CompName + "Stat.txt", true);

        Name = read.ReadLine();
        string emp = read.ReadLine();

        allegiance = (Empire)Enum.Parse(typeof(Empire), emp, true);
        string val = read.ReadLine();

        CharClass = (CharType)Enum.Parse(typeof(CharType), val, true);
        int.TryParse(read.ReadLine(), out attack);
        int.TryParse(read.ReadLine(), out defense);
        int.TryParse(read.ReadLine(), out hP);
        int.TryParse(read.ReadLine(), out magic);
        read.Close();
        string newPath = "Environment/Menu/Symbols/";

        symbol      = Resources.Load <GameObject>(newPath + allegiance.ToString().ToLower() + "Symbol");
        mat         = Resources.Load <Material>(newPath + "Particles/" + allegiance.ToString().ToLower() + "Material");
        bannerImage = (GameObject)Resources.Load("CharBanner/" + CompName + "Banner");
        CharIcon    = Resources.Load <Sprite>("CharacterIcons/Images/" + CompName.ToLower() + "Icon");
    }
Exemple #9
0
 protected int BuildInfrastructure(Empire empire)
 {
     return(0);
 }
Exemple #10
0
    public static float GetPriceWithSalesTaxes(StaticString boosterDefinitionName, TradableTransactionType transactionType, Empire empire, float quantity = 1f)
    {
        IDatabase <TradableCategoryDefinition> database = Databases.GetDatabase <TradableCategoryDefinition>(false);

        Diagnostics.Assert(database != null);
        StaticString key = "Tradable" + boosterDefinitionName;
        TradableCategoryDefinition tradableCategoryDefinition;

        if (database.TryGetValue(key, out tradableCategoryDefinition))
        {
            float num = Tradable.GetUnitPrice(tradableCategoryDefinition, 0f);
            if (ELCPUtilities.UseELCPStockpileRulseset && empire is MajorEmpire && empire.GetPropertyValue(SimulationProperties.MarketplaceStockpileCostMultiplier) > 0f)
            {
                num *= empire.GetPropertyValue(SimulationProperties.MarketplaceStockpileCostMultiplier);
            }
            return(Tradable.ApplySalesTaxes(num * quantity, transactionType, empire));
        }
        return(0f);
    }
Exemple #11
0
 public override bool IsObsoleteMemory(Empire emp)
 {
     return(Container.StarSystem.CheckVisibility(emp) >= Visibility.Visible && Timestamp < Galaxy.Current.Timestamp - 1);
 }
Exemple #12
0
        private void SetUpEmpiresAndStart()
        {
            SaveSettings();
            List <Race> selectedRaces = new List <Race>();

            foreach (Race race in _playerRaces)
            {
                if (race != null)
                {
                    selectedRaces.Add(race);
                }
            }
            while (_playerRaces[0] == null)
            {
                int random = _gameMain.Random.Next(_gameMain.RaceManager.Races.Count);
                if (!selectedRaces.Contains(_gameMain.RaceManager.Races[random]))
                {
                    _playerRaces[0] = _gameMain.RaceManager.Races[random];
                    selectedRaces.Add(_playerRaces[0]);
                }
            }
            //Galaxy already generated, move on to player setup
            _gameMain.DifficultyLevel = _difficultyComboBox.SelectedIndex;
            string     emperorName   = string.IsNullOrEmpty(_playerEmperorName.Text) ? _playerRaces[0].GetRandomEmperorName() : _playerEmperorName.Text;
            string     homeworldName = string.IsNullOrEmpty(_playerHomeworldName.Text) ? NameGenerator.GetName() : _playerHomeworldName.Text;
            Empire     empire        = new Empire(emperorName, 0, _playerRaces[0], PlayerType.HUMAN, _playerColors[0], _gameMain);
            Planet     homePlanet;
            StarSystem homeSystem = _gameMain.Galaxy.SetHomeworld(empire, out homePlanet);

            if (homeSystem == null)
            {
                _gameMain.EmpireManager.Reset();
                //No valid systems, start again
                SetUpGalaxy();
                return;
            }
            homeSystem.Name = homeworldName;
            empire.SetHomeSystem(homeSystem, homePlanet);
            empire.UpdateProduction();             //This sets up expenses and all that
            _gameMain.EmpireManager.AddEmpire(empire);

            for (int i = 0; i < _numericUpDownAI.Value; i++)
            {
                while (_playerRaces[i + 1] == null)
                {
                    int random = _gameMain.Random.Next(_gameMain.RaceManager.Races.Count);
                    if (!selectedRaces.Contains(_gameMain.RaceManager.Races[random]))
                    {
                        _playerRaces[i + 1] = _gameMain.RaceManager.Races[random];
                        selectedRaces.Add(_playerRaces[i + 1]);
                    }
                }
                empire = new Empire(_playerRaces[i + 1].GetRandomEmperorName(), i + 1, _playerRaces[i + 1], PlayerType.CPU, _playerColors[i + 1], _gameMain);
                //AI always have 50 initial population
                homeSystem = _gameMain.Galaxy.SetHomeworld(empire, out homePlanet);
                if (homeSystem == null)
                {
                    _gameMain.EmpireManager.Reset();
                    //No valid systems, start again
                    SetUpGalaxy();
                    return;
                }
                homeSystem.Name = NameGenerator.GetName();
                empire.SetHomeSystem(homeSystem, homePlanet);
                empire.UpdateProduction();                 //This sets up expenses and all that
                _gameMain.EmpireManager.AddEmpire(empire);
            }
            _gameMain.EmpireManager.SetupContacts();
            _gameMain.EmpireManager.SetInitialEmpireTurn();
            _generatingGalaxy = false;
            _gameMain.ChangeToScreen(Screen.Galaxy);
        }
 private void UpdateRelationship(Empire currentEmpire, Contact whichContact, int amount)
 {
 }
 public void MouseUp(int x, int y, int whichButton)
 {
     if (whichButton != 1)
     {
         return;
     }
     if (_exploredSystemsThisTurn.Count > 0)
     {
         _exploredSystemsThisTurn[_whichEmpireFocusedOn].RemoveAt(0);
         if (_exploredSystemsThisTurn[_whichEmpireFocusedOn].Count > 0)
         {
             _systemInfoWindow.LoadExploredSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0]);
             _systemView.LoadSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0], _whichEmpireFocusedOn);
             _camera.CenterCamera(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0].X, _exploredSystemsThisTurn[_whichEmpireFocusedOn][0].Y, 1);
         }
         else
         {
             _exploredSystemsThisTurn.Remove(_whichEmpireFocusedOn);
             if (_exploredSystemsThisTurn.Count > 0) //Hot seat humans
             {
                 foreach (var keyPair in _exploredSystemsThisTurn)
                 {
                     _whichEmpireFocusedOn = keyPair.Key;
                     break;
                 }
                 _systemInfoWindow.LoadExploredSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0]);
                 _systemView.LoadSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0], _whichEmpireFocusedOn);
                 _camera.CenterCamera(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0].X, _exploredSystemsThisTurn[_whichEmpireFocusedOn][0].Y, 1);
             }
             else
             {
                 _camera.CenterCamera(_camera.Width / 2, _camera.Height / 2, _camera.MaxZoom);
             }
         }
     }
     if (_colonizableFleetsThisTurn.Count > 0)
     {
         _colonizeScreen.MouseUp(x, y);
     }
     if (_newResearchTopicsNeeded.Count > 0)
     {
         _researchPrompt.MouseUp(x, y);
     }
 }
 private void HandleMessage(Contact contact, MessageType message, Empire whichEmpire)
 {
     switch (message)
     {
         case MessageType.ACCEPT_ALLIANCE:
             {
                 contact.Allied = true;
                 contact.ModifyRelationship(20);
             } break;
         case MessageType.ACCEPT_NONAGGRESSION:
             {
                 contact.NonAggression = true;
                 contact.ModifyRelationship(10);
             } break;
         case MessageType.ACCEPT_TRADE:
             {
                 contact.TradeTreaty = true;
                 contact.TradePercentage = -5;
                 contact.ModifyRelationship(5);
             } break;
         case MessageType.ACCEPT_RESEARCH:
             {
                 contact.ResearchTreaty = true;
                 contact.ResearchPercentage = -5;
                 contact.ModifyRelationship(5);
             } break;
         case MessageType.BREAK_ALLIANCE:
             {
                 contact.Allied = false;
                 contact.ModifyRelationship(-30);
             } break;
         case MessageType.BREAK_NONAGGRESSION:
             {
                 contact.NonAggression = false;
                 contact.ModifyRelationship(-20);
             } break;
         case MessageType.BREAK_RESEARCH:
             {
                 contact.ResearchTreaty = false;
                 contact.ResearchPercentage = 0;
                 contact.ModifyRelationship(-10);
             } break;
         case MessageType.BREAK_TRADE:
             {
                 contact.TradeTreaty = false;
                 contact.TradePercentage = 0;
                 contact.ModifyRelationship(-10);
             } break;
         case MessageType.DECLINE_REQUEST:
             {
                 contact.ModifyRelationship(-5);
             } break;
         case MessageType.WAR:
             {
                 contact.AtWar = true;
                 contact.ModifyRelationship(-75);
             } break;
         case MessageType.ACCEPT_PEACE:
             {
                 contact.AtWar = false;
                 contact.ModifyRelationship(15);
             } break;
         case MessageType.ACCEPT_RECONCILE:
             {
                 foreach (Contact whichContact in contact.EmpireInContact.ContactManager.Contacts)
                 {
                     if (whichContact.EmpireInContact == whichEmpire)
                     {
                         whichContact.ModifyRelationship(10);
                         return;
                     }
                 }
             } break;
         case MessageType.ACCEPT_HARASS:
             {
                 foreach (Contact whichContact in contact.EmpireInContact.ContactManager.Contacts)
                 {
                     if (whichContact.EmpireInContact == whichEmpire)
                     {
                         whichContact.ModifyRelationship(-15);
                         return;
                     }
                 }
             } break;
     }
 }
 private MessageType GetMessage(Empire forWhichEmpire, out Empire whichEmpireInRequest)
 {
     foreach (Contact contact in contacts)
     {
         if (contact.EmpireInContact == forWhichEmpire && contact.OutgoingMessage != MessageType.NONE)
         {
             whichEmpireInRequest = contact.OutgoingEmpireRequest;
             HandleMessage(contact, contact.OutgoingMessage, whichEmpireInRequest);
             MessageType message = contact.OutgoingMessage;
             //clear the outgoing message since it's now processed
             contact.OutgoingMessage = MessageType.NONE;
             contact.OutgoingEmpireRequest = null;
             return message;
         }
     }
     whichEmpireInRequest = null;
     return MessageType.NONE;
 }
        public void LoadEmpire(Empire empire, List<TechField> fields)
        {
            _currentEmpire = empire;
            _discoveredTechs.Clear();
            _fieldsNeedingNewTopics = new List<TechField>(fields);
            _availableTopics.Clear();

            foreach (var techField in _fieldsNeedingNewTopics)
            {
                switch (techField)
                {
                    case TechField.COMPUTER:
                    {
                        _availableTopics.Add(techField, new List<Technology>());
                        if (empire.TechnologyManager.WhichComputerBeingResearched != null)
                        {
                            _discoveredTechs.Add(empire.TechnologyManager.WhichComputerBeingResearched);
                            empire.TechnologyManager.WhichComputerBeingResearched = null;
                        }
                        if (empire.TechnologyManager.UnresearchedComputerTechs.Count == 0)
                        {
                            break;
                        }
                        //Now find the next tier of techs
                        int highestTech = 0;
                        foreach (var tech in empire.TechnologyManager.ResearchedComputerTechs)
                        {
                            if (tech.TechLevel > highestTech)
                            {
                                highestTech = tech.TechLevel;
                            }
                        }
                        highestTech = highestTech == 1 ? 5 : (((highestTech / 5) + (highestTech % 5 > 0 ? 2 : 1)) * 5);
                        foreach (var tech in empire.TechnologyManager.UnresearchedComputerTechs)
                        {
                            if (tech.TechLevel <= highestTech)
                            {
                                _availableTopics[techField].Add(tech);
                            }
                        }
                    } break;
                    case TechField.CONSTRUCTION:
                        {
                            _availableTopics.Add(techField, new List<Technology>());
                            if (empire.TechnologyManager.WhichConstructionBeingResearched != null)
                            {
                                _discoveredTechs.Add(empire.TechnologyManager.WhichConstructionBeingResearched);
                                empire.TechnologyManager.WhichConstructionBeingResearched = null;
                            }
                            if (empire.TechnologyManager.UnresearchedConstructionTechs.Count == 0)
                            {
                                break;
                            }
                            //Now find the next tier of techs
                            int highestTech = 0;
                            foreach (var tech in empire.TechnologyManager.ResearchedConstructionTechs)
                            {
                                if (tech.TechLevel > highestTech)
                                {
                                    highestTech = tech.TechLevel;
                                }
                            }
                            highestTech = highestTech == 1 ? 5 : (((highestTech / 5) + (highestTech % 5 > 0 ? 2 : 1)) * 5);
                            foreach (var tech in empire.TechnologyManager.UnresearchedConstructionTechs)
                            {
                                if (tech.TechLevel <= highestTech)
                                {
                                    _availableTopics[techField].Add(tech);
                                }
                            }
                        } break;
                    case TechField.FORCE_FIELD:
                        {
                            _availableTopics.Add(techField, new List<Technology>());
                            if (empire.TechnologyManager.WhichForceFieldBeingResearched != null)
                            {
                                _discoveredTechs.Add(empire.TechnologyManager.WhichForceFieldBeingResearched);
                                empire.TechnologyManager.WhichForceFieldBeingResearched = null;
                            }
                            if (empire.TechnologyManager.UnresearchedForceFieldTechs.Count == 0)
                            {
                                break;
                            }
                            //Now find the next tier of techs
                            int highestTech = 0;
                            foreach (var tech in empire.TechnologyManager.ResearchedForceFieldTechs)
                            {
                                if (tech.TechLevel > highestTech)
                                {
                                    highestTech = tech.TechLevel;
                                }
                            }
                            highestTech = highestTech == 1 ? 5 : (((highestTech / 5) + (highestTech % 5 > 0 ? 2 : 1)) * 5);
                            foreach (var tech in empire.TechnologyManager.UnresearchedForceFieldTechs)
                            {
                                if (tech.TechLevel <= highestTech)
                                {
                                    _availableTopics[techField].Add(tech);
                                }
                            }
                        } break;
                    case TechField.PLANETOLOGY:
                        {
                            _availableTopics.Add(techField, new List<Technology>());
                            if (empire.TechnologyManager.WhichPlanetologyBeingResearched != null)
                            {
                                _discoveredTechs.Add(empire.TechnologyManager.WhichPlanetologyBeingResearched);
                                empire.TechnologyManager.WhichPlanetologyBeingResearched = null;
                            }
                            if (empire.TechnologyManager.UnresearchedPlanetologyTechs.Count == 0)
                            {
                                break;
                            }
                            //Now find the next tier of techs
                            int highestTech = 0;
                            foreach (var tech in empire.TechnologyManager.ResearchedPlanetologyTechs)
                            {
                                if (tech.TechLevel > highestTech)
                                {
                                    highestTech = tech.TechLevel;
                                }
                            }
                            highestTech = highestTech == 1 ? 5 : (((highestTech / 5) + (highestTech % 5 > 0 ? 2 : 1)) * 5);
                            foreach (var tech in empire.TechnologyManager.UnresearchedPlanetologyTechs)
                            {
                                if (tech.TechLevel <= highestTech)
                                {
                                    _availableTopics[techField].Add(tech);
                                }
                            }
                        } break;
                    case TechField.PROPULSION:
                        {
                            _availableTopics.Add(techField, new List<Technology>());
                            if (empire.TechnologyManager.WhichPropulsionBeingResearched != null)
                            {
                                _discoveredTechs.Add(empire.TechnologyManager.WhichPropulsionBeingResearched);
                                empire.TechnologyManager.WhichPropulsionBeingResearched = null;
                            }
                            if (empire.TechnologyManager.UnresearchedPropulsionTechs.Count == 0)
                            {
                                break;
                            }
                            //Now find the next tier of techs
                            int highestTech = 0;
                            foreach (var tech in empire.TechnologyManager.ResearchedPropulsionTechs)
                            {
                                if (tech.TechLevel > highestTech)
                                {
                                    highestTech = tech.TechLevel;
                                }
                            }
                            highestTech = highestTech == 1 ? 5 : (((highestTech / 5) + (highestTech % 5 > 0 ? 2 : 1)) * 5);
                            foreach (var tech in empire.TechnologyManager.UnresearchedPropulsionTechs)
                            {
                                if (tech.TechLevel <= highestTech)
                                {
                                    _availableTopics[techField].Add(tech);
                                }
                            }
                        } break;
                    case TechField.WEAPON:
                        {
                            _availableTopics.Add(techField, new List<Technology>());
                            if (empire.TechnologyManager.WhichWeaponBeingResearched != null)
                            {
                                _discoveredTechs.Add(empire.TechnologyManager.WhichWeaponBeingResearched);
                                empire.TechnologyManager.WhichWeaponBeingResearched = null;
                            }
                            if (empire.TechnologyManager.UnresearchedWeaponTechs.Count == 0)
                            {
                                break;
                            }
                            //Now find the next tier of techs
                            int highestTech = 0;
                            foreach (var tech in empire.TechnologyManager.ResearchedWeaponTechs)
                            {
                                if (tech.TechLevel > highestTech)
                                {
                                    highestTech = tech.TechLevel;
                                }
                            }
                            highestTech = highestTech == 1 ? 5 : (((highestTech / 5) + (highestTech % 5 > 0 ? 2 : 1)) * 5);
                            foreach (var tech in empire.TechnologyManager.UnresearchedWeaponTechs)
                            {
                                if (tech.TechLevel <= highestTech)
                                {
                                    _availableTopics[techField].Add(tech);
                                }
                            }
                        } break;
                }
            }
            LoadNextTech();
        }
Exemple #18
0
 abstract public void RunBuildBehaviour(Empire empire, EmpireController empireController);
        private void OnColonizeComplete()
        {
            //Discard the current one, regardless of it colonized or not
            _colonizableFleetsThisTurn[_whichEmpireFocusedOn].RemoveAt(0);
            if (_colonizableFleetsThisTurn[_whichEmpireFocusedOn].Count > 0)
            {
                _colonizeScreen.LoadFleetAndSystem(_colonizableFleetsThisTurn[_whichEmpireFocusedOn][0]);
                _camera.CenterCamera(_colonizableFleetsThisTurn[_whichEmpireFocusedOn][0].AdjacentSystem.X, _colonizableFleetsThisTurn[_whichEmpireFocusedOn][0].AdjacentSystem.Y, 1);
            }
            else
            {
                _colonizableFleetsThisTurn.Remove(_whichEmpireFocusedOn);
                if (_colonizableFleetsThisTurn.Count > 0) //Hot seat humans
                {
                    foreach (var keyPair in _colonizableFleetsThisTurn)
                    {
                        _whichEmpireFocusedOn = keyPair.Key;
                        break;
                    }

                    _colonizeScreen.LoadFleetAndSystem(_colonizableFleetsThisTurn[_whichEmpireFocusedOn][0]);
                    _camera.CenterCamera(_colonizableFleetsThisTurn[_whichEmpireFocusedOn][0].AdjacentSystem.X, _colonizableFleetsThisTurn[_whichEmpireFocusedOn][0].AdjacentSystem.Y, 1);
                }
                else
                {
                    _camera.CenterCamera(_camera.Width / 2, _camera.Height / 2, _camera.MaxZoom);
                    _colonizeScreen.Completed = null;
                    _updateStep++;
                }
            }
        }
Exemple #20
0
    public void BuyShip(int i, Empire e)
    {
        InstantiateFleet fleet       = new InstantiateFleet();
        float            modifier    = 0;
        float            daysToBuild = fleet.getByID(i).daysToBuild;
        double           cost        = 0;

        if (fleet.getByID(i).name == "Cruiser")
        {
            if (e.hasAttribute(32))
            {
                return; // cannot build due to attribute 23 (Inferior Navy)
            }
        }

        if (fleet.getByID(i).name == "Warpship")
        {
            if (!e.getHomeworldPlanet().getConstruction(19))
            {
                return; // can't build due to not having a warp gate
            }
        }

        if (fleet.getByID(i).name == "Battlecruiser")
        {
            if (e.getHomeworldPlanet().getConstruction(3))
            {
                float mod2 = Construction.getConstruction(3).attrValue;

                modifier += mod2;
            }
        }

        if (e.hasAttribute(12))
        {
            float mod2 = Attributes.getAttribute(12).attrValue;
            modifier += mod2;
        }

        daysToBuild += (daysToBuild * modifier);
        modifier     = 0;

        Debug.Log(e.getActiveNavy());
        //if (e.getActiveNavy() >= fleet.getByID(i).maxCrew)
        //{
        e.changeDeployedNavy(fleet.getByID(i).maxCrew, false);

        cost = fleet.getByID(i).cost;

        if (e.hasAttribute(47))
        {
            float mod2 = Attributes.getAttribute(47).attrValue;
            modifier += mod2;
        }

        if (e.hasAttribute(32))
        {
            float mod2 = Attributes.getAttribute(32).attrValue;
            modifier += mod2;
        }

        cost += (cost * modifier);

        e.getPlayer().changeTreasury(-cost);

        e.underConstruction.Add(new UnderConstruction(fleet.getByID(i), shipNum, daysToBuild));
        shipNum++;
        //}
    }
 private void UpdateRelationship(Empire currentEmpire, Contact whichContact, int amount)
 {
 }
Exemple #22
0
 public string GetVictoryMessage(Empire emp)
 {
     return("The " + emp + " has, with the help of its allies, ushered in a new era of peace! All hail " + emp.LeaderName + ", master diplomat!");
 }
        public void Update(int x, int y, float frameDeltaTime)
        {
            if (_colonizableFleetsThisTurn.Count > 0)
            {
                _colonizeScreen.MouseHover(x, y, frameDeltaTime);
            }
            if (_newResearchTopicsNeeded.Count > 0)
            {
                _researchPrompt.MouseHover(x, y, frameDeltaTime);
            }
            switch (_updateStep)
            {
                case 0:
                    //Process AI's Turn here
                    //  TODO: AI checks for peace treaties, and plans accordingly
                    //  TODO: AI plan movement on basis of need to expand, to press attack, or to defend
                    //  TODO: AI designs any new ships, done randomly every 6-15 turns
                    //  TODO: AI plans production strategy and set their ratio bars
                    _updateStep++;
                    break;
                case 1:
                    _gameMain.EmpireManager.LaunchTransports();
                    //  TODO: Deduct cost for transports
                    //  TODO: Production is executed
                    _gameMain.EmpireManager.AccureIncome();
                    _gameMain.EmpireManager.UpdatePopulationGrowth();
                    _gameMain.EmpireManager.AccureResearch();
                    //  TODO: Trade growth occurs
                    //  TODO: New spies are added
                    _gameMain.EmpireManager.UpdateEmpires();
                    _updateStep++;
                    break;
                case 2:
                    //Diplomacy update:
                    //  TODO: Love nub move towards natural state if no treaty or war
                    //  TODO: Points added if there's trade, non-agg, or alliance
                    //  TODO: Points subtracted for military buildup, or owning more than 1/4 of map
                    //  TODO: Temp modifiers are adjusted toward 0 by 10 points each
                    _updateStep++;
                    break;
                case 3:
                    //  TODO: New missile bases/shields added here
                    _gameMain.EmpireManager.UpdateMilitary();
                    _updateStep++;
                    break;
                case 4:
                    //  TODO: Economic adjustments
                    //  TODO: Collect Tax and surplus industry spending and put into reserves
                    //  TODO: New factories are built
                    _updateStep++;
                    break;
                case 5:
                    if (!_gameMain.EmpireManager.UpdateFleetMovement(frameDeltaTime))
                    {
                        //Finished moving, merge fleets then move to next step
                        _gameMain.EmpireManager.MergeIdleFleets();
                        _updateStep++;
                    }
                    break;
                case 6:
                    // TODO: Space combat
                    _updateStep++;
                    break;
                case 7:
                    // TODO: Spies do stuff if not hiding
                    _updateStep++;
                    break;
                case 8:
                    if (_newResearchTopicsNeeded.Count == 0)
                    {
                        _newResearchTopicsNeeded = _gameMain.EmpireManager.RollForDiscoveries(_gameMain.Random);
                        if (_newResearchTopicsNeeded.Count > 0)
                        {
                            foreach (var keyPair in _newResearchTopicsNeeded)
                            {
                                //How else to get the first key?
                                _whichEmpireFocusedOn = keyPair.Key;
                                break;
                            }

                            _researchPrompt.LoadEmpire(_whichEmpireFocusedOn, _newResearchTopicsNeeded[_whichEmpireFocusedOn]);
                            _researchPrompt.Completed += OnResearchPromptComplete;
                        }
                    }
                    if (_newResearchTopicsNeeded.Count == 0)
                    {
                        _updateStep++;
                    }
                    // TODO: If computer player gets a new research item, it reevaluates its need to spy on other races here
                    break;
                case 9:
                    if (_exploredSystemsThisTurn.Count == 0)
                    {
                        _exploredSystemsThisTurn = _gameMain.EmpireManager.CheckExploredSystems(_gameMain.Galaxy);
                        if (_exploredSystemsThisTurn.Count > 0)
                        {
                            foreach (var keyPair in _exploredSystemsThisTurn)
                            {
                                //How else to get the first key?
                                _whichEmpireFocusedOn = keyPair.Key;
                                break;
                            }
                            _systemInfoWindow.LoadExploredSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0]);
                            _systemView.LoadSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0], _whichEmpireFocusedOn);
                            _camera.CenterCamera(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0].X, _exploredSystemsThisTurn[_whichEmpireFocusedOn][0].Y, 1);
                        }
                    }
                    // Results of planetary exploration are shown
                    if (_exploredSystemsThisTurn.Count == 0)
                    {
                        //Either no explored systems or finished displaying all explored systems
                        _updateStep++;
                    }
                    break;
                case 10:
                    if (_colonizableFleetsThisTurn.Count == 0)
                    {
                        _colonizableFleetsThisTurn = _gameMain.EmpireManager.CheckColonizableSystems(_gameMain.Galaxy);
                        if (_colonizableFleetsThisTurn.Count > 0)
                        {
                            foreach (var keyPair in _colonizableFleetsThisTurn)
                            {
                                _whichEmpireFocusedOn = keyPair.Key;
                                break;
                            }
                            _colonizeScreen.LoadFleetAndSystem(_colonizableFleetsThisTurn[_whichEmpireFocusedOn][0]);
                            _colonizeScreen.Completed += OnColonizeComplete;
                            _camera.CenterCamera(_colonizableFleetsThisTurn[_whichEmpireFocusedOn][0].AdjacentSystem.X, _colonizableFleetsThisTurn[_whichEmpireFocusedOn][0].AdjacentSystem.Y, 1);
                        }
                    }
                    if (_colonizableFleetsThisTurn.Count == 0)
                    {
                        _updateStep++;
                    }
                    break;
                case 11:
                    // TODO: resolve combat
                    _gameMain.EmpireManager.LandTransports();
                    // TODO: Orbital bombardments
                    // TODO: Transports land and ground combat is resolved
                    _updateStep++;
                    break;
                case 12:
                    // TODO: BNN checks for genocide, and if only one player remains, it is hailed as winner of game
                    _updateStep++;
                    break;
                case 13:
                    // TODO: Random events
                    // Add 2% to cumulative probability chance, multipled by game difficulty modifier, rolls d100 die to see if an event occurs
                    // If event occurs, randomly select from those that haven't occured yet, and reset probability to 0.  Target player determined and event takes effect
                    _updateStep++;
                    break;
                case 14:
                    // TODO: First contacts, if either race is not in contact, but overlaps one of two's colonies with their fuel range, establish contact
                    _updateStep++;
                    break;
                case 15:
                    //  TODO: All computer-initiated diplomacy initiated
                    //  TODO: High council convences if criterias are met.
                    //  TODO: Messages from computer players are delivered to human player
                    //  TODO: If contact is broken, notification occurs
                    _updateStep++;
                    break;
                case 16:
                    //  TODO: Planetary production/completion messages are displayed (i.e. shield built).  Slider bars can be adjusted
                    //  TODO: Production numbers for next turn are calculated
                    _updateStep++;
                    break;
                case 17:
                    //  TODO: Any star systems within advanced space scanner range of colonies/ships is updated
                    //  TODO: Turn advances by 1
                    //  TODO: Recalculate players' current technology levels
                    //  TODO: Autosave game
                    _updateStep = 0;
                    _gameMain.EmpireManager.ClearEmptyFleets();
                    _gameMain.EmpireManager.SetInitialEmpireTurn();
                    _gameMain.ChangeToScreen(Screen.Galaxy);
                    break;
            }
        }
        private void HandleMessage(Contact contact, MessageType message, Empire whichEmpire)
        {
            switch (message)
            {
            case MessageType.ACCEPT_ALLIANCE:
            {
                contact.Allied = true;
                contact.ModifyRelationship(20);
            } break;

            case MessageType.ACCEPT_NONAGGRESSION:
            {
                contact.NonAggression = true;
                contact.ModifyRelationship(10);
            } break;

            case MessageType.ACCEPT_TRADE:
            {
                contact.TradeTreaty     = true;
                contact.TradePercentage = -5;
                contact.ModifyRelationship(5);
            } break;

            case MessageType.ACCEPT_RESEARCH:
            {
                contact.ResearchTreaty     = true;
                contact.ResearchPercentage = -5;
                contact.ModifyRelationship(5);
            } break;

            case MessageType.BREAK_ALLIANCE:
            {
                contact.Allied = false;
                contact.ModifyRelationship(-30);
            } break;

            case MessageType.BREAK_NONAGGRESSION:
            {
                contact.NonAggression = false;
                contact.ModifyRelationship(-20);
            } break;

            case MessageType.BREAK_RESEARCH:
            {
                contact.ResearchTreaty     = false;
                contact.ResearchPercentage = 0;
                contact.ModifyRelationship(-10);
            } break;

            case MessageType.BREAK_TRADE:
            {
                contact.TradeTreaty     = false;
                contact.TradePercentage = 0;
                contact.ModifyRelationship(-10);
            } break;

            case MessageType.DECLINE_REQUEST:
            {
                contact.ModifyRelationship(-5);
            } break;

            case MessageType.WAR:
            {
                contact.AtWar = true;
                contact.ModifyRelationship(-75);
            } break;

            case MessageType.ACCEPT_PEACE:
            {
                contact.AtWar = false;
                contact.ModifyRelationship(15);
            } break;

            case MessageType.ACCEPT_RECONCILE:
            {
                foreach (Contact whichContact in contact.EmpireInContact.ContactManager.Contacts)
                {
                    if (whichContact.EmpireInContact == whichEmpire)
                    {
                        whichContact.ModifyRelationship(10);
                        return;
                    }
                }
            } break;

            case MessageType.ACCEPT_HARASS:
            {
                foreach (Contact whichContact in contact.EmpireInContact.ContactManager.Contacts)
                {
                    if (whichContact.EmpireInContact == whichEmpire)
                    {
                        whichContact.ModifyRelationship(-15);
                        return;
                    }
                }
            } break;
            }
        }
Exemple #25
0
        private void SetUpEmpiresAndStart()
        {
            SaveSettings();
            List<Race> selectedRaces = new List<Race>();
            foreach (Race race in _playerRaces)
            {
                if (race != null)
                {
                    selectedRaces.Add(race);
                }
            }
            while (_playerRaces[0] == null)
            {
                int random = _gameMain.Random.Next(_gameMain.RaceManager.Races.Count);
                if (!selectedRaces.Contains(_gameMain.RaceManager.Races[random]))
                {
                    _playerRaces[0] = _gameMain.RaceManager.Races[random];
                    selectedRaces.Add(_playerRaces[0]);
                }
            }
            //Galaxy already generated, move on to player setup
            _gameMain.DifficultyLevel = _difficultyComboBox.SelectedIndex;
            string emperorName = string.IsNullOrEmpty(_playerEmperorName.Text) ? _playerRaces[0].GetRandomEmperorName() : _playerEmperorName.Text;
            string homeworldName = string.IsNullOrEmpty(_playerHomeworldName.Text) ? NameGenerator.GetName() : _playerHomeworldName.Text;
            Empire empire = new Empire(emperorName, 0, _playerRaces[0], PlayerType.HUMAN, _playerColors[0], _gameMain);
            Planet homePlanet;
            StarSystem homeSystem = _gameMain.Galaxy.SetHomeworld(empire, out homePlanet);
            if (homeSystem == null)
            {
                _gameMain.EmpireManager.Reset();
                //No valid systems, start again
                SetUpGalaxy();
                return;
            }
            homeSystem.Name = homeworldName;
            empire.SetHomeSystem(homeSystem, homePlanet);
            empire.UpdateProduction(); //This sets up expenses and all that
            _gameMain.EmpireManager.AddEmpire(empire);

            for (int i = 0; i < _numericUpDownAI.Value; i++)
            {
                while (_playerRaces[i + 1] == null)
                {
                    int random = _gameMain.Random.Next(_gameMain.RaceManager.Races.Count);
                    if (!selectedRaces.Contains(_gameMain.RaceManager.Races[random]))
                    {
                        _playerRaces[i + 1] = _gameMain.RaceManager.Races[random];
                        selectedRaces.Add(_playerRaces[i + 1]);
                    }
                }
                empire = new Empire(_playerRaces[i + 1].GetRandomEmperorName(), i + 1, _playerRaces[i + 1], PlayerType.CPU, _playerColors[i + 1], _gameMain);
                //AI always have 50 initial population
                homeSystem = _gameMain.Galaxy.SetHomeworld(empire, out homePlanet);
                if (homeSystem == null)
                {
                    _gameMain.EmpireManager.Reset();
                    //No valid systems, start again
                    SetUpGalaxy();
                    return;
                }
                homeSystem.Name = NameGenerator.GetName();
                empire.SetHomeSystem(homeSystem, homePlanet);
                empire.UpdateProduction(); //This sets up expenses and all that
                _gameMain.EmpireManager.AddEmpire(empire);
            }
            _gameMain.EmpireManager.SetupContacts();
            _gameMain.EmpireManager.SetInitialEmpireTurn();
            _generatingGalaxy = false;
            _gameMain.ChangeToScreen(Screen.Galaxy);
        }
Exemple #26
0
        public void LoadSystem(StarSystem system, Empire currentEmpire)
        {
            _currentSystem = system;
            _currentEmpire = currentEmpire;
            if (_currentSystem.IsThisSystemExploredByEmpire(_currentEmpire))
            {
                _isExplored = true;
                var planet = _currentSystem.Planets[0];
                _name.SetText(_currentSystem.Name);
                _isOwnedSystem = _currentSystem.Planets[0].Owner == _currentEmpire;
                _name.SetTextAttributes(_currentSystem.Planets[0].Owner != null ? _currentSystem.Planets[0].Owner.EmpireColor : System.Drawing.Color.White, System.Drawing.Color.Empty);
                _popLabel.SetText(planet.Owner != null ? string.Format("{0:0.0}/{1:0} B", planet.TotalPopulation, planet.TotalMaxPopulation - planet.Waste) : string.Format("{0:0} B", planet.TotalMaxPopulation - planet.Waste));
                _terrainLabel.SetText(Utility.PlanetTypeToString(_currentSystem.Planets[0].PlanetType));
                if (_isOwnedSystem)
                {
                    _name.SetReadOnly(false);
                    _productionLabel.SetText(string.Format("{0:0.0} ({1:0.0}) Industry", _currentSystem.Planets[0].ActualProduction, _currentSystem.Planets[0].TotalProduction));
                    _infrastructureLabel.SetText(_currentSystem.Planets[0].InfrastructureStringOutput);
                    _researchLabel.SetText(_currentSystem.Planets[0].ResearchStringOutput);
                    _environmentLabel.SetText(_currentSystem.Planets[0].EnvironmentStringOutput);
                    _defenseLabel.SetText(_currentSystem.Planets[0].DefenseStringOutput);
                    _constructionLabel.SetText(_currentSystem.Planets[0].ConstructionStringOutput);
                    _infrastructureSlider.TopIndex = planet.InfrastructureAmount;
                    _researchSlider.TopIndex = planet.ResearchAmount;
                    _environmentSlider.TopIndex = planet.EnvironmentAmount;
                    _defenseSlider.TopIndex = planet.DefenseAmount;
                    _constructionSlider.TopIndex = planet.ConstructionAmount;

                    _infrastructureLockButton.Selected = planet.InfrastructureLocked;
                    _infrastructureSlider.SetEnabledState(!planet.InfrastructureLocked);
                    _researchLockButton.Selected = planet.ResearchLocked;
                    _researchSlider.SetEnabledState(!planet.ResearchLocked);
                    _environmentLockButton.Selected = planet.EnvironmentLocked;
                    _environmentSlider.SetEnabledState(!planet.EnvironmentLocked);
                    _defenseLockButton.Selected = planet.DefenseLocked;
                    _defenseSlider.SetEnabledState(!planet.DefenseLocked);
                    _constructionLockButton.Selected = planet.ConstructionLocked;
                    _constructionSlider.SetEnabledState(!planet.ConstructionLocked);

                    if (_currentSystem.Planets[0].TransferSystem.Key.StarSystem != null)
                    {
                        _transferLabel.SetText("Moving " + _currentSystem.Planets[0].TransferSystem.Value + " Pop");
                        _transferLabel.MoveTo(_xPos + 10, _yPos + 440);
                    }
                    else
                    {
                        _transferLabel.SetText(string.Empty);
                    }
                }
                else if (_currentSystem.Planets[0].Owner != null)
                {
                    _generalPurposeText.SetText("Colonized by " + _currentSystem.Planets[0].Owner.EmpireRace.RaceName + " Empire");
                    _name.SetReadOnly(true);
                }
                else
                {
                    _generalPurposeText.SetText("No colony");
                    _name.SetReadOnly(true);
                }
            }
            else
            {
                _isExplored = false;
                _name.SetText("Unexplored");
                _name.SetTextAttributes(System.Drawing.Color.White, System.Drawing.Color.Empty);
                _generalPurposeText.SetText(_currentSystem.Description);
                _popLabel.SetText(string.Empty);
                _terrainLabel.SetText(string.Empty);
                _productionLabel.SetText(string.Empty);
                _infrastructureLabel.SetText(string.Empty);
                _researchLabel.SetText(string.Empty);
                _environmentLabel.SetText(string.Empty);
                _defenseLabel.SetText(string.Empty);
                _constructionLabel.SetText(string.Empty);
                _name.SetReadOnly(true);
            }
        }
Exemple #27
0
 public bool IsObsoleteMemory(Empire emp)
 {
     return(false);
 }
Exemple #28
0
 public override bool TryGetReferenceName(Empire empire, out string referenceName)
 {
     referenceName = this.BoosterDefinitionName;
     return(true);
 }
Exemple #29
0
 /// <summary>
 /// Orders are visible only to their owners.
 /// </summary>
 /// <param name="emp"></param>
 /// <returns></returns>
 public Visibility CheckVisibility(Empire emp)
 {
     if (emp == Owner)
         return Visibility.Visible;
     return Visibility.Unknown;
 }
 public override void Bind(Empire empire)
 {
     base.Bind(empire);
     this.unitInfoPanel.Bind(this, empire);
 }
        private void OnResearchPromptComplete()
        {
            _newResearchTopicsNeeded.Remove(_whichEmpireFocusedOn);
            if (_newResearchTopicsNeeded.Count > 0)
            {
                foreach (var keyPair in _newResearchTopicsNeeded)
                {
                    _whichEmpireFocusedOn = keyPair.Key;
                    break;
                }

                _researchPrompt.LoadEmpire(_whichEmpireFocusedOn, _newResearchTopicsNeeded[_whichEmpireFocusedOn]);
            }
            else
            {
                _researchPrompt.Completed = null;
                _updateStep++;
            }
        }
Exemple #32
0
 /// <summary>
 /// Mod objects are fully known to everyone.
 /// </summary>
 /// <param name="emp"></param>
 /// <returns></returns>
 public Visibility CheckVisibility(Empire emp)
 {
     return(Visibility.Scanned);
 }
Exemple #33
0
        private void BindEmpire(Empire emp, TabPage tab = null)
        {
            empire = emp;
            if (tab != null)
            {
                tabs.SelectedTab = tab;
            }
            else if (emp == Empire.Current && tabs.SelectedTab == tabDiplomacy)
            {
                tabs.SelectedTab = tabBudget;
            }
            else if (emp != Empire.Current && tabs.SelectedTab == tabBudget)
            {
                tabs.SelectedTab = tabDiplomacy;
            }

            report.Empire = emp;

            if (emp == null)
            {
                txtTreaty.Text      = "N/A";
                txtTreaty.ForeColor = Color.White;
                toolTip.SetToolTip(txtTreaty, "Select an empire to view its treaty status.");
            }
            else
            {
                if (emp == Empire.Current)
                {
                    txtTreaty.Text      = "Self";
                    txtTreaty.ForeColor = Color.CornflowerBlue;
                    toolTip.SetToolTip(txtTreaty, "You can't have a treaty with your own empire. Nice try, though...");
                }
                else
                {
                    var treaty         = Empire.Current.GetTreaty(emp);
                    var giving         = treaty.Where(c => c.Giver == Empire.Current);
                    var receiving      = treaty.Where(c => c.Receiver == Empire.Current);
                    var givingTexts    = giving.Select(c => c.ToString());
                    var receivingTexts = receiving.Select(c => c.ToString());
                    var helptext       = "";
                    if (!treaty.Any())
                    {
                        txtTreaty.Text      = "None";
                        txtTreaty.ForeColor = Color.Yellow;
                        helptext            = "You don't have any treaty with this empire.";
                    }
                    else if (!giving.Any())
                    {
                        txtTreaty.Text      = "Receiving " + string.Join(", ", receivingTexts.ToArray());
                        txtTreaty.ForeColor = Color.Green;
                        helptext            = string.Join("\n", receiving.Select(x => x.FullDescription));
                    }
                    else if (!receiving.Any())
                    {
                        txtTreaty.Text      = "Giving " + string.Join(", ", givingTexts.ToArray());
                        txtTreaty.ForeColor = Color.LightGray;
                        helptext            = string.Join("\n", giving.Select(x => x.FullDescription));
                    }
                    else
                    {
                        var mutualTexts        = givingTexts.Join(receivingTexts, s => s, s => s, (g, r) => g);
                        var givingOnlyTexts    = givingTexts.Except(mutualTexts);
                        var receivingOnlyTexts = receivingTexts.Except(mutualTexts);
                        if (givingOnlyTexts.Any() && receivingTexts.Any())
                        {
                            txtTreaty.Text = "Trading " + string.Join(", ", givingOnlyTexts.ToArray()) + " for " + string.Join(", ", receivingOnlyTexts.ToArray());
                        }
                        else if (givingOnlyTexts.Any())
                        {
                            txtTreaty.Text = "Giving " + string.Join(", ", givingOnlyTexts.ToArray());
                        }
                        else if (receivingOnlyTexts.Any())
                        {
                            txtTreaty.Text = "Receiving " + string.Join(", ", receivingOnlyTexts.ToArray());
                        }
                        if (mutualTexts.Any())
                        {
                            if (givingOnlyTexts.Any() || receivingOnlyTexts.Any())
                            {
                                txtTreaty.Text = "Mutual " + string.Join(", ", mutualTexts.ToArray()) + "; " + txtTreaty.Text;
                            }
                            else
                            {
                                txtTreaty.Text = "Mutual " + string.Join(", ", mutualTexts.ToArray());
                            }
                        }
                        txtTreaty.ForeColor = Color.White;

                        helptext = string.Join("\n", giving.Union(receiving).Select(x => x.FullDescription));
                    }
                    toolTip.SetToolTip(txtTreaty, helptext);
                }

                // budget
                if (emp == Empire.Current)
                {
                    rqdConstruction.ResourceQuantity = emp.ConstructionSpending;
                }
                else
                {
                    // assume other empires' construction queues are running at full capacity
                    rqdConstruction.ResourceQuantity = emp.ConstructionQueues.Sum(rq => rq.Rate);
                }
                rqdExtraction.ResourceQuantity  = emp.ColonyIncome + emp.RemoteMiningIncome + emp.RawResourceIncome;
                rqdIncome.ResourceQuantity      = emp.GrossDomesticIncome;
                rqdMaintenance.ResourceQuantity = emp.Maintenance;
                rqdNet.ResourceQuantity         = emp.NetIncomeLessConstruction;
                rqdStorage.ResourceQuantity     = emp.ResourceStorage;
                var spoilageOrDeficit = new ResourceQuantity();
                var newResources      = emp.StoredResources + emp.NetIncomeLessConstruction;
                foreach (var r in Resource.All)
                {
                    if (newResources[r] > emp.ResourceStorage[r])
                    {
                        spoilageOrDeficit[r] = newResources[r] - emp.ResourceStorage[r];
                    }
                    else if (newResources[r] < 0)
                    {
                        spoilageOrDeficit[r] = newResources[r];
                    }
                    else
                    {
                        spoilageOrDeficit[r] = 0;
                    }
                }
                rqdSpoiledDeficit.ResourceQuantity = spoilageOrDeficit;
                rqdStored.ResourceQuantity         = emp.StoredResources;
                rqdTrade.ResourceQuantity          = emp.TradeIncome;
                rqdTributesIn.ResourceQuantity     = new ResourceQuantity();             // TODO - show tributes
                rqdTributesOut.ResourceQuantity    = new ResourceQuantity();             // TODO - show tributes
                rqExpenses.ResourceQuantity        = rqdConstruction.ResourceQuantity + rqdMaintenance.ResourceQuantity + rqdTributesOut.ResourceQuantity;
                lblBudgetWarning.Visible           = emp != Empire.Current;

                // message log
                var msgs = Empire.Current.IncomingMessages.Where(m => m.Owner == emp).Union(Empire.Current.SentMessages.Where(m => m.Recipient == emp)).Union(Empire.Current.Commands.OfType <SendMessageCommand>().Select(cmd => cmd.Message));
                lstMessages.Initialize(64, 64);
                foreach (var msg in msgs.OrderByDescending(m => m.TurnNumber))
                {
                    lstMessages.AddItemWithImage(msg.TurnNumber.ToStardate(), "", msg, msg.Owner.Portrait, null, msg.Owner == Empire.Current ? "Us" : msg.Owner.Name, msg.Recipient == Empire.Current ? "Us" : msg.Recipient.Name, msg.Text);
                }

                // player info
                txtName.Text    = emp.PlayerInfo?.Name;
                lnkPbw.Text     = emp.PlayerInfo?.Pbw;
                lnkEmail.Text   = emp.PlayerInfo?.Email;
                txtIrc.Text     = emp.PlayerInfo?.Irc;
                txtDiscord.Text = emp.PlayerInfo?.Discord;
                lnkWebsite.Text = emp.PlayerInfo?.Website;
                txtNotes.Text   = emp.PlayerInfo?.Notes;
            }
        }
Exemple #34
0
 public void Redact(Empire emp)
 {
     // TODO - tech items that aren't visible until some requirements are met
 }
Exemple #35
0
 /// <summary>
 /// Stellar objects don't typically have owners, so they can't usually be hostile.
 /// </summary>
 /// <param name="emp"></param>
 /// <returns></returns>
 public virtual bool IsHostileTo(Empire emp)
 {
     return(false);
 }
Exemple #36
0
 public static void SaveXML(Empire empire, string empireName)
 {
     XMLUtility.SaveUserXML <Empire>(Path.Combine(XMLUtility.userGalaxyXMLPath, empireName), empire);
 }
Exemple #37
0
    private bool IsSafe(Empire armyEmpire, WorldPosition position)
    {
        Region region = this.worldPositionService.GetRegion(position);

        return(!region.IsOcean && (region.City == null || region.City.Empire == armyEmpire));
    }
Exemple #38
0
    private void RouteDefensiveArmy(Army army, List <SolarSystem> enemyBorderSystems, List <Army> defensiveArmies, Empire empire)
    {
        // order by distance to this army

        List <SolarSystem> options;

        if (enemyBorderSystems.Count == 0)
        {
            options = empire.GetSystems().OrderBy(x => Vector2.Distance(army.transform.position, x.transform.position)).ToList();
        }
        else
        {
            options = enemyBorderSystems.OrderBy(x => Vector2.Distance(army.transform.position, x.transform.position)).ToList();
        }

        // Try to find closest border system with no defensive army in route
        foreach (SolarSystem system in options)
        {
            if (!defensiveArmies.Find(x => x != army && x.GetComponent <MovementController>().GetSystemTarget() == system))
            {
                army.MoveTo(system);
                return;
            }
        }

        // No Unoccupied systems to go to in list to move to closest
        army.MoveTo(options[0]);
        return;
    }
 public string GetDefeatMessage(Empire emp, IEnumerable <Empire> winners)
 {
     return("The " + emp + " is defeated! " + winners.Single() + " has conquered the galaxy!");
 }
 public SimulatedEmpire(Empire emp)
 {
     Empire       = emp.CopyAndAssignNewID();
     SpaceObjects = new HashSet <SimulatedSpaceObject>();
     Troops       = new HashSet <SimulatedUnit>();
 }
 public string GetVictoryMessage(Empire emp)
 {
     return("The " + emp + " has eliminated all other major empires and conquered the galaxy! All hail " + emp.LeaderName + ", ruler of the cosmos!");
 }
Exemple #42
0
    public override bool Check(IDiplomaticContract diplomaticContract, Empire empireWhichProvides, Empire empireWhichReceives)
    {
        Diagnostics.Assert(this.Prerequisites != null && this.Prerequisites.Length != 0);
        int num = 0;

        for (int i = 0; i < this.Prerequisites.Length; i++)
        {
            if (this.Prerequisites[i].Check(diplomaticContract, empireWhichProvides, empireWhichReceives))
            {
                num++;
            }
        }
        bool flag;

        switch (this.Operator)
        {
        case DiplomaticMetaPrerequisite.OperatorType.OR:
            flag = (num > 0);
            break;

        case DiplomaticMetaPrerequisite.OperatorType.XOR:
            flag = (num == 1);
            break;

        case DiplomaticMetaPrerequisite.OperatorType.NOR:
            flag = (num == 0);
            break;

        case DiplomaticMetaPrerequisite.OperatorType.AND:
            flag = (num == this.Prerequisites.Length);
            break;

        case DiplomaticMetaPrerequisite.OperatorType.NAND:
            flag = (num < this.Prerequisites.Length);
            break;

        default:
            throw new ArgumentOutOfRangeException("Operator");
        }
        return(base.Inverted ^ flag);
    }
Exemple #43
0
 public string GetDefeatMessage(Empire emp, IEnumerable <Empire> winners)
 {
     return("The " + emp + " must have been a warmongering menace! The following empires have achieved a peace victory: " + string.Join(", ", winners.Select(e => e.ToString()).ToArray()) + ".");
 }