private int LoadArmyData() { #if UNITY_EDITOR for (int j = 0; j < TurnManager.Instance.PlayerCount; j++) { if (TurnManager.Instance.GetPlayer(j).UnitCount > 0) { Debug.LogError("Player " + j + " has " + TurnManager.Instance.GetPlayer(j).UnitCount + " units at the start of the game!"); } } #endif TextAsset unitDataFile = Resources.Load(PathExtensions.CombineForward(CommonPaths.UNIT_DATA_DIR, "Army"), typeof(TextAsset)) as TextAsset; if (unitDataFile) { Dictionary <string, object> rawData = Json.Deserialize(unitDataFile.text) as Dictionary <string, object>; for (int i = 0; i < _maxArmySize; i++) { string unitKey = ARMY_UNITY_KEY + i; if (rawData != null && rawData.ContainsKey(unitKey)) { string unitName = rawData[unitKey] as string; for (int j = 0; j < TurnManager.Instance.PlayerCount; j++) { GameObject newUnit = PoolManager.instance.GetObjectForName(unitName, false); HexUnit hexUnit = newUnit.GetComponent <HexUnit>(); hexUnit.Reset(); if (j % 2 == 0) { hexUnit.FaceRight(); } else { hexUnit.FaceLeft(); } TurnManager.Instance.GetPlayer(j).AddUnit(hexUnit); newUnit.SetActive(false); } } else { return(i); } } return(_maxArmySize); } return(-1); }