Loading my shit

This commit is contained in:
falc@null.net 2016-10-30 13:57:48 +01:00
parent de7c915b86
commit 05a85ad006
13 changed files with 332 additions and 39 deletions

View file

@ -717,6 +717,7 @@ GameObject:
m_Component:
- 4: {fileID: 400094}
- 111: {fileID: 11100000}
- 114: {fileID: 114000010571928154}
m_Layer: 0
m_Name: Necromancer
m_TagString: Untagged
@ -1553,3 +1554,31 @@ Prefab:
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 100094}
m_IsPrefabParent: 1
--- !u!114 &114000010571928154
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100094}
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

@ -0,0 +1,19 @@
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject target;
private Vector3 offset;
// Use this for initialization
void Start () {
offset = transform.position - target.transform.position;
}
// Update is called once per frame
void LateUpdate () {
transform.position = target.transform.position + offset;
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8048a3f7e275fe54da2db471e3e80fb3
timeCreated: 1477827774
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -19,7 +19,7 @@ GameObject:
serializedVersion: 4
m_Component:
- 4: {fileID: 4000011966173314}
- 114: {fileID: 114000011647515354}
- 114: {fileID: 114000011525832052}
m_Layer: 0
m_Name: FloorCreator
m_TagString: Untagged
@ -40,7 +40,7 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!114 &114000011647515354
--- !u!114 &114000011525832052
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
@ -51,8 +51,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6f9a0bb9550360146929761331442cb6, type: 3}
m_Name:
m_EditorClassIdentifier:
vs: 20
hs: 40
basic_floor: {fileID: 1000011495271182, guid: a6d57f8cc0baf3545873654c3ae25492,
type: 2}
nhabitable_floor: {fileID: 1000013422381662, guid: f3b3de213fb3e0a4d9040dc4745e6303,

View file

@ -44,7 +44,10 @@ public class Generator : MonoBehaviour {
uScript.tutorialUnits ();
turnMan.GetComponent<TurnManagerScript> ().unitMap = uScript.getUnitMap ();
turnMan.GetComponent<TurnManagerScript> ().unitList = uScript.getUnitLists ();
tScript.mapSize = new Vector2 (20, 40);
tScript.terrain = map;
inputMan.GetComponent<InputManagerScript> ().setTurnMan(tScript);
}
// Update is called once per frame

View file

@ -36,7 +36,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012666769054}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 1.5, y: 1.5, z: 1.5}
m_LocalPosition: {x: 1, y: 1.5, z: 1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
m_Children: []
@ -92,10 +92,10 @@ Light:
m_Enabled: 1
serializedVersion: 7
m_Type: 0
m_Color: {r: 0.36445722, g: 0.7692899, b: 0.78676474, a: 1}
m_Color: {r: 0, g: 1, b: 1, a: 1}
m_Intensity: 1
m_Range: 90
m_SpotAngle: 50
m_SpotAngle: 45
m_CookieSize: 10
m_Shadows:
m_Type: 0

View file

@ -51,3 +51,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e30eb79cd423fd04691b1402c8e578ef, type: 3}
m_Name:
m_EditorClassIdentifier:
image_move: {fileID: 114000013716489878, guid: d80ae4a7a1bea5d48b549fbf1ef3f3f5,
type: 2}
image_attack: {fileID: 114000012902201940, guid: 8b74ce38e76531b42a1b0af65416b73a,
type: 2}

View file

