Many changes to Invector inventory system, added WIP UI system, added implementation for max stamina, moving speed, attack speed, attack power, thorns

This commit is contained in:
2025-12-05 15:10:52 +01:00
parent 53fa05e246
commit af7706bfac
21 changed files with 2352 additions and 3868 deletions

View File

@@ -108049,6 +108049,7 @@ MonoBehaviour:
faithMult: 0
damageMult: 0
speedMult: 0
staminaMult: 0
attackSpeedMult: 0
faithRegenMult: 0
thornDamageMult: 0

View File

@@ -1055,13 +1055,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 534348f104a39a54ba609e052d1810a8, type: 2}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -2071,13 +2071,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: ef221d5d8bf80884abcc0e2ceaea6808, type: 2}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -2934,13 +2934,13 @@ AnimatorState:
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: ef221d5d8bf80884abcc0e2ceaea6808, type: 2}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -3673,14 +3673,14 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 1827226128182048838, guid: 9ea3d471ba5f47f4dba10e92cd18dd3a,
type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -3772,14 +3772,14 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 1827226128182048838, guid: 6a317b388658f81408b11b9f07b421fd,
type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -5914,14 +5914,14 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 1827226128182048838, guid: d47c433a51e40974f8aaf2065beac139,
type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -6555,6 +6555,12 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
- m_Name: AttackSpeed
m_Type: 1
m_DefaultFloat: 1
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@@ -26502,13 +26508,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400066, guid: a9e228972999b0d46a21e30edf97d812, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -35525,13 +35531,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400026, guid: fb07a934dbc1969468121112ca048964, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -35554,13 +35560,13 @@ AnimatorState:
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400044, guid: 71a860de405aaeb44ace152c21808003, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -36520,13 +36526,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400004, guid: 5604d4bdf493f404dbe3ac4918a389e5, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -36634,13 +36640,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400032, guid: fb07a934dbc1969468121112ca048964, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -37894,13 +37900,13 @@ AnimatorState:
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400040, guid: 71a860de405aaeb44ace152c21808003, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -38431,13 +38437,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400036, guid: fb07a934dbc1969468121112ca048964, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -38461,13 +38467,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 5604d4bdf493f404dbe3ac4918a389e5, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -38546,13 +38552,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400002, guid: 5604d4bdf493f404dbe3ac4918a389e5, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -38576,13 +38582,13 @@ AnimatorState:
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400042, guid: 71a860de405aaeb44ace152c21808003, type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -40000,7 +40006,7 @@ AnimatorStateMachine:
m_Position: {x: 312, y: 120, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102897592577937754}
m_Position: {x: 312, y: 48, z: 0}
m_Position: {x: 310, y: 50, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102186440903726776}
m_Position: {x: 312, y: -24, z: 0}
@@ -45429,14 +45435,14 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 1827226128182048838, guid: 33155b0e0a894984aaa6d5beee3b6e77,
type: 3}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -49082,13 +49088,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: d9534dc6ee92ee641aa574603e830ef9, type: 2}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -49453,13 +49459,13 @@ AnimatorState:
m_IKOnFeet: 1
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_SpeedParameterActive: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: c0ea655bc6843ee46b9f3cf138dd2ac2, type: 2}
m_Tag:
m_SpeedParameter:
m_SpeedParameter: AttackSpeed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:

File diff suppressed because it is too large Load Diff

View File

