Ayyyyyyyy

This commit is contained in:
falc@null.net 2016-10-30 18:10:18 +01:00
parent 4a3a33ba19
commit b491a83afe
11 changed files with 70 additions and 195 deletions

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 456228f09d87f2c4a9df7b9ef04226bc
folderAsset: yes
timeCreated: 1477752003
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: f69e4ae1ab31a7b429d8d29157ff18a8
folderAsset: yes
timeCreated: 1477757782
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,57 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1000013182272914}
m_IsPrefabParent: 1
--- !u!1 &1000013182272914
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 4000011966173314}
- 114: {fileID: 114000011525832052}
m_Layer: 0
m_Name: FloorCreator
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4000011966173314
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013182272914}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.82340044, y: 3.3069942, z: -5.0329347}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!114 &114000011525832052
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013182272914}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6f9a0bb9550360146929761331442cb6, type: 3}
m_Name:
m_EditorClassIdentifier:
basic_floor: {fileID: 1000011495271182, guid: a6d57f8cc0baf3545873654c3ae25492,
type: 2}
nhabitable_floor: {fileID: 1000013422381662, guid: f3b3de213fb3e0a4d9040dc4745e6303,
type: 2}

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: bd3068e9944aae447a20ec5f0a4784be
timeCreated: 1477758385
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -39,7 +39,7 @@ public class Generator : MonoBehaviour {
//just to test //just to test
map [10, 10] = -1; map [10, 10] = -1;
map [10, 20] = -1; map [10, 20] = -1;
mScript.setMatrix (map, x, y); mScript.setMatrix (map, x, y, new Vector3 (45, -45, 0), 0.8f, Color.white);
uScript.tutorialUnits (); uScript.tutorialUnits ();
turnMan.GetComponent<TurnManagerScript> ().unitMap = uScript.getUnitMap (); turnMan.GetComponent<TurnManagerScript> ().unitMap = uScript.getUnitMap ();

View file

@ -1,12 +1,12 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4828dbfa7343efb49b36490a44cb05d7 guid: 4828dbfa7343efb49b36490a44cb05d7
timeCreated: 1477835629 timeCreated: 1477842453
licenseType: Free licenseType: Free
MonoImporter: MonoImporter:
serializedVersion: 2 serializedVersion: 2
defaultReferences: defaultReferences:
- tmanager: {fileID: 1000011212613648, guid: 0193d92a24b3bc94aad43f1f8c93643b, type: 2} - tmanager: {fileID: 1000011212613648, guid: 0193d92a24b3bc94aad43f1f8c93643b, type: 2}
- mcreator: {fileID: 1000013182272914, guid: bd3068e9944aae447a20ec5f0a4784be, type: 2} - mcreator: {fileID: 1000013182272914, guid: 9fe758e4b61ec0d4dbdd8b92521a6628, type: 2}
- ucreator: {fileID: 1000012081215776, guid: afbffbb7b9d986345b62d4e4b7969551, type: 2} - ucreator: {fileID: 1000012081215776, guid: afbffbb7b9d986345b62d4e4b7969551, type: 2}
- imanager: {fileID: 1000013024682154, guid: 85681a523e843e54895aa694f42139a4, type: 2} - imanager: {fileID: 1000013024682154, guid: 85681a523e843e54895aa694f42139a4, type: 2}
executionOrder: 0 executionOrder: 0

View file

@ -5,9 +5,9 @@ using UnityEngine.UI;
public class InputManagerScript : MonoBehaviour { public class InputManagerScript : MonoBehaviour {
private GameObject cursor; private GameObject cursor;
public Image image_move; public Image imageMove;
public Image image_attack; public Image imageAttack;
public Image imageEndTurn;
private float accTime; private float accTime;
private float timeStep; private float timeStep;
private float timeExp; private float timeExp;
@ -19,21 +19,18 @@ public class InputManagerScript : MonoBehaviour {
private bool showActions; private bool showActions;
private bool actionSelected; private bool actionSelected;
private bool selectTargetPos; private bool selectTargetPos;
private Image i1; private Image[] images;
private Image i2; private int actualImage;
private GameObject gosel; private GameObject gosel;
private int actionOption; private int actionOption;
private TurnManagerScript tmss; private TurnManagerScript tmss;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
timeStep = 0.75f;
timeExp = 0.0f;
timeExpStep = 0.05f;
timeExpLimit = 0.1f;
cursor = GameObject.Find ("Cursor"); cursor = GameObject.Find ("Cursor");
//cursor.transform.Rotate (new Vector3(90, 0, 0)); //cursor.transform.Rotate (new Vector3(90, 0, 0));
@ -43,56 +40,39 @@ public class InputManagerScript : MonoBehaviour {
actionSelected = false; actionSelected = false;
selectTargetPos = false; selectTargetPos = false;
gosel = null; gosel = null;
images = new Image[3];
actualImage = 0;
} }
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
accTime += Time.deltaTime;
if (!showActions) { if (!showActions) {
if (Input.GetKey (KeyCode.A) && accTime > (timeStep - timeExp)) { if (Input.GetKeyDown (KeyCode.A)) {
accTime -= (timeStep - timeExp);
if (timeExp < timeExpLimit)
timeExp += timeExpStep;
cursor.transform.Translate (-1f, 0, 0); cursor.transform.Translate (-1f, 0, 0);
} else if (Input.GetKeyUp (KeyCode.LeftArrow)) {
timeExp = 0.0f;
} }
if (Input.GetKey (KeyCode.D) && accTime > (timeStep - timeExp)) { if (Input.GetKeyDown (KeyCode.D)) {
accTime -= (timeStep - timeExp);
if (timeExp < timeExpLimit)
timeExp += timeExpStep;
cursor.transform.Translate (1f, 0, 0); cursor.transform.Translate (1f, 0, 0);
} else if (Input.GetKeyUp (KeyCode.D)) {
timeExp = 0.0f;
} }
if (Input.GetKey (KeyCode.W) && accTime > (timeStep - timeExp)) { if (Input.GetKeyDown (KeyCode.W)) {
accTime -= (timeStep - timeExp);
if (timeExp < timeExpLimit)
timeExp += timeExpStep;
cursor.transform.Translate (0, 1f, 0); cursor.transform.Translate (0, 1f, 0);
} else if (Input.GetKeyUp (KeyCode.W)) {
timeExp = 0.0f;
} }
if (Input.GetKey (KeyCode.S) && accTime > (timeStep - timeExp)) { if (Input.GetKeyDown (KeyCode.S)) {
accTime -= (timeStep - timeExp);
if (timeExp < timeExpLimit)
timeExp += timeExpStep;
cursor.transform.Translate (0, -1f, 0); cursor.transform.Translate (0, -1f, 0);
} else if (Input.GetKeyUp (KeyCode.S)) {
timeExp = 0.0f;
} }
} else if (showActions) { } else if (showActions) {
if (Input.GetKey (KeyCode.Escape)) { if (Input.GetKey (KeyCode.Escape)) {
showActions = false; showActions = false;
unitSelected = false; unitSelected = false;
DestroyObject (i1); for (int i = 0; i < images.Length; i++) {
DestroyObject (i2); DestroyObject (images [i]);
} }
}
} }
@ -104,16 +84,22 @@ public class InputManagerScript : MonoBehaviour {
if (c != null) { if (c != null) {
UnitBehaviour ub = c.GetComponent<UnitBehaviour> (); UnitBehaviour ub = c.GetComponent<UnitBehaviour> ();
UnitBehaviour.Team mahteam = (UnitBehaviour.Team) tmss.actualPlayer; UnitBehaviour.Team mahteam = (UnitBehaviour.Team) tmss.actualPlayer+1;
if (ub.teamID == UnitBehaviour.Team.Player && ub.remainingActions != 0) { if (ub.teamID == mahteam && ub.remainingActions != 0) {
gosel = c; gosel = c;
unitSelected = true; unitSelected = true;
showActions = true; showActions = true;
GameObject canv = GameObject.Find ("Canvas"); GameObject canv = GameObject.Find ("Canvas");
i1 = Instantiate (image_move); images [0] = Instantiate (imageMove);
i1.transform.SetParent (canv.transform, false); images[0].transform.SetParent (canv.transform, false);
i2 = Instantiate (image_attack); images [0].transform.position = new Vector3 (20, 0, 20);
i2.transform.SetParent (canv.transform, false); images[1] = Instantiate (imageAttack);
images[1].transform.SetParent (canv.transform, false);
images [1].transform.position = new Vector3 (40, 0, 20);
images[2] = Instantiate (imageEndTurn);
images[2].transform.SetParent (canv.transform, false);
images [2].transform.position = new Vector3 (60, 0, 20);
} else { } else {
changeCursorColor (Color.red); changeCursorColor (Color.red);
} }
@ -128,11 +114,13 @@ public class InputManagerScript : MonoBehaviour {
} }
if (Input.GetKeyUp (KeyCode.Space) && !selectTargetPos) { if (Input.GetKeyUp (KeyCode.Space) && !selectTargetPos) {
Vector3 tpos = cursor.transform.position;
switch (actionOption) { switch (actionOption) {
case 0: case 0:
tmss.attackTo (gosel, (int)tpos.z, (int)tpos.x);
changeCursorColor (Color.cyan);
break; break;
case 1: case 1:
Vector3 tpos = cursor.transform.position;
if (tmss.canMoveTo (gosel, (int)tpos.z, (int)tpos.x)) { if (tmss.canMoveTo (gosel, (int)tpos.z, (int)tpos.x)) {
tmss.moveTo (gosel, (int)tpos.z, (int)tpos.x); tmss.moveTo (gosel, (int)tpos.z, (int)tpos.x);
changeCursorColor (Color.cyan); changeCursorColor (Color.cyan);
@ -155,15 +143,22 @@ public class InputManagerScript : MonoBehaviour {
if (unitSelected) { if (unitSelected) {
if (Input.GetKeyUp (KeyCode.D)) { if (Input.GetKeyUp (KeyCode.D)) {
Color lol = i1.color; int previousImage = actualImage;
i1.color = new Color (1f, 0f, 0f); if (actualImage < 2) {
i2.color = new Color (1f, 1f, 1f); actualImage += 1;
actionOption = 1; images[actualImage].color = new Color (1f, 0f, 0f);
images[previousImage].color = new Color (1f, 1f, 1f);
actionOption = actualImage;
}
} }
if (Input.GetKeyUp (KeyCode.A)) { if (Input.GetKeyUp (KeyCode.A)) {
i2.color = new Color (1f, 0f, 0f); int previousImage = actualImage;
i1.color = new Color (1f, 1f, 1f); if (actualImage > 0) {
actionOption = 0; actualImage -= 1;
images[actualImage].color = new Color (1f, 0f, 0f);
images[previousImage].color = new Color (1f, 1f, 1f);
actionOption = actualImage;
}
} }
if (Input.GetKeyUp (KeyCode.Space) && actionOption > -1) { if (Input.GetKeyUp (KeyCode.Space) && actionOption > -1) {
@ -171,8 +166,9 @@ public class InputManagerScript : MonoBehaviour {
actionSelected = true; actionSelected = true;
unitSelected = false; unitSelected = false;
showActions = false; showActions = false;
DestroyObject (i1); for (int i = 0; i < images.Length; i++) {
DestroyObject (i2); DestroyObject (images [i]);
}
changeCursorColor(new Color(1,1,0)); changeCursorColor(new Color(1,1,0));
} }

View file

@ -1,31 +0,0 @@
using UnityEngine;
using System.Collections;
public class MapCreation : MonoBehaviour {
private int vs = 20;
private int hs = 40;
public int[,] matrix; //0 significa zona habitable
//dif de 0 zona no habitable
public GameObject basic_floor;
public GameObject nhabitable_floor;
void Start () {
//Creacion de suelo plano
GameObject basic_floor_instance = Instantiate(basic_floor, new Vector3(0,-0.5f,0), Quaternion.identity) as GameObject;
basic_floor_instance.transform.localScale = new Vector3 (vs, 1, hs);
basic_floor_instance.transform.Translate((vs / 2) - 0.5f, 0, (hs / 2) - 0.5f);
//Anadir pilares para zonas inaccesibles
for(int i = 0; i < vs; i++){
for(int j = 0; j < hs; j++){
if(matrix[i,j]!=0) basic_floor_instance = Instantiate(nhabitable_floor, new Vector3(i,1f,j), Quaternion.identity) as GameObject;
}
}
}
public void setMatrix(int[,] new_floor, int x, int z){
matrix = new_floor;
vs = x;
hs = z;
}
}

View file

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

View file

@ -32,7 +32,7 @@ public class TurnManagerScript : MonoBehaviour {
public int actualPlayer; public int actualPlayer;
private int actualNumChars; private int actualNumChars;
private int actualNumFinishedChars; private int actualNumFinishedChars = 0;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
@ -40,9 +40,8 @@ public class TurnManagerScript : MonoBehaviour {
//Estamos en turno //Estamos en turno
inTurn = true; inTurn = true;
actualPlayer = 0; actualPlayer = 0;
actualNumChars = 1;//charList [actualPlayer].Count; actualNumChars = unitList [actualPlayer].Count;
// Characters that have finished its actions // Characters that have finished its actions
actualNumFinishedChars = 0;
} }
@ -61,9 +60,6 @@ public class TurnManagerScript : MonoBehaviour {
act (c); act (c);
} }
void attack(int i, int j, params int[] altParams ) {
}
void attackRange (int i, int j, int k, int l, params int[] altParams ) { void attackRange (int i, int j, int k, int l, params int[] altParams ) {
@ -97,9 +93,22 @@ public class TurnManagerScript : MonoBehaviour {
unitMap.SetValue(go, i, j); unitMap.SetValue(go, i, j);
} }
public void attackTo(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;
if (unitMap [i, j] != null) {
GameObject t = unitMap [i, j];
UnitBehaviour ubt = t.GetComponent<UnitBehaviour> ();
int damage = ub.attackAct ();
ubt.receiveDamage (damage);
}
}
void changeTeam (int newTeam) { void changeTeam (int newTeam) {
actualPlayer = newTeam; actualPlayer = newTeam;
//actualNumChars = charList [actualPlayer].Count; actualNumChars = unitList [actualPlayer].Count;
actualNumFinishedChars = 0; actualNumFinishedChars = 0;
} }

View file

@ -180,7 +180,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
tmanager: {fileID: 1000011212613648, guid: 0193d92a24b3bc94aad43f1f8c93643b, type: 2} tmanager: {fileID: 1000011212613648, guid: 0193d92a24b3bc94aad43f1f8c93643b, type: 2}
mcreator: {fileID: 1000013182272914, guid: bd3068e9944aae447a20ec5f0a4784be, type: 2} mcreator: {fileID: 1000013182272914, guid: 9fe758e4b61ec0d4dbdd8b92521a6628, type: 2}
ucreator: {fileID: 1000012081215776, guid: afbffbb7b9d986345b62d4e4b7969551, type: 2} ucreator: {fileID: 1000012081215776, guid: afbffbb7b9d986345b62d4e4b7969551, type: 2}
imanager: {fileID: 1000013024682154, guid: 85681a523e843e54895aa694f42139a4, type: 2} imanager: {fileID: 1000013024682154, guid: 85681a523e843e54895aa694f42139a4, type: 2}
--- !u!4 &798253254 --- !u!4 &798253254