internal ReplayAction ReadAction(GameField field) { String str = sr.ReadLine(); String type = ""; int subNumb = 0; List <Cell> path = new List <Cell>(); while (!str.Contains("End action")) { if (str.Contains("Type")) { str = sr.ReadLine(); type = str; str = sr.ReadLine(); } if (str.Contains("Path")) { str = sr.ReadLine(); while (!str.Contains("End path")) { path.Add(field.Field[Int32.Parse(str.Split(' ').ElementAt(0)), Int32.Parse(str.Split(' ').ElementAt(1))]); str = sr.ReadLine(); } } if (str.Contains("Submarine")) { str = sr.ReadLine(); subNumb = Int32.Parse(str); str = sr.ReadLine(); } str = sr.ReadLine(); } AIAction action = null; switch (type) { case "Move": action = new Move(path); break; case "LaunchTorpedo": action = new LaunchTorpedo(path); break; case "PlaceMine": action = new PlaceMine(path); break; } return(new ReplayAction(action, subNumb)); }
// Start is called before the first frame update void Start() { damageScript = FindObjectOfType <damageManager>(); torpedoScript = FindObjectOfType <LaunchTorpedo>(); subBody = gameObject.GetComponent <Rigidbody>(); }