@ -4,7 +4,7 @@ using UnityEngine.UI;
public class InputManagerScript : MonoBehaviour {
public GameObject cursor;
private GameObject cursor;
public Image image_move;
public Image image_attack;
@ -18,8 +18,10 @@ public class InputManagerScript : MonoBehaviour {
private bool unitSelected;
private bool showActions;
private bool actionSelected;
private bool selectTargetPos;
private Image i1;
private Image i2;
private GameObject gosel;
private int actionOption;
@ -27,18 +29,20 @@ public class InputManagerScript : MonoBehaviour {
// Use this for initialization
void Start () {
timeStep = 0.3f;
timeStep = 0.75f;
timeExp = 0.0f;
timeExpStep = 0.02f;
timeExpLimit = 0.15f;
timeExpStep = 0.05f;
timeExpLimit = 0.1f;
cursor = Instantiate (cursor, new Vector3 (1.0f, 1.5f, 1.0f), Quaternion.identity) as GameObject;
cursor.transform.Rotate (new Vector3(90, 0, 0));
cursor = GameObject.Find ("Cursor");
//cursor.transform.Rotate (new Vector3(90, 0, 0));
unitSelected = false;
showActions = false;
actionOption = -1;
actionSelected = false;
selectTargetPos = false;
gosel = null;
}
// Update is called once per frame
@ -92,51 +96,99 @@ public class InputManagerScript : MonoBehaviour {
}
if (Input.GetKeyUp(KeyCode.Space) && !unitSelected) {
if (Input.GetKeyUp(KeyCode.Space) && !unitSelected && !actionSelected) {
Vector3 tilePosition = cursor.transform.position;
int ipos = (int)tilePosition.z;
int jpos = (int)tilePosition.x;
GameObject c = tmss.getUnitAtTile(ipos, jpos);
//UnitBehaviour ub = c.GetComponent<UnitBehaviour> ();
if (c != null) {
unitSelected = true;
showActions = true;
GameObject canv = GameObject.Find ("Canvas");
i1 = Instantiate (image_move);
i1.transform.SetParent (canv.transform, false);
i2 = Instantiate (image_attack);
i2.transform.SetParent (canv.transform, false);
UnitBehaviour ub = c.GetComponent<UnitBehaviour> ();
UnitBehaviour.Team mahteam = (UnitBehaviour.Team) tmss.actualPlayer;
if (ub.teamID == UnitBehaviour.Team.Player && ub.remainingActions != 0) {
gosel = c;
unitSelected = true;
showActions = true;
GameObject canv = GameObject.Find ("Canvas");
i1 = Instantiate (image_move);
i1.transform.SetParent (canv.transform, false);
i2 = Instantiate (image_attack);
i2.transform.SetParent (canv.transform, false);
} else {
changeCursorColor (Color.red);
}
}
}
if (actionSelected) {
if (Input.GetKeyUp (KeyCode.Escape)) {
actionSelected = false;
changeCursorColor (Color.cyan);
}
if (Input.GetKeyUp (KeyCode.Space) && !selectTargetPos) {
switch (actionOption) {
case 0:
break;
case 1:
Vector3 tpos = cursor.transform.position;
if (tmss.canMoveTo (gosel, (int)tpos.z, (int)tpos.x)) {
tmss.moveTo (gosel, (int)tpos.z, (int)tpos.x);
changeCursorColor (Color.cyan);
} else {
changeCursorColor (Color.red);
}
break;
default:
break;
}
actionSelected = false;
gosel = null;
actionOption = -1;
selectTargetPos = false;
}
}
if (unitSelected) {
if (Input.GetKeyUp (KeyCode.D)) {
Color lol = i1.color;
i1.color = new Color (1f, 0f, 0f);
i2.color = new Color (1f, 1f, 1f);
actionOption = 1;
} else if (Input.GetKeyUp (KeyCode.A)) {
}
if (Input.GetKeyUp (KeyCode.A)) {
i2.color = new Color (1f, 0f, 0f);
i1.color = new Color (1f, 1f, 1f);
actionOption = 0;
} else if (Input.GetKeyUp (KeyCode.Space) && actionOption > -1) {
}
if (Input.GetKeyUp (KeyCode.Space) && actionOption > -1) {
selectTargetPos = false;
actionSelected = true;
unitSelected = false;
showActions = false;
DestroyObject (i1);
DestroyObject (i2);
changeCursorColor(new Color(1,1,0));
}
}
if (actionSelected) {
}
}
public void setTurnMan(TurnManagerScript tms) {
tmss = tms;
}
private void changeCursorColor(Color c) {
Light li = cursor.GetComponent<Light> () as Light;
li.color = c;
}
}

View file

@ -1,10 +1,14 @@
fileFormatVersion: 2
guid: 6f9a0bb9550360146929761331442cb6
timeCreated: 1477706051
timeCreated: 1477751396
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
defaultReferences:
- basic_floor: {fileID: 1000011495271182, guid: a6d57f8cc0baf3545873654c3ae25492,
type: 2}
- nhabitable_floor: {fileID: 1000013422381662, guid: f3b3de213fb3e0a4d9040dc4745e6303,
type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -4,6 +4,20 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
public struct direction {
public int x;
public int y;
}
public struct position {
public int row;
public int column;
public position(int r, int c) {
this.row = r;
this.column = c;
}
}
public class TurnManagerScript : MonoBehaviour {
public int turnNum = 0;
@ -12,16 +26,14 @@ public class TurnManagerScript : MonoBehaviour {
public bool inTurn = true;
public List<List<GameObject> > unitList;
public List<int> terrain;
public int[,] terrain;
public GameObject[,] unitMap;
public Vector2 mapSize;
private int actualPlayer;
public int actualPlayer;
private int actualNumChars;
private int actualNumFinishedChars;
// Use this for initialization
void Start () {
@ -38,7 +50,6 @@ public class TurnManagerScript : MonoBehaviour {
// Update is called once per frame
void Update () {
if (actualNumFinishedChars == actualNumChars) {
changeTeam ((actualPlayer + 1) % playerNum);
}
@ -58,6 +69,34 @@ public class TurnManagerScript : MonoBehaviour {
}
public bool canMoveTo(GameObject go, int i, int j) {
UnitBehaviour ub = go.GetComponent<UnitBehaviour> ();
int ra = ub.remainingActions;
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
return false;
}
public void moveTo(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;
List<position> movement = getPathBFS (pi, pj, i, j);
//TODO: MOVEMENT
ub.moveAct ();
if (ub.remainingActions == 0)
actualNumFinishedChars += 1;
//Move the unit
go.transform.position = new Vector3 (j, 0, i);
//Update matrices
unitMap.SetValue(null, pi, pj);
unitMap.SetValue(go, i, j);
}
void changeTeam (int newTeam) {
actualPlayer = newTeam;
//actualNumChars = charList [actualPlayer].Count;
@ -68,6 +107,70 @@ public class TurnManagerScript : MonoBehaviour {
return unitMap [i, j];
}
private direction[] directions = {
new direction(){x = 1, y= 0},
new direction(){x = 0, y= 1},
new direction(){x = -1, y= 0},
new direction(){x = 0, y= -1}
};
public List<position> getPathBFS(int x, int y, int xx, int yy) {
int[,] map = new int[(int)mapSize.y, (int)mapSize.x];
int[,] road = new int[(int)mapSize.y, (int)mapSize.x*2];
position end;
end.row = yy;
end.column = xx;
position start;
start.row = y;
start.column = x;
map [start.row, start.column] = 0;
Queue<position> qp = new Queue<position> ();
qp.Enqueue (start);
while (qp.Count != 0) {
position p = qp.Dequeue();
position[] adj = {
new position (directions [0].y + p.row, directions [0].x + p.column),
new position (directions [1].y + p.row, directions [1].x + p.column),
new position (directions [2].y + p.row, directions [2].x + p.column),
new position (directions [3].y + p.row, directions [3].x + p.column)
};
for (int i = 0; i < 4; i++) {
position a = adj [i];
if (a.row >= 0 && a.row < mapSize.y && a.column >= 0 && a.column < mapSize.x) { // If not out of bounds
if(map[a.row,a.column] != -2){
if (terrain [a.row, a.column] != 0) {
if (map [a.row, a.column] > map [p.row, p.column] || map [a.row, a.column] == -1) {
qp.Enqueue (a);
map [a.row, a.column] = map [p.row, p.column] + 1;
road [a.row, a.column * 2] = p.row;
road [a.row, a.column * 2 + 1] = p.column;
}
} else {
map [a.row, a.column] = -2;
}
}
}
}
}
int e1 = end.row;
int e2 = end.column;
int t;
List<position> res = new List<position>();
while (map[e1,e2] != 0){
res.Add (new position (e1, e2));
t = e2;
e1 = road[t, e2*2];
e2 = road [t, (e2 * 2) + 1];
}
return res;
}
/*void OnGUI(){
if (showActions) {
GUI.Box (new Rect(0, 0, 100, 100), "Move");

View file

@ -95,7 +95,7 @@ public class UnitCreator : MonoBehaviour {
createUnit (8, 12, UnitBehaviour.Team.Enemy1);
createUnit (10, 12, UnitBehaviour.Team.Enemy1);
createUnit (8, 12, UnitBehaviour.Team.Enemy1);
createUnit (9, 13, UnitBehaviour.Team.Enemy1);
createUnit (5, 17, UnitBehaviour.Team.Enemy1);
createUnit (4, 18, UnitBehaviour.Team.Enemy1);
createUnit (5, 19, UnitBehaviour.Team.Enemy1);

View file

@ -152,6 +152,53 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
--- !u!1001 &201292958
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4000011097406802, guid: 5fe675c564d71cc44945f6ca7e09e827, type: 2}
propertyPath: m_LocalPosition.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4000011097406802, guid: 5fe675c564d71cc44945f6ca7e09e827, type: 2}
propertyPath: m_LocalPosition.y
value: 1.5
objectReference: {fileID: 0}
- target: {fileID: 4000011097406802, guid: 5fe675c564d71cc44945f6ca7e09e827, type: 2}
propertyPath: m_LocalPosition.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4000011097406802, guid: 5fe675c564d71cc44945f6ca7e09e827, type: 2}
propertyPath: m_LocalRotation.x
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4000011097406802, guid: 5fe675c564d71cc44945f6ca7e09e827, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4000011097406802, guid: 5fe675c564d71cc44945f6ca7e09e827, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4000011097406802, guid: 5fe675c564d71cc44945f6ca7e09e827, type: 2}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4000011097406802, guid: 5fe675c564d71cc44945f6ca7e09e827, type: 2}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 5fe675c564d71cc44945f6ca7e09e827, type: 2}
m_IsPrefabParent: 0
--- !u!1 &201292959 stripped
GameObject:
m_PrefabParentObject: {fileID: 1000012666769054, guid: 5fe675c564d71cc44945f6ca7e09e827,
type: 2}
m_PrefabInternal: {fileID: 201292958}
--- !u!1 &798253252
GameObject:
m_ObjectHideFlags: 0
@ -182,6 +229,7 @@ MonoBehaviour:
tmanager: {fileID: 1000011212613648, guid: 0193d92a24b3bc94aad43f1f8c93643b, type: 2}
mcreator: {fileID: 1000013182272914, guid: bd3068e9944aae447a20ec5f0a4784be, type: 2}
ucreator: {fileID: 1000012081215776, guid: afbffbb7b9d986345b62d4e4b7969551, type: 2}
imanager: {fileID: 1000013132162768, guid: c25c1548ba0651c429c11b0a9718bda8, type: 2}
--- !u!4 &798253254
Transform:
m_ObjectHideFlags: 0
@ -366,6 +414,7 @@ GameObject:
- 124: {fileID: 1724536060}
- 92: {fileID: 1724536059}
- 81: {fileID: 1724536058}
- 114: {fileID: 1724536062}
m_Layer: 0
m_Name: Camera
m_TagString: Untagged
@ -381,7 +430,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1724536056}
m_LocalRotation: {x: 0.38268343, y: 0, z: 0, w: 0.92387956}
m_LocalPosition: {x: 5, y: 5, z: 5.500001}
m_LocalPosition: {x: 0, y: 5, z: -2}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0}
m_Children:
@ -447,3 +496,15 @@ Camera:
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!114 &1724536062
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1724536056}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8048a3f7e275fe54da2db471e3e80fb3, type: 3}
m_Name:
m_EditorClassIdentifier:
target: {fileID: 201292959}

View file

@ -51,6 +51,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 13406b49a56381848a308c08e10f47dc, type: 3}
m_Name:
m_EditorClassIdentifier:
lichObject: {fileID: 1000013980076266, guid: 055ce9e83be0bd140a3e7aa52d871817, type: 2}
skeletonObject: {fileID: 137098, guid: c7e8a5bb79537a441836a1e2ea02a005, type: 2}
units: []
lichObject: {fileID: 100094, guid: 8b79114391319fb4bb56f64adb410eff, type: 2}
skeletonNone: {fileID: 137098, guid: c7e8a5bb79537a441836a1e2ea02a005, type: 2}
skeletonCyan: {fileID: 1000010498988072, guid: 375da41ce925bd546a34e406f609940f,
type: 2}
skeletonPurple: {fileID: 1000013814300192, guid: 4a967e9e95914194f9e81682db6faa8d,
type: 2}
skeletonPuke: {fileID: 1000012859847482, guid: 626c21f3dab5f254f87b4318c94f3a1f,
type: 2}
skeletonRed: {fileID: 1000011928221278, guid: c140ab0aafcd6364ca9ce9132e4f837a,
type: 2}
mapSize: {x: 0, y: 0}