@@ -11814,6 +11814,18 @@ MonoBehaviour:
velocityNoise: 0
velocityNoiseOffset: 0
velocityNoiseTiling: 1
--- !u!114 &727975805 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7579729609761860853, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
m_PrefabInstance: {fileID: 1004473948}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e673785925c433840a8a84c4bc9241a4, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &728120671
GameObject:
m_ObjectHideFlags: 0
@@ -13939,6 +13951,31 @@ PrefabInstance:
propertyPath: m_Layer
value: 5
objectReference: {fileID: 0}
- target: {fileID: 105329956921147143, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 105329956921147143, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 105329956921147143, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 105329956921147143, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 105329956921147143, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 119376054650965392, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_Layer
@@ -13954,6 +13991,36 @@ PrefabInstance:
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 214592637702616804, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 214592637702616804, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 214592637702616804, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 214592637702616804, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 214592637702616804, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 214592637702616804, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 429313324576581173, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
@@ -13962,41 +14029,61 @@ PrefabInstance:
- target: {fileID: 564995907207171390, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 564995907207171390, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 564995907207171390, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 210
objectReference: {fileID: 0}
- target: {fileID: 564995907207171390, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -135
objectReference: {fileID: 0}
- target: {fileID: 616128472424357225, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 616128472424357225, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 616128472424357225, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 210.00003
objectReference: {fileID: 0}
- target: {fileID: 616128472424357225, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -45
objectReference: {fileID: 0}
- target: {fileID: 703778627114599771, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 703778627114599771, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 703778627114599771, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 703778627114599771, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 763034042805173548, guid: 851e8e61247888340bdec90fc8aa37f5,
@@ -14044,6 +14131,31 @@ PrefabInstance:
propertyPath: m_Layer
value: 5
objectReference: {fileID: 0}
- target: {fileID: 1678797934751935751, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1678797934751935751, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1678797934751935751, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1678797934751935751, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1678797934751935751, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1743080568100117851, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_RootOrder
@@ -14054,6 +14166,11 @@ PrefabInstance:
propertyPath: 'm_Materials.Array.data[0]'
value:
objectReference: {fileID: 2050247494}
- target: {fileID: 1979772586129774935, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: changeEquipmentControllers.Array.data[4].equipArea
value:
objectReference: {fileID: 727975805}
- target: {fileID: 1979772586129774953, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_IsActive
@@ -14134,6 +14251,11 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1979772587011309954, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: selectedToolbar
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1979772587474207191, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_IsActive
@@ -14169,6 +14291,26 @@ PrefabInstance:
propertyPath: 'm_Materials.Array.data[0]'
value:
objectReference: {fileID: 204792018}
- target: {fileID: 2096271701100397905, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2096271701100397905, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2096271701100397905, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2096271701100397905, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2129222558149010038, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: openCloseWindow
@@ -14185,6 +14327,31 @@ PrefabInstance:
propertyPath: m_Layer
value: 5
objectReference: {fileID: 0}
- target: {fileID: 2153154902765628555, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2153154902765628555, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2153154902765628555, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2153154902765628555, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2153154902765628555, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2204495981219394073, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_Layer
@@ -14210,6 +14377,26 @@ PrefabInstance:
propertyPath: 'm_Materials.Array.data[0]'
value:
objectReference: {fileID: 1406880858}
- target: {fileID: 2830915517616789180, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2830915517616789180, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2830915517616789180, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2830915517616789180, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2849050943205937738, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
@@ -14685,6 +14872,31 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: -4.74
objectReference: {fileID: 0}
- target: {fileID: 3577842215316784680, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3577842215316784680, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3577842215316784680, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3577842215316784680, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3577842215316784680, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3667793487159446755, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_Layer
@@ -14770,6 +14982,31 @@ PrefabInstance:
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3821940979387483107, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3821940979387483107, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3821940979387483107, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3821940979387483107, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3821940979387483107, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3925395170508564942, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_Layer
@@ -14838,21 +15075,41 @@ PrefabInstance:
- target: {fileID: 4202610206940879906, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4202610206940879906, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4202610206940879906, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 210
objectReference: {fileID: 0}
- target: {fileID: 4202610206940879906, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -225
objectReference: {fileID: 0}
- target: {fileID: 4204595259268909078, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4204595259268909078, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4204595259268909078, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4204595259268909078, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4310148345887150382, guid: 851e8e61247888340bdec90fc8aa37f5,
@@ -14970,6 +15227,31 @@ PrefabInstance:
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4613483970324523691, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4613483970324523691, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4613483970324523691, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4613483970324523691, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4613483970324523691, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4670439730081820471, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_Layer
@@ -15018,22 +15300,22 @@ PrefabInstance:
- target: {fileID: 4796023216948086302, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4796023216948086302, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4796023216948086302, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 210
objectReference: {fileID: 0}
- target: {fileID: 4796023216948086302, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -315
objectReference: {fileID: 0}
- target: {fileID: 4907318199456855652, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
@@ -15500,6 +15782,16 @@ PrefabInstance:
propertyPath: m_Layer
value: 5
objectReference: {fileID: 0}
- target: {fileID: 5234664790783380194, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 1518440.2
objectReference: {fileID: 0}
- target: {fileID: 5234664790783380194, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -242950.23
objectReference: {fileID: 0}
- target: {fileID: 5265345828117443429, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_Layer
@@ -16383,22 +16675,22 @@ PrefabInstance:
- target: {fileID: 7465903852046106667, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7465903852046106667, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7465903852046106667, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 210
objectReference: {fileID: 0}
- target: {fileID: 7465903852046106667, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -405
objectReference: {fileID: 0}
- target: {fileID: 7534046934194550914, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
@@ -16520,6 +16812,31 @@ PrefabInstance:
propertyPath: m_Layer
value: 5
objectReference: {fileID: 0}
- target: {fileID: 8079800635808381054, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8079800635808381054, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8079800635808381054, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8079800635808381054, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8079800635808381054, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8107996228312656255, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: 'm_Materials.Array.data[0]'

View File

@@ -62,6 +62,7 @@ namespace Beyond
public static Player Instance => s_instance;
public bItemManager ItemManager { private set; get; }
public WeaponTrail ActiveWeaponTrail { set; get; }
private PlayerAttribute faithAttribute;
@@ -83,7 +84,8 @@ namespace Beyond
speedMult = 1f,
faithRegenMult = 1f,
attackSpeedMult = 1f,
thornDamageMult = 1f
thornDamageMult = 1f,
staminaMult = 1f
};
public TrinketManager.TrinketStats CurrentTrinketStats => m_trinketStats;
@@ -92,13 +94,28 @@ namespace Beyond
{
m_trinketStats = newStats;
// Force stats recalculation
UodatePlayerStatistics();
UpdatePlayerStatistics();
// Apply immediate effects
if (m_vController)
if (m_vController)
{
m_vController.speedMultiplier = m_trinketStats.speedMult;
// 2. Apply Attack Speed (UI Method)
if (m_vController.animator)
m_vController.animator.SetFloat("AttackSpeed", m_trinketStats.attackSpeedMult);
}
// 3. Apply Damage Multiplier (NEW)
if (m_meleeManager)
{
// Calculate the base multiplier from stats
float totalDamageMult = m_trinketStats.damageMult;
totalDamageMult += 0.10f;
// Send to Melee Manager
m_meleeManager.SetGlobalDamageMultiplier(totalDamageMult);
}
}
// --- TRINKET SYSTEM INTEGRATION END ---
@@ -155,7 +172,7 @@ namespace Beyond
private float faithBaseMaxValue = 100f;
private System.Action onMenuScrollClosed;
public System.Action<float> onStatsUpdated;
public System.Action<float, float, float> onStatsUpdated;
private UnityAction<Transform> onDialogueEnded;
private bLockOn m_lockOn;
public bLockOn LockOn => m_lockOn;
@@ -483,7 +500,7 @@ namespace Beyond
Lua.UnregisterFunction("GetMaturity");
}
public void UodatePlayerStatistics()
public void UpdatePlayerStatistics()
{
float maturityMupltiplier = (float)(1 + (float)(0.5f * maturityAttribute.AttributeCurrentValue / maturityAttribute.AttributeMaxValue));
float maxBrightness = brightnessAttribute.AttributeMaxValue;
@@ -507,33 +524,36 @@ namespace Beyond
{
// --- TRINKET INTEGRATION IN STATS CALCULATION ---
// Faith Regen
faithRegenMultiplier = sceneDependantFaithRegenMultiplier * finalMultiplier * m_trinketStats.faithRegenMult;
// Max Faith
// 1. Calculate specific total multipliers for UI scaling
// 1. Calculate specific total multipliers
float totalHealthMult = finalMultiplier * m_trinketStats.healthMult;
float totalFaithMult = finalMultiplier * m_trinketStats.faithMult;
float totalStaminaMult = finalMultiplier * (m_trinketStats.staminaMult > 0 ? m_trinketStats.staminaMult : 1f); // Handle 0 default
// 2. Capture Current Health Percentage BEFORE changes
float healthPercent = m_vController.maxHealth > 0 ? m_vController.currentHealth / m_vController.maxHealth : 1f;
// 3. Apply Stats
// Faith
faithRegenMultiplier = sceneDependantFaithRegenMultiplier * finalMultiplier * m_trinketStats.faithRegenMult;
faithAttribute.AttributeMaxValue = Mathf.RoundToInt(faithBaseMaxValue * totalFaithMult);
// Max Health
float totalHealthMult = finalMultiplier * m_trinketStats.healthMult;
m_vController.maxHealth = Mathf.RoundToInt(totalHealthMult * healthBaseMaxValue);
int newMaxHealth = Mathf.RoundToInt(totalHealthMult * healthBaseMaxValue);
m_vController.maxHealth = newMaxHealth;
// Reset health if caps changed downwards
if (m_vController.maxHealth < m_vController.currentHealth)
{
m_vController.ResetHealth();
}
// Apply Proportional Current Health
// We update the current health to match the previous percentage
//m_vController.currentHealth = Mathf.RoundToInt(newMaxHealth * healthPercent);
// Health Recovery
m_vController.SetHealthRecovery(finalMultiplier * healthBaseRegenValue);
// Stamina (assuming no trinket mult for stamina yet, if needed add m_trinketStats.staminaMult)
m_vController.maxStamina = Mathf.Round(finalMultiplier * staminaBaseMaxValue);
// Stamina
m_vController.maxStamina = Mathf.Round(totalStaminaMult * staminaBaseMaxValue);
m_vController.staminaRecovery = (finalMultiplier * staminaBaseRegenValue);
// ------------------------------------------------
onStatsUpdated?.Invoke(finalMultiplier);
onStatsUpdated?.Invoke(totalHealthMult, totalFaithMult, totalStaminaMult);
}
public void UpdatePlayerStatisticsOnMaturityChange(float val = 0, float prevVal = 0)

View File

@@ -12,7 +12,7 @@ namespace Beyond
private void Start()
{
Player.Instance.sceneDependantFaithRegenMultiplier = faithRegenMultiplier;
Player.Instance.UodatePlayerStatistics();
Player.Instance.UpdatePlayerStatistics();
}
// Update is called once per frame

View File

@@ -0,0 +1,315 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
using TMPro;
using Invector.vItemManager;
using System.Collections.Generic;
namespace Beyond
{
public class TrinketUIGenerator : MonoBehaviour
{
[MenuItem("Beyond/Generate Trinket UI")]
public static void CreateTrinketUI()
{
try
{
// 1. Create Dedicated Canvas
GameObject canvasObj = new GameObject("Trinket_UI_Canvas");
Canvas c = canvasObj.AddComponent<Canvas>();
c.renderMode = RenderMode.ScreenSpaceOverlay;
c.sortingOrder = 99;
CanvasScaler scaler = canvasObj.AddComponent<CanvasScaler>();
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
scaler.referenceResolution = new Vector2(1920, 1080);
scaler.matchWidthOrHeight = 0.5f; // Balanced scaling
canvasObj.AddComponent<GraphicRaycaster>();
// Add Controller
TrinketUIController uiController = canvasObj.AddComponent<TrinketUIController>();
uiController.mainCanvas = c;
//uiController.trinketType = bItemType.Trinkets;
// 2. Main Panel Background
GameObject mainPanel = CreateUIObject("Main_Panel", canvasObj.transform);
Image panelImg = mainPanel.AddComponent<Image>();
panelImg.color = new Color(0.05f, 0.05f, 0.05f, 0.95f);
StretchToFill(mainPanel.GetComponent<RectTransform>());
// 3. Layout Container (The Parent of Left/Right)
GameObject contentContainer = CreateUIObject("Content_Container", mainPanel.transform);
StretchToFill(contentContainer.GetComponent<RectTransform>());
RectTransform containerRect = contentContainer.GetComponent<RectTransform>();
// Add margins so it doesn't touch screen edges
containerRect.offsetMin = new Vector2(100, 100);
containerRect.offsetMax = new Vector2(-100, -100);
HorizontalLayoutGroup hLayout = contentContainer.AddComponent<HorizontalLayoutGroup>();
hLayout.childControlWidth = true;
hLayout.childControlHeight = true;
hLayout.childForceExpandWidth = true; // FORCE 50/50 SPLIT
hLayout.childForceExpandHeight = true;
hLayout.spacing = 50;
// =========================================================
// LEFT SIDE: EQUIP AREA
// =========================================================
GameObject leftPanel = CreateUIObject("Left_EquipArea", contentContainer.transform);
leftPanel.AddComponent<Image>().color = new Color(1, 1, 1, 0.05f);
bEquipArea equipArea = leftPanel.AddComponent<bEquipArea>();
equipArea.equipSlots = new List<bEquipSlot>();
equipArea.itemTypes = new List<bItemType>() { bItemType.Trinkets };
// Vertical Layout for the Left Panel itself
VerticalLayoutGroup leftVL = leftPanel.AddComponent<VerticalLayoutGroup>();
leftVL.padding = new RectOffset(20, 20, 20, 20);
leftVL.spacing = 20;
leftVL.childControlHeight = true;
leftVL.childControlWidth = true;
leftVL.childForceExpandHeight = false;
// Title
TMP_Text titleTxt = CreateTMPObject("Equip_Title", leftPanel.transform, "Equipped Trinkets");
titleTxt.rectTransform.sizeDelta = new Vector2(0, 60); // Fixed height for title
// References (Hidden Text)
equipArea.displayNameText = CreateTextObject("EA_Name", "", leftPanel.transform);
equipArea.displayDescriptionText = CreateTextObject("EA_Desc", "", leftPanel.transform);
// Slot Container (Centered)
GameObject slotsContainer = CreateUIObject("Slots_Container", leftPanel.transform);
// Make slots container take up remaining space but center its children
LayoutElement slotsLE = slotsContainer.AddComponent<LayoutElement>();
slotsLE.flexibleHeight = 1;
HorizontalLayoutGroup slotsLayout = slotsContainer.AddComponent<HorizontalLayoutGroup>();
slotsLayout.childAlignment = TextAnchor.MiddleCenter;
slotsLayout.spacing = 40;
slotsLayout.childControlWidth = false; // Don't stretch slots
slotsLayout.childControlHeight = false;
// Create 3 Equip Slots
for (int i = 0; i < 3; i++)
{
GameObject slotObj = CreateUIObject($"EquipSlot_{i}", slotsContainer.transform);
Image slotImg = slotObj.AddComponent<Image>();
slotImg.color = new Color(0.2f, 0.2f, 0.2f, 1f);
slotObj.GetComponent<RectTransform>().sizeDelta = new Vector2(120, 120);
slotObj.AddComponent<CanvasGroup>();
bEquipSlot equipSlot = slotObj.AddComponent<bEquipSlot>();
equipSlot.itemType = new List<bItemType>() { bItemType.Trinkets };
GameObject iconObj = CreateUIObject("Icon", slotObj.transform);
StretchToFill(iconObj.GetComponent<RectTransform>());
Image iconImg = iconObj.AddComponent<Image>();
iconImg.raycastTarget = false;
iconImg.color = Color.clear; // Relies on bItemSlot to turn alpha back to 1
equipSlot.icon = iconImg;
equipArea.equipSlots.Add(equipSlot);
}
// =========================================================
// RIGHT SIDE: ITEM WINDOW
// =========================================================
GameObject rightPanel = CreateUIObject("Right_ItemWindow", contentContainer.transform);
rightPanel.AddComponent<Image>().color = new Color(1, 1, 1, 0.05f);
bItemWindow itemWindow = rightPanel.AddComponent<bItemWindow>();
// Vertical Layout for Right Panel
VerticalLayoutGroup rightVL = rightPanel.AddComponent<VerticalLayoutGroup>();
rightVL.padding = new RectOffset(20, 20, 20, 20);
rightVL.spacing = 20;
rightVL.childControlWidth = true;
rightVL.childControlHeight = true;
// 1. Scroll View (Takes up flexible space)
GameObject scrollView = CreateUIObject("Scroll_View", rightPanel.transform);
LayoutElement svLE = scrollView.AddComponent<LayoutElement>();
svLE.flexibleHeight = 1; // Take available space
ScrollRect scrollRect = scrollView.AddComponent<ScrollRect>();
GameObject viewport = CreateUIObject("Viewport", scrollView.transform);
StretchToFill(viewport.GetComponent<RectTransform>());
viewport.AddComponent<Mask>();
viewport.AddComponent<Image>().color = new Color(1,1,1,0.01f);
GameObject content = CreateUIObject("Content", viewport.transform);
RectTransform contentRT = content.GetComponent<RectTransform>();
contentRT.anchorMin = new Vector2(0, 1);
contentRT.anchorMax = new Vector2(1, 1);
contentRT.pivot = new Vector2(0.5f, 1);
GridLayoutGroup grid = content.AddComponent<GridLayoutGroup>();
grid.cellSize = new Vector2(100, 100);
grid.spacing = new Vector2(15, 15);
ContentSizeFitter csf = content.AddComponent<ContentSizeFitter>();
csf.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
scrollRect.content = contentRT;
scrollRect.viewport = viewport.GetComponent<RectTransform>();
itemWindow.contentWindow = contentRT;
// 2. Details Panel (Fixed Height at bottom)
GameObject detailsPanel = CreateUIObject("Details_Panel", rightPanel.transform);
LayoutElement detailsLE = detailsPanel.AddComponent<LayoutElement>();
detailsLE.minHeight = 300;
detailsLE.preferredHeight = 300;
VerticalLayoutGroup detailsLayout = detailsPanel.AddComponent<VerticalLayoutGroup>();
detailsLayout.spacing = 5;
detailsLayout.childControlHeight = true;
detailsLayout.childForceExpandHeight = false;
// Details Components (Auto-Sizing Text)
itemWindow.displayNameText = CreateTMPObject("Name_Text", detailsPanel.transform, "Item Name");
itemWindow.displayNameText.fontStyle = FontStyles.Bold;
itemWindow.displayTypeText = CreateTextObject("Type_Text", "Item Type", detailsPanel.transform);
itemWindow.displayAttributesText = CreateTextObject("Attributes_Text", "Stats...", detailsPanel.transform);
itemWindow.displayAmountText = CreateTextObject("Amount_Text", "", detailsPanel.transform);
// Description
GameObject descContainer = CreateUIObject("Desc_Container", detailsPanel.transform);
LayoutElement descLE = descContainer.AddComponent<LayoutElement>();
descLE.flexibleHeight = 1; // Description expands to fill gap
descContainer.AddComponent<VerticalLayoutGroup>();
itemWindow.displayDescriptionText = CreateTMPObject("Desc_Text", descContainer.transform, "Description...");
itemWindow.displayDescriptionText.alignment = TextAlignmentOptions.TopLeft;
itemWindow.descriptionTransform = descContainer.GetComponent<RectTransform>();
// Submit Button
GameObject btnObj = CreateUIObject("Submit_Button", detailsPanel.transform);
LayoutElement btnLE = btnObj.AddComponent<LayoutElement>();
btnLE.minHeight = 50;
btnLE.preferredHeight = 50;
btnObj.AddComponent<Image>().color = new Color(0, 0.6f, 0, 1);
Button submitBtn = btnObj.AddComponent<Button>();
TMP_Text btnText = CreateTMPObject("Btn_Text", btnObj.transform, "EQUIP");
StretchToFill(btnText.rectTransform);
// Serialization
SerializedObject so = new SerializedObject(itemWindow);
so.Update();
SerializedProperty propBtn = so.FindProperty("button");
if (propBtn != null && btnObj != null) propBtn.objectReferenceValue = btnObj;
SerializedProperty propBtnText = so.FindProperty("submitButtonText");
if (propBtnText != null && btnText != null) propBtnText.objectReferenceValue = btnText;
SerializedProperty propConsumeBtn = so.FindProperty("consumeButton");
if (propConsumeBtn != null && btnObj != null) propConsumeBtn.objectReferenceValue = btnObj;
// Need to assign Image for serialization, even if we don't use it in UI layout much
GameObject dummyImg = CreateUIObject("DummyImg", detailsPanel.transform);
dummyImg.SetActive(false); // Hide it
itemWindow.displayItemImage = dummyImg.AddComponent<Image>();
so.ApplyModifiedProperties();
// =========================================================
// TEMPLATE SLOT PREFAB
// =========================================================
GameObject slotTemplate = CreateUIObject("Slot_Template_Prefab", canvasObj.transform);
Image templateBg = slotTemplate.AddComponent<Image>();
templateBg.color = new Color(0.3f, 0.3f, 0.3f);
slotTemplate.AddComponent<CanvasGroup>();
bItemSlot itemSlotScript = slotTemplate.AddComponent<bItemSlot>();
GameObject tIcon = CreateUIObject("Icon", slotTemplate.transform);
StretchToFill(tIcon.GetComponent<RectTransform>());
itemSlotScript.icon = tIcon.AddComponent<Image>();
itemSlotScript.icon.raycastTarget = false;
itemSlotScript.icon.color = Color.clear;
GameObject tCheck = CreateUIObject("CheckIcon", slotTemplate.transform);
RectTransform checkRT = tCheck.GetComponent<RectTransform>();
checkRT.anchorMin = new Vector2(1,1);
checkRT.anchorMax = new Vector2(1,1);
checkRT.sizeDelta = new Vector2(25,25);
checkRT.anchoredPosition = new Vector2(-10, -10);
itemSlotScript.checkIcon = tCheck.AddComponent<Image>();
itemSlotScript.checkIcon.color = Color.green;
tCheck.SetActive(false);
itemWindow.slotPrefab = itemSlotScript;
slotTemplate.SetActive(false);
// Final Wiring
equipArea.itemPicker = itemWindow;
uiController.trinketEquipArea = equipArea;
uiController.trinketItemWindow = itemWindow;
c.enabled = false;
Selection.activeGameObject = canvasObj;
Debug.Log("Trinket UI (Layout Fixed) Created Successfully.");
}
catch (System.Exception ex)
{
Debug.LogError("Error generating UI: " + ex.Message + "\n" + ex.StackTrace);
}
}
// --- Helpers ---
private static GameObject CreateUIObject(string name, Transform parent)
{
GameObject go = new GameObject(name);
go.AddComponent<RectTransform>();
if(parent != null) go.transform.SetParent(parent, false);
return go;
}
private static TMP_Text CreateTMPObject(string name, Transform parent, string text)
{
GameObject go = CreateUIObject(name, parent);
TMP_Text tmp = go.AddComponent<TextMeshProUGUI>();
if (tmp != null)
{
tmp.text = text;
tmp.alignment = TextAlignmentOptions.Center;
tmp.color = Color.white;
// AUTO SIZING IS KEY for fixing your issue
tmp.enableAutoSizing = true;
tmp.fontSizeMin = 12;
tmp.fontSizeMax = 72;
}
return tmp;
}
private static Text CreateTextObject(string name, string text, Transform parent)
{
GameObject go = CreateUIObject(name, parent);
Text txt = go.AddComponent<Text>();
txt.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
if(txt.font == null) txt.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
txt.text = text;
txt.alignment = TextAnchor.MiddleCenter;
txt.color = Color.white;
txt.resizeTextForBestFit = true; // Auto size for legacy text
txt.resizeTextMinSize = 10;
txt.resizeTextMaxSize = 60;
return txt;
}
private static void StretchToFill(RectTransform rt)
{
rt.anchorMin = Vector2.zero;
rt.anchorMax = Vector2.one;
rt.offsetMin = Vector2.zero;
rt.offsetMax = Vector2.zero;
}
}
}
#endif

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 16c0f64f2542a43e796e472d98159fc5

View File

@@ -5032,7 +5032,7 @@ MonoBehaviour:
icon: {fileID: 21300000, guid: 9e637b82da7408b45b28a9180b62ef60, type: 3}
secondaryIcon: {fileID: 0}
teriaryIcon: {fileID: 0}
iconPath:
iconPath: menu_Images/INVENTORY/Resources_17-05-2022/Amethyst
secondaryIconPath:
teriaryIconPath:
stackable: 0
@@ -5232,8 +5232,8 @@ MonoBehaviour:
iconPath:
secondaryIconPath:
teriaryIconPath:
stackable: 0
maxStack: 1
stackable: 1
maxStack: 3
amount: 0
originalObject: {fileID: 0}
dropObject: {fileID: 0}
@@ -5246,7 +5246,7 @@ MonoBehaviour:
checkColor: {r: 0.5372549, g: 0, b: 0, a: 1}
isEquiped: 0
destroyAfterUse: 0
canBeUsed: 1
canBeUsed: 0
canBeDroped: 0
canBeDestroyed: 0
EnableAnim: LowBack

View File

@@ -40,20 +40,24 @@ namespace Beyond
[vHelpBox("You can ignore display Attributes using this property")]
public List<bItemAttributes> ignoreAttributes;
public UnityEngine.Events.UnityEvent onInitPickUpItem, onFinishPickUpItem;
// --- FIX 1: Initialize Events inline to prevent NullReferenceException ---
public UnityEngine.Events.UnityEvent onInitPickUpItem = new UnityEngine.Events.UnityEvent();
public UnityEngine.Events.UnityEvent onFinishPickUpItem = new UnityEngine.Events.UnityEvent();
public InputField.OnChangeEvent onChangeName;
public InputField.OnChangeEvent onChangeType;
public InputField.OnChangeEvent onChangeAmount;
public InputField.OnChangeEvent onChangeDescription;
public InputField.OnChangeEvent onChangeAttributes;
public OnChangeEquipmentEvent onEquipItem;
public OnChangeEquipmentEvent onUnequipItem;
public OnSelectEquipArea onSelectEquipArea;
public OnChangeEquipmentEvent onEquipItem = new OnChangeEquipmentEvent();
public OnChangeEquipmentEvent onUnequipItem = new OnChangeEquipmentEvent();
public OnSelectEquipArea onSelectEquipArea = new OnSelectEquipArea();
// ------------------------------------------------------------------------
public event Action OnItemUsed;
public UnityEngine.UI.Toggle.ToggleEvent onSetLockToEquip;
public UnityEngine.UI.Toggle.ToggleEvent onSetLockToEquip = new UnityEngine.UI.Toggle.ToggleEvent();
[HideInInspector]
public bEquipSlot currentSelectedSlot;
@@ -79,10 +83,7 @@ namespace Beyond
public bool isLockedToEquip
{
get
{
return _isLockedToEquip;
}
get { return _isLockedToEquip; }
set
{
if (_isLockedToEquip != value) onSetLockToEquip.Invoke(value);
@@ -91,10 +92,6 @@ namespace Beyond
}
public bool ignoreEquipEvents;
/// <summary>
/// used to ignore <see cref="onEquipItem"/> event. if true, the inventory will just add the equipment to area but dont will send to Equip the item. you will nedd to call <see cref="EquipCurrentSlot"/> to equip the item in the area.
/// </summary>
internal bool isInit;
public void Init()
@@ -107,17 +104,24 @@ namespace Beyond
if (!isInit)
{
isInit = true;
//indexOfEquipedItem = -1;
inventory = GetComponentInParent<bInventory>();
itemManager = Player.Instance.GetComponent<bItemManager>();
//itemManager.onEquipItem
// Dependencies
if (inventory == null) inventory = GetComponentInParent<bInventory>();
if (inventory == null && Player.Instance != null && Player.Instance.ItemManager != null)
inventory = Player.Instance.ItemManager.inventory;
itemManager = Player.Instance != null ? Player.Instance.GetComponent<bItemManager>() : null;
if (equipSlots.Count == 0)
{
var equipSlotsArray = GetComponentsInChildren<bEquipSlot>(true);
equipSlots = equipSlotsArray.vToList();
}
foreach (bEquipSlot slot in equipSlots)
{
slot.SetInventory(this.inventory); // Explicitly set inventory
slot.onSubmitSlotCallBack = OnSubmitSlot;
slot.onSelectSlotCallBack = OnSelectSlot;
slot.onDeselectSlotCallBack = OnDeselect;
@@ -139,28 +143,17 @@ namespace Beyond
public void SetNewItemWindow(bItemWindow newItemPicker)
{
if (itemPicker)
{
DisableItemWindow();
}
if (itemPicker) DisableItemWindow();
itemPicker = newItemPicker;
EnableItemWindow();
}
public void DisableItemWindow()
{
itemPicker.gameObject.SetActive(false);
}
public void EnableItemWindow()
{
itemPicker.gameObject.SetActive(true);
}
public void DisableItemWindow() => itemPicker.gameObject.SetActive(false);
public void EnableItemWindow() => itemPicker.gameObject.SetActive(true);
public void SetEquipmentwindowWithFilter(List<bItemType> types)
{
itemPicker.CreateEquipmentWindow(inventory.items, types, null, OnPickItem);
//itemPicker.ReloadItems();
}
public void SetEquipmentWindowsUsableWithFilter(List<bItemType> types)
@@ -170,6 +163,7 @@ namespace Beyond
private void SetOccupiedIndexes()
{
usedIndexes.Clear();
for (int i = 0; i < equipSlots.Count; i++)
{
if (equipSlots[i].isOcupad())
@@ -179,155 +173,61 @@ namespace Beyond
public bool IsAnyItemEquipped()
{
for (int i = 0; i < equipSlots.Count; i++)
{
if (equipSlots[i].isOcupad())
{
return true;
}
}
for (int i = 0; i < equipSlots.Count; i++) if (equipSlots[i].isOcupad()) return true;
return false;
}
/// <summary>
/// Current Equipped Slot
/// </summary>
public bEquipSlot currentEquippedSlot
{
get
{
return equipSlots[indexOfEquippedItem];
}
}
public bEquipSlot currentEquippedSlot => equipSlots[indexOfEquippedItem];
/// <summary>
/// Item in Current Equipped Slot
/// </summary>
public bItem currentEquippedItem
{
get
{
var validEquipSlots = ValidSlots;
if (validEquipSlots.Count > 0 && indexOfEquippedItem >= 0 && indexOfEquippedItem < validEquipSlots.Count) return validEquipSlots[indexOfEquippedItem].item;
return null;
}
}
/// <summary>
/// All valid slot <seealso cref="vItemSlot.isValid"/>
/// </summary>
public List<bEquipSlot> ValidSlots
{
get { return equipSlots.FindAll(slot => slot.isValid && (!skipEmptySlots || slot.item != null)); }
}
public List<bEquipSlot> ValidSlots => equipSlots.FindAll(slot => slot.isValid && (!skipEmptySlots || slot.item != null));
/// <summary>
/// Check if Item is in Area
/// </summary>
/// <param name="item">item to check</param>
/// <returns></returns>
public bool ContainsItem(vItem item)
{
return ValidSlots.Find(slot => slot.item == item) != null;
}
public bool ContainsItem(vItem item) => ValidSlots.Find(slot => slot.item == item) != null;
private void UseItemInternal(bItem item)
{
if (item.type == bItemType.Gemstones)
if (item.type == bItemType.Gemstones)
{
if (gemableWeapons.Count < 1 || gemableWeapons[selectedGemableItemIndex] == null)
{
if (bItemCollectionDisplay.Instance && item.type == bItemType.Gemstones && item)
{
Player.Instance.PlayFullyChargedSound();
//in menu
if (PopupMenuController.Instance != null)
{
PopupMenuController.Instance.TryToShowPopupMesssage("No proper weapons available");
} //cant use gemstone with no proper weapons available
return;
}
}
else //if (item.type == bItemType.Gemstones)
else
{
bItemAttribute powerAttribute = gemableWeapons[selectedGemableItemIndex].attributes.First(attribute => attribute.name == bItemAttributes.Power);
if (powerAttribute.value >= powerChargesMaxValue)
{
Player.Instance.PlayFullyChargedSound();
//Player.Instance.MeleeManager.onEquipWeapon
if (PopupMenuController.Instance != null)
{
PopupMenuController.Instance.TryToShowPopupMesssage(gemableWeapons[selectedGemableItemIndex].name + " is already fully charged");
} //cant use gemstone with no proper weapons available
return;
}
powerAttribute.value += item.GetItemAttribute(bItemAttributes.Power).value;
if (powerAttribute.value > powerChargesMaxValue)
{
powerAttribute.value = powerChargesMaxValue;
}
if (powerAttribute.value > powerChargesMaxValue) powerAttribute.value = powerChargesMaxValue;
}
}
inventory.OnUseItem(item);
}
public void UseItem()
{
if (itemManager.UsingItem)
{
return;
}
//could move the logic to item manager
if (itemManager.UsingItem) return;
UseItemInternal(itemPicker.currentSelectedSlot.item);
/*
bItem itemBeingUsed = itemPicker.currentSelectedSlot.item;
//using here
if (itemBeingUsed.type == bItemType.Gemstones)
{
bItem item = itemBeingUsed;
if (gemableWeapons.Count < 1 || gemableWeapons[selectedGemableItemIndex] == null)
{
if (bItemCollectionDisplay.Instance && item.type == bItemType.Gemstones && item)
{
Player.Instance.PlayFullyChargedSound();
//in menu
if (PopupMenuController.Instance != null)
{
PopupMenuController.Instance.TryToShowPopupMesssage("No proper weapons available");
} //cant use gemstone with no proper weapons available
return;
}
}
else if (item.type == bItemType.Gemstones)
{
bItemAttribute powerAttribute = gemableWeapons[selectedGemableItemIndex].attributes.First(attribute => attribute.name == bItemAttributes.Power);
if (powerAttribute.value >= powerChargesMaxValue)
{
Player.Instance.PlayFullyChargedSound();
if (PopupMenuController.Instance != null)
{
PopupMenuController.Instance.TryToShowPopupMesssage(gemableWeapons[selectedGemableItemIndex].name + " is already fully charged");
} //cant use gemstone with no proper weapons available
return;
}
powerAttribute.value += item.GetItemAttribute(bItemAttributes.Power).value;
if (powerAttribute.value > powerChargesMaxValue)
{
powerAttribute.value = powerChargesMaxValue;
}
}
}
inventory.OnUseItem(itemBeingUsed);
*/
}
public void UseItem(bEquipSlot equipSlot)
@@ -335,8 +235,6 @@ namespace Beyond
bItem itemBeingUsed = equipSlot.item;
FindGemableWeapons();
UseItemInternal(itemBeingUsed);
//do some nice things here i think
//inventory.OnUseItem(itemBeingUsed);
}
public void UseEquippedItem()
@@ -344,10 +242,6 @@ namespace Beyond
inventory.OnUseItem(currentEquippedItem);
}
/// <summary>
/// Event called from Inventory slot UI on Submit
/// </summary>
/// <param name="slot"></param>
public void OnSubmitSlot(bItemSlot slot)
{
lastSelectedSlot = currentSelectedSlot;
@@ -366,39 +260,24 @@ namespace Beyond
}
}
/// <summary>
/// Event called to cancel Submit action
/// </summary>
public void CancelCurrentSlot()
{
if (currentSelectedSlot == null)
currentSelectedSlot = lastSelectedSlot;
if (currentSelectedSlot != null)
currentSelectedSlot.OnCancel();
if (currentSelectedSlot == null) currentSelectedSlot = lastSelectedSlot;
if (currentSelectedSlot != null) currentSelectedSlot.OnCancel();
onFinishPickUpItem.Invoke();
}
/// <summary>
/// Unequip Item of the Slot
/// </summary>
/// <param name="slot">target slot</param>
public void UnequipItem(bEquipSlot slot)
{
if (slot)
{
bItem item = slot.item;
if (ValidSlots[indexOfEquippedItem].item == item)
lastEquipedItem = item;
if (ValidSlots[indexOfEquippedItem].item == item) lastEquipedItem = item;
slot.RemoveItem();
onUnequipItem.Invoke(this, item);
}
}
/// <summary>
/// Unequip Item if is present in slots
/// </summary>
/// <param name="item"></param>
public void UnequipItem(bItem item)
{
var slot = ValidSlots.Find(_slot => _slot.item == item);
@@ -410,9 +289,6 @@ namespace Beyond
}
}
/// <summary>
/// Unequip <seealso cref="currentEquippedItem"/>
/// </summary>
public void UnequipCurrentItem()
{
if (currentSelectedSlot && currentSelectedSlot.item)
@@ -424,11 +300,6 @@ namespace Beyond
}
}
/// <summary>
/// Event called from inventory UI when select an slot
/// never fires apparently
/// </summary>
/// <param name="slot">target slot</param>
public void OnSelectSlot(bItemSlot slot)
{
if (equipSlots.Contains(slot as bEquipSlot))
@@ -439,22 +310,12 @@ namespace Beyond
CreateFullItemDescription(slot);
}
/// <summary>
/// Event called from inventory UI when unselect an slot
/// </summary>
/// <param name="slot">target slot</param>
public void OnDeselect(bItemSlot slot)
{
if (equipSlots.Contains(slot as bEquipSlot))
{
currentSelectedSlot = null;
}
}
/// <summary>
/// Create item description
/// </summary>
/// <param name="slot">target slot</param>
protected virtual void CreateFullItemDescription(bItemSlot slot)
{
var _name = slot.item ? slot.item.name : "";
@@ -477,43 +338,28 @@ namespace Beyond
if (displayAttributesText) displayAttributesText.text = _attributes;
onChangeAttributes.Invoke(_attributes);
Debug.LogError("happeingng?");
}
/// <summary>
/// Event called from inventory UI to open <see cref="vItemWindow"/> when submit slot
/// </summary>
/// <param name="slot">target slot</param>
// --- FIX 2: Safer OnPickItem implementation ---
public void OnPickItem(bItemSlot slot)
{
/*
//for gemstones it does something different, it switches internal idnex of currently selected sword
if (usedIndexes.Count == 0) SetOccupiedIndexes();
if (slot.item.type == bItemType.Gemstones)
{
SwitchPowerableWeapon();
return;
}
*/
//1 check if any slot has this item, if it does, unequip it
//2 if not fill the first free slot
//3 if no free slots available swap with the oldest one
if (usedIndexes.Count == 0)
{
SetOccupiedIndexes();
}
//1
// 1. Unequip if checked
if (slot.isChecked)
{
bEquipSlot occupiedSlot = equipSlots.Find(eSlot => eSlot.item == slot.item);
usedIndexes.Remove(equipSlots.IndexOf(occupiedSlot));
occupiedSlot.RemoveItem();
onUnequipItem.Invoke(this, slot.item);
onFinishPickUpItem.Invoke();
if (occupiedSlot != null) // Check if slot was actually found
{
usedIndexes.Remove(equipSlots.IndexOf(occupiedSlot));
occupiedSlot.RemoveItem();
onUnequipItem?.Invoke(this, slot.item); // Safe Invoke
}
onFinishPickUpItem?.Invoke(); // Safe Invoke
return;
}
//2
// 2. Fill first free slot
bEquipSlot freeSlot = equipSlots.Find(eslot => !eslot.isOcupad() && eslot.isValid && eslot.itemType.Contains(slot.item.type));
if (freeSlot)
{
@@ -521,76 +367,55 @@ namespace Beyond
freeSlot.AddItem(slot.item);
if (!ignoreEquipEvents)
{
onEquipItem.Invoke(this, slot.item);
onEquipItem?.Invoke(this, slot.item);
}
onFinishPickUpItem.Invoke();
onFinishPickUpItem?.Invoke();
usedIndexes.Add(equipSlots.IndexOf(freeSlot));
return;
}
//3
//get last used index that is of valid type
bEquipSlot slotToBeTaken = equipSlots[0];
for (int i = 0; i < usedIndexes.Count; i++)
// 3. Swap with oldest (FIFO) if full
if (usedIndexes.Count > 0)
{
int tempIndex = usedIndexes[i];
if (equipSlots[tempIndex].itemType.Contains(slot.item.type))
int slotIndexToTake = -1;
// Iterate through used indexes to find a compatible slot
for (int i = 0; i < usedIndexes.Count; i++)
{
slotToBeTaken = equipSlots[tempIndex];
usedIndexes.RemoveAt(i);
usedIndexes.Add(tempIndex);
i = usedIndexes.Count;
int idx = usedIndexes[i];
if (equipSlots[idx].itemType.Contains(slot.item.type))
{
slotIndexToTake = idx;
usedIndexes.RemoveAt(i);
usedIndexes.Add(idx);
break;
}
}
// If we found a compatible slot to swap
if (slotIndexToTake != -1)
{
bEquipSlot slotToBeTaken = equipSlots[slotIndexToTake];
if (slotToBeTaken.isOcupad())
{
onUnequipItem?.Invoke(this, slotToBeTaken.item);
slotToBeTaken.RemoveItem();
}
onPickUpItemCallBack?.Invoke(this, slot);
slotToBeTaken.AddItem(slot.item);
if (!ignoreEquipEvents)
{
onEquipItem?.Invoke(this, slot.item);
}
}
}
// bEquipSlot slotToBeTaken = equipSlots[usedIndexes[0]];
//remove old 1st
slotToBeTaken.RemoveItem();
onUnequipItem.Invoke(this, slot.item);
onFinishPickUpItem.Invoke();
//add new
onPickUpItemCallBack?.Invoke(this, slot);
slotToBeTaken.AddItem(slot.item);
if (!ignoreEquipEvents)
{
onEquipItem.Invoke(this, slot.item);
}
onFinishPickUpItem.Invoke();
return;
if (!currentSelectedSlot)
{
currentSelectedSlot = lastSelectedSlot;
}
if (!currentSelectedSlot)
{
return;
}
if (currentSelectedSlot.item != null && slot.item != currentSelectedSlot.item)
{
currentSelectedSlot.item.isInEquipArea = false;
var item = currentSelectedSlot.item;
if (item == slot.item) lastEquipedItem = item;
currentSelectedSlot.RemoveItem();
onUnequipItem.Invoke(this, item);
}
if (slot.item != currentSelectedSlot.item)
{
if (onPickUpItemCallBack != null)
onPickUpItemCallBack(this, slot);
currentSelectedSlot.AddItem(slot.item);
if (!ignoreEquipEvents) onEquipItem.Invoke(this, currentSelectedSlot.item);
}
currentSelectedSlot.OnCancel();
currentSelectedSlot = null;
lastSelectedSlot = null;
onFinishPickUpItem.Invoke();
onFinishPickUpItem?.Invoke();
}
// ----------------------------------------------
void FindGemableWeapons()
{
@@ -603,7 +428,6 @@ namespace Beyond
{
if (itemSelected.item.type == bItemType.Gemstones)
{
//for gemstones reset selection of gemable weapon, no saving per gem as of now
FindGemableWeapons();
if (gemableWeapons.Count > 0)
{
@@ -627,12 +451,8 @@ namespace Beyond
}
selectedPowerableItem = gemableWeapons[selectedGemableItemIndex];
itemPicker.SetPowerableSwitchSwordImage(selectedPowerableItem);
//updaing ui
}
/// <summary>
/// Equip next slot <seealso cref="currentEquippedItem"/>
/// </summary>
public void NextEquipSlot()
{
if (equipSlots == null || equipSlots.Count == 0) return;
@@ -645,13 +465,10 @@ namespace Beyond
indexOfEquippedItem = 0;
if (currentEquippedItem != null && !ignoreEquipEvents)
onEquipItem.Invoke(this, currentEquippedItem);
onUnequipItem.Invoke(this, lastEquipedItem);
onEquipItem?.Invoke(this, currentEquippedItem);
onUnequipItem?.Invoke(this, lastEquipedItem);
}
/// <summary>
/// Equip previous slot <seealso cref="currentEquippedItem"/>
/// </summary>
public void PreviousEquipSlot()
{
if (equipSlots == null || equipSlots.Count == 0) return;
@@ -665,15 +482,11 @@ namespace Beyond
indexOfEquippedItem = validEquipSlots.Count - 1;
if (currentEquippedItem != null && !ignoreEquipEvents)
onEquipItem.Invoke(this, currentEquippedItem);
onEquipItem?.Invoke(this, currentEquippedItem);
onUnequipItem.Invoke(this, lastEquipedItem);
onUnequipItem?.Invoke(this, lastEquipedItem);
}
/// <summary>
/// Equip slot <see cref="currentEquippedItem"/>
/// </summary>
/// <param name="indexOfSlot">index of target slot</param>
public void SetEquipSlot(int indexOfSlot)
{
if (equipSlots == null || equipSlots.Count == 0) return;
@@ -683,25 +496,20 @@ namespace Beyond
indexOfEquippedItem = indexOfSlot;
if (currentEquippedItem != null && !ignoreEquipEvents)
{
onEquipItem.Invoke(this, currentEquippedItem);
onEquipItem?.Invoke(this, currentEquippedItem);
}
if (currentEquippedItem != lastEquipedItem)
onUnequipItem.Invoke(this, lastEquipedItem);
onUnequipItem?.Invoke(this, lastEquipedItem);
}
}
public void EquipCurrentSlot()
{
if (!currentEquippedSlot || (currentEquippedSlot.item != null && currentEquippedSlot.item.isEquiped)) return;
if (currentEquippedItem) onEquipItem.Invoke(this, currentEquippedItem);
else if (lastEquipedItem) onUnequipItem.Invoke(this, lastEquipedItem);
if (currentEquippedItem) onEquipItem?.Invoke(this, currentEquippedItem);
else if (lastEquipedItem) onUnequipItem?.Invoke(this, lastEquipedItem);
}
/// <summary>
/// Add an item to an slot
/// </summary>
/// <param name="slot">target Slot</param>
/// <param name="item">target Item</param>
public void AddItemToEquipSlot(bItemSlot slot, bItem item, bool autoEquip = false)
{
if (slot is bEquipSlot && equipSlots.Contains(slot as bEquipSlot))
@@ -710,11 +518,6 @@ namespace Beyond
}
}
/// <summary>
/// Add an item to an slot
/// </summary>
/// <param name="indexOfSlot">index of target Slot</param>
/// <param name="item">target Item</param>
public void AddItemToEquipSlot(int indexOfSlot, bItem item, bool autoEquip = false)
{
if (indexOfSlot < equipSlots.Count && item != null && item.canBeUsed)
@@ -732,7 +535,7 @@ namespace Beyond
{
if (currentEquippedItem == slot.item) lastEquipedItem = slot.item;
slot.item.isInEquipArea = false;
onUnequipItem.Invoke(this, slot.item);
onUnequipItem?.Invoke(this, slot.item);
}
item.checkColor = slot.checkColor;
item.isInEquipArea = true;
@@ -740,15 +543,11 @@ namespace Beyond
if (autoEquip)
SetEquipSlot(indexOfSlot);
else if (!ignoreEquipEvents)
onEquipItem.Invoke(this, item);
onEquipItem?.Invoke(this, item);
}
}
}
/// <summary>
/// Remove item of an slot
/// </summary>
/// <param name="slot">target Slot</param>
public void RemoveItemOfEquipSlot(bItemSlot slot)
{
if (slot is bEquipSlot && equipSlots.Contains(slot as bEquipSlot))
@@ -757,10 +556,6 @@ namespace Beyond
}
}
/// <summary>
/// Remove item of an slot
/// </summary>
/// <param name="slot">index of target Slot</param>
public void RemoveItemOfEquipSlot(int indexOfSlot)
{
if (indexOfSlot < equipSlots.Count)
@@ -772,15 +567,11 @@ namespace Beyond
item.isInEquipArea = false;
if (currentEquippedItem == item) lastEquipedItem = currentEquippedItem;
slot.RemoveItem();
onUnequipItem.Invoke(this, item);
onUnequipItem?.Invoke(this, item);
}
}
}
/// <summary>
/// Add item to current equiped slot
/// </summary>
/// <param name="item">target item</param>
public void AddCurrentItem(bItem item)
{
if (indexOfEquippedItem < equipSlots.Count)
@@ -790,22 +581,19 @@ namespace Beyond
{
if (currentEquippedItem == slot.item) lastEquipedItem = slot.item;
slot.item.isInEquipArea = false;
onUnequipItem.Invoke(this, currentSelectedSlot.item);
onUnequipItem?.Invoke(this, currentSelectedSlot.item);
}
slot.AddItem(item);
if (!ignoreEquipEvents) onEquipItem.Invoke(this, item);
if (!ignoreEquipEvents) onEquipItem?.Invoke(this, item);
}
}
/// <summary>
/// Remove current equiped Item
/// </summary>
public void RemoveCurrentItem()
{
if (!currentEquippedItem) return;
lastEquipedItem = currentEquippedItem;
ValidSlots[indexOfEquippedItem].RemoveItem();
onUnequipItem.Invoke(this, lastEquipedItem);
onUnequipItem?.Invoke(this, lastEquipedItem);
}
}
}

View File

@@ -135,7 +135,7 @@ namespace Beyond
maturity = Player.Instance.GetAttribute("Maturity");
brightness.OnValueChanged.AddListener(PlayBrightnessEffectOnValueChanged);
Player.Instance.onStatsUpdated += SetSlidersScales;
Player.Instance.UodatePlayerStatistics();
Player.Instance.UpdatePlayerStatistics();
// Player.Instance.brig
}
@@ -348,11 +348,12 @@ namespace Beyond
yield return StartCoroutine(FlashBrightnesOnce(finalColorGained, brighntessAnimTime));
}
public void SetSlidersScales(float value)
public void SetSlidersScales(float healthScale, float faithScale, float staminaScale)
{
staminaSlider.SetScale(value);
healthSlider.SetScale(value);
faithSlider.SetScale(value);
// Apply specific scales to specific sliders
staminaSlider.SetScale(staminaScale);
healthSlider.SetScale(healthScale);
faithSlider.SetScale(faithScale);
}
private void SetTextureOffset(Material material, float value)

View File

@@ -60,7 +60,8 @@ namespace Beyond
[Description("Move Speed Bonus")] MoveSpeedBonusPercent = 25,
[Description("Attack Speed Bonus")] AttackSpeedBonusPercent = 26,
[Description("Faith Regen Bonus")] FaithRegenBonusPercent = 27,
[Description("Thorn Damage Bonus")] ThornDamageBonusPercent = 28
[Description("Thorn Damage Bonus")] ThornDamageBonusPercent = 28,
[Description("Stamina Bonus")] StaminaBonusPercent = 29
}
public enum TrinketColor

View File

@@ -1,8 +1,5 @@
using Invector;
using Invector.vCharacterController;
using Invector.vItemManager;
using Sirenix.OdinInspector;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
@@ -17,33 +14,24 @@ namespace Beyond
[vClassHeader("Item Slot", openClose = false)]
public class bItemSlot : vMonoBehaviour, IPointerClickHandler, ISelectHandler, IDeselectHandler, ISubmitHandler, IPointerEnterHandler, IPointerExitHandler
{
[Header("Dependencies")]
public bInventory inventory;
[vEditorToolbar("Default")]
[SerializeField]
private CanvasGroup m_canvasGroup;
[SerializeField] private CanvasGroup m_canvasGroup;
public bItem item;
public bool isValid = true;
[HideInInspector]
public bool isChecked;
[HideInInspector] public bool isChecked;
public List<bItemType> rarityInterestedType = new List<bItemType> { bItemType.Swords, bItemType.Axes, bItemType.Resources, bItemType.Consumable, bItemType.ConsumablesFaith, bItemType.Gemstones };
public Color checkColor = Color.cyan;
[vEditorToolbar("Optional")]
public Image icon, secondaryIcon, teriaryIcon, rarityImage;
public Image blockIcon;
public Image checkIconBG;
public Image checkIcon;
public Image isSelectedIcon;
public Image blockIcon, checkIconBG, checkIcon, isSelectedIcon;
public TMP_Text displayNameText;
public Text displayTypeText;
public TMP_Text displayAmountText;
public Text displayDescriptionText;
public Text displayAttributesText;
public Text displayDescriptionText, displayAttributesText;
public GameObject notSeenMark;
public bool IsClickable = true;
@@ -53,74 +41,72 @@ namespace Beyond
{
set {
m_isClickable = value;
m_canvasGroup.alpha = m_isClickable ? 1f : 0.5f;
m_canvasGroup.blocksRaycasts = m_isClickable;
if(m_canvasGroup) {
m_canvasGroup.alpha = m_isClickable ? 1f : 0.5f;
m_canvasGroup.blocksRaycasts = m_isClickable;
}
}
get => m_isClickable;
}
[SerializeField]
public List<Sprite> raritySprites;
[SerializeField] public List<Sprite> raritySprites;
[vHelpBox("You can ignore display Attributes using this property")]
public List<bItemAttributes> ignoreAttributes;
[vEditorToolbar("Events")]
public InputField.OnChangeEvent onChangeName;
public InputField.OnChangeEvent onChangeType;
public InputField.OnChangeEvent onChangeAmount;
public InputField.OnChangeEvent onChangeDescription;
public InputField.OnChangeEvent onChangeAttributes;
public InputField.OnChangeEvent onChangeName, onChangeType, onChangeAmount, onChangeDescription, onChangeAttributes;
public List<AttributeDisplay> customAttributeDisplay;
[System.Serializable]
public class AttributeDisplay
{
public Invector.vItemManager.vItemAttributes name;
[Tooltip("Special Tags\n(NAME) = Display name of the Attribute\n(VALUE) = Display the value of the Attribute\n ***Keep Empty to use default attribute display***")]
public string displayFormat = "(VALUE)";
public Text text;
public InputField.OnChangeEvent onChangeDisplay;
}
[vEditorToolbar("Events")]
public ItemSlotEvent onSubmitSlotCallBack, onSelectSlotCallBack, onDeselectSlotCallBack;
public OnHandleItemEvent onAddItem, onRemoveItem;
public UnityEvent onEnable;
public UnityEvent onDisable;
public UnityEvent onClick;
public UnityEvent onEnable, onDisable, onClick;
protected Selectable selectable;
protected Color color = Color.white;
// --- Static Colors (Restored) ---
private static Color deselectedImageColor = new Color(1, 1, 1, 0.7f);
private static Color selectedImageColor = new Color(1, 1, 1, 1);
private static Color selectedTextColor = new Color(0, 0, 0, 1);
private static Color defaultTextColor = new Color(0.3f, 0.3f, 0.3f, 1);
public static Color GetDefaultButtonTextColor()
public static Color GetDefaultButtonTextColor() => defaultTextColor;
public static Color GetSelectedButtonTextColor() => selectedTextColor;
public static Color GetDeselectedImageColor() => deselectedImageColor;
public static Color GetSelectedImageColor() => selectedImageColor;
// --- Explicit Inventory Setter ---
public void SetInventory(bInventory newInventory)
{
return defaultTextColor;
if (this.inventory != null) this.inventory.OnUpdateInventory -= UpdateDisplays;
this.inventory = newInventory;
if (this.inventory != null) this.inventory.OnUpdateInventory += UpdateDisplays;
UpdateDisplays();
}
public static Color GetSelectedButtonTextColor()
protected virtual void Start()
{
return selectedTextColor;
}
if (inventory == null)
{
var equipArea = GetComponentInParent<bEquipArea>();
if (equipArea != null) inventory = equipArea.inventory;
if (inventory == null && Player.Instance != null && Player.Instance.ItemManager != null)
inventory = Player.Instance.ItemManager.inventory;
}
public static Color GetDeselectedImageColor()
{
return deselectedImageColor;
}
if (inventory) inventory.OnUpdateInventory += UpdateDisplays;
public static Color GetSelectedImageColor()
{
return selectedImageColor;
selectable = GetComponent<Selectable>();
if (!m_canvasGroup) m_canvasGroup = GetComponent<CanvasGroup>();
SetValid(isValid);
}
private void OnEnable()
@@ -132,77 +118,28 @@ namespace Beyond
private void OnDisable()
{
onDisable.Invoke();
UnloadCurrentImage();
//unload
}
private void UnloadCurrentImage()
{
if (icon)
{
Resources.UnloadAsset(icon.sprite);
}
if (secondaryIcon)
{
Resources.UnloadAsset(secondaryIcon.sprite);
}
if (teriaryIcon)
{
Resources.UnloadAsset(teriaryIcon.sprite);
}
// icon.sprite = null;
// secondaryIcon.sprite = null;
// teriaryIcon.sprite = null;
//Resources.UnloadUnusedAssets();
if (icon && icon.sprite) Resources.UnloadAsset(icon.sprite);
if (secondaryIcon && secondaryIcon.sprite) Resources.UnloadAsset(secondaryIcon.sprite);
if (teriaryIcon && teriaryIcon.sprite) Resources.UnloadAsset(teriaryIcon.sprite);
}
protected virtual void Start()
{
var inventory = GetComponentInParent<bInventory>();
if (inventory)
inventory.OnUpdateInventory += UpdateDisplays;
selectable = GetComponent<Selectable>();
if (!m_canvasGroup)
m_canvasGroup = GetComponent<CanvasGroup>();
SetValid(isValid);
}
/// <summary>
/// Update all slot display texts
/// </summary>
public virtual void UpdateDisplays()
{
UpdateDisplays(item);
}
public virtual void UpdateDisplays() => UpdateDisplays(item);
private void OnDestroy()
{
var inventory = GetComponentInParent<bInventory>();
if (inventory)
inventory.OnUpdateInventory -= UpdateDisplays;
if (inventory) inventory.OnUpdateInventory -= UpdateDisplays;
}
/// <summary>
/// Enable or disable checkIcon
/// </summary>
/// <param name="value">Enable or disable value</param>
// ... Existing Methods ...
public virtual void CheckItem(bool value)
{
/*
if (item && item.type == bItemType.Gemstones && checkIcon)
{
//checkIconBG.gameObject.SetActive(false);
// checkIcon.gameObject.SetActive(false);
return;
}
*/
if (item && item.type == bItemType.PowerScroll && item.canBeDroped) //there are power scrolls which are not equippable
{
isChecked = true;
}
if (item && item.type == bItemType.PowerScroll && item.canBeDroped) isChecked = true;
else if (checkIcon && item)
{
isChecked = value;
@@ -213,40 +150,25 @@ namespace Beyond
public void TryToMarkAsSpeciallEquipped()
{
if (!checkIcon)
{
return;
}
checkIcon.gameObject.SetActive(true);
checkIcon.color = Color.gray;
if (checkIcon) { checkIcon.gameObject.SetActive(true); checkIcon.color = Color.gray; }
}
/// <summary>
/// Set if the slot is Selectable or not
/// </summary>
/// <param name="value">Enable or disable value</param>
public virtual void SetValid(bool value)
{
isValid = value;
if (selectable) selectable.interactable = value;
if (blockIcon == null) return;
blockIcon.color = value ? Color.clear : Color.white;
blockIcon.SetAllDirty();
isValid = value;
if (blockIcon) { blockIcon.color = value ? Color.clear : Color.white; blockIcon.SetAllDirty(); }
}
/// <summary>
/// Add item to slot
/// </summary>
/// <param name="item">target item</param>
public virtual void AddItem(bItem item)
{
if (item != null)
{
this.item = item;
onAddItem.Invoke(item);
// UpdateDisplays(item);
// --- FIX: Force display update immediately ---
UpdateDisplays(item);
// ---------------------------------------------
}
else RemoveItem();
}
@@ -262,26 +184,12 @@ namespace Beyond
ChangeDisplayAttributes(item);
CheckItem(item != null && item.isInEquipArea);
TryToSetRarityIcon(item);
if (item)
{
SetNotSeenIcon(item.id);
}
if (item) SetNotSeenIcon(item.id);
}
private void SetNotSeenIcon(int itemId)
{
if (notSeenMark == null)
{
return;
}
if (NewItemPopupSaver.itemsSeen.Contains(itemId))
{
notSeenMark.SetActive(false);
}
else
{
notSeenMark.SetActive(true);
}
if (notSeenMark) notSeenMark.SetActive(!NewItemPopupSaver.itemsSeen.Contains(itemId));
}
private void TryToSetRarityIcon(bItem item)
@@ -290,314 +198,127 @@ namespace Beyond
{
rarityImage.gameObject.SetActive(true);
bItemAttribute rarityAttribute = item.GetItemAttribute(bItemAttributes.Rarity);
if (rarityAttribute != null)
{
rarityImage.sprite = raritySprites[rarityAttribute.value];
}
else
{
rarityImage.sprite = raritySprites[0];
}
rarityImage.sprite = (rarityAttribute != null && rarityAttribute.value < raritySprites.Count) ? raritySprites[rarityAttribute.value] : raritySprites[0];
}
}
/// <summary>
/// Update the Display type text
/// </summary>
/// <param name="item">target item</param>
protected virtual void ChangeDisplayType(bItem item)
{
if (item)
{
onChangeType.Invoke(item.ItemTypeText());
if (displayTypeText) displayTypeText.text = item.ItemTypeText();
}
else
{
onChangeType.Invoke("");
if (displayTypeText) displayTypeText.text = "";
}
string txt = item ? item.ItemTypeText() : "";
onChangeType.Invoke(txt);
if (displayTypeText) displayTypeText.text = txt;
}
/// <summary>
/// Update the Display attribute text
/// </summary>
/// <param name="item"></param>
protected virtual void ChangeDisplayAttributes(bItem item)
{
if (item)
{
if (displayAttributesText) displayAttributesText.text = item.GetItemAttributesText(ignoreAttributes);
onChangeAttributes.Invoke(item.GetItemAttributesText(ignoreAttributes));
for (int i = 0; i < item.attributes.Count; i++)
{
AttributeDisplay attributeDisplay = customAttributeDisplay.Find(att => att.name.Equals(item.attributes[i].name));
if (attributeDisplay != null)
{
string displayText = item.attributes[i].GetDisplayText();
if (attributeDisplay.text) attributeDisplay.text.text = displayText;
attributeDisplay.onChangeDisplay.Invoke(displayText);
string txt = item ? item.GetItemAttributesText(ignoreAttributes) : "";
if (displayAttributesText) displayAttributesText.text = txt;
onChangeAttributes.Invoke(txt);
if(item && customAttributeDisplay != null) {
foreach(var attr in item.attributes) {
var display = customAttributeDisplay.Find(a => a.name.Equals(attr.name));
if(display != null) {
string val = attr.GetDisplayText();
if(display.text) display.text.text = val;
display.onChangeDisplay.Invoke(val);
}
}
}
else
{
if (displayAttributesText) displayAttributesText.text = "";
onChangeAttributes.Invoke("");
for (int i = 0; i < customAttributeDisplay.Count; i++)
{
if (customAttributeDisplay[i].text) customAttributeDisplay[i].text.text = "";
customAttributeDisplay[i].onChangeDisplay.Invoke("");
}
}
}
/// <summary>
/// Update the Display item Icon image
/// </summary>
/// <param name="item"></param>
protected virtual void ChangeDisplayIcon(bItem item)
{
if (!item) return;
if (icon)
{
icon.sprite = Resources.Load<Sprite>(item.iconPath);
// color.a = 1;
// icon.color = color;
}
if (!item || !icon) return;
if (item.icon != null) icon.sprite = item.icon;
else if (!string.IsNullOrEmpty(item.iconPath)) icon.sprite = Resources.Load<Sprite>(item.iconPath);
}
public void ChangeAdditionalDisplayIcons(bItem item)
{
if (!item) return;
if (secondaryIcon && item.secondaryIconPath.Length > 1)
{
secondaryIcon.sprite = Resources.Load<Sprite>(item.secondaryIconPath);
}
if (teriaryIcon && item.teriaryIconPath.Length > 1)
{
teriaryIcon.sprite = Resources.Load<Sprite>(item.teriaryIconPath);
}
if (secondaryIcon && item.secondaryIconPath.Length > 1) secondaryIcon.sprite = Resources.Load<Sprite>(item.secondaryIconPath);
if (teriaryIcon && item.teriaryIconPath.Length > 1) teriaryIcon.sprite = Resources.Load<Sprite>(item.teriaryIconPath);
}
/// <summary>
/// Update the Display Description text
/// </summary>
/// <param name="item"></param>
protected virtual void ChangeDisplayDescription(bItem item)
{
if (item)
{
onChangeDescription.Invoke(item.description);
if (displayDescriptionText) displayDescriptionText.text = item.description;
}
else
{
onChangeDescription.Invoke("");
if (displayDescriptionText) displayDescriptionText.text = "";
}
string txt = item ? item.description : "";
onChangeDescription.Invoke(txt);
if (displayDescriptionText) displayDescriptionText.text = txt;
}
/// <summary>
/// Update the Display Amount text
/// </summary>
/// <param name="item"></param>
protected virtual void ChangeDisplayAmount(bItem item)
{
string amountText = "";
if (item != null && this.gameObject.activeSelf)
{
if (item.stackable && item.amount > 1)
amountText = " " + item.amount.ToString();
else
amountText = "";
}
else if (item == null) amountText = "";
if (displayAmountText) displayNameText.text += amountText;
onChangeAmount.Invoke(amountText);
string txt = (item != null && item.stackable && item.amount > 1) ? " " + item.amount.ToString() : "";
if (displayAmountText) displayAmountText.text = txt;
onChangeAmount.Invoke(txt);
}
/// <summary>
/// Update the Display item Name text
/// </summary>
/// <param name="item"></param>
protected virtual void ChangeDisplayName(bItem item)
{
if (item)
{
onChangeName.Invoke(item.name);
if (displayNameText)
{
displayNameText.text = item.name;
}
}
else
{
onChangeName.Invoke("");
if (displayNameText) displayNameText.text = "";
}
string txt = item ? item.name : "";
onChangeName.Invoke(txt);
if (displayNameText) displayNameText.text = txt;
}
/// <summary>
/// Remove current item from the slot
/// </summary>
public virtual void RemoveItem()
{
this.item = null;
onRemoveItem.Invoke(item);
if (icon)
{
// color.a = 0;
//icon.color = color;
icon.sprite = null;
icon.SetAllDirty();
}
if (icon) { icon.sprite = null; icon.SetAllDirty(); }
UpdateDisplays(null);
}
/// <summary>
/// Check if slot has an item
/// </summary>
/// <returns></returns>
public virtual bool isOcupad()
{
return item != null;
}
public virtual bool isOcupad() => item != null;
#region UnityEngine.EventSystems Implementation
public virtual void OnSelect(BaseEventData eventData)
{
// isSelectedIcon.enabled = true;
if (onSelectSlotCallBack != null)
onSelectSlotCallBack(this);
}
public virtual void OnSelect(BaseEventData eventData) => onSelectSlotCallBack?.Invoke(this);
public virtual void OnDeselect(BaseEventData eventData) => onDeselectSlotCallBack?.Invoke(this);
public void MarkSlotAsSelected()
{
displayNameText.color = GetSelectedButtonTextColor();
if (!NewItemPopupSaver.itemsSeen.Contains(item.id))
{
NewItemPopupSaver.itemsSeen.Add(item.id);
SetNotSeenIcon(item.id);
}
if (isSelectedIcon)
{
isSelectedIcon.enabled = true;
}
else
{
icon.color = GetSelectedImageColor();
if (secondaryIcon)
{
secondaryIcon.color = icon.color;
}
if (teriaryIcon)
{
teriaryIcon.color = icon.color;
}
if (rarityImage)
{
rarityImage.color = icon.color;
}
}
if (displayNameText) displayNameText.color = GetSelectedButtonTextColor();
if (item && !NewItemPopupSaver.itemsSeen.Contains(item.id)) { NewItemPopupSaver.itemsSeen.Add(item.id); SetNotSeenIcon(item.id); }
if (isSelectedIcon) isSelectedIcon.enabled = true;
else SetIconColor(GetSelectedImageColor());
}
public void MarkSlotAsDeselected()
{
displayNameText.color = GetDefaultButtonTextColor();
if (isSelectedIcon)
{
isSelectedIcon.enabled = false;
}
else
{
icon.color = GetDeselectedImageColor();
if (secondaryIcon)
{
secondaryIcon.color = icon.color;
}
if (teriaryIcon)
{
teriaryIcon.color = icon.color;
}
if (rarityImage)
{
rarityImage.color = icon.color;
}
}
if (displayNameText) displayNameText.color = GetDefaultButtonTextColor();
if (isSelectedIcon) isSelectedIcon.enabled = false;
else SetIconColor(GetDeselectedImageColor());
}
public virtual void OnDeselect(BaseEventData eventData)
private void SetIconColor(Color c)
{
// isSelectedIcon.enabled = false;
if (onDeselectSlotCallBack != null)
onDeselectSlotCallBack(this);
if (icon) icon.color = c;
if (secondaryIcon) secondaryIcon.color = c;
if (teriaryIcon) teriaryIcon.color = c;
if (rarityImage) rarityImage.color = c;
}
public virtual void OnSubmit(BaseEventData eventData)
{
if (isValid)
{
onClick.Invoke();
if (onSubmitSlotCallBack != null)
onSubmitSlotCallBack(this);
}
if (isValid) { onClick.Invoke(); onSubmitSlotCallBack?.Invoke(this); }
CheckItem(item != null && item.isInEquipArea);
}
public virtual void OnPointerEnter(PointerEventData eventData)
{
//if(vInput.instance.inputDevice == InputDevice.MouseKeyboard)
{
EventSystem.current.SetSelectedGameObject(this.gameObject);
if (onSelectSlotCallBack != null)
onSelectSlotCallBack(this);
}
///DEBUG
if (IsClickable != Clickable)
{
Clickable = IsClickable;
}
EventSystem.current.SetSelectedGameObject(gameObject);
onSelectSlotCallBack?.Invoke(this);
if (IsClickable != Clickable) Clickable = IsClickable;
}
public virtual void OnPointerExit(PointerEventData eventData)
{
//if (vInput.instance.inputDevice == InputDevice.MouseKeyboard)
{
if (onDeselectSlotCallBack != null)
onDeselectSlotCallBack(this);
}
}
public virtual void OnPointerExit(PointerEventData eventData) => onDeselectSlotCallBack?.Invoke(this);
public virtual void OnPointerClick(PointerEventData eventData)
{
return;
#if UNITY_ANDROID || UNITY_IOS
if (vInput.instance.inputDevice == InputDevice.Mobile)
#else
//if (vInput.instance.inputDevice == InputDevice.MouseKeyboard)
#endif
if (eventData.button == PointerEventData.InputButton.Left && isValid)
{
if (eventData.button == PointerEventData.InputButton.Left)
{
if (isValid)
{
onClick.Invoke();
if (onSubmitSlotCallBack != null)
onSubmitSlotCallBack(this);
}
}
onClick.Invoke();
onSubmitSlotCallBack?.Invoke(this);
}
}
#endregion UnityEngine.EventSystems Implementation
}
}

View File

@@ -3,7 +3,6 @@ using Invector.vItemManager;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
@@ -13,24 +12,29 @@ using UnityEngine.UI;
namespace Beyond
{
[System.Serializable]
public class OnHandleSlot : UnityEngine.Events.UnityEvent<bItemSlot>
{ }
public class OnHandleSlot : UnityEngine.Events.UnityEvent<bItemSlot> { }
[System.Serializable]
public class OnCompleteSlotList : UnityEngine.Events.UnityEvent<List<bItemSlot>>
{ }
public class OnCompleteSlotList : UnityEngine.Events.UnityEvent<List<bItemSlot>> { }
[vClassHeader("Item Window", openClose = false)]
public class bItemWindow : vMonoBehaviour
{
public bInventory inventory;
[vReadOnly] public bItem currentItem;
private List<bItem> items;
[Header("Required References")]
[Tooltip("The prefab used to instantiate items in the list.")]
public bItemSlot slotPrefab;
[Tooltip("The Content RectTransform inside your Scroll View.")]
public RectTransform contentWindow;
public List<bItemSlot> slots;
public List<bItemType> supportedItems;
public bool updateSlotCount = true;
[Header("UI References")]
public TMP_Text displayNameText;
public Image rarityImage;
public Text displayTypeText;
@@ -42,104 +46,56 @@ namespace Beyond
public Image displayItemImage, secondaryItemImage, teriaryItemImage;
[SerializeField] private Sprite defaultSprite;
[Header("Additional things")]
[Header("Selection & Buttons")]
public bItemSlot currentSelectedSlot;
[SerializeField] private TMP_Text submitButtonText, consumeButtonText;
[SerializeField] private RectTransform descriptionTransform;
[SerializeField] public RectTransform descriptionTransform;
[SerializeField] private Scrollbar descriptionScroolbar;
[SerializeField] private string useButtonString = "";
[SerializeField]
private GameObject button, consumeButton;
[SerializeField]
private bool isTradeWindow = false;
[SerializeField] private GameObject button, consumeButton;
[SerializeField] private bool isTradeWindow = false;
[vHelpBox("You can ignore display Attributes using this property")]
public List<bItemAttributes> ignoreAttributes;
[vEditorToolbar("Text Events")]
public InputField.OnChangeEvent onChangeName;
public InputField.OnChangeEvent onChangeType;
public InputField.OnChangeEvent onChangeAmount;
public InputField.OnChangeEvent onChangeDescription;
public InputField.OnChangeEvent onChangeAttributes;
// public InputField.OnChangeEvent onChangeImage;
public InputField.OnChangeEvent onChangeName, onChangeType, onChangeAmount, onChangeDescription, onChangeAttributes;
[vEditorToolbar("Events")]
public OnCompleteSlotList onCompleteSlotListCallBack;
public OnHandleSlot onSubmitSlot;
public OnHandleSlot onSelectSlot;
public UnityEvent onCancelSlot;
[Tooltip("Called when item window has slots on enable")]
public UnityEvent onAddSlots;
[Tooltip("Called when item window dont have slots on enable")]
public UnityEvent onClearSlots;
private UnityAction<bItemSlot> onSubmitSlotCallback;
private UnityAction<bItemSlot> onSelectCallback;
private readonly WaitForEndOfFrame WaitForEndOfFrame = new WaitForEndOfFrame();
private List<bItemType> chroniclesTypes = new List<bItemType> { bItemType.ChronicleResources, bItemType.Locations, bItemType.Science, bItemType.Characters };
private void OnEnable()
{
if (descriptionScroolbar)
{
StartCoroutine(RebuildLayoutCoroutine());
}
if (descriptionScroolbar && descriptionTransform)
StartCoroutine(RebuildLayoutCoroutine(descriptionTransform));
}
private void OnDisable()
{
//unload stuff
UnloadCurrentImage();
}
private void OnDisable() => UnloadCurrentImage();
private void UnloadCurrentImage()
{
// Sprite spriteToUnload = displayItemImage.sprite;
if (displayItemImage)
{
Resources.UnloadAsset(displayItemImage.sprite);
}
if (secondaryItemImage)
{
Resources.UnloadAsset(secondaryItemImage.sprite);
}
if (teriaryItemImage)
{
Resources.UnloadAsset(teriaryItemImage.sprite);
}
if (powerSwordImage)
{
Resources.UnloadAsset(powerSwordImage.sprite);
}
// displayItemImage.sprite = null;
// secondaryItemImage.sprite = null;
// teriaryItemImage.sprite = null;
// Resources.UnloadAsset(spriteToUnload);
//Resources.UnloadUnusedAssets();
if (displayItemImage && displayItemImage.sprite) Resources.UnloadAsset(displayItemImage.sprite);
if (secondaryItemImage && secondaryItemImage.sprite) Resources.UnloadAsset(secondaryItemImage.sprite);
if (teriaryItemImage && teriaryItemImage.sprite) Resources.UnloadAsset(teriaryItemImage.sprite);
if (powerSwordImage && powerSwordImage.sprite) Resources.UnloadAsset(powerSwordImage.sprite);
}
public void ReloadItems()
{
ReloadItems(items);
}
public void ReloadItems() => ReloadItems(items);
public void ClearSlots()
{
int slotsCount = slots.Count;
for (int i = 0; i < slotsCount; i++)
{
Destroy(slots[i].gameObject);
}
if (slots == null) return;
for (int i = 0; i < slots.Count; i++) if (slots[i]) Destroy(slots[i].gameObject);
slots.Clear();
currentSelectedSlot = null;
}
@@ -162,11 +118,7 @@ namespace Beyond
}
i--;
}
else if (slots[i] == null)
{
slots.RemoveAt(i);
i--;
}
else if (slots[i] == null) { slots.RemoveAt(i); i--; }
}
}
if (currentSelectedSlot == null || currentSelectedSlot.item == null || slots.Count == 0)
@@ -184,121 +136,111 @@ namespace Beyond
public virtual void CreateEquipmentWindow(List<bItem> items, List<bItemType> type, bItem currentItem = null, UnityAction<bItemSlot> onPickUpItemCallback = null, UnityAction<bItemSlot> onSelectSlotCallBack = null)
{
this.supportedItems = type;
this.items = items.FindAll(item => type.Contains(item.type));
List<bItem> list = new List<bItem>();
foreach (var bItem in this.items.OrderBy(item => item.type)
.ThenBy(item => item.name))
list.Add(bItem);
foreach (var bItem in this.items.OrderBy(item => item.type).ThenBy(item => item.name)) list.Add(bItem);
this.items = list;
this.currentItem = currentItem;
if (!this.currentItem && this.items.Count > 0)
{
this.currentItem = this.items[0];
}
CreateEquipmentWindowNormal(this.items, onPickUpItemCallback, destroyAdictionSlots: true);
if (!this.currentItem && this.items.Count > 0) this.currentItem = this.items[0];
CreateEquipmentWindowNormal(this.items, onPickUpItemCallback, onSelectSlotCallBack, destroyAdictionSlots: true);
}
public virtual void CreateEquipmentWindowUsable(List<bItem> items, List<bItemType> type, bItem currentItem = null, UnityAction<bItemSlot> onPickUpItemCallback = null, UnityAction<bItemSlot> onSelectSlotCallBack = null)
{
this.supportedItems = type;
this.currentItem = currentItem;
var _items = items.FindAll(item => type.Contains(item.type));
var _itemsUsable = _items.FindAll(item => item.canBeUsed);
CreateEquipmentWindowNormal(_itemsUsable, onPickUpItemCallback, destroyAdictionSlots: true);
CreateEquipmentWindowNormal(_itemsUsable, onPickUpItemCallback, onSelectSlotCallBack, destroyAdictionSlots: true);
}
public void CreateEquipmentWindowNormal(List<bItem> items, UnityAction<bItemSlot> onPickUpItemCallBack = null, UnityAction<bItemSlot> onSelectSlotCallBack = null, bool destroyAdictionSlots = true)
{
var _items = supportedItems.Count == 0 ? items : items.FindAll(i => supportedItems.Contains(i.type));
if (inventory == null && Player.Instance != null && Player.Instance.ItemManager != null)
inventory = Player.Instance.ItemManager.inventory;
var _items = supportedItems == null || supportedItems.Count == 0 ? items : items.FindAll(i => supportedItems.Contains(i.type));
if (_items.Count == 0)
{
CreateFullItemDescription(null);
onClearSlots.Invoke();
if (slots.Count > 0 && destroyAdictionSlots && updateSlotCount)
{
for (int i = 0; i < slots.Count; i++)
{
// yield return null;
Destroy(slots[i].gameObject);
}
slots.Clear();
}
if (slots != null && slots.Count > 0 && destroyAdictionSlots && updateSlotCount) ClearSlots();
currentSelectedSlot = null;
}
else
{
if (slots == null) slots = new List<bItemSlot>();
if (slots.Count > _items.Count && destroyAdictionSlots && updateSlotCount)
{
int difference = slots.Count - _items.Count;
for (int i = 0; i < difference; i++)
{
// yield return null;
Destroy(slots[0].gameObject);
slots.RemoveAt(0);
}
for (int i = 0; i < difference; i++) { if (slots[0]) Destroy(slots[0].gameObject); slots.RemoveAt(0); }
}
bool selecItem = false;
onSubmitSlotCallback = onPickUpItemCallBack;
onSelectCallback = onSelectSlotCallBack;
if (slots == null) slots = new List<bItemSlot>();
var count = items.Count;
if (updateSlotCount)
{
for (int i = 0; i < _items.Count; i++)
{
bItemSlot slot = null;
if (i < slots.Count)
{
slot = slots[i];
}
if (i < slots.Count) slot = slots[i];
else
{
slot = Instantiate(slotPrefab) as bItemSlot;
// --- SAFETY CHECK ---
if (slotPrefab == null)
{
Debug.LogError("<b>[bItemWindow]</b> Error: 'Slot Prefab' is not assigned! Please drag a bItemSlot prefab into the 'Slot Prefab' field in the Inspector.", this);
return;
}
if (contentWindow == null)
{
Debug.LogError("<b>[bItemWindow]</b> Error: 'Content Window' is not assigned! Please assign the Content RectTransform of your Scroll View.", this);
return;
}
// --------------------
slot = Instantiate(slotPrefab) as bItemSlot;
slots.Add(slot);
var rectTranform = slot.GetComponent<RectTransform>();
rectTranform.SetParent(contentWindow);
rectTranform.localPosition = Vector3.zero;
rectTranform.localScale = Vector3.one;
rectTranform.localRotation = Quaternion.identity;
// yield return null;
// Ensure the new slot is visible and active
slot.gameObject.SetActive(true);
}
// slot = slots[i];
slot.SetInventory(this.inventory);
slot.AddItem(_items[i]);
if (slot.item.type == bItemType.PowerScroll && slot.item.canBeDroped)
{
slot.TryToMarkAsSpeciallEquipped();
}
else
{
slot.CheckItem(_items[i].isInEquipArea);
}
if (slot.item.type == bItemType.PowerScroll && slot.item.canBeDroped) slot.TryToMarkAsSpeciallEquipped();
else slot.CheckItem(_items[i].isInEquipArea);
slot.onSubmitSlotCallBack = OnSubmit;
slot.onSelectSlotCallBack = OnSelect;
if (currentItem != null && currentItem == _items[i])
{
if (currentSelectedSlot)
{
currentSelectedSlot.MarkSlotAsDeselected();
}
if (currentSelectedSlot) currentSelectedSlot.MarkSlotAsDeselected();
selecItem = true;
currentSelectedSlot = slot;
OnSelect(slot);
}
slot.UpdateDisplays();
}
}
if (slots.Count > 0 && !selecItem)
{
currentSelectedSlot = slots[0];
//StartCoroutine(SetSelectableHandle(slots[0].gameObject));
}
if (slots.Count > 0 && !selecItem) currentSelectedSlot = slots[0];
if (contentWindow) LayoutRebuilder.ForceRebuildLayoutImmediate(contentWindow);
}
SetSubmitButton(currentSelectedSlot);
if (slots.Count > 0)
@@ -307,124 +249,98 @@ namespace Beyond
EnableDescriptionObjects();
CreateFullItemDescription(currentSelectedSlot);
}
else
{
DisableDescriptionObjects();
}
else DisableDescriptionObjects();
onCompleteSlotListCallBack.Invoke(slots);
}
public void EnableDescriptionObjects()
{
displayNameText.enabled = true;
descriptionTransform.gameObject.SetActive(true);
if (displayNameText) displayNameText.enabled = true;
if (descriptionTransform) descriptionTransform.gameObject.SetActive(true);
}
public void DisableDescriptionObjects()
{
displayNameText.enabled = false;
descriptionTransform.gameObject.SetActive(false);
if (displayNameText) displayNameText.enabled = false;
if (descriptionTransform) descriptionTransform.gameObject.SetActive(false);
}
public void SetPowerableSwitchSwordImage(bItem selectedPowerableItem)
{
if (powerSwordImage == null) return;
if (powerSwordImage.sprite) Resources.UnloadAsset(powerSwordImage.sprite);
if (!selectedPowerableItem) powerSwordImage.enabled = false;
else
{
powerSwordImage.enabled = true;
powerSwordImage.sprite = Resources.Load<Sprite>(selectedPowerableItem.iconPath);
}
}
protected virtual IEnumerator CreateEquipmentWindowRoutine(List<bItem> items, UnityAction<bItemSlot> onPickUpItemCallBack = null, UnityAction<bItemSlot> onSelectSlotCallBack = null, bool destroyAdictionSlots = true)
{
var _items = supportedItems.Count == 0 ? items : items.FindAll(i => supportedItems.Contains(i.type));
if (inventory == null && Player.Instance != null && Player.Instance.ItemManager != null)
inventory = Player.Instance.ItemManager.inventory;
var _items = supportedItems == null || supportedItems.Count == 0 ? items : items.FindAll(i => supportedItems.Contains(i.type));
if (_items.Count == 0)
{
CreateFullItemDescription(null);
onClearSlots.Invoke();
if (slots.Count > 0 && destroyAdictionSlots && updateSlotCount)
{
for (int i = 0; i < slots.Count; i++)
{
// yield return null;
Destroy(slots[i].gameObject);
}
slots.Clear();
currentSelectedSlot = null;
}
ClearSlots();
}
else
{
if (slots.Count > _items.Count && destroyAdictionSlots && updateSlotCount)
{
int difference = slots.Count - _items.Count;
for (int i = 0; i < difference; i++)
{
yield return null;
Destroy(slots[0].gameObject);
slots.RemoveAt(0);
}
}
bool selecItem = false;
onSubmitSlotCallback = onPickUpItemCallBack;
onSelectCallback = onSelectSlotCallBack;
if (slots == null) slots = new List<bItemSlot>();
var count = items.Count;
// if (updateSlotCount)
ClearSlots();
for (int i = 0; i < _items.Count; i++)
{
for (int i = 0; i < _items.Count; i++)
if (slotPrefab == null)
{
bItemSlot slot = null;
if (i < slots.Count)
{
slot = slots[i];
}
else
{
slot = Instantiate(slotPrefab) as bItemSlot;
slots.Add(slot);
var rectTranform = slot.GetComponent<RectTransform>();
rectTranform.SetParent(contentWindow);
rectTranform.localPosition = Vector3.zero;
rectTranform.localScale = Vector3.one;
// yield return null;
}
// slot = slots[i];
slot.AddItem(_items[i]);
slot.CheckItem(_items[i].isInEquipArea);
slot.onSubmitSlotCallBack = OnSubmit;
slot.onSelectSlotCallBack = OnSelect;
if (currentItem != null && currentItem == _items[i])
{
selecItem = true;
currentSelectedSlot = slot;
SetSelectable(slot.gameObject);
}
slot.UpdateDisplays();
Debug.LogError("<b>[bItemWindow]</b> Error: 'Slot Prefab' is missing!", this);
yield break;
}
bItemSlot slot = Instantiate(slotPrefab) as bItemSlot;
slots.Add(slot);
var rectTranform = slot.GetComponent<RectTransform>();
rectTranform.SetParent(contentWindow);
rectTranform.localPosition = Vector3.zero;
rectTranform.localScale = Vector3.one;
slot.gameObject.SetActive(true);
slot.inventory = this.inventory;
slot.AddItem(_items[i]);
slot.CheckItem(_items[i].isInEquipArea);
slot.onSubmitSlotCallBack = OnSubmit;
slot.onSelectSlotCallBack = OnSelect;
slot.UpdateDisplays();
yield return null;
}
if (slots.Count > 0 && !selecItem)
{
currentSelectedSlot = slots[0];
StartCoroutine(SetSelectableHandle(slots[0].gameObject));
}
if (contentWindow) LayoutRebuilder.ForceRebuildLayoutImmediate(contentWindow);
if (slots.Count > 0) { currentSelectedSlot = slots[0]; CreateFullItemDescription(currentSelectedSlot); }
}
if (slots.Count > 0)
{
onAddSlots.Invoke();
CreateFullItemDescription(currentSelectedSlot);
}
if (slots.Count > 0) onAddSlots.Invoke();
onCompleteSlotListCallBack.Invoke(slots);
}
public virtual IEnumerator SetSelectableHandle(GameObject target)
{
if (this.enabled)
{
yield return WaitForEndOfFrame;
SetSelectable(target);
}
if (this.enabled) { yield return WaitForEndOfFrame; SetSelectable(target); }
}
public virtual void SetSelectable(GameObject target)
{
if (!EventSystem.current) return;
var pointer = new PointerEventData(EventSystem.current);
ExecuteEvents.Execute(EventSystem.current.currentSelectedGameObject, pointer, ExecuteEvents.pointerExitHandler);
if (EventSystem.current.currentSelectedGameObject)
ExecuteEvents.Execute(EventSystem.current.currentSelectedGameObject, pointer, ExecuteEvents.pointerExitHandler);
EventSystem.current.SetSelectedGameObject(target, new BaseEventData(EventSystem.current));
ExecuteEvents.Execute(target, pointer, ExecuteEvents.selectHandler);
}
@@ -433,7 +349,8 @@ namespace Beyond
{
if (ShouldDissalowUseOfScrolls(slot))
{
PopupMenuController.Instance.TryToShowPopupMesssage("Skill Required: " + SkillsManager.instance.GetStringNameOf(Skills.MasterOfScrolls));
if (PopupMenuController.Instance != null && SkillsManager.instance != null)
PopupMenuController.Instance.TryToShowPopupMesssage("Skill Required: " + SkillsManager.instance.GetStringNameOf(Skills.MasterOfScrolls));
}
else
{
@@ -446,118 +363,57 @@ namespace Beyond
private bool ShouldDissalowUseOfScrolls(bItemSlot slot)
{
if (slot == null || slot.item == null) return false;
if (SkillsManager.instance == null) return false;
return slot.item.type == bItemType.PowerScroll && SkillsManager.instance.GetSkillLevelOf(Skills.MasterOfScrolls) == 0 && PopupMenuController.Instance != null && !isTradeWindow;
}
private void SetSubmitButton(bItemSlot slot)
{
if (!slot)
if (!slot || !button)
{
button.SetActive(false);
if (consumeButton)
if (button) button.SetActive(false);
if (consumeButton) consumeButton.SetActive(false);
return;
}
button.SetActive(true);
if (useButtonString != "") { if (submitButtonText) submitButtonText.text = useButtonString; return; }
if (submitButtonText)
{
bItemType itemType = slot.item.type;
switch (itemType)
{
consumeButton.SetActive(false);
}
return;
}
else
{
button.SetActive(true);
}
if (useButtonString != "")
{
submitButtonText.text = useButtonString;
return;
}
bItemType itemType = slot.item.type;
switch (itemType)
{
case bItemType.MeleeWeapon:
case bItemType.Swords:
case bItemType.Axes:
case bItemType.QuantaPower:
case bItemType.Gemstones:
submitButtonText.text = slot.isChecked ? "Unequip" : "Equip";
break;
case bItemType.PowerScroll:
if (!slot.item.canBeDroped)
{
case bItemType.MeleeWeapon:
case bItemType.Swords:
case bItemType.Axes:
case bItemType.QuantaPower:
case bItemType.Gemstones:
case bItemType.Trinkets:
submitButtonText.text = slot.isChecked ? "Unequip" : "Equip";
}
else
{
button.SetActive(false);
}
break;
case bItemType.Builder:
submitButtonText.text = "Create";
break;
case bItemType.Consumable:
case bItemType.ConsumablesFaith:
submitButtonText.text = slot.isChecked ? "Unequip" : "Equip";
consumeButton.SetActive(true);
consumeButtonText.text = "Consume";
break;
/*
case bItemType.Gemstones:
submitButtonText.text = "Switch Weapon";
consumeButton.SetActive(true);
consumeButtonText.text = "Equip";
break;
*/
case bItemType.Guilts:
submitButtonText.text = "Agree";
break;
default:
button.SetActive(false);
if (consumeButton)
{
consumeButton.SetActive(false);
}
break;
break;
case bItemType.PowerScroll:
if (!slot.item.canBeDroped) submitButtonText.text = slot.isChecked ? "Unequip" : "Equip";
else button.SetActive(false);
break;
case bItemType.Builder: submitButtonText.text = "Create"; break;
case bItemType.Consumable:
case bItemType.ConsumablesFaith:
submitButtonText.text = slot.isChecked ? "Unequip" : "Equip";
if (consumeButton) { consumeButton.SetActive(true); if (consumeButtonText) consumeButtonText.text = "Consume"; }
break;
case bItemType.Guilts: submitButtonText.text = "Agree"; break;
default: submitButtonText.text = slot.isChecked ? "Unequip" : "Equip"; if (consumeButton) consumeButton.SetActive(false); break;
}
}
}
public void SetPowerableSwitchSwordImage(bItem selectedPowerableItem)
{
Resources.UnloadAsset(powerSwordImage.sprite);
if (!selectedPowerableItem)
{
powerSwordImage.enabled = false;
}
else
{
powerSwordImage.enabled = true;
powerSwordImage.sprite = Resources.Load<Sprite>(selectedPowerableItem.iconPath);
}
}
public void OnSubmit()
{
OnSubmit(currentSelectedSlot);
}
public void OnSubmit() => OnSubmit(currentSelectedSlot);
public virtual void OnSelect(bItemSlot slot)
{
if (slot == null || slot.item == null)
{
return;
}
if (currentSelectedSlot)
{
currentSelectedSlot.MarkSlotAsDeselected();
}
if (slot == null || slot.item == null) return;
if (currentSelectedSlot) currentSelectedSlot.MarkSlotAsDeselected();
currentSelectedSlot = slot;
slot.MarkSlotAsSelected();
CreateFullItemDescription(slot);
@@ -570,144 +426,124 @@ namespace Beyond
{
if (!slot)
{
if (displayNameText) displayNameText.text = "";
if (displayDescriptionText) displayDescriptionText.text = "";
return;
}
var _name = slot.item ? slot.item.name : "";
var _rarity = -1;
if (ItemIsRarityInterested(slot))
{
bItemAttribute rarityAttribute = slot.item.GetItemAttribute(bItemAttributes.Rarity);
_rarity = rarityAttribute != null ? rarityAttribute.value : 0; // 0 means ordinary, 1 ancient, 2 mystical
}
var _description = slot.item ? slot.item.description : "";
var _image = slot.item ? Resources.Load<Sprite>(slot.item.iconPath) /* slot.item.icon */: defaultSprite;
var _secondaryImage = slot.item ? Resources.Load<Sprite>(slot.item.secondaryIconPath) : null;
var _teriaryImage = slot.item ? Resources.Load<Sprite>(slot.item.teriaryIconPath) : null;
var _type = slot.item ? slot.item.ItemTypeText() : "";
var _amount = slot.item ? slot.item.amount.ToString() : "";
var _attributes = slot.item ? slot.item.GetItemAttributesText(ignoreAttributes) : "";
var _power = slot.item ? slot.item.GetItemAttribute(bItemAttributes.Power) : null;
var _Damage = slot.item ? slot.item.GetItemAttribute(bItemAttributes.Damage) : null;
Sprite _image = defaultSprite;
Sprite _secondaryImage = null;
Sprite _teriaryImage = null;
if (slot.item)
{
if (!string.IsNullOrEmpty(slot.item.iconPath)) _image = Resources.Load<Sprite>(slot.item.iconPath);
if (!string.IsNullOrEmpty(slot.item.secondaryIconPath)) _secondaryImage = Resources.Load<Sprite>(slot.item.secondaryIconPath);
if (!string.IsNullOrEmpty(slot.item.teriaryIconPath)) _teriaryImage = Resources.Load<Sprite>(slot.item.teriaryIconPath);
}
int _rarity = -1;
if (ItemIsRarityInterested(slot))
{
bItemAttribute rarityAttribute = slot.item.GetItemAttribute(bItemAttributes.Rarity);
_rarity = rarityAttribute != null ? rarityAttribute.value : 0;
}
if (displayNameText) displayNameText.text = _name;
onChangeName.Invoke(_name);
if (rarityImage && _rarity >= 0)
{
rarityImage.gameObject.SetActive(true);
rarityImage.sprite = slot.raritySprites[_rarity];
}
else
{
rarityImage.gameObject.SetActive(false);
}
if (displayTypeText) displayTypeText.text = _type;
onChangeType.Invoke(_type);
if (displayAmountText) displayAmountText.text = _amount;
onChangeAmount.Invoke(_amount);
if (displayDescriptionText) displayDescriptionText.text = _description;
onChangeDescription.Invoke(_description);
if (displayAttributesText) displayAttributesText.text = _attributes;
onChangeAttributes.Invoke(_attributes);
if (chroniclesTypes.Contains(slot.item.type))
if (rarityImage)
{
displayItemImage.sprite = (Sprite)_secondaryImage;
}
else if (displayItemImage)
{
displayItemImage.sprite = (Sprite)_image;
if (_rarity >= 0 && slot.raritySprites != null && _rarity < slot.raritySprites.Count)
{
rarityImage.gameObject.SetActive(true);
rarityImage.sprite = slot.raritySprites[_rarity];
}
else rarityImage.gameObject.SetActive(false);
}
bItemAttribute yOffsetAttribute = slot.item.GetItemAttribute(bItemAttributes.ImageYDescOffset);
bItemAttribute xOffsetAttribute = slot.item.GetItemAttribute(bItemAttributes.ImageXDescOffset);
Vector3 imagePosition = displayItemImage.transform.localPosition;
float yOffset = 0;
float xOffset = 0;
if (yOffsetAttribute != null)
if (displayItemImage)
{
yOffset = yOffsetAttribute.value;
if (slot.item != null && chroniclesTypes.Contains(slot.item.type)) displayItemImage.sprite = _secondaryImage;
else displayItemImage.sprite = _image;
if (slot.item != null)
{
bItemAttribute xOffset = slot.item.GetItemAttribute(bItemAttributes.ImageXDescOffset);
bItemAttribute yOffset = slot.item.GetItemAttribute(bItemAttributes.ImageYDescOffset);
displayItemImage.transform.localPosition = new Vector3(xOffset != null ? xOffset.value : 0, yOffset != null ? yOffset.value : 0, 0);
}
}
if (xOffsetAttribute != null)
{
xOffset = xOffsetAttribute.value;
}
displayItemImage.transform.localPosition = new Vector3(xOffset, yOffset, imagePosition.z);
if (secondaryItemImage) secondaryItemImage.sprite = _secondaryImage;
if (teriaryItemImage) teriaryItemImage.sprite = _teriaryImage;
if (slot.item.type == bItemType.Gemstones)
if (changeableAttributesText) changeableAttributesText.gameObject.SetActive(false);
if (powerSwordImage) powerSwordImage.gameObject.SetActive(false);
if (slot.item != null)
{
if (powerSwordImage && powerSwordImage.sprite)
bItemAttribute _power = slot.item.GetItemAttribute(bItemAttributes.Power);
bItemAttribute _Damage = slot.item.GetItemAttribute(bItemAttributes.Damage);
if (slot.item.type == bItemType.Gemstones)
{
powerSwordImage.gameObject.SetActive(true);
if (powerSwordImage && powerSwordImage.sprite) powerSwordImage.gameObject.SetActive(true);
if (changeableAttributesText && _power != null)
{
changeableAttributesText.gameObject.SetActive(true);
changeableAttributesText.text = "<color=blue>+" + _power.value.ToString() + " Quantum Charge</color>";
}
}
else //in case we have no valid weapons for gemstone
else if (_power != null && changeableAttributesText)
{
powerSwordImage.gameObject.SetActive(false);
}
// //for gemstones power value is constant
changeableAttributesText.gameObject.SetActive(true);
changeableAttributesText.text = "<color=blue>+" + _power.value.ToString() + " Quantum Charge</color>";
}
else if (_power != null) //powerable weapons
{
// < color = blue > (+15) </ color > Damage </ color >
//< color = purple > 0 < color = blue > (+30) </ color > Spectral Damage </ color ></ align >
changeableAttributesText.gameObject.SetActive(true);
changeableAttributesText.text = "<color=blue>" + _power.value.ToString() + "/100 Quantum Charge </color>";
if (_power.value > 0)
{
changeableAttributesText.text += "<color=grey>\n" + (_Damage.value * 2).ToString() + " Damage</color>" +
"<color=purple>\n" + (_Damage.value * 2).ToString() + " Spectral Damage</color>";
}
else
{
changeableAttributesText.text += "<color=grey>\n" + (_Damage.value).ToString() + " Damage</color>" +
"<color=purple>\n" + "0" + " Spectral Damage</color>";
}
}
else
{
if (changeableAttributesText)
{
changeableAttributesText.gameObject.SetActive(false);
}
if (powerSwordImage)
{
powerSwordImage.gameObject.SetActive(false);
changeableAttributesText.gameObject.SetActive(true);
changeableAttributesText.text = "<color=blue>" + _power.value.ToString() + "/100 Quantum Charge </color>";
if (_Damage != null)
{
if (_power.value > 0)
{
changeableAttributesText.text += "<color=grey>\n" + (_Damage.value * 2).ToString() + " Damage</color>" +
"<color=purple>\n" + (_Damage.value * 2).ToString() + " Spectral Damage</color>";
}
else
{
changeableAttributesText.text += "<color=grey>\n" + (_Damage.value).ToString() + " Damage</color>" +
"<color=purple>\n" + "0" + " Spectral Damage</color>";
}
}
}
}
if (descriptionTransform)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(descriptionTransform);
}
if (descriptionTransform) LayoutRebuilder.ForceRebuildLayoutImmediate(descriptionTransform);
}
//need to handle equip
private static bool ItemIsRarityInterested(bItemSlot slot)
{
return slot.item && slot.rarityInterestedType.Contains(slot.item.type);
}
private IEnumerator RebuildLayoutCoroutine()
private IEnumerator RebuildLayoutCoroutine(RectTransform transform)
{
yield return new WaitForSecondsRealtime(Time.fixedDeltaTime);
LayoutRebuilder.ForceRebuildLayoutImmediate(descriptionTransform);
if (transform) LayoutRebuilder.ForceRebuildLayoutImmediate(transform);
}
public virtual void OnCancel()
{
onCancelSlot.Invoke();
}
public virtual void OnCancel() => onCancelSlot.Invoke();
public void BlockAllButGaze(bool b)
{
@@ -718,17 +554,8 @@ namespace Beyond
{
foreach (var s in slots)
{
if (block)
{
if (s.item.id != exceptionItem)
{
s.Clickable = false;
}
}
else
{
s.Clickable = true;
}
if (block) { if (s.item.id != exceptionItem) s.Clickable = false; }
else s.Clickable = true;
}
}
}

View File

@@ -48,17 +48,15 @@ namespace Beyond
{
if (m != this)
{
Members = new List<vBodyMember>();
for (int i = 0; i < m.Members.Count; i++)
{
Members.Add(m.Members[i]);
}
this.hitProperties = m.hitProperties;
this.defaultDamage = m.defaultDamage;
this.defaultDefenseRate = m.defaultDefenseRate;
this.defaultAttackDistance = m.defaultAttackDistance;
this.defaultStaminaCost = m.defaultStaminaCost;
// This copies EVERY Serialized field from 'm' to 'this'
// It works perfectly because bMeleeManager inherits vMeleeManager
JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(m), this);
// Re-run init to apply the copied data
this.Init();
// Stop after finding the first match so we don't copy ourselves if checking later
break;
}
}
}

View File

@@ -24,6 +24,7 @@ namespace Beyond
public float faithMult;
public float damageMult;
public float speedMult;
public float staminaMult;
public float attackSpeedMult;
public float faithRegenMult;
public float thornDamageMult;
@@ -77,7 +78,8 @@ namespace Beyond
speedMult = 1f,
attackSpeedMult = 1f,
faithRegenMult = 1f,
thornDamageMult = 1f
thornDamageMult = 1f,
staminaMult = 1f
};
// 2. Get Currently Equipped Items
@@ -101,6 +103,7 @@ namespace Beyond
stats.attackSpeedMult += GetPct(item, bItemAttributes.AttackSpeedBonusPercent);
stats.faithRegenMult += GetPct(item, bItemAttributes.FaithRegenBonusPercent);
stats.thornDamageMult += GetPct(item, bItemAttributes.ThornDamageBonusPercent);
stats.staminaMult += GetPct(item, bItemAttributes.StaminaBonusPercent);
}
// 4. Apply Harmonies (Based on Table)

View File

@@ -0,0 +1,91 @@
using UnityEngine;
using UnityEngine.Events;
using Invector.vItemManager;
using Invector.vCharacterController;
using System.Collections.Generic;
using Sirenix.OdinInspector;
namespace Beyond
{
public class TrinketUIController : MonoBehaviour
{
[Header("Main References")]
public Canvas mainCanvas;
public bEquipArea trinketEquipArea;
public bItemWindow trinketItemWindow;
[Header("Settings")]
public KeyCode openKey = KeyCode.T;
// CHANGED: Use a list to catch all potential item types (Gemstones, Trinkets, etc)
public List<bItemType> trinketTypes = new List<bItemType>() { bItemType.Gemstones, bItemType.Trinkets };
[Header("Events")]
public UnityEvent onOpenWindow;
public UnityEvent onCloseWindow;
private bool isOpen = false;
void Start()
{
if (!mainCanvas) mainCanvas = GetComponent<Canvas>();
if (mainCanvas) mainCanvas.enabled = false;
if (trinketItemWindow) trinketItemWindow.gameObject.SetActive(false);
}
void Update()
{
if (Input.GetKeyDown(openKey)) Toggle();
}
[Button]
public void Toggle()
{
isOpen = !isOpen;
if (isOpen) Open(); else Close();
}
[Button]
public void Open()
{
var player = Player.Instance;
if (!player) return;
var itemManager = player.ItemManager;
var inventory = itemManager.inventory;
if (!inventory) return;
// Setup Components
trinketEquipArea.inventory = inventory;
trinketEquipArea.itemManager = itemManager;
trinketEquipArea.Init(); // This calls Start(), which calls SetInventory() on slots
// Setup Window
trinketItemWindow.inventory = inventory;
trinketItemWindow.gameObject.SetActive(true);
if (mainCanvas) mainCanvas.enabled = true;
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
Time.timeScale = 0;
trinketEquipArea.SetNewItemWindow(trinketItemWindow);
// Pass the list of types instead of just one
trinketEquipArea.SetEquipmentwindowWithFilter(trinketTypes);
onOpenWindow.Invoke();
}
[Button]
public void Close()
{
if (mainCanvas) mainCanvas.enabled = false;
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
Time.timeScale = 1;
onCloseWindow.Invoke();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 10136cee38aa547eeb77d6233acc00a4

View File

@@ -14,4 +14,4 @@ MonoBehaviour:
m_EditorClassIdentifier:
items: []
inEdition: 0
itemsHidden: 0
itemsHidden: 1

View File

@@ -26,7 +26,13 @@ namespace Invector.vMelee
public vMeleeWeapon leftWeapon, rightWeapon;
public vOnHitEvent onDamageHit, onRecoilHit;
public OnEquipWeaponEvent onEquipWeapon;
protected float globalDamageMultiplier = 1f;
// CHANGE 2: Add a public method to set this multiplier from Player.cs
public void SetGlobalDamageMultiplier(float multiplier)
{
globalDamageMultiplier = multiplier;
}
#endregion SeralizedProperties in CustomEditor
[Tooltip("NPC ONLY- Ideal distance for the attack")]
@@ -184,10 +190,24 @@ namespace Invector.vMelee
if (this.attackName != string.Empty) damage.damageType = this.attackName;
if (this.ignoreDefense) damage.ignoreDefense = this.ignoreDefense;
if (this.senselessTime != 0) damage.senselessTime = this.senselessTime;
/// Calc damage with multiplier
/// and Call ApplyDamage of attackObject
damage.damageValue *= damageMultiplier > 1 ? damageMultiplier : 1;
// CHANGE 3: Update the Math to include your global multiplier
// -----------------------------------------------------------
float calculatedDamage = damage.damageValue;
// 1. Apply Animation Multiplier (Heavy attacks, etc)
if (damageMultiplier > 1) calculatedDamage *= damageMultiplier;
// 2. Apply Trinket/Global Multiplier
calculatedDamage *= globalDamageMultiplier;
// 3. Apply Result back to the integer (Rounding to nearest)
damage.damageValue = Mathf.RoundToInt(calculatedDamage);
// -----------------------------------------------------------
hitInfo.targetIsBlocking = !hitInfo.attackObject.ApplyDamage(hitInfo.hitBox, hitInfo.targetCollider, damage);
onDamageHit.Invoke(hitInfo);