Trineks Manager - WIP implementation
This commit is contained in:
73
Assets/Scripts/Powers/TrinketDebugger.cs
Normal file
73
Assets/Scripts/Powers/TrinketDebugger.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector; // You are using Odin
|
||||
using Invector.vItemManager;
|
||||
|
||||
namespace Beyond
|
||||
{
|
||||
public class TrinketDebugger : MonoBehaviour
|
||||
{
|
||||
public bItemManager itemManager;
|
||||
public bEquipArea trinketArea;
|
||||
|
||||
[Header("Test Items")]
|
||||
public int azureItemId = 200; // ID of item you created in Phase 1
|
||||
public int crimsonItemId = 201;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if(!itemManager) itemManager = GetComponent<bItemManager>();
|
||||
}
|
||||
|
||||
[Button("Add & Equip Azure Gem")]
|
||||
public void TestEquipAzure()
|
||||
{
|
||||
// 1. Add to inventory
|
||||
var reference = new ItemReference(azureItemId);
|
||||
reference.amount = 1;
|
||||
itemManager.AddItem(reference);
|
||||
|
||||
// 2. Find the item object we just added
|
||||
var item = itemManager.GetItem(azureItemId);
|
||||
|
||||
// 3. Force Equip into first available slot
|
||||
if (item != null && trinketArea != null)
|
||||
{
|
||||
trinketArea.AddItemToEquipSlot(0, item, true);
|
||||
Debug.Log("<color=cyan>Test: Equipped Azure Gem</color>");
|
||||
}
|
||||
}
|
||||
|
||||
[Button("Equip 3 Azure (Test Calmness Harmony)")]
|
||||
public void TestFullAzureHarmony()
|
||||
{
|
||||
// Add 3 items
|
||||
itemManager.AddItem(new ItemReference(azureItemId) { amount = 1 });
|
||||
itemManager.AddItem(new ItemReference(azureItemId) { amount = 1 });
|
||||
itemManager.AddItem(new ItemReference(azureItemId) { amount = 1 });
|
||||
|
||||
// Get list of them
|
||||
var items = itemManager.items.FindAll(i => i.id == azureItemId);
|
||||
|
||||
// Equip to slots 0, 1, 2
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
if(i < items.Count)
|
||||
trinketArea.AddItemToEquipSlot(i, items[i], true);
|
||||
}
|
||||
Debug.Log("<color=cyan>Test: Equipped 3 Azure Gems</color>");
|
||||
}
|
||||
|
||||
[Button("Unequip All")]
|
||||
public void UnequipAll()
|
||||
{
|
||||
foreach(var slot in trinketArea.equipSlots)
|
||||
{
|
||||
if(slot.item != null)
|
||||
{
|
||||
trinketArea.RemoveItemOfEquipSlot(slot);
|
||||
}
|
||||
}
|
||||
Debug.Log("Test: Unequipped All");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Powers/TrinketDebugger.cs.meta
Normal file
2
Assets/Scripts/Powers/TrinketDebugger.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b18079ac2a5e34669b98a17925ad9f90
|
||||
191
Assets/Scripts/Powers/TrinketManager.cs
Normal file
191
Assets/Scripts/Powers/TrinketManager.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Invector.vItemManager;
|
||||
|
||||
namespace Beyond
|
||||
{
|
||||
public class TrinketManager : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[Tooltip("Drag the bEquipArea used for Trinkets here")]
|
||||
[SerializeField] private bEquipArea trinketEquipArea;
|
||||
|
||||
[Header("Debug")]
|
||||
[SerializeField] private TrinketStats currentStats;
|
||||
|
||||
// Struct to pass calculated data to Player
|
||||
[System.Serializable]
|
||||
public struct TrinketStats
|
||||
{
|
||||
// Multipliers (1.0 = 100% / Normal)
|
||||
public float healthMult;
|
||||
public float defenseMult;
|
||||
public float faithMult;
|
||||
public float damageMult;
|
||||
public float speedMult;
|
||||
public float attackSpeedMult;
|
||||
public float faithRegenMult;
|
||||
public float thornDamageMult;
|
||||
|
||||
// Harmony Flags (Effects from table)
|
||||
// Renamed to match Player.cs usage
|
||||
public bool effectBalance; // Balance (Flask bonus)
|
||||
public bool effectCalmness; // Calmness (Longer shield)
|
||||
public bool effectFaithVampirism; // Trust (Faith vampirism) - Was effectTrust
|
||||
public bool effectBreeze; // Breeze (Freezing blast cost)
|
||||
public bool effectDetermination; // Determination (Combo damage)
|
||||
public bool effectHealthVampirism; // Vitality (Health vampirism) - Was effectVitality
|
||||
public bool effectEagerness; // Eagerness (Dash cooldown)
|
||||
public bool effectBloom; // Bloom (Spell cost reduced)
|
||||
public bool effectGrowth; // Growth (Cast restores HP)
|
||||
public bool effectRose; // Rose (Thorn damage)
|
||||
public bool effectDarkening; // The Darkening (Bonus dmg)
|
||||
public bool effectEclipse; // Eclipse (Bonus all)
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (!trinketEquipArea)
|
||||
{
|
||||
Debug.LogError($"[TrinketManager] No bEquipArea assigned on {gameObject.name}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Subscribe to changes
|
||||
trinketEquipArea.onEquipItem.AddListener(OnTrinketChanged);
|
||||
trinketEquipArea.onUnequipItem.AddListener(OnTrinketChanged);
|
||||
|
||||
// Initial Calculation
|
||||
Invoke(nameof(RecalculateStats), 0.2f);
|
||||
}
|
||||
|
||||
private void OnTrinketChanged(bEquipArea area, bItem item)
|
||||
{
|
||||
RecalculateStats();
|
||||
}
|
||||
|
||||
public void RecalculateStats()
|
||||
{
|
||||
// 1. Reset Stats to Default
|
||||
TrinketStats stats = new TrinketStats
|
||||
{
|
||||
healthMult = 1f,
|
||||
defenseMult = 1f,
|
||||
faithMult = 1f,
|
||||
damageMult = 1f,
|
||||
speedMult = 1f,
|
||||
attackSpeedMult = 1f,
|
||||
faithRegenMult = 1f,
|
||||
thornDamageMult = 1f
|
||||
};
|
||||
|
||||
// 2. Get Currently Equipped Items
|
||||
List<bItem> equippedItems = new List<bItem>();
|
||||
foreach (var slot in trinketEquipArea.equipSlots)
|
||||
{
|
||||
if (slot.isValid && slot.item != null)
|
||||
{
|
||||
equippedItems.Add(slot.item);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Sum up Percentage Attributes
|
||||
foreach (var item in equippedItems)
|
||||
{
|
||||
stats.healthMult += GetPct(item, bItemAttributes.HealthBonusPercent);
|
||||
stats.defenseMult -= GetPct(item, bItemAttributes.DefenseBonusPercent); // Defense reduces damage taken
|
||||
stats.faithMult += GetPct(item, bItemAttributes.FaithBonusPercent);
|
||||
stats.damageMult += GetPct(item, bItemAttributes.DamageBonusPercent);
|
||||
stats.speedMult += GetPct(item, bItemAttributes.MoveSpeedBonusPercent);
|
||||
stats.attackSpeedMult += GetPct(item, bItemAttributes.AttackSpeedBonusPercent);
|
||||
stats.faithRegenMult += GetPct(item, bItemAttributes.FaithRegenBonusPercent);
|
||||
stats.thornDamageMult += GetPct(item, bItemAttributes.ThornDamageBonusPercent);
|
||||
}
|
||||
|
||||
// 4. Apply Harmonies (Based on Table)
|
||||
ApplyHarmonies(equippedItems, ref stats);
|
||||
|
||||
currentStats = stats;
|
||||
|
||||
// 5. Send to Player
|
||||
if (Player.Instance != null)
|
||||
{
|
||||
Player.Instance.UpdateTrinketStats(stats);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyHarmonies(List<bItem> items, ref TrinketStats stats)
|
||||
{
|
||||
int azure = items.Count(i => i.trinketColor == TrinketColor.Azure);
|
||||
int crimson = items.Count(i => i.trinketColor == TrinketColor.Crimson);
|
||||
int viridian = items.Count(i => i.trinketColor == TrinketColor.Viridian);
|
||||
int bright = items.Count(i => i.trinketColor == TrinketColor.Bright);
|
||||
int dark = items.Count(i => i.trinketColor == TrinketColor.Dark);
|
||||
|
||||
// --- TABLE LOGIC IMPLEMENTATION ---
|
||||
|
||||
// Balance: Azure + Crimson + Viridian (A C V) -> Bonus Water of Life Flask
|
||||
if (azure >= 1 && crimson >= 1 && viridian >= 1)
|
||||
stats.effectBalance = true;
|
||||
|
||||
// Calmness: 3 Azure (A A A) -> Longer Shield
|
||||
if (azure >= 3)
|
||||
stats.effectCalmness = true;
|
||||
|
||||
// Trust: 2 Azure + 1 Crimson (A A C) -> Faith Vampirism
|
||||
if (azure >= 2 && crimson >= 1)
|
||||
stats.effectFaithVampirism = true;
|
||||
|
||||
// Breeze: 2 Azure + 1 Viridian (A A V) -> Freezing blast free
|
||||
if (azure >= 2 && viridian >= 1)
|
||||
stats.effectBreeze = true;
|
||||
|
||||
// Determination: 3 Crimson (C C C) -> Combo finish +5% dmg
|
||||
if (crimson >= 3)
|
||||
stats.effectDetermination = true;
|
||||
|
||||
// Vitality: 2 Crimson + 1 Azure (C C A) -> Health Vampirism
|
||||
if (crimson >= 2 && azure >= 1)
|
||||
stats.effectHealthVampirism = true;
|
||||
|
||||
// Eagerness: 2 Crimson + 1 Viridian (C C V) -> Reduce Dash Cooldown
|
||||
if (crimson >= 2 && viridian >= 1)
|
||||
stats.effectEagerness = true;
|
||||
|
||||
// Bloom: 3 Viridian (V V V) -> Spell cost reduced 20%
|
||||
if (viridian >= 3)
|
||||
stats.effectBloom = true;
|
||||
|
||||
// Growth: 2 Viridian + 1 Azure (V V A) -> Cast restores HP
|
||||
if (viridian >= 2 && azure >= 1)
|
||||
stats.effectGrowth = true;
|
||||
|
||||
// Rose: 2 Viridian + 1 Crimson (V V C) -> Bonus Thorn Dmg
|
||||
if (viridian >= 2 && crimson >= 1)
|
||||
{
|
||||
stats.effectRose = true;
|
||||
stats.thornDamageMult += 0.05f;
|
||||
}
|
||||
|
||||
// The Darkening: 3 Bright
|
||||
if (bright >= 3)
|
||||
stats.effectDarkening = true;
|
||||
|
||||
// Eclipse: 2 Bright + 1 Dark
|
||||
if (bright >= 1 && dark >= 1)
|
||||
stats.effectEclipse = true;
|
||||
}
|
||||
|
||||
// Helper: Convert Integer Attribute (5) to Float Percentage (0.05)
|
||||
private float GetPct(bItem item, bItemAttributes attrName)
|
||||
{
|
||||
var attr = item.GetItemAttribute(attrName);
|
||||
if (attr != null)
|
||||
{
|
||||
return (float)attr.value / 100f;
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Powers/TrinketManager.cs.meta
Normal file
2
Assets/Scripts/Powers/TrinketManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: daafd720d70724ce49b9d0c5c420a6e7
|
||||
Reference in New Issue
Block a user