From d76ce99e7da99a98875394bbaeaa3116a45cacbc Mon Sep 17 00:00:00 2001 From: WyrnCael Date: Wed, 2 May 2018 17:06:30 +0200 Subject: [PATCH] Formulas finished, damage added and fixes - Formulas script changed - Calculate formulas in editor and in play mode (when slots changes) - Attributes calculated from formulas added and showed in editor - Added damage attribute to battleOptions and reflected in combat - Character slots defined in specialized classes changed - Editor fixes --- .../Database/Characters/NewCharacter(1).asset | 8 ++ .../Database/Characters/NewCharacter(2).asset | 62 +++++++++++++ .../NewCharacter(2).asset.meta} | 4 +- .../Database/Characters/NewCharacter(4).asset | 14 ++- .../Database/Characters/NewCharacter(5).asset | 9 ++ .../Database/Characters/NewCharacter(6).asset | 9 ++ .../Database/Characters/NewCharacter(7).asset | 7 ++ .../Database/Characters/NewCharacter.asset | 85 ++++++++++++++--- Assets/TRPGMaker/Database/Database.asset | 44 ++++++--- Assets/TRPGMaker/Database/Items/Axe.asset | 8 +- .../Database/Items/New Item(3).asset | 17 ---- .../Database/Items/New Item(3).asset.meta | 10 -- .../Items/{New Item(2).asset => Rod.asset} | 10 +- ...{New Item(2).asset.meta => Rod.asset.meta} | 4 +- Assets/TRPGMaker/Database/Items/Sword.asset | 12 ++- .../Database/Skills/NewSkill(1).asset | 17 ---- .../Database/Skills/NewSkill(2).asset | 17 ---- .../Database/Skills/NewSkill(2).asset.meta | 10 -- .../TRPGMaker/Database/Skills/NewSkill.asset | 17 ---- .../Database/Skills/NewSkill.asset.meta | 10 -- ...{NewSpecializedClass.asset => Wizar.asset} | 25 ++++- ...lizedClass.asset.meta => Wizar.asset.meta} | 0 .../{NewTeam(1).asset => Enemy Tea.asset} | 6 +- ...eam(1).asset.meta => Enemy Tea.asset.meta} | 0 .../{NewTeam.asset => Playable Tea.asset} | 4 +- ...eam.asset.meta => Playable Tea.asset.meta} | 0 Assets/TRPGMaker/Editor/CharacterEditor.cs | 76 ++++++++++++++-- Assets/TRPGMaker/Editor/ItemEditor.cs | 82 +++++++++++++---- .../Editor/SpecializedClassEditor.cs | 17 ++-- .../Windows/Battle/BattleOptionsWindow.cs | 8 ++ .../TRPGMaker/Scripts/Database/Attribute.cs | 2 +- .../TRPGMaker/Scripts/Database/Character.cs | 33 +++++++ Assets/TRPGMaker/Scripts/Database/Formula.cs | 58 ++---------- .../Scripts/Database/Formula.cs.meta | 4 +- Assets/TRPGMaker/Scripts/Database/Modifier.cs | 16 +++- Assets/TRPGMaker/Scripts/Database/Slot.cs | 29 +++--- .../Scripts/Database/SpecializedClass.cs | 4 +- .../TRPGMaker/Scripts/Game/CharacterScript.cs | 17 +++- .../TRPGMaker/Scripts/Game/FormulaScript.cs | 52 +++++++++++ .../Scripts/Game/FormulaScript.cs.meta | 13 +++ .../TRPGMaker/Scripts/Game/GamePlayManager.cs | 4 +- Assets/TRPGMaker/Scripts/Game/TRPGOptions.cs | 15 +++ .../TRPGMaker/Scripts/Utils/FormulaParser.cs | 91 ++----------------- ProjectSettings/ProjectSettings.asset | 84 +++++++++++++---- 44 files changed, 657 insertions(+), 357 deletions(-) create mode 100644 Assets/TRPGMaker/Database/Characters/NewCharacter(2).asset rename Assets/TRPGMaker/Database/{Skills/NewSkill(1).asset.meta => Characters/NewCharacter(2).asset.meta} (72%) delete mode 100644 Assets/TRPGMaker/Database/Items/New Item(3).asset delete mode 100644 Assets/TRPGMaker/Database/Items/New Item(3).asset.meta rename Assets/TRPGMaker/Database/Items/{New Item(2).asset => Rod.asset} (78%) rename Assets/TRPGMaker/Database/Items/{New Item(2).asset.meta => Rod.asset.meta} (72%) delete mode 100644 Assets/TRPGMaker/Database/Skills/NewSkill(1).asset delete mode 100644 Assets/TRPGMaker/Database/Skills/NewSkill(2).asset delete mode 100644 Assets/TRPGMaker/Database/Skills/NewSkill(2).asset.meta delete mode 100644 Assets/TRPGMaker/Database/Skills/NewSkill.asset delete mode 100644 Assets/TRPGMaker/Database/Skills/NewSkill.asset.meta rename Assets/TRPGMaker/Database/SpecializedClasses/{NewSpecializedClass.asset => Wizar.asset} (70%) rename Assets/TRPGMaker/Database/SpecializedClasses/{NewSpecializedClass.asset.meta => Wizar.asset.meta} (100%) rename Assets/TRPGMaker/Database/Teams/{NewTeam(1).asset => Enemy Tea.asset} (92%) rename Assets/TRPGMaker/Database/Teams/{NewTeam(1).asset.meta => Enemy Tea.asset.meta} (100%) rename Assets/TRPGMaker/Database/Teams/{NewTeam.asset => Playable Tea.asset} (92%) rename Assets/TRPGMaker/Database/Teams/{NewTeam.asset.meta => Playable Tea.asset.meta} (100%) create mode 100644 Assets/TRPGMaker/Scripts/Game/FormulaScript.cs create mode 100644 Assets/TRPGMaker/Scripts/Game/FormulaScript.cs.meta diff --git a/Assets/TRPGMaker/Database/Characters/NewCharacter(1).asset b/Assets/TRPGMaker/Database/Characters/NewCharacter(1).asset index 75c3f92..1a3573a 100644 --- a/Assets/TRPGMaker/Database/Characters/NewCharacter(1).asset +++ b/Assets/TRPGMaker/Database/Characters/NewCharacter(1).asset @@ -50,4 +50,12 @@ MonoBehaviour: minValue: 0 value: 1 isCore: 1 + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 + attributesWithFormulas: [] specializedClasses: [] diff --git a/Assets/TRPGMaker/Database/Characters/NewCharacter(2).asset b/Assets/TRPGMaker/Database/Characters/NewCharacter(2).asset new file mode 100644 index 0000000..cc2339c --- /dev/null +++ b/Assets/TRPGMaker/Database/Characters/NewCharacter(2).asset @@ -0,0 +1,62 @@ +%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: 2d9fb3b8c5fa23c4e8313ab14ed5bdb8, type: 3} + m_Name: NewCharacter(2) + m_EditorClassIdentifier: + name: NewCharacter(2) + inventory: {fileID: 0} + Slots: [] + attributes: + - name: Health + id: HP + description: + maxValue: 0 + minValue: 0 + value: 0 + isCore: 1 + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 + - name: Move Range + id: MVR + description: + maxValue: 30 + minValue: 0 + value: 5 + isCore: 1 + - name: Move height + id: MVH + description: + maxValue: 15 + minValue: 0 + value: 1 + isCore: 1 + - name: Attack Range + id: ATR + description: + maxValue: 30 + minValue: 0 + value: 4 + isCore: 1 + - name: Attack Height + id: ATH + description: + maxValue: 15 + minValue: 0 + value: 1 + isCore: 1 + attributesWithFormulas: [] + specializedClasses: [] + specializedClassesCount: 0 diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset.meta b/Assets/TRPGMaker/Database/Characters/NewCharacter(2).asset.meta similarity index 72% rename from Assets/TRPGMaker/Database/Skills/NewSkill(1).asset.meta rename to Assets/TRPGMaker/Database/Characters/NewCharacter(2).asset.meta index 9d08e6d..fe17f43 100644 --- a/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset.meta +++ b/Assets/TRPGMaker/Database/Characters/NewCharacter(2).asset.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: dfe22705bcdd79847ba1a5df96149c38 -timeCreated: 1524505621 +guid: a0544f3bb46f87e4b902b7442a6702ca +timeCreated: 1525271138 licenseType: Free NativeFormatImporter: externalObjects: {} diff --git a/Assets/TRPGMaker/Database/Characters/NewCharacter(4).asset b/Assets/TRPGMaker/Database/Characters/NewCharacter(4).asset index 4e05988..9ba745a 100644 --- a/Assets/TRPGMaker/Database/Characters/NewCharacter(4).asset +++ b/Assets/TRPGMaker/Database/Characters/NewCharacter(4).asset @@ -13,7 +13,10 @@ MonoBehaviour: m_EditorClassIdentifier: name: NewCharacter(4) inventory: {fileID: 0} - Slots: [] + Slots: + - slotType: Head + _modifier: {fileID: 11400000, guid: 242d1289cf2bba54c88d032eafa8eec4, type: 2} + calculatedFormula: 1 attributes: - name: Health id: HP @@ -50,4 +53,13 @@ MonoBehaviour: minValue: 0 value: 1 isCore: 1 + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 + attributesWithFormulas: [] specializedClasses: [] + specializedClassesCount: 0 diff --git a/Assets/TRPGMaker/Database/Characters/NewCharacter(5).asset b/Assets/TRPGMaker/Database/Characters/NewCharacter(5).asset index 122a885..f065d23 100644 --- a/Assets/TRPGMaker/Database/Characters/NewCharacter(5).asset +++ b/Assets/TRPGMaker/Database/Characters/NewCharacter(5).asset @@ -50,4 +50,13 @@ MonoBehaviour: minValue: 0 value: 1 isCore: 1 + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 + attributesWithFormulas: [] specializedClasses: [] + specializedClassesCount: 0 diff --git a/Assets/TRPGMaker/Database/Characters/NewCharacter(6).asset b/Assets/TRPGMaker/Database/Characters/NewCharacter(6).asset index ac4d85c..bb6fef2 100644 --- a/Assets/TRPGMaker/Database/Characters/NewCharacter(6).asset +++ b/Assets/TRPGMaker/Database/Characters/NewCharacter(6).asset @@ -50,4 +50,13 @@ MonoBehaviour: minValue: 0 value: 1 isCore: 1 + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 + attributesWithFormulas: [] specializedClasses: [] + specializedClassesCount: 0 diff --git a/Assets/TRPGMaker/Database/Characters/NewCharacter(7).asset b/Assets/TRPGMaker/Database/Characters/NewCharacter(7).asset index cfe2b55..916dc2f 100644 --- a/Assets/TRPGMaker/Database/Characters/NewCharacter(7).asset +++ b/Assets/TRPGMaker/Database/Characters/NewCharacter(7).asset @@ -50,4 +50,11 @@ MonoBehaviour: minValue: 0 value: 1 isCore: 1 + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 specializedClasses: [] diff --git a/Assets/TRPGMaker/Database/Characters/NewCharacter.asset b/Assets/TRPGMaker/Database/Characters/NewCharacter.asset index 0419ff7..5797c7a 100644 --- a/Assets/TRPGMaker/Database/Characters/NewCharacter.asset +++ b/Assets/TRPGMaker/Database/Characters/NewCharacter.asset @@ -14,25 +14,16 @@ MonoBehaviour: name: NewCharacter inventory: {fileID: 0} Slots: - - slotType: Head - modifier: {fileID: 11400000, guid: 4c69bdc0758205346836ff1ddb49b90d, type: 2} - - slotType: Right Hand - modifier: {fileID: 11400000, guid: 4c69bdc0758205346836ff1ddb49b90d, type: 2} - - slotType: - modifier: {fileID: 0} - - slotType: - modifier: {fileID: 0} - - slotType: - modifier: {fileID: 0} - - slotType: - modifier: {fileID: 0} + - slotType: Left hand + _modifier: {fileID: 11400000, guid: 242d1289cf2bba54c88d032eafa8eec4, type: 2} + calculatedFormula: 1 attributes: - name: Health id: HP description: maxValue: 300 minValue: 0 - value: 300 + value: 250 isCore: 0 - name: Move Range id: MVR @@ -62,4 +53,70 @@ MonoBehaviour: minValue: 0 value: 1 isCore: 1 - specializedClasses: [] + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 + - name: Mana + id: MAN + description: + maxValue: 0 + minValue: 0 + value: 0 + isCore: 0 + attributesWithFormulas: + - name: Health + id: HP + description: + maxValue: 300 + minValue: 0 + value: 265 + isCore: 0 + - name: Move Range + id: MVR + description: + maxValue: 30 + minValue: 0 + value: 5 + isCore: 1 + - name: Move height + id: MVH + description: + maxValue: 15 + minValue: 0 + value: 1 + isCore: 1 + - name: Attack Range + id: ATR + description: + maxValue: 30 + minValue: 0 + value: 4 + isCore: 1 + - name: Attack Height + id: ATH + description: + maxValue: 15 + minValue: 0 + value: 1 + isCore: 1 + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 110 + isCore: 1 + - name: Mana + id: MAN + description: + maxValue: 0 + minValue: 0 + value: 0 + isCore: 0 + specializedClasses: + - {fileID: 11400000, guid: 684c928e26a3b364c9cc9cff30e18082, type: 2} + specializedClassesCount: 1 diff --git a/Assets/TRPGMaker/Database/Database.asset b/Assets/TRPGMaker/Database/Database.asset index 9f5ee14..fdd3ddd 100644 --- a/Assets/TRPGMaker/Database/Database.asset +++ b/Assets/TRPGMaker/Database/Database.asset @@ -19,6 +19,13 @@ MonoBehaviour: minValue: 0 value: 0 isCore: 1 + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 - name: Move Range id: MVR description: @@ -47,22 +54,23 @@ MonoBehaviour: minValue: 0 value: 1 isCore: 1 + - name: Mana + id: MAN + description: + maxValue: 0 + minValue: 0 + value: 0 + isCore: 0 tags: - - Espada - - Mandoble - - Casco - - Vara - - Escudo - - Armadura ligera + - Light armour slotTypes: - Head - - Right Hand - - Left Hand + - Right hand + - Left hand items: - - {fileID: 11400000, guid: 4c69bdc0758205346836ff1ddb49b90d, type: 2} - {fileID: 11400000, guid: 242d1289cf2bba54c88d032eafa8eec4, type: 2} - - {fileID: 11400000, guid: f6b6622b87c152f4599e44b22cdddc5a, type: 2} - - {fileID: 11400000, guid: a06817ff9fca9d14b9df2b85c4fd2c2e, type: 2} + - {fileID: 11400000, guid: 4c69bdc0758205346836ff1ddb49b90d, type: 2} + - {fileID: 11400000, guid: 7182cd41f7eb67743a3612a0fd7c9ac5, type: 2} specializedClasses: - {fileID: 11400000, guid: 684c928e26a3b364c9cc9cff30e18082, type: 2} characters: @@ -72,13 +80,11 @@ MonoBehaviour: - {fileID: 11400000, guid: 75942776545ea02418c221a9273f406b, type: 2} - {fileID: 11400000, guid: bac31a58c9f786c4a9d5b67034ba5482, type: 2} - {fileID: 11400000, guid: 496024b31fb8d604ba8b12317f0d4762, type: 2} + - {fileID: 11400000, guid: a0544f3bb46f87e4b902b7442a6702ca, type: 2} teams: - {fileID: 11400000, guid: 15bb40f2e1f0dd04a8ec14b3c2bb0cc4, type: 2} - {fileID: 11400000, guid: edbd6fc84edad7749b2192b14449f153, type: 2} - skills: - - {fileID: 11400000, guid: e0fa9d1311b88f547beee49449fc519f, type: 2} - - {fileID: 11400000, guid: dfe22705bcdd79847ba1a5df96149c38, type: 2} - - {fileID: 11400000, guid: 9216a251e61bcfe4d80b1430c9b830a7, type: 2} + skills: [] _TRPGOptions: _gameType: 0 _turnType: 0 @@ -90,6 +96,14 @@ MonoBehaviour: minValue: 0 value: 0 isCore: 1 + _damageAttribute: + name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 _moveRange: name: Move Range id: MVR diff --git a/Assets/TRPGMaker/Database/Items/Axe.asset b/Assets/TRPGMaker/Database/Items/Axe.asset index 6f2da02..19e0fa2 100644 --- a/Assets/TRPGMaker/Database/Items/Axe.asset +++ b/Assets/TRPGMaker/Database/Items/Axe.asset @@ -14,7 +14,13 @@ MonoBehaviour: name: Axe description: Enter item description tags: [] + _formulas: + - attributeID: HP + formula: HP + 15 + - attributeID: DMG + formula: DMG + 10 icon: {fileID: 2800000, guid: c0470fcd9b1259b4c972a2f119f22e43, type: 3} SlotType: - slotsOcupped: - - Head + - Right hand + - Left hand diff --git a/Assets/TRPGMaker/Database/Items/New Item(3).asset b/Assets/TRPGMaker/Database/Items/New Item(3).asset deleted file mode 100644 index 94e8f7d..0000000 --- a/Assets/TRPGMaker/Database/Items/New Item(3).asset +++ /dev/null @@ -1,17 +0,0 @@ -%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: 169f70efb2d642342bccf93f555f7742, type: 3} - m_Name: New Item(3) - m_EditorClassIdentifier: - name: New Item(3) - description: Enter item description - tags: [] - SlotType: [] diff --git a/Assets/TRPGMaker/Database/Items/New Item(3).asset.meta b/Assets/TRPGMaker/Database/Items/New Item(3).asset.meta deleted file mode 100644 index 084431f..0000000 --- a/Assets/TRPGMaker/Database/Items/New Item(3).asset.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: a06817ff9fca9d14b9df2b85c4fd2c2e -timeCreated: 1521548723 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 11400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/TRPGMaker/Database/Items/New Item(2).asset b/Assets/TRPGMaker/Database/Items/Rod.asset similarity index 78% rename from Assets/TRPGMaker/Database/Items/New Item(2).asset rename to Assets/TRPGMaker/Database/Items/Rod.asset index db40687..f846130 100644 --- a/Assets/TRPGMaker/Database/Items/New Item(2).asset +++ b/Assets/TRPGMaker/Database/Items/Rod.asset @@ -9,9 +9,13 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 169f70efb2d642342bccf93f555f7742, type: 3} - m_Name: New Item(2) + m_Name: Rod m_EditorClassIdentifier: - name: New Item(2) + name: Rod description: Enter item description tags: [] - SlotType: [] + _formulas: [] + icon: {fileID: 0} + SlotType: + - slotsOcupped: + - Right hand diff --git a/Assets/TRPGMaker/Database/Items/New Item(2).asset.meta b/Assets/TRPGMaker/Database/Items/Rod.asset.meta similarity index 72% rename from Assets/TRPGMaker/Database/Items/New Item(2).asset.meta rename to Assets/TRPGMaker/Database/Items/Rod.asset.meta index eabf9d1..84879fc 100644 --- a/Assets/TRPGMaker/Database/Items/New Item(2).asset.meta +++ b/Assets/TRPGMaker/Database/Items/Rod.asset.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: f6b6622b87c152f4599e44b22cdddc5a -timeCreated: 1521548721 +guid: 7182cd41f7eb67743a3612a0fd7c9ac5 +timeCreated: 1525259812 licenseType: Free NativeFormatImporter: externalObjects: {} diff --git a/Assets/TRPGMaker/Database/Items/Sword.asset b/Assets/TRPGMaker/Database/Items/Sword.asset index c71cce1..a2ec6d7 100644 --- a/Assets/TRPGMaker/Database/Items/Sword.asset +++ b/Assets/TRPGMaker/Database/Items/Sword.asset @@ -12,8 +12,12 @@ MonoBehaviour: m_Name: Sword m_EditorClassIdentifier: name: Sword - description: Enter item description - tags: - - Espada + description: sgrgsdrgd + tags: [] + _formulas: [] icon: {fileID: 2800000, guid: c547d731c4e32864b989aab9fe59d085, type: 3} - SlotType: [] + SlotType: + - slotsOcupped: + - Right hand + - slotsOcupped: + - Left hand diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset b/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset deleted file mode 100644 index 8c21f7f..0000000 --- a/Assets/TRPGMaker/Database/Skills/NewSkill(1).asset +++ /dev/null @@ -1,17 +0,0 @@ -%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: NewSkill(1) - description: - skillType: 0 - damage: 0 diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset b/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset deleted file mode 100644 index b1336e2..0000000 --- a/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset +++ /dev/null @@ -1,17 +0,0 @@ -%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: NewSkill(2) - description: - skillType: 0 - damage: 0 diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset.meta b/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset.meta deleted file mode 100644 index 9732054..0000000 --- a/Assets/TRPGMaker/Database/Skills/NewSkill(2).asset.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 9216a251e61bcfe4d80b1430c9b830a7 -timeCreated: 1524505622 -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 deleted file mode 100644 index c1f19f4..0000000 --- a/Assets/TRPGMaker/Database/Skills/NewSkill.asset +++ /dev/null @@ -1,17 +0,0 @@ -%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: NewSkill - description: - skillType: 3 - damage: 0 diff --git a/Assets/TRPGMaker/Database/Skills/NewSkill.asset.meta b/Assets/TRPGMaker/Database/Skills/NewSkill.asset.meta deleted file mode 100644 index 27f98ed..0000000 --- a/Assets/TRPGMaker/Database/Skills/NewSkill.asset.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: e0fa9d1311b88f547beee49449fc519f -timeCreated: 1524503959 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 11400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset b/Assets/TRPGMaker/Database/SpecializedClasses/Wizar.asset similarity index 70% rename from Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset rename to Assets/TRPGMaker/Database/SpecializedClasses/Wizar.asset index 7218907..5f0c009 100644 --- a/Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset +++ b/Assets/TRPGMaker/Database/SpecializedClasses/Wizar.asset @@ -9,18 +9,21 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: a4cfe1e2b18c9494b8e22325c9a32ff7, type: 3} - m_Name: NewSpecializedClass + m_Name: Wizar m_EditorClassIdentifier: - name: New Specialized Class + name: Wizard tags: [] - slots: [] + slots: + - slotType: Right hand + _modifier: {fileID: 11400000, guid: 7182cd41f7eb67743a3612a0fd7c9ac5, type: 2} + calculatedFormula: 0 attributes: - name: Health id: HP description: maxValue: 0 minValue: 0 - value: 0 + value: 10 isCore: 1 - name: Move Range id: MVR @@ -50,5 +53,19 @@ MonoBehaviour: minValue: 0 value: 1 isCore: 1 + - name: Damage + id: DMG + description: Damage + maxValue: 300 + minValue: 0 + value: 50 + isCore: 1 + - name: Mana + id: MAN + description: + maxValue: 0 + minValue: 0 + value: 0 + isCore: 0 formula: {fileID: 0} skills: [] diff --git a/Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset.meta b/Assets/TRPGMaker/Database/SpecializedClasses/Wizar.asset.meta similarity index 100% rename from Assets/TRPGMaker/Database/SpecializedClasses/NewSpecializedClass.asset.meta rename to Assets/TRPGMaker/Database/SpecializedClasses/Wizar.asset.meta diff --git a/Assets/TRPGMaker/Database/Teams/NewTeam(1).asset b/Assets/TRPGMaker/Database/Teams/Enemy Tea.asset similarity index 92% rename from Assets/TRPGMaker/Database/Teams/NewTeam(1).asset rename to Assets/TRPGMaker/Database/Teams/Enemy Tea.asset index 666e486..6c5389e 100644 --- a/Assets/TRPGMaker/Database/Teams/NewTeam(1).asset +++ b/Assets/TRPGMaker/Database/Teams/Enemy Tea.asset @@ -9,13 +9,13 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 4a7b1fcdece9778478b2575993f98a72, type: 3} - m_Name: NewTeam(1) + m_Name: Enemy Tea m_EditorClassIdentifier: - name: NewTeam(1) + name: Enemy Team id: 0 characters: - {fileID: 11400000, guid: 2ce6ded48f42c8e46b99a9a665a8efda, type: 2} - {fileID: 11400000, guid: 75942776545ea02418c221a9273f406b, type: 2} - {fileID: 11400000, guid: bac31a58c9f786c4a9d5b67034ba5482, type: 2} - {fileID: 11400000, guid: 496024b31fb8d604ba8b12317f0d4762, type: 2} - playable: 1 + playable: 0 diff --git a/Assets/TRPGMaker/Database/Teams/NewTeam(1).asset.meta b/Assets/TRPGMaker/Database/Teams/Enemy Tea.asset.meta similarity index 100% rename from Assets/TRPGMaker/Database/Teams/NewTeam(1).asset.meta rename to Assets/TRPGMaker/Database/Teams/Enemy Tea.asset.meta diff --git a/Assets/TRPGMaker/Database/Teams/NewTeam.asset b/Assets/TRPGMaker/Database/Teams/Playable Tea.asset similarity index 92% rename from Assets/TRPGMaker/Database/Teams/NewTeam.asset rename to Assets/TRPGMaker/Database/Teams/Playable Tea.asset index 67968c1..fb99a46 100644 --- a/Assets/TRPGMaker/Database/Teams/NewTeam.asset +++ b/Assets/TRPGMaker/Database/Teams/Playable Tea.asset @@ -9,9 +9,9 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 4a7b1fcdece9778478b2575993f98a72, type: 3} - m_Name: NewTeam + m_Name: Playable Tea m_EditorClassIdentifier: - name: NewTeam + name: Playable Team id: 0 characters: - {fileID: 11400000, guid: 36a63a88f336fee4fbee3ca4e3812861, type: 2} diff --git a/Assets/TRPGMaker/Database/Teams/NewTeam.asset.meta b/Assets/TRPGMaker/Database/Teams/Playable Tea.asset.meta similarity index 100% rename from Assets/TRPGMaker/Database/Teams/NewTeam.asset.meta rename to Assets/TRPGMaker/Database/Teams/Playable Tea.asset.meta diff --git a/Assets/TRPGMaker/Editor/CharacterEditor.cs b/Assets/TRPGMaker/Editor/CharacterEditor.cs index ca4d6e6..bacaa60 100644 --- a/Assets/TRPGMaker/Editor/CharacterEditor.cs +++ b/Assets/TRPGMaker/Editor/CharacterEditor.cs @@ -13,6 +13,7 @@ public class CharacterEditor : Editor { private ReorderableList listSlots; private ReorderableList listSlotsSpecializedClasses; private ReorderableList listAttributes; + private ReorderableList listAttributesFormulas; List foldout; private Vector2 scrollPosition; @@ -55,7 +56,12 @@ private void OnEnable() // Get Attributes listAttributes = new ReorderableList(serializedObject, serializedObject.FindProperty("attributes"), - false, true, true, true); + false, true, true, true); + + // Get Attributes Formulas + listAttributesFormulas = new ReorderableList(serializedObject, + serializedObject.FindProperty("attributesWithFormulas"), + false, true, true, true); //Get List SpecializedClass listSpecializedClass = new ReorderableList(serializedObject, @@ -92,15 +98,36 @@ private void OnEnable() var element = listSlotsSpecializedClasses.serializedProperty.GetArrayElementAtIndex(index); SpecializedClass specializedClass = (SpecializedClass)element.objectReferenceValue; + int i = 0; foreach (Slot slot in specializedClass.slots) { if (slot.slotType != null && slot.modifier != null) { - EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), slot.slotType + " - " + slot.modifier.name); + EditorGUI.LabelField(new Rect(rect.x, rect.y + (EditorGUIUtility.singleLineHeight * i), rect.width, EditorGUIUtility.singleLineHeight), slot.slotType + " - " + slot.modifier.name); + //listSlotsSpecializedClasses.elementHeight += EditorGUIUtility.singleLineHeight; + i++; } - } + } + }; + // Set height of Slots defined in specialized classes + listSlotsSpecializedClasses.elementHeightCallback = (index) => + { + var element = listSlotsSpecializedClasses.serializedProperty.GetArrayElementAtIndex(index); + SpecializedClass specializedClass = (SpecializedClass)element.objectReferenceValue; + + int i = 0; + foreach (Slot slot in specializedClass.slots) + { + if (slot.slotType != null && slot.modifier != null) + { + i++; + } + } + return EditorGUIUtility.singleLineHeight * i; + }; + //Draw specialzed classes listSpecializedClass.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { @@ -143,6 +170,18 @@ private void OnEnable() else return EditorGUIUtility.singleLineHeight + 4.0f; }; + // Draw attributes with formulas + listAttributesFormulas.drawElementCallback = + (Rect rectL, int index, bool isActive, bool isFocused) => { + var element = character.attributesWithFormulas[index]; + var textDimensions = GUI.skin.label.CalcSize(new GUIContent(element.name)); + rectL.y += 2; + + EditorGUI.LabelField(new Rect(rectL.x, rectL.y, textDimensions.x, rectL.height), element.name); + EditorGUI.LabelField(new Rect(rectL.x + textDimensions.x - 5, rectL.y, 10, rectL.height), " = "); + EditorGUI.LabelField(new Rect(rectL.x + textDimensions.x + 5, rectL.y, rectL.width - textDimensions.x - 5, rectL.height), element.value.ToString()); + }; + // Slots header listSlots.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Slots"); @@ -158,6 +197,11 @@ private void OnEnable() EditorGUI.LabelField(rect, "Attributes"); }; + // listAttributes with Formulas header + listAttributesFormulas.drawHeaderCallback = (Rect rect) => { + EditorGUI.LabelField(rect, "Attributes from Formulas"); + }; + //listSpecializedClass header listSpecializedClass.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Specialized Classes"); @@ -199,20 +243,35 @@ private void OnEnable() else return true; }; + + // Remove specialized classes + listSpecializedClass.onRemoveCallback = (ReorderableList l) => { + character.specializedClasses.Remove(listSpecializedClass.serializedProperty.GetArrayElementAtIndex(l.index).objectReferenceValue as SpecializedClass); + }; } public override void OnInspectorGUI() { serializedObject.Update(); - // Clean array if there are null objects - for (int i = 0; i < listSpecializedClass.serializedProperty.arraySize; i++) + // Check if slots changed + foreach (Slot s in character.Slots) { - var elementProperty = listSpecializedClass.serializedProperty.GetArrayElementAtIndex(i); - if (elementProperty.objectReferenceValue == null) - listSpecializedClass.serializedProperty.DeleteArrayElementAtIndex(i); + var calculate = false; + if (s.modifier != null && !s.calculatedFormula) + { + Debug.Log(s.modifier.name); + calculate = true; + s.calculatedFormula = true; + } + if (calculate) + character.calculateFormulas(); } + // Check is specialiazed Classes changed + if(character.specializedClasses.Count != character.specializedClassesCount) + character.calculateFormulas(); + var customStyle = new GUIStyle(); customStyle.alignment = TextAnchor.UpperCenter; @@ -231,6 +290,7 @@ public override void OnInspectorGUI() } listAttributes.DoLayoutList(); + listAttributesFormulas.DoLayoutList(); listSlots.DoLayoutList(); listSlotsSpecializedClasses.DoLayoutList(); listSpecializedClass.DoLayoutList(); diff --git a/Assets/TRPGMaker/Editor/ItemEditor.cs b/Assets/TRPGMaker/Editor/ItemEditor.cs index 6ecb82d..2c5ebd3 100644 --- a/Assets/TRPGMaker/Editor/ItemEditor.cs +++ b/Assets/TRPGMaker/Editor/ItemEditor.cs @@ -1,8 +1,10 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Reflection; using UnityEditor; using UnityEditor.SceneManagement; +using UnityEditorInternal; using UnityEngine; using UnityEngine.SceneManagement; @@ -15,8 +17,9 @@ public class ItemEditor : Editor private string tag; private string lastTag; int lastCursorPos = 0; + int indexFormula; - + private ReorderableList listFormulas; private Vector2 scrollPosition; void Init() @@ -24,13 +27,64 @@ void Init() dropDown = new DropDown("Tags:"); item = (Item)target; - if(item.formula == null) - item.formula = ScriptableObject.CreateInstance(); - // Draw stored tags drawTags(); } + private void OnEnable() + { + // 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 = item.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 - 70, EditorGUIUtility.singleLineHeight), formula.formula); + + var f = FormulaScript.Create(formula.formula); + if (!f.FormulaParser.IsValidExpression) + { + EditorGUI.LabelField(new Rect(rect.x + 70, rect.y + EditorGUIUtility.singleLineHeight + 2.0f, rect.width, EditorGUIUtility.singleLineHeight), f.FormulaParser.Error); + } + + if (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) => { + item.formulas.Add(new Formula()); + serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(target); + }; + + // Remove formula + listFormulas.onRemoveCallback = (ReorderableList l) => { + item.formulas.Remove(item.formulas[l.index]); + serializedObject.ApplyModifiedProperties(); + }; + } + public override void OnInspectorGUI() { if (dropDown == null) @@ -114,7 +168,10 @@ public override void OnInspectorGUI() if(i != item.SlotType.Count - 1) GUILayout.Label("OR", centeredStyle); } - + + // For formulas + listFormulas.DoLayoutList(); + // Detect if text changed if (EditorGUI.EndChangeCheck()) { @@ -134,7 +191,6 @@ public override void OnInspectorGUI() { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); - EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath((Item)target), item.name + ".asset"); } @@ -151,19 +207,11 @@ public override void OnInspectorGUI() } } - // For formulas - EditorGUI.BeginChangeCheck(); - EditorGUILayout.LabelField("Formula:", EditorStyles.boldLabel); - var f = item.formula; - f.formula = EditorGUILayout.TextField(f.formula); - - if (!f.FormulaParser.IsValidExpression) - { - EditorGUILayout.LabelField(f.FormulaParser.Error); - } - EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); + + serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(target); } void dropDownSearch() diff --git a/Assets/TRPGMaker/Editor/SpecializedClassEditor.cs b/Assets/TRPGMaker/Editor/SpecializedClassEditor.cs index c2c4c92..3508552 100644 --- a/Assets/TRPGMaker/Editor/SpecializedClassEditor.cs +++ b/Assets/TRPGMaker/Editor/SpecializedClassEditor.cs @@ -245,20 +245,17 @@ private void OnEnable() } menu.ShowAsContext(); }; + + // Remove skill + listSkills.onRemoveCallback = (ReorderableList l) => { + specializedClass.skills.Remove(listSkills.serializedProperty.GetArrayElementAtIndex(l.index).objectReferenceValue as Skills); + }; } public override void OnInspectorGUI() { serializedObject.Update(); - // Clean array if there are null objects - for (int i = 0; i < listSkills.serializedProperty.arraySize; i++) - { - var elementProperty = listSkills.serializedProperty.GetArrayElementAtIndex(i); - if (elementProperty.objectReferenceValue == null) - listSkills.serializedProperty.DeleteArrayElementAtIndex(i); - } - var customStyle = new GUIStyle(); customStyle.alignment = TextAnchor.UpperCenter; customStyle.fontSize = 17; @@ -280,7 +277,7 @@ public override void OnInspectorGUI() listSkills.DoLayoutList(); //listFormulas.DoLayoutList(); - // For formulas + /* // For formulas EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Formula:", EditorStyles.boldLabel); var f = specializedClass.formula; @@ -289,7 +286,7 @@ public override void OnInspectorGUI() if (!f.FormulaParser.IsValidExpression) { EditorGUILayout.LabelField(f.FormulaParser.Error); - } + }*/ EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); diff --git a/Assets/TRPGMaker/Editor/Windows/Battle/BattleOptionsWindow.cs b/Assets/TRPGMaker/Editor/Windows/Battle/BattleOptionsWindow.cs index fc48d2e..77ee18c 100644 --- a/Assets/TRPGMaker/Editor/Windows/Battle/BattleOptionsWindow.cs +++ b/Assets/TRPGMaker/Editor/Windows/Battle/BattleOptionsWindow.cs @@ -9,6 +9,7 @@ public class BattleOptionsWindow : EditorWindow private int selectedGameType = -1; private int selectedTurnStyle = -1; private int selectedHealthAttribte = -1; + private int selectedDamageAttribute = -1; private int selectedMovementRange = -1; private int selectedMovementHeight = -1; private int selectedAttackRange = -1; @@ -29,6 +30,7 @@ private void OnEnable() { this.selectedTurnStyle = (int) Database.Instance.battleOptions.turnType; this.selectedHealthAttribte = Database.Instance.attributes.IndexOf(Database.Instance.battleOptions.healthAttribute); + this.selectedDamageAttribute = Database.Instance.attributes.IndexOf(Database.Instance.battleOptions.damageAttribute); this.selectedMovementRange = Database.Instance.attributes.IndexOf(Database.Instance.battleOptions.moveRange); this.selectedMovementHeight = Database.Instance.attributes.IndexOf(Database.Instance.battleOptions.moveHeight); this.selectedAttackRange = Database.Instance.attributes.IndexOf(Database.Instance.battleOptions.attackRange); @@ -65,6 +67,11 @@ void OnGUI() selectedHealthAttribte = EditorGUILayout.Popup(selectedHealthAttribte, Database.Instance.attributes.Select(o => o.name).ToArray()); EditorGUILayout.EndHorizontal(); + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Damage attribute name:"); + selectedDamageAttribute = EditorGUILayout.Popup(selectedDamageAttribute, Database.Instance.attributes.Select(o => o.name).ToArray()); + EditorGUILayout.EndHorizontal(); + EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Movement range attribute name:"); selectedMovementRange = EditorGUILayout.Popup(selectedMovementRange, Database.Instance.attributes.Select(o => o.name).ToArray()); @@ -89,6 +96,7 @@ void OnGUI() { if (selectedTurnStyle != -1) Database.Instance.battleOptions.turnType = (TurnTypes) selectedTurnStyle; if(selectedHealthAttribte != -1) Database.Instance.battleOptions.healthAttribute = Database.Instance.attributes[selectedHealthAttribte]; + if (selectedDamageAttribute != -1) Database.Instance.battleOptions.damageAttribute = Database.Instance.attributes[selectedDamageAttribute]; if (selectedMovementRange != -1) Database.Instance.battleOptions.moveRange = Database.Instance.attributes[selectedMovementRange]; if (selectedMovementHeight != -1) Database.Instance.battleOptions.moveHeight = Database.Instance.attributes[selectedMovementHeight]; if (selectedAttackRange != -1) Database.Instance.battleOptions.attackRange = Database.Instance.attributes[selectedAttackRange]; diff --git a/Assets/TRPGMaker/Scripts/Database/Attribute.cs b/Assets/TRPGMaker/Scripts/Database/Attribute.cs index f5212b5..f06315a 100644 --- a/Assets/TRPGMaker/Scripts/Database/Attribute.cs +++ b/Assets/TRPGMaker/Scripts/Database/Attribute.cs @@ -57,6 +57,6 @@ public override bool Equals(object obj) public override int GetHashCode() { - return Int32.Parse(id); + return id.GetHashCode(); } } diff --git a/Assets/TRPGMaker/Scripts/Database/Character.cs b/Assets/TRPGMaker/Scripts/Database/Character.cs index f23e9d8..f27f7f9 100644 --- a/Assets/TRPGMaker/Scripts/Database/Character.cs +++ b/Assets/TRPGMaker/Scripts/Database/Character.cs @@ -19,7 +19,10 @@ public class Character: ScriptableObject{ [SerializeField] public List attributes = null; [SerializeField] + public List attributesWithFormulas = null; + [SerializeField] public List specializedClasses; + public int specializedClassesCount = 0; public void init() { @@ -48,4 +51,34 @@ public void refresh() attributes.AddRange(specializedClasses.SelectMany(z => z.attributes).Where(x => !attributes.Any(y => y.id == x.id))); } } + + public void calculateFormulas() + { + var f = FormulaScript.Create(""); + attributesWithFormulas = Extensions.Clone(attributes).ToList(); + // Formulas in slots + foreach (Slot slot in Slots) + { + foreach(Formula formula in slot.modifier.formulas) + { + f.formula = formula.formula; + var r = f.FormulaParser.Evaluate(); + attributesWithFormulas.Find(x => x.id == formula.attributeID).value += (int) r; + } + } + // Formulas in slots of specialized classes + foreach (SpecializedClass specializedClass in specializedClasses) + { + foreach (Slot slot in specializedClass.slots) + { + foreach (Formula formula in slot.modifier.formulas) + { + f.formula = formula.formula; + var r = f.FormulaParser.Evaluate(); + attributesWithFormulas.Find(x => x.id == formula.attributeID).value += (int)r; + } + } + } + specializedClassesCount = specializedClasses.Count; + } } \ No newline at end of file diff --git a/Assets/TRPGMaker/Scripts/Database/Formula.cs b/Assets/TRPGMaker/Scripts/Database/Formula.cs index 31f9200..19b835b 100644 --- a/Assets/TRPGMaker/Scripts/Database/Formula.cs +++ b/Assets/TRPGMaker/Scripts/Database/Formula.cs @@ -1,51 +1,11 @@ -using UnityEngine; -using NCalc; -using System.Reflection; +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; -public class Formula : ScriptableObject { +[Serializable] +public class Formula { - public static Formula Create(string formula) - { - var r = ScriptableObject.CreateInstance(); - r.formula = formula; - return r; - } - - [SerializeField] - private string _formula = ""; - public string formula - { - get { return _formula; } - set - { - name = value; - _formula = value; - FormulaParser.Formula = _formula; - } - } - - public FormulaParser FormulaParser { get; private set; } - - void Awake() - { - FormulaParser = new FormulaParser(); - } - - void OnEnable() - { - FormulaParser = new FormulaParser(); - FormulaParser.Formula = _formula; - } - - - public bool check() - { - var r = FormulaParser.Evaluate(); - return r is bool ? (bool)r : false; - } - - public override string ToString() - { - return this._formula; - } -} \ No newline at end of file + public string attributeID = ""; + public string formula = ""; +} diff --git a/Assets/TRPGMaker/Scripts/Database/Formula.cs.meta b/Assets/TRPGMaker/Scripts/Database/Formula.cs.meta index dc8a1da..673f3b8 100644 --- a/Assets/TRPGMaker/Scripts/Database/Formula.cs.meta +++ b/Assets/TRPGMaker/Scripts/Database/Formula.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 042bef02c534c4448a01dfc62b089d8c -timeCreated: 1524657384 +guid: 0277865a899b2a84d8c74a7d06575e10 +timeCreated: 1525212652 licenseType: Free MonoImporter: externalObjects: {} diff --git a/Assets/TRPGMaker/Scripts/Database/Modifier.cs b/Assets/TRPGMaker/Scripts/Database/Modifier.cs index c661230..ad5e947 100644 --- a/Assets/TRPGMaker/Scripts/Database/Modifier.cs +++ b/Assets/TRPGMaker/Scripts/Database/Modifier.cs @@ -15,7 +15,21 @@ public class Modifier: ScriptableObject { public new string name = "Enter item name"; public string description = "Enter item description"; public List tags = new List(); - public Formula formula; + [SerializeField] + private List _formulas = new List(); + public List formulas + { + get + { + return _formulas; + } + set + { + _formulas = value; + } + } + + public Texture2D icon; [Serializable] diff --git a/Assets/TRPGMaker/Scripts/Database/Slot.cs b/Assets/TRPGMaker/Scripts/Database/Slot.cs index 10b9a85..05819a6 100644 --- a/Assets/TRPGMaker/Scripts/Database/Slot.cs +++ b/Assets/TRPGMaker/Scripts/Database/Slot.cs @@ -7,17 +7,23 @@ public class Slot{ public string slotType; - public Modifier modifier; - - // Use this for initialization - void Start () { - - } - - // Update is called once per frame - void Update () { - - } + public Modifier _modifier; + + public Modifier modifier + { + get + { + return _modifier; + } + + set + { + //#3 + _modifier = value; + calculatedFormula = false; + } + } + public bool calculatedFormula; public void setModifier(Modifier modifier) { @@ -136,4 +142,5 @@ public Boolean canEquip(Modifier modifier) return slotExist; } + } diff --git a/Assets/TRPGMaker/Scripts/Database/SpecializedClass.cs b/Assets/TRPGMaker/Scripts/Database/SpecializedClass.cs index 11fc56b..fc323ce 100644 --- a/Assets/TRPGMaker/Scripts/Database/SpecializedClass.cs +++ b/Assets/TRPGMaker/Scripts/Database/SpecializedClass.cs @@ -13,14 +13,14 @@ public class SpecializedClass : ScriptableObject public List tags; public List slots; public List attributes = null; - public Formula formula; + public FormulaScript formula; public List skills; public void Init() { tags = new List(); slots = new List(); - formula = ScriptableObject.CreateInstance(); + formula = ScriptableObject.CreateInstance(); } public void refreshAttributes() diff --git a/Assets/TRPGMaker/Scripts/Game/CharacterScript.cs b/Assets/TRPGMaker/Scripts/Game/CharacterScript.cs index 8c6b449..34d300d 100644 --- a/Assets/TRPGMaker/Scripts/Game/CharacterScript.cs +++ b/Assets/TRPGMaker/Scripts/Game/CharacterScript.cs @@ -13,7 +13,7 @@ public class CharacterScript : MonoBehaviour { private void Start() { - + } private void OnGUI() @@ -36,13 +36,24 @@ private void OnGUI() void OnMouseEnter() { - Debug.Log("AAA"); + } void Update() { - + foreach(Slot s in character.Slots) + { + var calculate = false; + if (s.modifier != null && !s.calculatedFormula) + { + Debug.Log(s.modifier.name); + calculate = true; + s.calculatedFormula = true; + } + if (calculate) + character.calculateFormulas(); + } } } diff --git a/Assets/TRPGMaker/Scripts/Game/FormulaScript.cs b/Assets/TRPGMaker/Scripts/Game/FormulaScript.cs new file mode 100644 index 0000000..3614730 --- /dev/null +++ b/Assets/TRPGMaker/Scripts/Game/FormulaScript.cs @@ -0,0 +1,52 @@ +using UnityEngine; +using NCalc; +using System.Reflection; +using System; + +[Serializable] +public class FormulaScript : ScriptableObject { + + public static FormulaScript Create(string formula) + { + var r = ScriptableObject.CreateInstance(); + r.formula = formula; + return r; + } + + [SerializeField] + private string _formula; + public string formula + { + get { return _formula; } + set + { + _formula = value; + FormulaParser.Formula = _formula; + } + } + + public FormulaParser FormulaParser { get; private set; } + + void Awake() + { + FormulaParser = new FormulaParser(); + } + + void OnEnable() + { + FormulaParser = new FormulaParser(); + FormulaParser.Formula = _formula; + } + + + public bool check() + { + var r = FormulaParser.Evaluate(); + return r is bool ? (bool)r : false; + } + + public override string ToString() + { + return this._formula; + } +} \ No newline at end of file diff --git a/Assets/TRPGMaker/Scripts/Game/FormulaScript.cs.meta b/Assets/TRPGMaker/Scripts/Game/FormulaScript.cs.meta new file mode 100644 index 0000000..dc8a1da --- /dev/null +++ b/Assets/TRPGMaker/Scripts/Game/FormulaScript.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 042bef02c534c4448a01dfc62b089d8c +timeCreated: 1524657384 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TRPGMaker/Scripts/Game/GamePlayManager.cs b/Assets/TRPGMaker/Scripts/Game/GamePlayManager.cs index 44ee00c..7933da4 100644 --- a/Assets/TRPGMaker/Scripts/Game/GamePlayManager.cs +++ b/Assets/TRPGMaker/Scripts/Game/GamePlayManager.cs @@ -212,7 +212,7 @@ public void AttackEvent() { CharacterScript characterDestAttack = connector.GetCharacterAtCell(selectedCell); - characterDestAttack.character.attributes.Find(x => x.id == Database.Instance.battleOptions.healthAttribute.id).value -= 150; // This is a test. CHANGE THIS!! + characterDestAttack.character.attributes.Find(x => x.id == Database.Instance.battleOptions.healthAttribute.id).value -= character.character.attributes.Find(x => x.id == Database.Instance.battleOptions.damageAttribute.id).value; if (characterDestAttack.character.attributes.Find(x => x.id == Database.Instance.battleOptions.healthAttribute.id).value <= 0) { @@ -230,7 +230,7 @@ public void attackEventIA(CharacterScript target) { connector.IAAttack(character, target, ShowAreaCallBackParametrizedCallback(character, (character1, selectedCell, result1) => { - target.character.attributes.Find(x => x.id == Database.Instance.battleOptions.healthAttribute.id).value -= 50; // This is a test. CHANGE THIS!! + target.character.attributes.Find(x => x.id == Database.Instance.battleOptions.healthAttribute.id).value -= character.character.attributes.Find(x => x.id == Database.Instance.battleOptions.damageAttribute.id).value; Turn(); })); } diff --git a/Assets/TRPGMaker/Scripts/Game/TRPGOptions.cs b/Assets/TRPGMaker/Scripts/Game/TRPGOptions.cs index f48597e..9a50681 100644 --- a/Assets/TRPGMaker/Scripts/Game/TRPGOptions.cs +++ b/Assets/TRPGMaker/Scripts/Game/TRPGOptions.cs @@ -50,6 +50,21 @@ public Attribute healthAttribute } } + [SerializeField] + private Attribute _damageAttribute; + + public Attribute damageAttribute + { + get + { + return _damageAttribute; + } + set + { + _damageAttribute = value; + } + } + [SerializeField] private Attribute _moveRange; diff --git a/Assets/TRPGMaker/Scripts/Utils/FormulaParser.cs b/Assets/TRPGMaker/Scripts/Utils/FormulaParser.cs index 118e521..a182045 100644 --- a/Assets/TRPGMaker/Scripts/Utils/FormulaParser.cs +++ b/Assets/TRPGMaker/Scripts/Utils/FormulaParser.cs @@ -2,7 +2,9 @@ using NCalc; using System.Reflection; using System.Linq; +using System; +[Serializable] public class FormulaParser { private Expression expression; @@ -91,7 +93,7 @@ private void CheckParameter(string param, ParameterArgs args) if (Database.Instance.attributes.Any(x => x.id == param)) { args.HasResult = true; - args.Result = Database.Instance.attributes.Select(x => x.id == param); + args.Result = Database.Instance.attributes.Find(x => x.id == param).value; } else { @@ -102,92 +104,11 @@ private void CheckParameter(string param, ParameterArgs args) private void EvaluateFunction(string name, FunctionArgs args) { - functionError = ""; - - switch (name) - { - case "var": - { - if (args.Parameters.Length < 3) - { - functionError = "Function 'var' requires 3 arguments."; - return; - } - - var gameObject = (string)args.Parameters[0].Evaluate(); - if (!(gameObject is string)) - { - functionError = "Function 'var' 1st parameter is not string."; - return; - } - var component = (string)args.Parameters[1].Evaluate(); - if (!(component is string)) - { - functionError = "Function 'var' 2nd parameter is not string."; - return; - } - var property = (string)args.Parameters[2].Evaluate(); - if (!(property is string)) - { - functionError = "Function 'var' 3rd parameter is not string."; - return; - } - - if (Application.isPlaying) // Only real check runtime - { - GameObject go = GameObject.Find(gameObject); - Component co = null; - PropertyInfo p = null; - - if (go) co = go.GetComponent(component); - if (co) p = co.GetType().GetProperty(property); - - // Result - args.HasResult = go != null && co != null && p != null; - if (args.HasResult) args.Result = p.GetValue(co, null); - else - { - if (go == null) - functionError = "Formula '" + name + "' function error: GameObject \"" + gameObject + "\" not found in scene."; - else if (co == null) - functionError = "Formula '" + name + "' function error: Component \"" + component + "\" not found in \"" + gameObject + "\" gameObject."; - else if (p == null) - functionError = "Formula '" + name + "' function error: Property \"" + property + "\" not found in \"" + component + "\" component."; - } - } - } - - break; - - case "varObject": - case "objectVar": - { - if (args.Parameters.Length < 2) - { - functionError = "Function '" + name + "' requires 2 arguments."; - return; - } - - var objectName = (string)args.Parameters[0].Evaluate(); - if (!(objectName is string)) - { - functionError = "Function '" + name + "' 1st parameter is not string."; - return; - } - var property = (string)args.Parameters[1].Evaluate(); - if (!(property is string)) - { - functionError = "Function '" + name + "' 2nd parameter is not string."; - return; - } - } - break; - /*default: - functionError = "Missing function \"" + name + "\""; - break;*/ - } + } + + public object Evaluate() { return expression.Evaluate(); diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 52b0903..7ff3f1a 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,9 +3,10 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 12 + serializedVersion: 14 productGUID: 716526984c76f0348af44a9b11730748 AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 defaultScreenOrientation: 4 targetDevice: 2 useOnDemandResources: 0 @@ -38,8 +39,6 @@ PlayerSettings: width: 1 height: 1 m_SplashScreenLogos: [] - m_SplashScreenBackgroundLandscape: {fileID: 0} - m_SplashScreenBackgroundPortrait: {fileID: 0} m_VirtualRealitySplashScreen: {fileID: 0} m_HolographicTrackingLossScreen: {fileID: 0} defaultScreenWidth: 1024 @@ -49,7 +48,6 @@ PlayerSettings: m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 m_MTRendering: 1 - m_MobileMTRendering: 0 m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 @@ -63,14 +61,19 @@ PlayerSettings: allowedAutorotateToLandscapeLeft: 1 useOSAutorotation: 1 use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 disableDepthAndStencilBuffers: 0 + androidBlitType: 0 defaultIsFullScreen: 1 defaultIsNativeResolution: 1 + macRetinaSupport: 1 runInBackground: 0 captureSingleScreen: 0 muteOtherAudioSources: 0 Prepare IOS For Recording: 0 Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 submitAnalytics: 1 usePlayerLog: 1 bakeCollisionMeshes: 0 @@ -89,20 +92,22 @@ PlayerSettings: allowFullscreenSwitch: 1 graphicsJobMode: 0 macFullscreenMode: 2 - d3d9FullscreenMode: 1 d3d11FullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 xboxEnablePIXSampling: 0 + metalFramebufferOnly: 0 n3dsDisableStereoscopicView: 0 n3dsEnableSharedListOpt: 1 n3dsEnableVSync: 0 - ignoreAlphaClear: 0 xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 xboxOneMonoLoggingLevel: 0 xboxOneLoggingLevel: 1 xboxOneDisableEsram: 0 + xboxOnePresentImmediateThreshold: 0 videoMemoryForVertexBuffers: 0 psp2PowerMode: 0 psp2AcquireBGM: 1 @@ -124,6 +129,7 @@ PlayerSettings: bundleVersion: 1.0 preloadedAssets: [] metroInputSource: 0 + wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 xboxOneDisableKinectGpuReservation: 0 xboxOneEnable7thCore: 0 @@ -134,12 +140,23 @@ PlayerSettings: daydream: depthFormat: 0 useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 hololens: depthFormat: 1 + depthBufferSharingEnabled: 0 + oculus: + sharedDepthBuffer: 0 + dashSupport: 0 protectGraphicsMemory: 0 useHDRDisplay: 0 - targetPixelDensity: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 applicationIdentifier: {} buildNumber: {} AndroidBundleVersionCode: 1 @@ -160,10 +177,10 @@ PlayerSettings: serializedVersion: 2 m_Bits: 238 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: + iOSTargetOSVersionString: 7.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 - tvOSTargetOSVersionString: + tvOSTargetOSVersionString: 9.0 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 uIRequiresFullScreen: 1 @@ -176,15 +193,22 @@ PlayerSettings: iPhone47inSplashScreen: {fileID: 0} iPhone55inPortraitSplashScreen: {fileID: 0} iPhone55inLandscapeSplashScreen: {fileID: 0} + iPhone58inPortraitSplashScreen: {fileID: 0} + iPhone58inLandscapeSplashScreen: {fileID: 0} iPadPortraitSplashScreen: {fileID: 0} iPadHighResPortraitSplashScreen: {fileID: 0} iPadLandscapeSplashScreen: {fileID: 0} iPadHighResLandscapeSplashScreen: {fileID: 0} appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] iOSLaunchScreenType: 0 iOSLaunchScreenPortrait: {fileID: 0} iOSLaunchScreenLandscape: {fileID: 0} @@ -202,6 +226,8 @@ PlayerSettings: iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] iOSBackgroundModes: 0 @@ -213,6 +239,7 @@ PlayerSettings: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: appleEnableAutomaticSigning: 0 + clonedFromGUID: 00000000000000000000000000000000 AndroidTargetDevice: 0 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} @@ -220,7 +247,9 @@ PlayerSettings: AndroidKeyaliasName: AndroidTVCompatibility: 1 AndroidIsGame: 1 + AndroidEnableTango: 0 androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 m_AndroidBanners: - width: 320 height: 180 @@ -231,10 +260,21 @@ PlayerSettings: m_BuildTargetBatching: [] m_BuildTargetGraphicsAPIs: [] m_BuildTargetVRSettings: [] + m_BuildTargetEnableVuforiaSettings: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 - webPlayerTemplate: APPLICATION:Default m_TemplateCustomTags: {} + mobileMTRendering: + Android: 1 + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: + - m_BuildTarget: Standalone + m_EncodingQuality: 1 + - m_BuildTarget: XboxOne + m_EncodingQuality: 1 + - m_BuildTarget: PS4 + m_EncodingQuality: 1 wiiUTitleID: 0005000011000000 wiiUGroupID: 00010000 wiiUCommonSaveSize: 4096 @@ -281,6 +321,9 @@ PlayerSettings: switchTitleNames_9: switchTitleNames_10: switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: switchPublisherNames_0: switchPublisherNames_1: switchPublisherNames_2: @@ -293,6 +336,9 @@ PlayerSettings: switchPublisherNames_9: switchPublisherNames_10: switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -305,6 +351,9 @@ PlayerSettings: switchIcons_9: {fileID: 0} switchIcons_10: {fileID: 0} switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} switchSmallIcons_0: {fileID: 0} switchSmallIcons_1: {fileID: 0} switchSmallIcons_2: {fileID: 0} @@ -317,6 +366,9 @@ PlayerSettings: switchSmallIcons_9: {fileID: 0} switchSmallIcons_10: {fileID: 0} switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} switchManualHTML: switchAccessibleURLs: switchLegalInformation: @@ -358,6 +410,8 @@ PlayerSettings: switchLocalCommunicationIds_7: switchParentalControl: 0 switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 switchDataLossConfirmation: 0 switchSupportedNpadStyles: 3 switchSocketConfigEnabled: 0 @@ -389,6 +443,8 @@ PlayerSettings: ps4PronunciationSIGPath: ps4BackgroundImagePath: ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: ps4SaveDataImagePath: ps4SdkOverride: ps4BGMPath: @@ -553,12 +609,6 @@ PlayerSettings: n3dsTitle: GameName n3dsProductCode: n3dsApplicationId: 0xFF3FF - stvDeviceAddress: - stvProductDescription: - stvProductAuthor: - stvProductAuthorEmail: - stvProductLink: - stvProductCategory: 0 XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -589,7 +639,7 @@ PlayerSettings: cloudServicesEnabled: UNet: 1 facebookSdkVersion: 7.9.4 - apiCompatibilityLevel: 2 + apiCompatibilityLevel: 3 cloudProjectId: 66f399e4-23f7-434e-98cc-473b30b6a90c projectName: RPGMaker organizationId: juanjpri