From b491a83afef8e866d937366bf7bf00599d22fe8c Mon Sep 17 00:00:00 2001 From: "falc@null.net" Date: Sun, 30 Oct 2016 18:10:18 +0100 Subject: [PATCH] Ayyyyyyyy --- Assets/3rdParty/ArcherSkeleton/prefab.meta | 9 -- Assets/3rdParty/DemonImp/prefab.meta | 9 -- Assets/FloorCreator.prefab | 57 ----------- Assets/FloorCreator.prefab.meta | 8 -- Assets/Generator.cs | 2 +- Assets/Generator.cs.meta | 4 +- Assets/InputManagerScript.cs | 104 ++++++++++----------- Assets/MapCreation.cs | 31 ------ Assets/MapCreation.cs.meta | 16 ---- Assets/TurnManagerScript.cs | 23 +++-- Assets/scene1.unity | 2 +- 11 files changed, 70 insertions(+), 195 deletions(-) delete mode 100644 Assets/3rdParty/ArcherSkeleton/prefab.meta delete mode 100644 Assets/3rdParty/DemonImp/prefab.meta delete mode 100644 Assets/FloorCreator.prefab delete mode 100644 Assets/FloorCreator.prefab.meta delete mode 100644 Assets/MapCreation.cs delete mode 100644 Assets/MapCreation.cs.meta diff --git a/Assets/3rdParty/ArcherSkeleton/prefab.meta b/Assets/3rdParty/ArcherSkeleton/prefab.meta deleted file mode 100644 index 42ddf7e..0000000 --- a/Assets/3rdParty/ArcherSkeleton/prefab.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 456228f09d87f2c4a9df7b9ef04226bc -folderAsset: yes -timeCreated: 1477752003 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/3rdParty/DemonImp/prefab.meta b/Assets/3rdParty/DemonImp/prefab.meta deleted file mode 100644 index 638eafb..0000000 --- a/Assets/3rdParty/DemonImp/prefab.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: f69e4ae1ab31a7b429d8d29157ff18a8 -folderAsset: yes -timeCreated: 1477757782 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/FloorCreator.prefab b/Assets/FloorCreator.prefab deleted file mode 100644 index fe051f0..0000000 --- a/Assets/FloorCreator.prefab +++ /dev/null @@ -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} diff --git a/Assets/FloorCreator.prefab.meta b/Assets/FloorCreator.prefab.meta deleted file mode 100644 index 5bca116..0000000 --- a/Assets/FloorCreator.prefab.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bd3068e9944aae447a20ec5f0a4784be -timeCreated: 1477758385 -licenseType: Free -NativeFormatImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Generator.cs b/Assets/Generator.cs index 2aeade0..3ae7824 100644 --- a/Assets/Generator.cs +++ b/Assets/Generator.cs @@ -39,7 +39,7 @@ public class Generator : MonoBehaviour { //just to test map [10, 10] = -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 (); turnMan.GetComponent ().unitMap = uScript.getUnitMap (); diff --git a/Assets/Generator.cs.meta b/Assets/Generator.cs.meta index 38ede7a..285c8ac 100644 --- a/Assets/Generator.cs.meta +++ b/Assets/Generator.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 4828dbfa7343efb49b36490a44cb05d7 -timeCreated: 1477835629 +timeCreated: 1477842453 licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: - 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} - imanager: {fileID: 1000013024682154, guid: 85681a523e843e54895aa694f42139a4, type: 2} executionOrder: 0 diff --git a/Assets/InputManagerScript.cs b/Assets/InputManagerScript.cs index b01b6c9..ea430d7 100644 --- a/Assets/InputManagerScript.cs +++ b/Assets/InputManagerScript.cs @@ -5,9 +5,9 @@ using UnityEngine.UI; public class InputManagerScript : MonoBehaviour { private GameObject cursor; - public Image image_move; - public Image image_attack; - + public Image imageMove; + public Image imageAttack; + public Image imageEndTurn; private float accTime; private float timeStep; private float timeExp; @@ -19,21 +19,18 @@ public class InputManagerScript : MonoBehaviour { private bool showActions; private bool actionSelected; private bool selectTargetPos; - private Image i1; - private Image i2; + private Image[] images; + private int actualImage; private GameObject gosel; private int actionOption; private TurnManagerScript tmss; + + // Use this for initialization void Start () { - timeStep = 0.75f; - timeExp = 0.0f; - timeExpStep = 0.05f; - timeExpLimit = 0.1f; - cursor = GameObject.Find ("Cursor"); //cursor.transform.Rotate (new Vector3(90, 0, 0)); @@ -43,56 +40,39 @@ public class InputManagerScript : MonoBehaviour { actionSelected = false; selectTargetPos = false; gosel = null; + images = new Image[3]; + actualImage = 0; } // Update is called once per frame void Update () { - accTime += Time.deltaTime; if (!showActions) { - if (Input.GetKey (KeyCode.A) && accTime > (timeStep - timeExp)) { - accTime -= (timeStep - timeExp); - if (timeExp < timeExpLimit) - timeExp += timeExpStep; + if (Input.GetKeyDown (KeyCode.A)) { cursor.transform.Translate (-1f, 0, 0); - } else if (Input.GetKeyUp (KeyCode.LeftArrow)) { - timeExp = 0.0f; } - if (Input.GetKey (KeyCode.D) && accTime > (timeStep - timeExp)) { - accTime -= (timeStep - timeExp); - if (timeExp < timeExpLimit) - timeExp += timeExpStep; + if (Input.GetKeyDown (KeyCode.D)) { cursor.transform.Translate (1f, 0, 0); - } else if (Input.GetKeyUp (KeyCode.D)) { - timeExp = 0.0f; } - if (Input.GetKey (KeyCode.W) && accTime > (timeStep - timeExp)) { - accTime -= (timeStep - timeExp); - if (timeExp < timeExpLimit) - timeExp += timeExpStep; + if (Input.GetKeyDown (KeyCode.W)) { cursor.transform.Translate (0, 1f, 0); - } else if (Input.GetKeyUp (KeyCode.W)) { - timeExp = 0.0f; } - if (Input.GetKey (KeyCode.S) && accTime > (timeStep - timeExp)) { - accTime -= (timeStep - timeExp); - if (timeExp < timeExpLimit) - timeExp += timeExpStep; + if (Input.GetKeyDown (KeyCode.S)) { cursor.transform.Translate (0, -1f, 0); - } else if (Input.GetKeyUp (KeyCode.S)) { - timeExp = 0.0f; } + } else if (showActions) { if (Input.GetKey (KeyCode.Escape)) { showActions = false; unitSelected = false; - DestroyObject (i1); - DestroyObject (i2); - } + for (int i = 0; i < images.Length; i++) { + DestroyObject (images [i]); + } + } } @@ -104,16 +84,22 @@ public class InputManagerScript : MonoBehaviour { if (c != null) { UnitBehaviour ub = c.GetComponent (); - UnitBehaviour.Team mahteam = (UnitBehaviour.Team) tmss.actualPlayer; - if (ub.teamID == UnitBehaviour.Team.Player && ub.remainingActions != 0) { + UnitBehaviour.Team mahteam = (UnitBehaviour.Team) tmss.actualPlayer+1; + if (ub.teamID == mahteam && 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); + images [0] = Instantiate (imageMove); + images[0].transform.SetParent (canv.transform, false); + images [0].transform.position = new Vector3 (20, 0, 20); + 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 { changeCursorColor (Color.red); } @@ -128,11 +114,13 @@ public class InputManagerScript : MonoBehaviour { } if (Input.GetKeyUp (KeyCode.Space) && !selectTargetPos) { + Vector3 tpos = cursor.transform.position; switch (actionOption) { case 0: + tmss.attackTo (gosel, (int)tpos.z, (int)tpos.x); + changeCursorColor (Color.cyan); 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); @@ -155,15 +143,22 @@ public class InputManagerScript : MonoBehaviour { 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; + int previousImage = actualImage; + if (actualImage < 2) { + actualImage += 1; + images[actualImage].color = new Color (1f, 0f, 0f); + images[previousImage].color = new Color (1f, 1f, 1f); + actionOption = actualImage; + } } if (Input.GetKeyUp (KeyCode.A)) { - i2.color = new Color (1f, 0f, 0f); - i1.color = new Color (1f, 1f, 1f); - actionOption = 0; + int previousImage = actualImage; + if (actualImage > 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) { @@ -171,8 +166,9 @@ public class InputManagerScript : MonoBehaviour { actionSelected = true; unitSelected = false; showActions = false; - DestroyObject (i1); - DestroyObject (i2); + for (int i = 0; i < images.Length; i++) { + DestroyObject (images [i]); + } changeCursorColor(new Color(1,1,0)); } diff --git a/Assets/MapCreation.cs b/Assets/MapCreation.cs deleted file mode 100644 index c5066c9..0000000 --- a/Assets/MapCreation.cs +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/Assets/MapCreation.cs.meta b/Assets/MapCreation.cs.meta deleted file mode 100644 index bd6e944..0000000 --- a/Assets/MapCreation.cs.meta +++ /dev/null @@ -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: diff --git a/Assets/TurnManagerScript.cs b/Assets/TurnManagerScript.cs index 8c1c74f..22378a6 100644 --- a/Assets/TurnManagerScript.cs +++ b/Assets/TurnManagerScript.cs @@ -32,7 +32,7 @@ public class TurnManagerScript : MonoBehaviour { public int actualPlayer; private int actualNumChars; - private int actualNumFinishedChars; + private int actualNumFinishedChars = 0; // Use this for initialization void Start () { @@ -40,9 +40,8 @@ public class TurnManagerScript : MonoBehaviour { //Estamos en turno inTurn = true; actualPlayer = 0; - actualNumChars = 1;//charList [actualPlayer].Count; + actualNumChars = unitList [actualPlayer].Count; // Characters that have finished its actions - actualNumFinishedChars = 0; } @@ -61,9 +60,6 @@ public class TurnManagerScript : MonoBehaviour { act (c); } - void attack(int i, int j, 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); } + public void attackTo(GameObject go, int i, int j) { + UnitBehaviour ub = go.GetComponent (); + 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 (); + int damage = ub.attackAct (); + ubt.receiveDamage (damage); + } + } + void changeTeam (int newTeam) { actualPlayer = newTeam; - //actualNumChars = charList [actualPlayer].Count; + actualNumChars = unitList [actualPlayer].Count; actualNumFinishedChars = 0; } diff --git a/Assets/scene1.unity b/Assets/scene1.unity index 587483f..8fc86ea 100644 --- a/Assets/scene1.unity +++ b/Assets/scene1.unity @@ -180,7 +180,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: 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} imanager: {fileID: 1000013024682154, guid: 85681a523e843e54895aa694f42139a4, type: 2} --- !u!4 &798253254