diff --git a/Assets/InputManagerScript.cs b/Assets/InputManagerScript.cs index cbcd7dd..23e0655 100644 --- a/Assets/InputManagerScript.cs +++ b/Assets/InputManagerScript.cs @@ -92,7 +92,7 @@ public class InputManagerScript : MonoBehaviour { unitSelected = true; showActions = true; actualImage = 0; - actionOption = 0; + actionOption = -1; GameObject canv = GameObject.Find ("Canvas"); images [0] = Instantiate (imageAttack); images[0].transform.SetParent (canv.transform, false); @@ -142,7 +142,7 @@ public class InputManagerScript : MonoBehaviour { actionSelected = false; gosel = null; - actionOption = 0; + actionOption = -1; selectTargetPos = false; @@ -172,7 +172,7 @@ public class InputManagerScript : MonoBehaviour { } - if (Input.GetKeyUp (KeyCode.Space) && actionOption != -1) { + if (Input.GetKeyUp (KeyCode.Space) && actionOption > -1) { selectTargetPos = false; actionSelected = true; unitSelected = false; diff --git a/Assets/TurnManagerScript.cs b/Assets/TurnManagerScript.cs index fbd517a..ae3447f 100644 --- a/Assets/TurnManagerScript.cs +++ b/Assets/TurnManagerScript.cs @@ -71,6 +71,7 @@ public class TurnManagerScript : MonoBehaviour { int pi = (int)go.transform.position.z; int pj = (int)go.transform.position.x; Vector2 diff = new Vector2(Math.Abs(pi - i), Math.Abs(pj - j)); + if ((diff.x+diff.y) < ub.stepLength && ra > 0 && terrain [j, i] == 0) return true; else @@ -96,6 +97,15 @@ public class TurnManagerScript : MonoBehaviour { } public void attackTo(GameObject go, int i, int j) { + int area = go.GetComponent ().attackArea; + + if (area > 1) + attackToArea (go, i, j); + else + attackToSingleTarget (go, i, j); + } + + void attackToSingleTarget(GameObject go, int i, int j) { UnitBehaviour ub = go.GetComponent (); int pi = (int)go.transform.position.z; int pj = (int)go.transform.position.x; @@ -107,8 +117,26 @@ public class TurnManagerScript : MonoBehaviour { ubt.receiveDamage (damage); } } + + void attackToArea(GameObject go, int x, int y) { + UnitBehaviour ub = go.GetComponent (); + int pi = (int)go.transform.position.z; + int pj = (int)go.transform.position.x; + int area = ub.attackArea; - public void changeTeam (int newTeam) { + for (int i = -area; i <= area; i++) { + for (int j = -area; j <= area; j++) { + if (x+i >= 0 && y+j >= 0 && unitMap [x+i, y+j] != null) { + GameObject t = unitMap [x+i, y+j]; + UnitBehaviour ubt = t.GetComponent (); + int damage = ub.attackAct (); + ubt.receiveDamage (damage); + } + } + } + } + + void changeTeam (int newTeam) { actualPlayer = newTeam; actualNumChars = unitList [actualPlayer].Count; actualNumFinishedChars = 0; diff --git a/Assets/UnitBehaviour.cs b/Assets/UnitBehaviour.cs index bdd26fb..ebe4c0a 100644 --- a/Assets/UnitBehaviour.cs +++ b/Assets/UnitBehaviour.cs @@ -49,10 +49,11 @@ public class UnitBehaviour : MonoBehaviour { public Animator anim; - 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) { + public void SetupStats (int pX, int pZ, Team id, int h = 4, int p = 50, int crit = 10, int pRange = 20, int critRange = 10, int steps = 5, int actions = 2) { posX = pX; posZ = pZ; teamID = id; + health = h; actionsPerTurn = actions; stepLength = steps; if (pRange > 0) { @@ -72,7 +73,7 @@ public class UnitBehaviour : MonoBehaviour { remainingActions = actionsPerTurn; } - public void SetupBaseAttack (int r = 1, int a = 1, int d = 1, Elemental e = Elemental.None, int act = 2) { + public void SetupBaseAttack (int r = 1, int d = 1, int a = 1, int act = 2, Elemental e = Elemental.None) { attackRange = r; attackArea = a; attackDamage = d; diff --git a/Assets/UnitCreator.cs b/Assets/UnitCreator.cs index 571b0df..43542a9 100644 --- a/Assets/UnitCreator.cs +++ b/Assets/UnitCreator.cs @@ -68,8 +68,8 @@ public class UnitCreator : MonoBehaviour { else unit = Instantiate (lichNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject; - unit.GetComponent ().SetupStats (posX, posZ, team, 3, 3, 100, 0, 0, 0); - unit.GetComponent ().SetupBaseAttack (4, 2, 3); + unit.GetComponent ().SetupStats (posX, posZ, team, 10, 100, 0, 0, 0, 3, 3); + unit.GetComponent ().SetupBaseAttack (4, 3, 2); unit.transform.localScale = new Vector3 (unit.transform.localScale.x*0.3f, unit.transform.localScale.y*0.3f, unit.transform.localScale.z*0.3f); if (team == UnitBehaviour.Team.Player && playerLichScript == null ) @@ -93,8 +93,9 @@ public class UnitCreator : MonoBehaviour { unit = Instantiate (archerRed, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject; else unit = Instantiate (archerNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject; - - unit.GetComponent ().SetupStats (posX, posZ, team); + + unit.GetComponent ().SetupStats (posX, posZ, team, 2, 80, 10, 15, 5, 7, 1); + unit.GetComponent ().SetupBaseAttack (5, 2); } else if (type == UnitType.Imp) { if (team == UnitBehaviour.Team.Player) @@ -104,7 +105,7 @@ public class UnitCreator : MonoBehaviour { else unit = Instantiate (impNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject; - unit.GetComponent ().SetupStats (posX, posZ, team); + unit.GetComponent ().SetupStats (posX, posZ, team, 2, 30, 10, 30, 15, 10, 2); } else if (type == UnitType.Zombie) { if (team == UnitBehaviour.Team.Player)