Exemplo n.º 1
0
        /*private void RefreshContactList()
         * {
         *      foreach (Button button in empireButtons)
         *      {
         *              button.Selected = false;
         *      }
         *      int whichButton = whichContactSelected - empireScrollBar.TopIndex;
         *      if (whichButton >= 0 && whichButton < 4)
         *      {
         *              empireButtons[whichButton].Selected = true;
         *      }
         *      for (int i = 0; i < maxVisible; i++)
         *      {
         *              spyEffortScrollbars[i].TopIndex = empiresInContact[i + empireScrollBar.TopIndex].SpyEffort;
         *              spyDefenseScrollbars[i].TopIndex = empiresInContact[i + empireScrollBar.TopIndex].AntiSpyEffort;
         *              avatars[i] = empiresInContact[i + empireScrollBar.TopIndex].EmpireInContact.EmpireRace.GetMiniAvatar();
         *              relationLabels[i] = new Label(Utility.RelationToLabel(empiresInContact[i + empireScrollBar.TopIndex].RelationshipStatus), x + 165, y + 104 + (i * 150));
         *              empireNameLabels[i] = new Label(empiresInContact[i + empireScrollBar.TopIndex].EmpireInContact.EmpireName, x + 145, y + 3 + (i * 150), empiresInContact[i + empireScrollBar.TopIndex].EmpireInContact.EmpireColor);
         *      }
         * }
         *
         * private void LoadContact()
         * {
         *      isViewingReceivedMessage = false;
         *      for (int i = 0; i < messageOptions.Length; i++)
         *      {
         *              messageOptions[i].Selected = false;
         *              messageOptions[i].Active = true;
         *      }
         *      Contact contact = empiresInContact[whichContactSelected];
         *      Expression whichExpression = Expression.NEUTRAL;
         *      if (contact.RelationshipStatus < 70)
         *      {
         *              whichExpression = Expression.ANGRY;
         *      }
         *      else if (contact.RelationshipStatus > 130)
         *      {
         *              whichExpression = Expression.HAPPY;
         *      }
         *      profile = contact.EmpireInContact.EmpireRace.GetAvatar(whichExpression);
         *      if (contact.AtWar)
         *      {
         *              messageOptions[TRADE].Active = false;
         *              messageOptions[RESEARCH].Active = false;
         *              messageOptions[ALLY].Active = false;
         *              messageOptions[UNALLY].Active = false;
         *              messageOptions[HARASS].Active = false;
         *              messageOptions[RECONCILE].Active = false;
         *              messageOptions[WAR].Active = true;
         *              messageOptions[WAR].SetText("Offer Peace");
         *      }
         *      else
         *      {
         *              messageOptions[TRADE].Active = true;
         *              messageOptions[RESEARCH].Active = true;
         *              messageOptions[ALLY].Active = true;
         *              messageOptions[UNALLY].Active = true;
         *              messageOptions[HARASS].Active = true;
         *              messageOptions[RECONCILE].Active = true;
         *              messageOptions[WAR].Active = true;
         *              messageOptions[WAR].SetText("Declare War");
         *      }
         *      if (contact.Allied)
         *      {
         *              messageOptions[ALLY].Active = false;
         *              messageOptions[ALLY].SetText("Already Allied");
         *              messageOptions[UNALLY].SetText("Break Alliance");
         *      }
         *      else if (contact.NonAggression)
         *      {
         *              messageOptions[ALLY].SetText("Offer Alliance");
         *              messageOptions[UNALLY].SetText("Break Non-Aggression");
         *      }
         *      else if (!contact.AtWar)
         *      {
         *              messageOptions[UNALLY].Active = false;
         *              messageOptions[ALLY].SetText("Offer Non-Aggression");
         *              messageOptions[UNALLY].SetText("No Military Pacts to Break");
         *      }
         *      if (contact.TradeTreaty)
         *      {
         *              messageOptions[TRADE].SetText("Halt Trade");
         *      }
         *      else
         *      {
         *              messageOptions[TRADE].SetText("Offer Trade");
         *      }
         *      if (contact.ResearchTreaty)
         *      {
         *              messageOptions[RESEARCH].SetText("Halt Shared Research");
         *      }
         *      else
         *      {
         *              messageOptions[RESEARCH].SetText("Offer Shared Research");
         *      }
         *
         *      List<string> empires = new List<string>();
         *      adjustedEmpiresForSelection = new List<Empire>();
         *      foreach (Contact empireInContact in empiresInContact)
         *      {
         *              if (empireInContact != empiresInContact[whichContactSelected])
         *              {
         *                      empires.Add(empireInContact.EmpireInContact.EmpireName);
         *                      adjustedEmpiresForSelection.Add(empireInContact.EmpireInContact);
         *              }
         *      }
         *
         *      listOfEmpires = new ComboBox(spriteNames, empires, x + 505, y + 440, 200, 25, 6);
         *      if (empires.Count == 0)
         *      {
         *              listOfEmpires.Active = false;
         *              messageOptions[RECONCILE].Active = false;
         *              messageOptions[HARASS].Active = false;
         *      }
         *
         *      if (empiresInContact[whichContactSelected].OutgoingMessage != MessageType.NONE)
         *      {
         *              //already sending a message, disable everything
         *              for (int i = 0; i < 8; i++)
         *              {
         *                      messageOptions[i].Active = false;
         *              }
         *              listOfEmpires.Active = false;
         *              switch (empiresInContact[whichContactSelected].OutgoingMessage)
         *              {
         *                      case MessageType.BREAK_TRADE:
         *                      case MessageType.TRADE: messageOptions[TRADE].Selected = true;
         *                              break;
         *                      case MessageType.BREAK_RESEARCH:
         *                      case MessageType.RESEARCH: messageOptions[RESEARCH].Selected = true;
         *                              break;
         *                      case MessageType.ALLIANCE:
         *                      case MessageType.NONAGGRESSION: messageOptions[ALLY].Selected = true;
         *                              break;
         *                      case MessageType.BREAK_NONAGGRESSION:
         *                      case MessageType.BREAK_ALLIANCE: messageOptions[UNALLY].Selected = true;
         *                              break;
         *                      case MessageType.HARASS_EMPIRE: messageOptions[HARASS].Selected = true;
         *                              for (int i = 0; i < adjustedEmpiresForSelection.Count; i++)
         *                              {
         *                                      if (adjustedEmpiresForSelection[i] == empiresInContact[whichContactSelected].OutgoingEmpireRequest)
         *                                      {
         *                                              listOfEmpires.SelectedIndex = i;
         *                                              break;
         *                                      }
         *                              }
         *                              break;
         *                      case MessageType.RECONCILE_EMPIRE: messageOptions[RECONCILE].Selected = true;
         *                              for (int i = 0; i < adjustedEmpiresForSelection.Count; i++)
         *                              {
         *                                      if (adjustedEmpiresForSelection[i] == empiresInContact[whichContactSelected].OutgoingEmpireRequest)
         *                                      {
         *                                              listOfEmpires.SelectedIndex = i;
         *                                              break;
         *                                      }
         *                              }
         *                              break;
         *                      case MessageType.WAR:
         *                      case MessageType.OFFER_PEACE: messageOptions[WAR].Selected = true;
         *                              break;
         *              }
         *              messageOptions[7].Selected = true;
         *      }
         * }
         * private void LoadMessage()
         * {
         *      isViewingReceivedMessage = true;
         *      Contact contact = empiresInContact[whichContactSelected];
         *      Expression whichExpression = Expression.NEUTRAL;
         *      if (contact.RelationshipStatus < 70)
         *      {
         *              whichExpression = Expression.ANGRY;
         *      }
         *      else if (contact.RelationshipStatus > 130)
         *      {
         *              whichExpression = Expression.HAPPY;
         *      }
         *      profile = contact.EmpireInContact.EmpireRace.GetAvatar(whichExpression);
         *      MessageType whichMessage = empiresInContact[whichContactSelected].IncomingMessage;
         *      switch (contact.IncomingMessage)
         *      {
         *              case MessageType.TRADE:
         *                      IncomingMessageTextBox.SetText("We want trade agreement, do you agree?");
         *                      break;
         *              case MessageType.BREAK_TRADE:
         *                      IncomingMessageTextBox.SetText("We don't want your cheap items anymore!");
         *                      break;
         *              case MessageType.RESEARCH:
         *                      IncomingMessageTextBox.SetText("We would like us to share our research.");
         *                      break;
         *              case MessageType.BREAK_RESEARCH:
         *                      IncomingMessageTextBox.SetText("We don't want your lousy research!");
         *                      break;
         *              case MessageType.NONAGGRESSION:
         *                      IncomingMessageTextBox.SetText("We want non-aggression!");
         *                      break;
         *              case MessageType.ALLIANCE:
         *                      IncomingMessageTextBox.SetText("We want alliance!");
         *                      break;
         *              case MessageType.BREAK_NONAGGRESSION:
         *                      IncomingMessageTextBox.SetText("We want aggression!");
         *                      break;
         *              case MessageType.BREAK_ALLIANCE:
         *                      IncomingMessageTextBox.SetText("We want to break our alliance!");
         *                      break;
         *              case MessageType.HARASS_EMPIRE:
         *                      IncomingMessageTextBox.SetText("We want you to bully " + empiresInContact[whichContactSelected].IncomingEmpireRequest.EmpireName + "!");
         *                      break;
         *              case MessageType.RECONCILE_EMPIRE:
         *                      IncomingMessageTextBox.SetText("We want you to make peace with " + empiresInContact[whichContactSelected].IncomingEmpireRequest.EmpireName + "!");
         *                      break;
         *              case MessageType.WAR:
         *                      IncomingMessageTextBox.SetText("We're going to KILL you!");
         *                      break;
         *              case MessageType.OFFER_PEACE:
         *                      IncomingMessageTextBox.SetText("Please have mercy on us!");
         *                      break;
         *              case MessageType.ACCEPT_ALLIANCE:
         *                      IncomingMessageTextBox.SetText("We agree to ally with you!");
         *                      break;
         *              case MessageType.ACCEPT_NONAGGRESSION:
         *                      IncomingMessageTextBox.SetText("We agree to not be aggressive!");
         *                      break;
         *              case MessageType.ACCEPT_PEACE:
         *                      IncomingMessageTextBox.SetText("We will spare you for now!");
         *                      break;
         *              case MessageType.ACCEPT_RECONCILE:
         *                      IncomingMessageTextBox.SetText("We will make peace with " + "!");
         *                      break;
         *              case MessageType.ACCEPT_HARASS:
         *                      IncomingMessageTextBox.SetText("We will bully " + "!");
         *                      break;
         *              case MessageType.ACCEPT_RESEARCH:
         *                      IncomingMessageTextBox.SetText("We accept the deal to share research!");
         *                      break;
         *              case MessageType.ACCEPT_TRADE:
         *                      IncomingMessageTextBox.SetText("We accept the trade offer!");
         *                      break;
         *              case MessageType.DECLINE_REQUEST:
         *                      IncomingMessageTextBox.SetText("We decline your request.");
         *                      break;
         *      }
         *      if (whichMessage == MessageType.BREAK_ALLIANCE || whichMessage == MessageType.BREAK_NONAGGRESSION || whichMessage == MessageType.BREAK_RESEARCH ||
         *              whichMessage == MessageType.BREAK_TRADE || whichMessage == MessageType.WAR || whichMessage == MessageType.DECLINE_REQUEST)
         *      {
         *              messageOptions[ACCEPT].SetText("Oh really?");
         *              messageOptions[ACCEPT].Active = false;
         *              messageOptions[REJECT].SetText(string.Empty);
         *              messageOptions[REJECT].Active = false;
         *      }
         *      else if (whichMessage == MessageType.ACCEPT_ALLIANCE || whichMessage == MessageType.ACCEPT_HARASS || whichMessage == MessageType.ACCEPT_NONAGGRESSION ||
         *              whichMessage == MessageType.ACCEPT_PEACE || whichMessage == MessageType.ACCEPT_RECONCILE || whichMessage == MessageType.ACCEPT_RESEARCH ||
         *              whichMessage == MessageType.ACCEPT_TRADE)
         *      {
         *              messageOptions[ACCEPT].SetText("Yayification!");
         *              messageOptions[ACCEPT].Active = false;
         *              messageOptions[REJECT].SetText(string.Empty);
         *              messageOptions[REJECT].Active = false;
         *      }
         *      else
         *      {
         *              messageOptions[ACCEPT].SetText("Accept Offer");
         *              messageOptions[ACCEPT].Active = true;
         *              messageOptions[REJECT].SetText("Reject Offer");
         *              messageOptions[REJECT].Active = true;
         *      }
         *      messageOptions[ACCEPT].Selected = false;
         *      messageOptions[REJECT].Selected = false;
         *      if (empiresInContact[whichContactSelected].OutgoingMessage != MessageType.NONE)
         *      {
         *              messageOptions[ACCEPT].Active = false;
         *              messageOptions[REJECT].Active = false;
         *              switch(empiresInContact[whichContactSelected].OutgoingMessage)
         *              {
         *                      case MessageType.ACCEPT_ALLIANCE:
         *                      case MessageType.ACCEPT_HARASS:
         *                      case MessageType.ACCEPT_NONAGGRESSION:
         *                      case MessageType.ACCEPT_PEACE:
         *                      case MessageType.ACCEPT_RECONCILE:
         *                      case MessageType.ACCEPT_RESEARCH:
         *                      case MessageType.ACCEPT_TRADE:
         *                              messageOptions[ACCEPT].Selected = true;
         *                              break;
         *                      case MessageType.DECLINE_REQUEST:
         *                              messageOptions[REJECT].Selected = true;
         *                              break;
         *              }
         *      }
         * }*/

        public void KeyDown(KeyboardInputEventArgs e)
        {
            if (e.Key == KeyboardKeys.Escape)
            {
                gameMain.ChangeToScreen(Screen.Galaxy);
            }
        }
