Unfinished enemy instantiation

This commit is contained in:
vylion 2016-10-29 06:31:39 +02:00
parent 8718b8ca24
commit 10eff32373
4 changed files with 51 additions and 12 deletions

View file

@ -34,6 +34,7 @@ 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 ();
} }
// Update is called once per frame // Update is called once per frame

View file

@ -8,7 +8,7 @@ public class UnitCreator : MonoBehaviour {
public GameObject skeletonObject; public GameObject skeletonObject;
public List<GameObject> units; public List<GameObject> units;
private UnitBehaviour script; private UnitBehaviour playerLichScript;
public enum UnitType { public enum UnitType {
Lich = 0, Lich = 0,
@ -19,7 +19,7 @@ public class UnitCreator : MonoBehaviour {
// Use this for initialization // Use this for initialization
void Start () { void Start () {
units = new List<GameObject> (); units = new List<GameObject> ();
script = null; playerLichScript = null;
} }
// Update is called once per frame // Update is called once per frame
@ -28,19 +28,28 @@ 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 lich; GameObject unit;
if (type == UnitType.Lich) { if (type == UnitType.Lich) {
lich = Instantiate (lichObject, new Vector3(posX, 0, posZ), Quaternion.identity) as GameObject; unit = Instantiate (lichObject, new Vector3(posX, lichObject.transform.lossyScale.y/2f, posZ), Quaternion.identity) as GameObject;
lich.GetComponent<UnitBehaviour> ().SetupStats (posX, posZ, 3, 3, 100, 0, 0, 0); unit.transform.localScale = new Vector3 (unit.transform.lossyScale.y/unit.transform.lossyScale.y, 1, unit.transform.lossyScale.z/unit.transform.lossyScale.y);
lich.GetComponent<UnitBehaviour> ().SetupBaseAttack (4, 2, 3); unit.GetComponent<UnitBehaviour> ().SetupStats (posX, posZ, 3, 3, 100, 0, 0, 0);
unit.GetComponent<UnitBehaviour> ().SetupBaseAttack (4, 2, 3);
units.Add (unit);
if (team == UnitBehaviour.Team.Player && playerLichScript == null )
playerLichScript = unit.GetComponent<UnitBehaviour> ();
if (team == UnitBehaviour.Team.Player && script == null )
script = lich.GetComponent<UnitBehaviour> ();
} else if (type == UnitType.Skeleton) { } else if (type == UnitType.Skeleton) {
GameObject skeleton; unit = Instantiate (skeletonObject, new Vector3(posX, skeletonObject.transform.lossyScale/2f, posZ), Quaternion.identity) as GameObject;
skeleton = Instantiate (skeletonObject, new Vector3(posX, 0, 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);
units.Add (skeleton); unit.GetComponent<UnitBehaviour> ().SetupStats (posX, posZ);
if (team == UnitBehaviour.Team.Enemy1) {
unit.transform.Rotate (new Vector3 (0, 180, 0));
}
units.Add (unit);
} }
} }

View file

@ -117,6 +117,7 @@ GameObject:
m_Component: m_Component:
- 4: {fileID: 495872} - 4: {fileID: 495872}
- 111: {fileID: 11195950} - 111: {fileID: 11195950}
- 114: {fileID: 114000012057328986}
m_Layer: 0 m_Layer: 0
m_Name: SKELETON m_Name: SKELETON
m_TagString: Untagged m_TagString: Untagged
@ -1321,3 +1322,31 @@ Prefab:
m_ParentPrefab: {fileID: 0} m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 137098} m_RootGameObject: {fileID: 137098}
m_IsPrefabParent: 1 m_IsPrefabParent: 1
--- !u!114 &114000012057328986
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 137098}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f685a25083417604590f9afdb346f66f, type: 3}
m_Name:
m_EditorClassIdentifier:
actionsPerTurn: 2
remainingActions: 0
stepLength: 5
precision: 50
critChance: 10
health: 4
armour: 0
mana: 0
element: 0
teamID: 1
posX: 0
posZ: 0
attackRange: 1
attackArea: 1
attackDamage: 1
attackActions: 2
attackElem: 0

View file

@ -52,5 +52,5 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
lichObject: {fileID: 1000013980076266, guid: 055ce9e83be0bd140a3e7aa52d871817, type: 2} lichObject: {fileID: 1000013980076266, guid: 055ce9e83be0bd140a3e7aa52d871817, type: 2}
skeletonObject: {fileID: 0} skeletonObject: {fileID: 137098, guid: c7e8a5bb79537a441836a1e2ea02a005, type: 2}
units: [] units: []