Created attack to area
This commit is contained in:
parent
db2748b12f
commit
f82b807406
5 changed files with 55 additions and 7 deletions
9
Assets/3rdParty/ArcherSkeleton/prefab.meta
vendored
Normal file
9
Assets/3rdParty/ArcherSkeleton/prefab.meta
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 456228f09d87f2c4a9df7b9ef04226bc
|
||||
folderAsset: yes
|
||||
timeCreated: 1477752003
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/3rdParty/DemonImp/prefab.meta
vendored
Normal file
9
Assets/3rdParty/DemonImp/prefab.meta
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f69e4ae1ab31a7b429d8d29157ff18a8
|
||||
folderAsset: yes
|
||||
timeCreated: 1477757782
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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<UnitBehaviour> ().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<UnitBehaviour> ();
|
||||
int pi = (int)go.transform.position.z;
|
||||
int pj = (int)go.transform.position.x;
|
||||
|
@ -108,6 +118,24 @@ public class TurnManagerScript : MonoBehaviour {
|
|||
}
|
||||
}
|
||||
|
||||
void attackToArea(GameObject go, int x, int y) {
|
||||
UnitBehaviour ub = go.GetComponent<UnitBehaviour> ();
|
||||
int pi = (int)go.transform.position.z;
|
||||
int pj = (int)go.transform.position.x;
|
||||
int area = ub.attackArea;
|
||||
|
||||
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<UnitBehaviour> ();
|
||||
int damage = ub.attackAct ();
|
||||
ubt.receiveDamage (damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void changeTeam (int newTeam) {
|
||||
actualPlayer = newTeam;
|
||||
actualNumChars = unitList [actualPlayer].Count;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -68,8 +68,8 @@ public class UnitCreator : MonoBehaviour {
|
|||
else
|
||||
unit = Instantiate (lichNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
|
||||
|
||||
unit.GetComponent<UnitBehaviour> ().SetupStats (posX, posZ, team, 3, 3, 100, 0, 0, 0);
|
||||
unit.GetComponent<UnitBehaviour> ().SetupBaseAttack (4, 2, 3);
|
||||
unit.GetComponent<UnitBehaviour> ().SetupStats (posX, posZ, team, 10, 100, 0, 0, 0, 3, 3);
|
||||
unit.GetComponent<UnitBehaviour> ().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 )
|
||||
|
@ -94,7 +94,8 @@ public class UnitCreator : MonoBehaviour {
|
|||
else
|
||||
unit = Instantiate (archerNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
|
||||
|
||||
unit.GetComponent<UnitBehaviour> ().SetupStats (posX, posZ, team);
|
||||
unit.GetComponent<UnitBehaviour> ().SetupStats (posX, posZ, team, 2, 80, 10, 15, 5, 7, 1);
|
||||
unit.GetComponent<UnitBehaviour> ().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<UnitBehaviour> ().SetupStats (posX, posZ, team);
|
||||
unit.GetComponent<UnitBehaviour> ().SetupStats (posX, posZ, team, 2, 30, 10, 30, 15, 10, 2);
|
||||
|
||||
} else if (type == UnitType.Zombie) {
|
||||
if (team == UnitBehaviour.Team.Player)
|
||||
|
|
Loading…
Reference in a new issue