Exemplo n.º 2
0
 public void MouseUp(int x, int y, int whichButton)
 {
     if (whichButton != 1)
     {
         return;
     }
     if (_generatingGalaxy)
     {
         return;
     }
     if (_showingSelection)
     {
         _raceSelection.MouseUp(x, y);
         return;
     }
     _playerEmperorName.MouseUp(x, y);
     _playerHomeworldName.MouseUp(x, y);
     _numericUpDownAI.MouseUp(x, y);
     _difficultyComboBox.MouseUp(x, y);
     if (_playerRaceDescription.MouseUp(x, y))
     {
         return;
     }
     if (_galaxyComboBox.MouseUp(x, y))
     {
         if (!_galaxyComboBox.Dropped)
         {
             //Update galaxy here
             _generatingGalaxy = true;
             _busyText.MoveTo((int)((_gameMain.ScreenWidth / 2) - (_busyText.GetWidth() / 2)), (int)((_gameMain.ScreenHeight / 2) - (_busyText.GetHeight() / 2)));
             _gameMain.Galaxy.OnGenerateComplete += OnGalaxyGenerated;
             string reason;
             if (!_gameMain.Galaxy.GenerateGalaxy((GALAXYTYPE)_galaxyComboBox.SelectedIndex, 1, 1, _gameMain.Random, out reason))
             {
                 _generatingGalaxy = false;
             }
         }
     }
     if (_playerRaceButton.MouseUp(x, y))
     {
         _showingSelection = true;
         _raceSelection.SetCurrentPlayerInfo(0, _playerRaces[0], _playerColors[0]);
     }
     for (int i = 0; i < _numericUpDownAI.Value; i++)
     {
         if (_AIRaceButtons[i].MouseUp(x, y))
         {
             _showingSelection = true;
             _raceSelection.SetCurrentPlayerInfo(i + 1, _playerRaces[i + 1], _playerColors[i + 1]);
         }
     }
     if (_cancelButton.MouseUp(x, y))
     {
         _gameMain.ChangeToScreen(Screen.MainMenu);
     }
     if (_okButton.MouseUp(x, y))
     {
         //See if the galaxy is generated.  If not, generate it now, then proceed to player setup
         if (_gameMain.Galaxy.GetAllStars().Count == 0)
         {
             SetUpGalaxy();
         }
         else
         {
             SetUpEmpiresAndStart();
         }
     }
 }
