diff --git a/Assets/Scenes/test.unity b/Assets/Scenes/test.unity index ed71af0..08467e7 100644 --- a/Assets/Scenes/test.unity +++ b/Assets/Scenes/test.unity @@ -31475,6 +31475,7 @@ MonoBehaviour: m_EditorClassIdentifier: moveCell: {fileID: 11400000, guid: 1285aa62ffa004945b03dfbda9cf0afd, type: 2} attackCell: {fileID: 11400000, guid: e7bd64f3e7f95d54289deccf42920283, type: 2} + skillCell: {fileID: 11400000, guid: 121fd29bd24ece6439bdf3010f2e1b41, type: 2} arrowDecoration: {fileID: 11400000, guid: 0db37da799e54d5458c420331560f165, type: 2} --- !u!43 &771847860 Mesh: diff --git a/Assets/SkillCell.asset b/Assets/SkillCell.asset new file mode 100644 index 0000000..d4b28bd --- /dev/null +++ b/Assets/SkillCell.asset @@ -0,0 +1,19 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3c453d041690ab642b6e517807c4ef31, type: 3} + m_Name: SkillCell + m_EditorClassIdentifier: + realTexture: {fileID: 2800000, guid: ee93a90737cf8724cbd5c661141efdaf, type: 3} + xCorner: 0 + yCorner: 0 + isXSimetric: 0 + isYSimetric: 0 + rotation: 0 diff --git a/Assets/SkillCell.asset.meta b/Assets/SkillCell.asset.meta new file mode 100644 index 0000000..1203d4b --- /dev/null +++ b/Assets/SkillCell.asset.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 121fd29bd24ece6439bdf3010f2e1b41 +timeCreated: 1526748176 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TRPGMaker/Database/Characters/NewCharacter.asset b/Assets/TRPGMaker/Database/Characters/NewCharacter.asset index 26a16ff..1752b16 100644 --- a/Assets/TRPGMaker/Database/Characters/NewCharacter.asset +++ b/Assets/TRPGMaker/Database/Characters/NewCharacter.asset @@ -33,11 +33,11 @@ MonoBehaviour: value: 0 attributesWithFormulas: - _attribute: {fileID: 11400000, guid: 570466ba20bcf074aa9cb2a7bc75d9aa, type: 2} - maxValue: 0 + maxValue: 20 minValue: 0 - value: 0 + value: 20 - _attribute: {fileID: 11400000, guid: 2bacf50ce194d1b46b929529f5723ad4, type: 2} - maxValue: 0 + maxValue: 23 minValue: 0 value: 21 - _attribute: {fileID: 11400000, guid: 7a51ab61027fe2842b7277a93add2237, type: 2} diff --git a/Assets/TRPGMaker/Database/Database.asset b/Assets/TRPGMaker/Database/Database.asset index 4a7bf8a..c518c4f 100644 --- a/Assets/TRPGMaker/Database/Database.asset +++ b/Assets/TRPGMaker/Database/Database.asset @@ -28,7 +28,10 @@ MonoBehaviour: - {fileID: 11400000, guid: e7f127d3314f50841893ffe7a2ef77e7, type: 2} teams: - {fileID: 11400000, guid: ff36771f8c32cc64b9f083fbe542428e, type: 2} - skills: [] + skills: + - {fileID: 11400000, guid: 6140f844d2699c34183175b8e0937e5e, type: 2} + - {fileID: 11400000, guid: 58c4a5f649a699b4282451a006428fc1, type: 2} + - {fileID: 11400000, guid: 347122fdaa7394b4baf27c18b79176bb, type: 2} _TRPGOptions: _gameType: 0 _turnType: 0 diff --git a/Assets/TRPGMaker/Database/Skills.meta b/Assets/TRPGMaker/Database/Skills.meta new file mode 100644 index 0000000..0bf2a5b --- /dev/null +++ b/Assets/TRPGMaker/Database/Skills.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 55ff63addd47c0149967b612b103f403 +folderAsset: yes +timeCreated: 1526670324 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset b/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset new file mode 100644 index 0000000..4ec0b75 --- /dev/null +++ b/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset @@ -0,0 +1,18 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2fcfda68e797b224485786ca9e52d4b9, type: 3} + m_Name: NewSkill(1) + m_EditorClassIdentifier: + name: Area + description: + skillType: 1 + areaRange: 4 + formulas: [] diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset.meta b/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset.meta new file mode 100644 index 0000000..dbcc04f --- /dev/null +++ b/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 58c4a5f649a699b4282451a006428fc1 +timeCreated: 1526755881 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset b/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset new file mode 100644 index 0000000..683aaf9 --- /dev/null +++ b/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset @@ -0,0 +1,18 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2fcfda68e797b224485786ca9e52d4b9, type: 3} + m_Name: NewSkill(2) + m_EditorClassIdentifier: + name: Target + description: + skillType: 0 + areaRange: 0 + formulas: [] diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset.meta b/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset.meta new file mode 100644 index 0000000..937f56b --- /dev/null +++ b/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 347122fdaa7394b4baf27c18b79176bb +timeCreated: 1526755883 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill.asset b/Assets/TRPGMaker/Database/Skills/NewSkill.asset new file mode 100644 index 0000000..81befb3 --- /dev/null +++ b/Assets/TRPGMaker/Database/Skills/NewSkill.asset @@ -0,0 +1,18 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2fcfda68e797b224485786ca9e52d4b9, type: 3} + m_Name: NewSkill + m_EditorClassIdentifier: + name: Area Objetive + description: new skill + skillType: 2 + areaRange: 3 + formulas: [] diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill.asset.meta b/Assets/TRPGMaker/Database/Skills/NewSkill.asset.meta new file mode 100644 index 0000000..5304620 --- /dev/null +++ b/Assets/TRPGMaker/Database/Skills/NewSkill.asset.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6140f844d2699c34183175b8e0937e5e +timeCreated: 1526744293 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset b/Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset index 8a84196..1cd62d0 100644 --- a/Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset +++ b/Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset @@ -20,4 +20,7 @@ MonoBehaviour: minValue: 0 value: 0 formula: {fileID: 0} - skills: [] + skills: + - {fileID: 11400000, guid: 347122fdaa7394b4baf27c18b79176bb, type: 2} + - {fileID: 11400000, guid: 58c4a5f649a699b4282451a006428fc1, type: 2} + - {fileID: 11400000, guid: 6140f844d2699c34183175b8e0937e5e, type: 2} diff --git a/Assets/TRPGMaker/Editor/ConnectorEditor.cs b/Assets/TRPGMaker/Editor/ConnectorEditor.cs new file mode 100644 index 0000000..15cbcc9 --- /dev/null +++ b/Assets/TRPGMaker/Editor/ConnectorEditor.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +[CustomEditor(typeof(IsoUnityOptions))] +public class ConnectorEditor : Editor +{ + + private static readonly string[] _dontIncludeMe = new string[] { "m_Script" }; + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + DrawPropertiesExcluding(serializedObject, _dontIncludeMe); + + serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(target); + } +} diff --git a/Assets/TRPGMaker/Editor/ConnectorEditor.cs.meta b/Assets/TRPGMaker/Editor/ConnectorEditor.cs.meta new file mode 100644 index 0000000..53e827b --- /dev/null +++ b/Assets/TRPGMaker/Editor/ConnectorEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5a035f165d5bd454db9a90482740146d +timeCreated: 1526748015 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TRPGMaker/Editor/SkillsEditor.cs b/Assets/TRPGMaker/Editor/SkillsEditor.cs index c140d7f..adb71cf 100644 --- a/Assets/TRPGMaker/Editor/SkillsEditor.cs +++ b/Assets/TRPGMaker/Editor/SkillsEditor.cs @@ -1,12 +1,84 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEditor; +using UnityEditorInternal; using UnityEngine; [CustomEditor(typeof(Skills))] public class SkillsEditor : Editor { - private static readonly string[] _dontIncludeMe = new string[] { "m_Script" }; + //private static readonly string[] _dontIncludeMe = new string[] { "m_Script" }; + private ReorderableList listFormulas; + private Texture2D removeTexture; + int indexFormula; + private GUIStyle removeStyle; + + private void OnEnable() + { + Skills skill = (Skills)target; + + // Remove button + removeTexture = (Texture2D)Resources.Load("Buttons/remove", typeof(Texture2D)); + + // Get Formulas + listFormulas = new ReorderableList(serializedObject, + serializedObject.FindProperty("formulas"), + true, true, true, true); + + // Draw formulas + listFormulas.drawElementCallback = + (Rect rect, int index, bool isActive, bool isFocused) => { + //var element = listFormulas.serializedProperty.GetArrayElementAtIndex(index); + var formula = skill.formulas[index]; + rect.y += 2; + + indexFormula = Database.Instance.attributes.IndexOf(Database.Instance.attributes.Find(x => x.id == formula.attributeID)); + + EditorGUI.BeginChangeCheck(); + indexFormula = EditorGUI.Popup(new Rect(rect.x, rect.y, 50, EditorGUIUtility.singleLineHeight), indexFormula, Database.Instance.attributes.Select(x => x.id).ToArray()); + + EditorGUI.LabelField(new Rect(rect.x + 55, rect.y, 10, EditorGUIUtility.singleLineHeight), "=", EditorStyles.boldLabel); + + formula.formula = EditorGUI.TextField(new Rect(rect.x + 70, rect.y, rect.width - 98, EditorGUIUtility.singleLineHeight), formula.formula); + + bool removed = false; + if (GUI.Button(new Rect(rect.width, rect.y, 16, 16), new GUIContent("", removeTexture), removeStyle)) + { + skill.formulas.Remove(skill.formulas[index]); + removed = true; + } + + var f = FormulaScript.Create(formula.formula); + if (!removed && !f.FormulaParser.IsValidExpression) + { + EditorGUI.LabelField(new Rect(rect.x + 70, rect.y + EditorGUIUtility.singleLineHeight + 2.0f, rect.width, EditorGUIUtility.singleLineHeight), f.FormulaParser.Error); + } + + if (!removed && EditorGUI.EndChangeCheck()) + formula.attributeID = Database.Instance.attributes[indexFormula].id; + }; + + listFormulas.elementHeight = (EditorGUIUtility.singleLineHeight * 2) + 4.0f; + + // listFormulas header + listFormulas.drawHeaderCallback = (Rect rect) => { + EditorGUI.LabelField(rect, "Formulas"); + }; + + // Add formula + listFormulas.onAddDropdownCallback = (Rect buttonRect, ReorderableList l) => { + skill.formulas.Add(new Formula()); + serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(target); + }; + + // Remove formula + listFormulas.onRemoveCallback = (ReorderableList l) => { + skill.formulas.Remove(skill.formulas[l.index]); + serializedObject.ApplyModifiedProperties(); + }; + } public override void OnInspectorGUI() { @@ -17,7 +89,19 @@ public override void OnInspectorGUI() customStyle.fontSize = 17; GUI.Label(new Rect(EditorGUILayout.GetControlRect().x, EditorGUILayout.GetControlRect().y, EditorGUILayout.GetControlRect().width, 30), "Editing \"" + ((Skills)target).name + "\" skill:", customStyle); - DrawPropertiesExcluding(serializedObject, _dontIncludeMe); + EditorGUILayout.PropertyField(serializedObject.FindProperty("name")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("description")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("skillType")); + //DrawPropertiesExcluding(serializedObject, _dontIncludeMe); + + Skills skill = (Skills) target; + + if (skill.skillType.ToString().Contains("AREA")) + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("areaRange")); + } + + listFormulas.DoLayoutList(); serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); diff --git a/Assets/TRPGMaker/Editor/Windows/Connector/ConnectorWindow.cs b/Assets/TRPGMaker/Editor/Windows/Connector/ConnectorWindow.cs index a2c09da..b8321be 100644 --- a/Assets/TRPGMaker/Editor/Windows/Connector/ConnectorWindow.cs +++ b/Assets/TRPGMaker/Editor/Windows/Connector/ConnectorWindow.cs @@ -73,7 +73,7 @@ void OnGUI() } else { Editor editor = Editor.CreateEditor(objects[0]); - editor.DrawDefaultInspector(); + editor.OnInspectorGUI(); } } diff --git a/Assets/TRPGMaker/Resources/SkillCell.png b/Assets/TRPGMaker/Resources/SkillCell.png new file mode 100644 index 0000000..34c091e Binary files /dev/null and b/Assets/TRPGMaker/Resources/SkillCell.png differ diff --git a/Assets/TRPGMaker/Resources/superheroe.png.meta b/Assets/TRPGMaker/Resources/SkillCell.png.meta similarity index 59% rename from Assets/TRPGMaker/Resources/superheroe.png.meta rename to Assets/TRPGMaker/Resources/SkillCell.png.meta index aea1286..8d7db3e 100644 --- a/Assets/TRPGMaker/Resources/superheroe.png.meta +++ b/Assets/TRPGMaker/Resources/SkillCell.png.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 8ad7c00e4d787dc458844d963c59e775 -timeCreated: 1521213128 +guid: ee93a90737cf8724cbd5c661141efdaf +timeCreated: 1526745018 licenseType: Free TextureImporter: fileIDToRecycleName: {} @@ -22,7 +22,7 @@ TextureImporter: externalNormalMap: 0 heightScale: 0.25 normalMapFilter: 0 - isReadable: 0 + isReadable: 1 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -66,6 +66,46 @@ TextureImporter: allowsAlphaSplitting: 0 overridden: 0 androidETC2FallbackOverride: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/TRPGMaker/Resources/superheroe.png b/Assets/TRPGMaker/Resources/superheroe.png deleted file mode 100644 index 7f7f2f1..0000000 Binary files a/Assets/TRPGMaker/Resources/superheroe.png and /dev/null differ diff --git a/Assets/TRPGMaker/Scripts/Connectors/ITRPGMapConnector.cs b/Assets/TRPGMaker/Scripts/Connectors/ITRPGMapConnector.cs index f6a18f0..0891b65 100644 --- a/Assets/TRPGMaker/Scripts/Connectors/ITRPGMapConnector.cs +++ b/Assets/TRPGMaker/Scripts/Connectors/ITRPGMapConnector.cs @@ -15,7 +15,7 @@ public interface ITRPGMapConnector { void MoveCameraToCharacter(CharacterScript character, MoveCameraToCallback callback); void MoveCharacterTo(CharacterScript character, Cell cell, MoveCharacterToCallBack callback); void SetCharacterPosition(CharacterScript character, Cell cell, SetCharacterPositionCallBack callback); - void ShowArea(CharacterScript character, EventTypes eventType, ShowAreaCallBack callback); + void ShowArea(CharacterScript character, EventTypes eventType, ShowAreaCallBack callback, Skills skill = null); void triggerAnimation(Character character, Cell cell); CharacterScript GetCharacterAtCell(Cell cell); Cell GetCellAtCharacter(CharacterScript character); diff --git a/Assets/TRPGMaker/Scripts/Connectors/IsoUnityConnector.cs b/Assets/TRPGMaker/Scripts/Connectors/IsoUnityConnector.cs index 9fd9813..bda1fa6 100644 --- a/Assets/TRPGMaker/Scripts/Connectors/IsoUnityConnector.cs +++ b/Assets/TRPGMaker/Scripts/Connectors/IsoUnityConnector.cs @@ -12,6 +12,7 @@ public class IsoUnityConnector : EventedEventManager, ITRPGMapConnector private GameEvent selectedCellEvent; private IsoUnity.IsoTexture colorMove; private IsoUnity.IsoTexture colorAttack; + private IsoUnity.IsoTexture colorSkill; private IsoUnity.IsoDecoration arrow; private Attribute health; @@ -28,6 +29,7 @@ void Start() IsoUnityOptions isoUnityOptions = GameObject.Find("Game").GetComponent(typeof(IsoUnityOptions)) as IsoUnityOptions; colorMove = isoUnityOptions.moveCell; colorAttack = isoUnityOptions.attackCell; + colorSkill = isoUnityOptions.skillCell; arrow = isoUnityOptions.arrowDecoration; } catch (NullReferenceException e) @@ -100,13 +102,13 @@ private IEnumerator MoveCharacterToAsync(CharacterScript character, Cell cell, M } // Show calculated area with the character distance requirement - public void ShowArea(CharacterScript character, EventTypes eventType, ShowAreaCallBack callback) + public void ShowArea(CharacterScript character, EventTypes eventType, ShowAreaCallBack callback, Skills skill = null) { - StartCoroutine(ShowAreaAsync(character, eventType, callback)); + StartCoroutine(ShowAreaAsync(character, eventType, skill, callback)); } // Async method for show area - private IEnumerator ShowAreaAsync(CharacterScript character, EventTypes eventType, ShowAreaCallBack callback) + private IEnumerator ShowAreaAsync(CharacterScript character, EventTypes eventType, Skills skill, ShowAreaCallBack callback) { Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity; IsoUnity.Cell characterCurrentCell = character.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; @@ -131,10 +133,12 @@ private IEnumerator ShowAreaAsync(CharacterScript character, EventTypes eventTyp CalculateDistanceArea(entity, characterCurrentCell, eventType, character.character.attributesWithFormulas.Find(x => x.attribute.id == moveRange.id).value, character.character.attributesWithFormulas.Find(x => x.attribute.id == moveHeight.id).value); else if (eventType == EventTypes.ATTACK) CalculateDistanceArea(entity, characterCurrentCell, eventType, character.character.attributesWithFormulas.Find(x => x.attribute.id == attackRange.id).value, character.character.attributesWithFormulas.Find(x => x.attribute.id == attackHeight.id).value); + else if(eventType == EventTypes.SKILL) + SkillsParser(entity, characterCurrentCell, eventType, character, skill); } catch (NullReferenceException e) { - Debug.Log("Character '" + character.character.name + "' doesn't have some or any of this attributes: '" + moveHeight.name + "', '" + moveRange.name + "', '" + attackHeight.name + "', '" + attackRange.name + "'"); + Debug.Log(e); } Dictionary outParams; @@ -438,7 +442,7 @@ private void CalculateDistanceArea(Entity entity, IsoUnity.Cell currentCell, Eve { if (!openList.Any(x => x.cell == neighbour)) { - PaintCell(neighbour, eventType); + PaintCell(neighbour, eventType); openList.Add(new CellWithDistance(neighbour, distanceManhattanFromCharacterToNeigh, null)); } } @@ -462,14 +466,19 @@ private void PaintCell(IsoUnity.Cell cell, EventTypes eventType) case EventTypes.IA_MOVE: texture = colorMove; break; + case EventTypes.SKILL: + texture = colorSkill; + break; } cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping = texture; cell.Properties.faces[cell.Properties.faces.Length - 1].Texture = texture.getTexture(); cell.forceRefresh(); } + public delegate void CallbackSelector(IsoUnity.Cell cell); + // Show an arrow in selectables cells - private void showSelector(IsoUnity.Cell cell, EventTypes eventType) + private void showSelector(IsoUnity.Cell cell, EventTypes eventType, CallbackSelector callback = null) { SelectableCell selectableCell = cell.transform.gameObject.AddComponent(); selectableCell.arrow = arrow; @@ -477,6 +486,61 @@ private void showSelector(IsoUnity.Cell cell, EventTypes eventType) selectableCell.previousTexture = cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping; selectableCell.cell = cell; selectableCell.eventType = eventType; + selectableCell.callback = callback; + } + + // Calculate the skill events + private void SkillsParser(Entity entity, IsoUnity.Cell currentCell, EventTypes eventType, CharacterScript character, Skills skill) + { + // Get all characters + List characters = FindObjectsOfType().ToList(); + + // Switch + if (skill.skillType == SkillTypes.SINGLE_TARGET) + { + foreach (CharacterScript target in characters) + { + IsoUnity.Cell targetCell = target.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; + PaintCell(targetCell, eventType); + } + } + else if (skill.skillType == SkillTypes.AREA) + { + IsoUnity.Cell characterCurrentCell = character.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; + CalculateDistanceArea(entity, characterCurrentCell, eventType, skill.areaRange, int.MaxValue); + PaintCell(characterCurrentCell, eventType); + } + else if(skill.skillType == SkillTypes.AREA_IN_OBJETIVE) + { + foreach (IsoUnity.Cell cell in currentCell.Map.Cells) + { + showSelector(cell, eventType, ((result) => { + cleanSkillCells(); + CalculateDistanceArea(null, result, eventType, skill.areaRange, int.MaxValue); + PaintCell(cell, eventType); + })); + } + } + } + + private void cleanSkillCells() + { + SelectableCell[] selectableCells = FindObjectsOfType(); + foreach (SelectableCell selectableCell in selectableCells) + { + IsoUnity.Cell cell = selectableCell.cell; + if (selectableCell.previousTexture != null) + { + cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping = selectableCell.previousTexture; + cell.Properties.faces[cell.Properties.faces.Length - 1].Texture = selectableCell.previousTexture.getTexture(); + } + else + { + cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping = null; + cell.Properties.faces[cell.Properties.faces.Length - 1].Texture = null; + } + cell.forceRefresh(); + } } private IsoUnity.Cell SearchCellInMap(Cell cell) @@ -518,6 +582,7 @@ public CellWithDistance(IsoUnity.Cell cell, float distance, CellWithDistance pre // Specific class make a cell selectable and draw an arrow class SelectableCell : MonoBehaviour { + public CallbackSelector callback; public GameEvent selectedCellEvent; public IsoDecoration arrow; public IsoUnity.Cell cell = null; @@ -545,13 +610,17 @@ private void OnMouseOver() { arrowObject = cell.addDecoration(cell.transform.position + new Vector3(0, cell.WalkingHeight, 0), 0, false, true, arrow); } + else if (eventType == EventTypes.SKILL) + { + arrowObject = cell.addDecoration(cell.transform.position + new Vector3(0, cell.WalkingHeight, 0), 0, false, true, arrow); + if(callback != null) callback(cell); + } } } void OnMouseExit() { if (arrowObject != null) - GameObject.Destroy(arrowObject); } diff --git a/Assets/TRPGMaker/Scripts/Connectors/IsoUnityOptions.cs b/Assets/TRPGMaker/Scripts/Connectors/IsoUnityOptions.cs index c828aed..f544c7f 100644 --- a/Assets/TRPGMaker/Scripts/Connectors/IsoUnityOptions.cs +++ b/Assets/TRPGMaker/Scripts/Connectors/IsoUnityOptions.cs @@ -6,5 +6,6 @@ public class IsoUnityOptions : MonoBehaviour { public IsoUnity.IsoTexture moveCell; public IsoUnity.IsoTexture attackCell; + public IsoUnity.IsoTexture skillCell; public IsoUnity.IsoDecoration arrowDecoration; } diff --git a/Assets/TRPGMaker/Scripts/Database/SkillTypes.cs b/Assets/TRPGMaker/Scripts/Database/SkillTypes.cs index dff185c..d54ee40 100644 --- a/Assets/TRPGMaker/Scripts/Database/SkillTypes.cs +++ b/Assets/TRPGMaker/Scripts/Database/SkillTypes.cs @@ -4,7 +4,6 @@ public enum SkillTypes{ SINGLE_TARGET, - PROYECTILE, AREA, AREA_IN_OBJETIVE } diff --git a/Assets/TRPGMaker/Scripts/Database/Skills.cs b/Assets/TRPGMaker/Scripts/Database/Skills.cs index 169d3ca..79cb75d 100644 --- a/Assets/TRPGMaker/Scripts/Database/Skills.cs +++ b/Assets/TRPGMaker/Scripts/Database/Skills.cs @@ -5,14 +5,11 @@ public class Skills : ScriptableObject, ICloneable { - [SerializeField] public string name; - [SerializeField] public string description; - [SerializeField] public SkillTypes skillType; - [SerializeField] - public float damage; + public int areaRange; + public List formulas; public object Clone() { diff --git a/Assets/TRPGMaker/Scripts/Game/EventTypes.cs b/Assets/TRPGMaker/Scripts/Game/EventTypes.cs index aaa36d2..8ac1e71 100644 --- a/Assets/TRPGMaker/Scripts/Game/EventTypes.cs +++ b/Assets/TRPGMaker/Scripts/Game/EventTypes.cs @@ -5,5 +5,6 @@ public enum EventTypes{ ATTACK, MOVE, IA_ATTACK, - IA_MOVE + IA_MOVE, + SKILL }; diff --git a/Assets/TRPGMaker/Scripts/Game/GamePlayManager.cs b/Assets/TRPGMaker/Scripts/Game/GamePlayManager.cs index 4166ee9..596a6a8 100644 --- a/Assets/TRPGMaker/Scripts/Game/GamePlayManager.cs +++ b/Assets/TRPGMaker/Scripts/Game/GamePlayManager.cs @@ -18,6 +18,7 @@ public class GamePlayManager : MonoBehaviour private Boolean attack; private int round = 0; private GameObject skillsObjectScrollRect; + private Image imagebuttonSkill; // Use this for initialization void Start() @@ -230,6 +231,15 @@ public void AttackEvent() })); } + public void SkillEvent(Skills skill) + { + connector.cleanCells(); + connector.ShowArea(character, EventTypes.SKILL, ShowAreaCallBackParametrizedCallback(character, (character1, selectedCell, result1) => + { + + }), skill); + } + public void attackEventIA(CharacterScript target) { connector.IAAttack(character, target, ShowAreaCallBackParametrizedCallback(character, (character1, selectedCell, result1) => @@ -417,7 +427,7 @@ private void DrawCanvas() objectButtonSkill.transform.parent = objectCanvas.transform; Button buttonSkill = objectButtonSkill.AddComponent