void MakePlayerActions() { XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(RaceGameAi)); System.IO.StreamReader file = new System.IO.StreamReader(FILE_PATH); _raceGameAi = (RaceGameAi)reader.Deserialize(file); file.Close(); _playerInputs = _raceGameAi._patternVirage[0]._playerInputs; _nbInputsToDo = _playerInputs.Count; if (_nbInputsToDo > 0) { _currentInputToDo = 0; _actionsLaunched = true; _moveScript._playerMove = false; //_tickStart = Time.frameCount; Debug.Log("----- Begin -----"); } }
// Update is called once per frame /*void Update() { if ((Input.GetKey(KeyCode.P)) && (_actionsLaunched == false)) { Debug.Log("Make Action"); // MakePlayerActions(); } if (_nbInputsToDo > 0) { _currentPlayerInput = _playerInputs[_currentInputToDo]; ++_currentInputToDo; --_nbInputsToDo; if (_currentPlayerInput != null) _moveScript.makeMove(_currentPlayerInput); if (_nbInputsToDo <= 0) { _currentInputToDo = 0; _actionsLaunched = false; _moveScript._playerMove = true; Debug.Log("----- End -----"); } } }*/ public PatternRaceGame ReadXmlFile(string playerName) { XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(RaceGameAi)); System.IO.StreamReader file = new System.IO.StreamReader(FileNemForSavingSharableIA(playerName)); if (file == null) { return null; } _raceGameAi = (RaceGameAi)reader.Deserialize(file); file.Close(); int randVal = Random.Range(0, _raceGameAi._listPatternRaceGame.Count); PatternRaceGame racegame = _raceGameAi._listPatternRaceGame[randVal]; return racegame; }
void LoadAiFile() { if (File.Exists(FILE_PATH)) { XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(RaceGameAi)); System.IO.StreamReader file = new System.IO.StreamReader(FILE_PATH); _raceGameAi = (RaceGameAi)reader.Deserialize(file); file.Close(); } else { CreateXmlFile(); _raceGameAi = new RaceGameAi(); } }
void LoadAiFile(string playerName) { string fileName = FileNemForSavingSharableIA(playerName); if (File.Exists(fileName)) { XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(RaceGameAi)); System.IO.StreamReader file = new System.IO.StreamReader(fileName); _raceGameAi = (RaceGameAi)reader.Deserialize(file); file.Close(); } else { CreateXmlFile(playerName); _raceGameAi = new RaceGameAi(); } }