Example #1
0
 public bool Initialize(DirectoryInfo directory, Random r, out string reason)
 {
     try
     {
         string path = Path.Combine(directory.FullName, "races");
         DirectoryInfo di = new DirectoryInfo(path);
         if (!di.Exists)
         {
             //If it don't exist, create one so users can add races
             di.Create();
         }
         foreach (FileInfo fi in di.GetFiles("*.xml"))
         {
             Race race = new Race();
             if (!race.Initialize(fi, r, out reason))
             {
                 return false;
             }
             Races.Add(race);
         }
         reason = null;
         return true;
     }
     catch (Exception e)
     {
         reason = e.Message;
         return false;
     }
 }
Example #2
0
        public Empire(string emperorName, int empireID, Race race, PlayerType type, Color color, GameMain gameMain)
            : this()
        {
            Reserves = 0;
            TaxRate = 0;
            this.empireName = emperorName;
            this.empireID = empireID;
            this.type = type;
            EmpireColor = color;
            try
            {
                TechnologyManager.SetComputerTechs(gameMain.MasterTechnologyManager.GetRandomizedComputerTechs());
                TechnologyManager.SetConstructionTechs(gameMain.MasterTechnologyManager.GetRandomizedConstructionTechs());
                TechnologyManager.SetForceFieldTechs(gameMain.MasterTechnologyManager.GetRandomizedForceFieldTechs());
                TechnologyManager.SetPlanetologyTechs(gameMain.MasterTechnologyManager.GetRandomizedPlanetologyTechs());
                TechnologyManager.SetPropulsionTechs(gameMain.MasterTechnologyManager.GetRandomizedPropulsionTechs());
                TechnologyManager.SetWeaponTechs(gameMain.MasterTechnologyManager.GetRandomizedWeaponTechs());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            EmpireRace = race;
        }
Example #3
0
 private void OnRaceSelectionOKClick(int whichPlayer, Race whichRace)
 {
     _showingSelection = false;
     for (int i = 0; i < _playerRaces.Length; i++)
     {
         if (i != whichPlayer && _playerRaces[i] == whichRace)
         {
             _playerRaces[i] = null;
             _raceSprites[i] = _randomRaceSprite;
             if (i == 0)
             {
                 _playerRaceDescription.SetText("A random race will be chosen.  If the Emperor and/or Homeworld name fields are left blank, default race names for those will be used.");
             }
             break;
         }
     }
     _playerRaces[whichPlayer] = whichRace;
     if (whichRace == null)
     {
         _raceSprites[whichPlayer] = _randomRaceSprite;
     }
     else
     {
         _raceSprites[whichPlayer] = whichRace.MiniAvatar;
     }
     if (whichPlayer == 0)
     {
         if (whichRace == null)
         {
             _playerRaceDescription.SetText("A random race will be chosen.  If the Emperor and/or Homeworld name fields are left blank, default race names for those will be used.");
         }
         else
         {
             _playerRaceDescription.SetText(whichRace.RaceDescription);
         }
     }
 }
Example #4
0
 public override bool MouseUp(int x, int y)
 {
     if (_okButton.MouseUp(x, y))
     {
         if (OnOkClick != null)
         {
             OnOkClick(_whichPlayerSelecting, _whichRaceSelected);
             return true;
         }
     }
     if (_raceDescription.MouseUp(x, y))
     {
         return true;
     }
     for (int i = 0; i < _maxVisible; i++)
     {
         if (_raceButtons[i].MouseUp(x, y))
         {
             if (_raceButtons[i].DoubleClicked)
             {
                 if (OnOkClick != null)
                 {
                     OnOkClick(_whichPlayerSelecting, _whichRaceSelected);
                     return true;
                 }
             }
             if (i == 0 && _raceScrollBar.TopIndex == 0)
             {
                 _whichRaceSelected = null;
             }
             else
             {
                 _whichRaceSelected = _raceManager.Races[i + _raceScrollBar.TopIndex - 1];
             }
             RefreshRaceDescription();
             RefreshRaceLabels();
             return true;
         }
     }
     return base.MouseUp(x, y);
 }
Example #5
0
 public void SetCurrentPlayerInfo(int whichPlayer, Race race, Color color)
 {
     _whichPlayerSelecting = whichPlayer;
     _whichRaceSelected = race;
     RefreshRaceLabels(); //This also sets the correct button to selected state
     RefreshRaceDescription();
 }
Example #6
0
 public void RemoveRacePopulation(Race whichRace, float amount)
 {
     _racePopulations[whichRace] -= amount;
     if (_racePopulations[whichRace] <= 0)
     {
         //They died out on this planet
         RemoveRace(whichRace);
     }
 }
Example #7
0
 private float CalculateRaceGrowth(Race race)
 {
     float pop = _racePopulations[race];
     pop = pop - (pop * ((Waste / _populationMax) * 0.1f));
     pop = pop + (_racePopulations[race] * ((1 - (pop / TotalMaxPopulation)) * 0.1f));
     return (pop - _racePopulations[race]);
 }
Example #8
0
 public void RemoveRace(Race whichRace)
 {
     _racePopulations.Remove(whichRace);
     _races.Remove(whichRace);
 }
Example #9
0
 public float GetRacePopulation(Race whichRace)
 {
     return _racePopulations[whichRace];
 }
Example #10
0
 public void AddRacePopulation(Race whichRace, float amount)
 {
     if (_racePopulations.ContainsKey(whichRace))
     {
         _racePopulations[whichRace] += amount;
     }
     else
     {
         //Add it
         if (!_races.Contains(whichRace))
         {
             _races.Add(whichRace);
         }
         _racePopulations[whichRace] = amount;
     }
 }
Example #11
0
 public void SubtractTransport(Race race, int amount)
 {
     TransportShip transportShipToRemove = null;
     foreach (TransportShip transport in _transportShips)
     {
         if (transport.raceOnShip == race)
         {
             transport.amount -= amount;
             if (transport.amount <= 0)
             {
                 transportShipToRemove = transport;
             }
         }
     }
     if (transportShipToRemove != null)
     {
         TransportShips.Remove(transportShipToRemove);
     }
 }
Example #12
0
 public void AddTransport(Race race, int amount)
 {
     bool added = false;
     foreach (TransportShip transport in _transportShips)
     {
         if (transport.raceOnShip == race)
         {
             transport.amount += amount;
             added = true;
             break;
         }
     }
     if (!added)
     {
         TransportShip transport = new TransportShip();
         transport.raceOnShip = race;
         transport.amount = amount;
         _transportShips.Add(transport);
     }
     _maxSpeed = 1;
 }