This commit is contained in:
falc@null.net 2016-10-29 10:29:31 +02:00
parent 29bcb027db
commit 26b2fb2f93
3 changed files with 37 additions and 17 deletions

View file

@ -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<TurnManagerScript>();
mScript = mapCreator.GetComponent<MapCreation>();
uScript = unitCreator.GetComponent<UnitCreator>();
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)

View file

@ -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);

View file

@ -7,6 +7,7 @@ public class UnitCreator : MonoBehaviour {
public GameObject lichObject;
public GameObject skeletonObject;
public List<GameObject> units;
public Vector2 mapSize;
private UnitBehaviour playerLichScript;
@ -18,8 +19,13 @@ public class UnitCreator : MonoBehaviour {
// Use this for initialization
void Start () {
units = new List<GameObject> ();
units = new List<GameObject>((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,24 +41,28 @@ 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<UnitBehaviour> ().SetupStats (posX, posZ, 3, 3, 100, 0, 0, 0);
unit.GetComponent<UnitBehaviour> ().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<UnitBehaviour> ();
} 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<UnitBehaviour> ().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<GameObject> tutorialUnits() {
createUnit (9, 5, UnitBehaviour.Team.Player, UnitType.Lich);