private void ReadConvergeEcosystemsFile() { ResponseConvergeEcosystems response = new ResponseConvergeEcosystems(); string filename = "converge-ecosystems.txt"; ecosystemList = new List <ConvergeEcosystem> (); if (!File.Exists(filename)) { Debug.LogError(filename + " not found."); } else { using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { using (BinaryReader br = new BinaryReader(fs, Encoding.UTF8)) { int size = br.ReadInt16(); int responseId = br.ReadInt16(); int ecosystemCnt = br.ReadInt16(); for (int i = 0; i < ecosystemCnt; i++) { int ecosystem_id = br.ReadInt32(); ConvergeEcosystem ecosystem = new ConvergeEcosystem(ecosystem_id); int fldSize = br.ReadInt16(); ecosystem.description = System.Text.Encoding.UTF8.GetString(br.ReadBytes(fldSize)); ecosystem.timesteps = br.ReadInt32(); fldSize = br.ReadInt16(); ecosystem.config_default = System.Text.Encoding.UTF8.GetString(br.ReadBytes(fldSize)); fldSize = br.ReadInt16(); ecosystem.config_target = System.Text.Encoding.UTF8.GetString(br.ReadBytes(fldSize)); fldSize = br.ReadInt16(); ecosystem.csv_default_string = System.Text.Encoding.UTF8.GetString(br.ReadBytes(fldSize)); fldSize = br.ReadInt16(); ecosystem.csv_target_string = System.Text.Encoding.UTF8.GetString(br.ReadBytes(fldSize)); ecosystemList.Add(ecosystem); } //set initial ecosystem id if (ecosystemList.Count == 0) { Debug.LogError("No converge ecosystems found."); } response.ecosystemList = ecosystemList; } } } }
// Use this for initialization void Start () { // DH change // Get room that player is in var room = RoomManager.getInstance().getRoom(matchID); Debug.Log("MC: room id / host name / player_id: " + matchID + " " + room.host + " " + player_id); Debug.Log("MC: Number of players: " + room.numPlayers()); if (GameState.player.GetName () == room.host) { host = true; Debug.Log ("This player is the host"); } else { host = false; Debug.Log ("This player is not the host"); } Game.StartEnterTransition (); //to generate converge-ecosystem.txt, remove comments and let protocol run; //server will generate txt from sql table //NetworkManager.Send(ConvergeEcosystemsProtocol.Prepare(),ProcessConvergeEcosystems); //get list of ecosystems ReadConvergeEcosystemsFile (); //set default ecosystem values new_ecosystem_id = Constants.ID_NOT_SET; ecosystem_idx = 0; // Initially set to first ecosystem ecosystem_id = GetEcosystemId (ecosystem_idx); //get player's most recent prior attempts // DH change - start everyone at beginning to make equal // GetPriorAttempts (); // Replacement for GetPriorAttempts() NoPriorAttempts(); //create array of ecosystem descriptions if (ecosystemList != null) { ecosysDescripts = ConvergeEcosystem.GetDescriptions (ecosystemList); } // GetHints (); Debug.Log ("Now in MultiConverge.cs"); moment = DateTime.Now; timeNow = moment.Millisecond; Debug.Log ("Time: " + timeNow); InitializeBarGraph(); }
// Use this for initialization void Start() { Game.StartEnterTransition(); //get list of ecosystems //NetworkManager.Send(ConvergeEcosystemsProtocol.Prepare(),ProcessConvergeEcosystems); ReadConvergeEcosystemsFile(); //set default ecosystem values new_ecosystem_id = Constants.ID_NOT_SET; ecosystem_idx = 0; ecosystem_id = GetEcosystemId(ecosystem_idx); //get player's most recent prior attempts GetPriorAttempts(); //create array of ecosystem descriptions if (ecosystemList != null) { ecosysDescripts = ConvergeEcosystem.GetDescriptions(ecosystemList); } GetHints(); }
private void ReadConvergeEcosystemsFile() { ResponseConvergeEcosystems response = new ResponseConvergeEcosystems (); string filename = "converge-ecosystems.txt"; ecosystemList = new List<ConvergeEcosystem> (); if (!File.Exists (filename)) { Debug.LogError (filename + " not found."); } else { using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { using (BinaryReader br = new BinaryReader(fs, Encoding.UTF8)) { int size = br.ReadInt16 (); int responseId = br.ReadInt16 (); int ecosystemCnt = br.ReadInt16 (); for (int i = 0; i < ecosystemCnt; i++) { int ecosystem_id = br.ReadInt32 (); ConvergeEcosystem ecosystem = new ConvergeEcosystem (ecosystem_id); int fldSize = br.ReadInt16 (); ecosystem.description = System.Text.Encoding.UTF8.GetString (br.ReadBytes (fldSize)); ecosystem.timesteps = br.ReadInt32 (); fldSize = br.ReadInt16 (); ecosystem.config_default = System.Text.Encoding.UTF8.GetString (br.ReadBytes (fldSize)); fldSize = br.ReadInt16 (); ecosystem.config_target = System.Text.Encoding.UTF8.GetString (br.ReadBytes (fldSize)); fldSize = br.ReadInt16 (); ecosystem.csv_default_string = System.Text.Encoding.UTF8.GetString (br.ReadBytes (fldSize)); fldSize = br.ReadInt16 (); ecosystem.csv_target_string = System.Text.Encoding.UTF8.GetString (br.ReadBytes (fldSize)); ecosystemList.Add (ecosystem); } //set initial ecosystem id if (ecosystemList.Count == 0) { Debug.LogError ("No converge ecosystems found."); } response.ecosystemList = ecosystemList; } } } }