Exemplo n.º 3
0
        public void MouseUp(int x, int y, int whichButton)
        {
            if (_showingLoadMenu)
            {
                for (int i = 0; i < _maxVisible; i++)
                {
                    if (_saveGameButtons[i].MouseUp(x, y))
                    {
                        _gameMain.LoadGame(_files[i + _scrollBar.TopIndex].Name);
                        _gameMain.ChangeToScreen(Screen.Galaxy);
                        _showingLoadMenu = false;
                        return;
                    }
                }
                if (_scrollBar.MouseUp(x, y))
                {
                    RefreshSaves();
                    return;
                }
                //Since the player didn't click on one of the buttons, it's considered as cancel.
                _showingLoadMenu = false;
                return;
            }
            for (int i = 0; i < _buttons.Length; i++)
            {
                if (_buttons[i].MouseUp(x, y))
                {
                    switch (i)
                    {
                    case 0:                             //Continue button
                        FileInfo mostRecentGame = null;
                        foreach (var file in _files)
                        {
                            if (mostRecentGame == null)
                            {
                                mostRecentGame = file;
                            }
                            else if (mostRecentGame.LastWriteTime.CompareTo(file.LastWriteTime) < 0)
                            {
                                mostRecentGame = file;
                            }
                        }
                        if (mostRecentGame != null)
                        {
                            _gameMain.LoadGame(mostRecentGame.Name);
                            _gameMain.ChangeToScreen(Screen.Galaxy);
                        }
                        break;

                    case 1:                             //New Game button
                        _gameMain.ChangeToScreen(Screen.NewGame);
                        break;

                    case 2:
                        _showingLoadMenu = true;
                        break;

                    case 3:
                        _gameMain.ExitGame();
                        break;
                    }
                }
            }
        }
        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;
            }
        }