Created different unit lists by map position and team
This commit is contained in:
parent
e15dbc9182
commit
6d8fc52d3b
4 changed files with 58 additions and 33 deletions
|
@ -37,7 +37,9 @@ public class Generator : MonoBehaviour {
|
||||||
map [10, 20] = -1;
|
map [10, 20] = -1;
|
||||||
mScript.setMatrix (map, x, y);
|
mScript.setMatrix (map, x, y);
|
||||||
|
|
||||||
turnMan.GetComponent<TurnManagerScript> ().charMap = uScript.tutorialUnits (x, y);
|
uScript.tutorialUnits ();
|
||||||
|
turnMan.GetComponent<TurnManagerScript> ().charMap = uScript.getUnitMap ();
|
||||||
|
turnMan.GetComponent<TurnManagerScript> ().charList = uScript.getUnitLists ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class TurnManagerScript : MonoBehaviour {
|
||||||
public int playerNum = 2;
|
public int playerNum = 2;
|
||||||
public int iaNum = 0;
|
public int iaNum = 0;
|
||||||
public bool inTurn = true;
|
public bool inTurn = true;
|
||||||
//public List<List<GameObject> > charList;
|
public List<List<GameObject> > charList;
|
||||||
|
|
||||||
public List<int> terrain;
|
public List<int> terrain;
|
||||||
public List<GameObject> charMap;
|
public List<GameObject> charMap;
|
||||||
|
|
|
@ -38,9 +38,10 @@ public class UnitBehaviour : MonoBehaviour {
|
||||||
public int attackActions = 2;
|
public int attackActions = 2;
|
||||||
public Elemental attackElem = Elemental.None;
|
public Elemental attackElem = Elemental.None;
|
||||||
|
|
||||||
public void SetupStats (int pX, int pZ, int actions = 2, int steps = 5, int p = 50, int crit = 10, int pRange = 20, int critRange = 10) {
|
public void SetupStats (int pX, int pZ, Team id, int actions = 2, int steps = 5, int p = 50, int crit = 10, int pRange = 20, int critRange = 10) {
|
||||||
posX = pX;
|
posX = pX;
|
||||||
posZ = pZ;
|
posZ = pZ;
|
||||||
|
teamID = id;
|
||||||
actionsPerTurn = actions;
|
actionsPerTurn = actions;
|
||||||
stepLength = steps;
|
stepLength = steps;
|
||||||
if (pRange > 0) {
|
if (pRange > 0) {
|
||||||
|
|
|
@ -6,10 +6,14 @@ public class UnitCreator : MonoBehaviour {
|
||||||
|
|
||||||
public GameObject lichObject;
|
public GameObject lichObject;
|
||||||
public GameObject skeletonObject;
|
public GameObject skeletonObject;
|
||||||
public List<GameObject> units;
|
public List<GameObject> unitsByMap;
|
||||||
public Vector2 mapSize;
|
public Vector2 mapSize;
|
||||||
|
public List<List<GameObject>> unitsByTeam;
|
||||||
|
|
||||||
private UnitBehaviour playerLichScript;
|
private UnitBehaviour playerLichScript;
|
||||||
|
private List<GameObject> teamNone;
|
||||||
|
private List<GameObject> teamPlayer;
|
||||||
|
private List<GameObject> teamEnemy1;
|
||||||
|
|
||||||
public enum UnitType {
|
public enum UnitType {
|
||||||
Lich = 0,
|
Lich = 0,
|
||||||
|
@ -30,14 +34,14 @@ public class UnitCreator : MonoBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
void createUnit(int posX, int posZ, UnitBehaviour.Team team, UnitType type = UnitType.Skeleton) {
|
void createUnit(int posX, int posZ, UnitBehaviour.Team team, UnitType type = UnitType.Skeleton) {
|
||||||
GameObject unit;
|
GameObject unit = null;
|
||||||
|
|
||||||
if (type == UnitType.Lich) {
|
if (type == UnitType.Lich) {
|
||||||
unit = Instantiate (lichObject, new Vector3(posX, lichObject.transform.lossyScale.y/2f, posZ), Quaternion.identity) as GameObject;
|
unit = Instantiate (lichObject, new Vector3(posX, lichObject.transform.lossyScale.y/2f, posZ), Quaternion.identity) as GameObject;
|
||||||
unit.transform.localScale = new Vector3 (unit.transform.lossyScale.y/unit.transform.lossyScale.y, 1, unit.transform.lossyScale.z/unit.transform.lossyScale.y);
|
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> ().SetupStats (posX, posZ, team, 3, 3, 100, 0, 0, 0);
|
||||||
unit.GetComponent<UnitBehaviour> ().SetupBaseAttack (4, 2, 3);
|
unit.GetComponent<UnitBehaviour> ().SetupBaseAttack (4, 2, 3);
|
||||||
units.Insert(posX*(int)mapSize.x+posZ, unit);
|
unitsByMap.Insert(posX*(int)mapSize.x+posZ, unit);
|
||||||
|
|
||||||
if (team == UnitBehaviour.Team.Player && playerLichScript == null )
|
if (team == UnitBehaviour.Team.Player && playerLichScript == null )
|
||||||
playerLichScript = unit.GetComponent<UnitBehaviour> ();
|
playerLichScript = unit.GetComponent<UnitBehaviour> ();
|
||||||
|
@ -45,28 +49,37 @@ public class UnitCreator : MonoBehaviour {
|
||||||
} else if (type == UnitType.Skeleton) {
|
} else if (type == UnitType.Skeleton) {
|
||||||
unit = Instantiate (skeletonObject, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
|
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.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);
|
unit.GetComponent<UnitBehaviour> ().SetupStats (posX, posZ, team);
|
||||||
units.Insert(posX*(int)mapSize.x+posZ, unit);
|
unitsByMap.Insert(posX*(int)mapSize.x+posZ, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (team == UnitBehaviour.Team.Player) {
|
||||||
if (team == UnitBehaviour.Team.Enemy1) {
|
teamPlayer.Add (unit);
|
||||||
|
} else if (team == UnitBehaviour.Team.Enemy1) {
|
||||||
unit.transform.Rotate (new Vector3 (0, 180, 0));
|
unit.transform.Rotate (new Vector3 (0, 180, 0));
|
||||||
|
teamEnemy1.Add (unit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//units.Add (unit);
|
void setMap(int x, int y) {
|
||||||
}
|
unitsByMap = new List<GameObject>(x * y);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<GameObject> tutorialUnits(int x, int y) {
|
|
||||||
units = new List<GameObject>(x * y);
|
|
||||||
for (int i = 0; i < y; i++) {
|
for (int i = 0; i < y; i++) {
|
||||||
for (int j = 0; j < x; j++) {
|
for (int j = 0; j < x; j++) {
|
||||||
units.Insert(i * x + j, null);
|
unitsByMap.Insert(i * x + j, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unitsByTeam = new List<List<GameObject>> ();
|
||||||
|
|
||||||
|
teamNone = new List<GameObject> ();
|
||||||
|
teamPlayer = new List<GameObject> ();
|
||||||
|
teamEnemy1 = new List<GameObject> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void tutorialUnits() {
|
||||||
|
setMap (20, 40);
|
||||||
|
|
||||||
createUnit (9, 5, UnitBehaviour.Team.Player, UnitType.Lich);
|
createUnit (9, 5, UnitBehaviour.Team.Player, UnitType.Lich);
|
||||||
|
|
||||||
createUnit (8, 7, UnitBehaviour.Team.Player);
|
createUnit (8, 7, UnitBehaviour.Team.Player);
|
||||||
|
@ -84,6 +97,15 @@ public class UnitCreator : MonoBehaviour {
|
||||||
createUnit (16, 24, UnitBehaviour.Team.Enemy1);
|
createUnit (16, 24, UnitBehaviour.Team.Enemy1);
|
||||||
createUnit (17, 26, UnitBehaviour.Team.Enemy1);
|
createUnit (17, 26, UnitBehaviour.Team.Enemy1);
|
||||||
|
|
||||||
return units;
|
unitsByTeam.Add (teamPlayer);
|
||||||
|
unitsByTeam.Add (teamEnemy1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<List<GameObject>> getUnitLists() {
|
||||||
|
return unitsByTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GameObject> getUnitMap() {
|
||||||
|
return unitsByMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue