public override void Begin() { base.Begin(); // Setup galaxy & star system information: BEFORE LOADING Galaxy = new Entity_Galaxy(this, Program.PATH_PA, Program.PATH_MOD); // Load thread if (FileToLoad != "") { Thread_Load = new Thread(new ThreadStart(this.ThreadLoadGame)); FileToSave = true; } // Connect to server if (IPToConnect != "") { CurrentGame = new Info_Game(); NetworkManager.Connect(IPToConnect); } Game.Instance.QuitButton.Clear(); // Cursor last Add(new Entity_Cursor(Program.PATH_PA + "media/ui/main/shared/img/icons/cursor.png")); }
static public void SendInitialState(NetConnection sendto) { Info_Game game = ((Scene_Game)Scene.Instance).CurrentGame; // Send the player ID NetOutgoingMessage msg_playerid = StartDefaultMessage(MESSAGE_PLAYERID); { msg_playerid.Write(NetworkHandler.ConnectionsCount); } SendMessage(sendto, msg_playerid); // Send the initial world state SendString(sendto, MESSAGE_INITIAL, game.GetNetworkString()); }
public void ThreadLoadGame() { string json = JSONToLoad; if (JSONToLoad == "") { json = Helper.ReadFile(FileToLoad); } CurrentGame = JsonConvert.DeserializeObject <Info_Game>(json); FileToLoad = null; Galaxy.Initialise(CurrentGame.Galaxy); SetupGame(); Galaxy.InitialisePlayers(); foreach (Info_Player player in CurrentPlayers) { ApplyCards(player, player.Commander.CommanderCards, player.Commander.Cards); } }
private void NewGame() { // Create new CurrentGame = new Info_Game(); { CurrentGame.StartDate = DateTime.Today.ToShortDateString(); CurrentGame.Players = 2; CurrentGame.Commanders = new List <CommanderType>(); for (int com = 0; com < CurrentGame.Players; com++) { CommanderType commander = new CommanderType(); { commander.PlayerName = "Matthew"; commander.UberID = "\"7420260152538080746\""; //"friends":"[\"11035761434068835310\",\"16024636805495278681\",\"6884095390246756552\"]", commander.FactionName = "Legion"; commander.ModelID = 0; commander.Colour = Color.Random.ColorString; commander.CommanderCards = new List <string>(); { commander.CommanderCards.Add("Miner Upgrade"); } commander.Cards = new List <string>(); { commander.Cards.Add("Advanced Bots"); } commander.Armies = new List <ArmyType>(); { ArmyType army; { army.Name = ""; army.Strength = 1; army.SystemPosition = Rand.Int(0, Galaxy.MaxSystems); } commander.Armies.Add(army); // Store initial state SetPlayerTurn(com); DoTurn(Helper.ACTION_MOVE, army.SystemPosition, com, 0, false); } } CurrentGame.Commanders.Add(commander); // Revert back to player 1 having first turn SetPlayerTurn(0); } // Generate the initial galaxy Galaxy.Generate(); } Galaxy.Initialise(); Galaxy.Generate_Info(); SetupGame(); // Add ownership of the starting locations to those players int playerid = 0; foreach (CommanderType player in CurrentGame.Commanders) { foreach (ArmyType army in player.Armies) { Galaxy.GetSystemByID(army.SystemPosition).SetOwner(playerid); } playerid++; } IsNewGame = true; SaveGame(); }