From 26b2fb2f9387bd6acfde3681f8c50343d72f16c4 Mon Sep 17 00:00:00 2001 From: "falc@null.net" Date: Sat, 29 Oct 2016 10:29:31 +0200 Subject: [PATCH] ayyy --- Assets/Generator.cs | 9 ++++++--- Assets/TurnManagerScript.cs | 23 +++++++++++++++-------- Assets/UnitCreator.cs | 22 ++++++++++++++++------ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Assets/Generator.cs b/Assets/Generator.cs index 8951814..b6dbf3f 100644 --- a/Assets/Generator.cs +++ b/Assets/Generator.cs @@ -12,15 +12,18 @@ public class Generator : MonoBehaviour { // Use this for initialization void Start () { + int x = 20; + int y = 40; + GameObject turnMan = Instantiate (tmanager); GameObject mapCreator = Instantiate (mcreator); GameObject unitCreator = Instantiate (ucreator); tScript = turnMan.GetComponent(); mScript = mapCreator.GetComponent(); uScript = unitCreator.GetComponent(); - int x = 20; - int y = 40; - int[,] map = new int [x,y] ; + uScript.mapSize = new Vector2 (20, 40); + + int[,] map = new int [x,y]; for(int i = 0; i < x; ++i) { for(int j = 0; j < y; ++j) { if (i == 0 || i == x-1 || j == 0 || j == y-1) diff --git a/Assets/TurnManagerScript.cs b/Assets/TurnManagerScript.cs index b615c77..ba3061d 100644 --- a/Assets/TurnManagerScript.cs +++ b/Assets/TurnManagerScript.cs @@ -39,7 +39,7 @@ public class TurnManagerScript : MonoBehaviour { timeStep = 0.4f; timeExp = 0.0f; - timeExpStep = 0.05f; + timeExpStep = 0.04f; timeExpLimit = 0.3f; cursor = Instantiate (cursor, new Vector3 (1.0f, 1.5f, 1.0f), Quaternion.identity) as GameObject; @@ -52,7 +52,7 @@ public class TurnManagerScript : MonoBehaviour { accTime += Time.deltaTime; - if (Input.GetKey (KeyCode.LeftArrow) && accTime > (timeStep-timeExp)) { + if (Input.GetKey (KeyCode.A) && accTime > (timeStep-timeExp)) { accTime -= (timeStep - timeExp); if (timeExp < timeExpLimit) timeExp += timeExpStep; cursor.transform.Translate (-1f, 0, 0); @@ -60,30 +60,37 @@ public class TurnManagerScript : MonoBehaviour { timeExp = 0.0f; } - if (Input.GetKey (KeyCode.RightArrow) && accTime > (timeStep-timeExp)) { + if (Input.GetKey (KeyCode.D) && accTime > (timeStep-timeExp)) { accTime -= (timeStep - timeExp); if (timeExp < timeExpLimit) timeExp += timeExpStep; cursor.transform.Translate (1f, 0, 0); - } else if (Input.GetKeyUp (KeyCode.RightArrow)) { + } else if (Input.GetKeyUp (KeyCode.D)) { timeExp = 0.0f; } - if (Input.GetKey (KeyCode.UpArrow) && accTime > (timeStep-timeExp)) { + if (Input.GetKey (KeyCode.W) && accTime > (timeStep-timeExp)) { accTime -= (timeStep - timeExp); if (timeExp < timeExpLimit) timeExp += timeExpStep; cursor.transform.Translate (0, 1f, 0); - } else if (Input.GetKeyUp (KeyCode.UpArrow)) { + } else if (Input.GetKeyUp (KeyCode.W)) { timeExp = 0.0f; } - if (Input.GetKey (KeyCode.DownArrow) && accTime > (timeStep-timeExp)) { + if (Input.GetKey (KeyCode.S) && accTime > (timeStep-timeExp)) { accTime -= (timeStep - timeExp); if (timeExp < timeExpLimit) timeExp += timeExpStep; cursor.transform.Translate (0, -1f, 0); - } else if (Input.GetKeyUp (KeyCode.DownArrow)) { + } else if (Input.GetKeyUp (KeyCode.S)) { timeExp = 0.0f; } + if (Input.GetKeyUp (KeyCode.Space)) { + Vector2 tilePosition = cursor.transform.position; + //Obtener GameObject de la matriz luego extraer sus funciones + //Mostrar opciones y elegir una + //Ejecutar acción + //Profit + } if (actualNumFinishedChars == actualNumChars) { changeTeam ((actualPlayer + 1) % playerNum); diff --git a/Assets/UnitCreator.cs b/Assets/UnitCreator.cs index 9046d4a..e8deef9 100644 --- a/Assets/UnitCreator.cs +++ b/Assets/UnitCreator.cs @@ -7,6 +7,7 @@ public class UnitCreator : MonoBehaviour { public GameObject lichObject; public GameObject skeletonObject; public List units; + public Vector2 mapSize; private UnitBehaviour playerLichScript; @@ -18,8 +19,13 @@ public class UnitCreator : MonoBehaviour { // Use this for initialization void Start () { - units = new List (); + 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 @@ -35,27 +41,31 @@ 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.Add (unit); + units.Insert(posX*(int)mapSize.x*posZ, unit); if (team == UnitBehaviour.Team.Player && playerLichScript == null ) playerLichScript = unit.GetComponent (); } else if (type == UnitType.Skeleton) { - unit = Instantiate (skeletonObject, new Vector3(posX, skeletonObject.transform.lossyScale/2f, posZ), Quaternion.identity) as GameObject; - unit.transform.localScale = new Vector3 (unit.transform.lossyScale.x/unit.transform.lossyScale.y, 1, unit.transform.lossyScale.z/unit.transform.lossyScale.y); + 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); + if (team == UnitBehaviour.Team.Enemy1) { unit.transform.Rotate (new Vector3 (0, 180, 0)); } - units.Add (unit); + //units.Add (unit); } + } + public List tutorialUnits() { createUnit (9, 5, UnitBehaviour.Team.Player, UnitType.Lich); - + createUnit (8, 7, UnitBehaviour.Team.Player); createUnit (10, 7, UnitBehaviour.Team.Player);