diff --git a/Assets/Generator.cs b/Assets/Generator.cs index b6dbf3f..84abce8 100644 --- a/Assets/Generator.cs +++ b/Assets/Generator.cs @@ -37,7 +37,7 @@ public class Generator : MonoBehaviour { map [10, 20] = -1; mScript.setMatrix (map,x,y); - turnMan.GetComponent ().charMap = uScript.tutorialUnits (); + turnMan.GetComponent ().charMap = uScript.tutorialUnits (x, y); } // Update is called once per frame diff --git a/Assets/UnitCreator.cs b/Assets/UnitCreator.cs index e8deef9..746cabf 100644 --- a/Assets/UnitCreator.cs +++ b/Assets/UnitCreator.cs @@ -19,13 +19,9 @@ public class UnitCreator : MonoBehaviour { // Use this for initialization void Start () { - units = new List((int)(mapSize.y*mapSize.x)); + playerLichScript = null; - for (int i = 0; i < mapSize.y; i++) { - for (int j = 0; j < mapSize.x; j++) { - units.Insert(i * (int) mapSize.x + j, null); - } - } + } // Update is called once per frame @@ -41,7 +37,7 @@ public class UnitCreator : MonoBehaviour { unit.transform.localScale = new Vector3 (unit.transform.lossyScale.y/unit.transform.lossyScale.y, 1, unit.transform.lossyScale.z/unit.transform.lossyScale.y); unit.GetComponent ().SetupStats (posX, posZ, 3, 3, 100, 0, 0, 0); unit.GetComponent ().SetupBaseAttack (4, 2, 3); - units.Insert(posX*(int)mapSize.x*posZ, unit); + units.Insert(posX*(int)mapSize.x+posZ, unit); if (team == UnitBehaviour.Team.Player && playerLichScript == null ) playerLichScript = unit.GetComponent (); @@ -50,7 +46,7 @@ public class UnitCreator : MonoBehaviour { unit = Instantiate (skeletonObject, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject; unit.transform.localScale = new Vector3 (unit.transform.localScale.x*0.3f, unit.transform.localScale.y*0.3f, unit.transform.localScale.z*0.3f); unit.GetComponent ().SetupStats (posX, posZ); - units.Insert(posX*(int)mapSize.x*posZ, unit); + units.Insert(posX*(int)mapSize.x+posZ, unit); if (team == UnitBehaviour.Team.Enemy1) { @@ -63,7 +59,14 @@ public class UnitCreator : MonoBehaviour { } - public List tutorialUnits() { + public List tutorialUnits(int x, int y) { + units = new List(x * y); + for (int i = 0; i < y; i++) { + for (int j = 0; j < x; j++) { + units.Insert(i * x + j, null); + } + } + createUnit (9, 5, UnitBehaviour.Team.Player, UnitType.Lich); createUnit (8, 7, UnitBehaviour.Team.Player);