public Game(Hashtable hash, SpaceTrader parentWin) : base(hash) { _game = this; ParentWindow = parentWin; string version = (string)GetValueFromHash(hash, "_version"); if (version.CompareTo(Consts.CurrentVersion) > 0) throw new FutureVersionException(); _universe = (StarSystem[])ArrayListToArray((ArrayList)GetValueFromHash(hash, "_universe"), "StarSystem"); _wormholes = (int[])GetValueFromHash(hash, "_wormholes", _wormholes); _mercenaries = (CrewMember[])ArrayListToArray((ArrayList)GetValueFromHash(hash, "_mercenaries"), "CrewMember"); _commander = new Commander((Hashtable)GetValueFromHash(hash, "_commander")); _dragonfly = new Ship((Hashtable)GetValueFromHash(hash, "_dragonfly", _dragonfly.Serialize())); _scarab = new Ship((Hashtable)GetValueFromHash(hash, "_scarab", _scarab.Serialize())); _scorpion = new Ship((Hashtable)GetValueFromHash(hash, "_scorpion", _scorpion.Serialize())); _spaceMonster = new Ship((Hashtable)GetValueFromHash(hash, "_spaceMonster", _spaceMonster.Serialize())); _opponent = new Ship((Hashtable)GetValueFromHash(hash, "_opponent", _opponent.Serialize())); _chanceOfTradeInOrbit = (int)GetValueFromHash(hash, "_chanceOfTradeInOrbit", _chanceOfTradeInOrbit); _clicks = (int)GetValueFromHash(hash, "_clicks", _clicks); _raided = (bool)GetValueFromHash(hash, "_raided", _raided); _inspected = (bool)GetValueFromHash(hash, "_inspected", _inspected); _tribbleMessage = (bool)GetValueFromHash(hash, "_tribbleMessage", _tribbleMessage); _arrivedViaWormhole = (bool)GetValueFromHash(hash, "_arrivedViaWormhole", _arrivedViaWormhole); _paidForNewspaper = (bool)GetValueFromHash(hash, "_paidForNewspaper", _paidForNewspaper); _litterWarning = (bool)GetValueFromHash(hash, "_litterWarning", _litterWarning); _newsEvents = new ArrayList((int[])GetValueFromHash(hash, "_newsEvents", _newsEvents.ToArray(System.Type.GetType("System.Int32")))); _difficulty = (Difficulty)GetValueFromHash(hash, "_difficulty", _difficulty); _cheatEnabled = (bool)GetValueFromHash(hash, "_cheatEnabled", _cheatEnabled); _autoSave = (bool)GetValueFromHash(hash, "_autoSave", _autoSave); _easyEncounters = (bool)GetValueFromHash(hash, "_easyEncounters", _easyEncounters); _endStatus = (GameEndType)GetValueFromHash(hash, "_endStatus", _endStatus); _encounterType = (EncounterType)GetValueFromHash(hash, "_encounterType", _encounterType); _selectedSystemId = (StarSystemId)GetValueFromHash(hash, "_selectedSystemId", _selectedSystemId); _warpSystemId = (StarSystemId)GetValueFromHash(hash, "_warpSystemId", _warpSystemId); _trackedSystemId = (StarSystemId)GetValueFromHash(hash, "_trackedSystemId", _trackedSystemId); _targetWormhole = (bool)GetValueFromHash(hash, "_targetWormhole", _targetWormhole); _priceCargoBuy = (int[])GetValueFromHash(hash, "_priceCargoBuy", _priceCargoBuy); _priceCargoSell = (int[])GetValueFromHash(hash, "_priceCargoSell", _priceCargoSell); _questStatusArtifact = (int)GetValueFromHash(hash, "_questStatusArtifact", _questStatusArtifact); _questStatusDragonfly = (int)GetValueFromHash(hash, "_questStatusDragonfly", _questStatusDragonfly); _questStatusExperiment = (int)GetValueFromHash(hash, "_questStatusExperiment", _questStatusExperiment); _questStatusGemulon = (int)GetValueFromHash(hash, "_questStatusGemulon", _questStatusGemulon); _questStatusJapori = (int)GetValueFromHash(hash, "_questStatusJapori", _questStatusJapori); _questStatusJarek = (int)GetValueFromHash(hash, "_questStatusJarek", _questStatusJarek); _questStatusMoon = (int)GetValueFromHash(hash, "_questStatusMoon", _questStatusMoon); _questStatusPrincess = (int)GetValueFromHash(hash, "_questStatusPrincess", _questStatusPrincess); _questStatusReactor = (int)GetValueFromHash(hash, "_questStatusReactor", _questStatusReactor); _questStatusScarab = (int)GetValueFromHash(hash, "_questStatusScarab", _questStatusScarab); _questStatusSculpture = (int)GetValueFromHash(hash, "_questStatusSculpture", _questStatusSculpture); _questStatusSpaceMonster = (int)GetValueFromHash(hash, "_questStatusSpaceMonster", _questStatusSpaceMonster); _questStatusWild = (int)GetValueFromHash(hash, "_questStatusWild", _questStatusWild); _fabricRipProbability = (int)GetValueFromHash(hash, "_fabricRipProbability", _fabricRipProbability); _justLootedMarie = (bool)GetValueFromHash(hash, "_justLootedMarie", _justLootedMarie); _canSuperWarp = (bool)GetValueFromHash(hash, "_canSuperWarp", _canSuperWarp); _chanceOfVeryRareEncounter = (int)GetValueFromHash(hash, "_chanceOfVeryRareEncounter", _chanceOfVeryRareEncounter); _veryRareEncounters = new ArrayList((int[])GetValueFromHash(hash, "_veryRareEncounters", _veryRareEncounters.ToArray(System.Type.GetType("System.Int32")))); _options = new GameOptions((Hashtable)GetValueFromHash(hash, "_options", _options.Serialize())); }
public Game(string name, Difficulty difficulty, int pilot, int fighter, int trader, int engineer, SpaceTrader parentWin) { _game = this; ParentWindow = parentWin; _difficulty = difficulty; // Keep Generating a new universe until PlaceSpecialEvents and PlaceShipyards return true, // indicating all special events and shipyards were placed. do GenerateUniverse(); while (!(PlaceSpecialEvents() && PlaceShipyards())); InitializeCommander(name, new CrewMember(CrewMemberId.Commander, pilot, fighter, trader, engineer, StarSystemId.Na)); GenerateCrewMemberList(); CreateShips(); CalculatePrices(Commander.CurrentSystem); ResetVeryRareEncounters(); if (Difficulty < Difficulty.Normal) Commander.CurrentSystem.SpecialEventType = SpecialEventType.Lottery; // TODO: JAF - DEBUG /* Commander.Cash = 1000000; CheatEnabled = true; EasyEncounters = true; */ }
private void LoadGame(string fileName) { try { object obj = Functions.LoadFile(fileName, false, this); if (obj != null) { game = new Game((Hashtable)obj, this); SaveGameFile = fileName; SaveGameDays = game.Commander.Days; SetInGameControlsEnabled(true); UpdateAll(); } } catch (FutureVersionException) { FormAlert.Alert(AlertType.FileErrorOpen, this, fileName, Strings.FileFutureVersion); } }
private void mnuGameNew_Click(object sender, System.EventArgs e) { FormNewCommander form = new FormNewCommander(); if ((game == null || game.Commander.Days == SaveGameDays || FormAlert.Alert(AlertType.GameAbandonConfirm, this) == DialogResult.Yes) && form.ShowDialog(this) == DialogResult.OK) { game = new Game(form.CommanderName, form.Difficulty, form.Pilot, form.Fighter, form.Trader, form.Engineer, this); SaveGameFile = null; SaveGameDays = 0; SetInGameControlsEnabled(true); UpdateAll(); if (game.Options.NewsAutoShow) game.ShowNewspaper(); } }
private void GameEnd() { SetInGameControlsEnabled(false); AlertType alertType = AlertType.Alert; switch (game.EndStatus) { case GameEndType.Killed: alertType = AlertType.GameEndKilled; break; case GameEndType.Retired: alertType = AlertType.GameEndRetired; break; case GameEndType.BoughtMoon: alertType = AlertType.GameEndBoughtMoon; break; } FormAlert.Alert(alertType, this); FormAlert.Alert(AlertType.GameEndScore, this, Functions.FormatNumber(game.Score / 10), Functions.FormatNumber(game.Score % 10)); HighScoreRecord candidate = new HighScoreRecord(game.Commander.Name, game.Score, game.EndStatus, game.Commander.Days, game.Commander.Worth, game.Difficulty); if (candidate > Functions.GetHighScores(this)[0]) { if (game.CheatEnabled) FormAlert.Alert(AlertType.GameEndHighScoreCheat, this); else { AddHighScore(candidate); FormAlert.Alert(AlertType.GameEndHighScoreAchieved, this); } } else FormAlert.Alert(AlertType.GameEndHighScoreMissed, this); Game.CurrentGame = null; game = null; }