Pedro Gomes fdd55142f9 Small class tunning & Rework item drops
- Slight increase to priest, necro and mage scaling
- Updated overall item drops on all enemies:
   - bosses are guaranteed to drop one item
   - drops are weighted and with min/max difficulty restrictions
2025-01-01 20:39:41 +00:00

106 lines
4.0 KiB
C#

using Kryz.CharacterStats.Examples;
using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DropTable : MonoBehaviour
{
[SerializeField] private GameObject interactableDropPrefab;
[SerializeField] private GameObject coinPrefab;
[SerializeField] private int coinAmount;
[SerializeField] private int extraDropChance;
[SerializeField] private GameEvent_Int onCoinDrop;
public List<EquippableItem> guaranteedItemDrop = new List<EquippableItem>();
public List<EquippableItem> extraDrops = new List<EquippableItem>();
public List<Item> nonEquippablesDrops = new List<Item>();
[Space]
[SerializeField] private List<WeightedDrop> weightedDropLootTable = new List<WeightedDrop>();
PhotonView photonView;
GameObject instantiatedDrop;
GameObject instantiatedEquippableDrop;
EquippableItemDrop equippableItemDrop;
EquippableItemDrop itemDrop;
Item possibleItem;
GameObject instantiatedCoinDrop;
CoinDrop coinDrop;
int finalCoinAmount;
Vector3 spawnPosition;
private void Awake()
{
photonView = GetComponentInParent<PhotonView>();
}
// Start is called before the first frame update
void Start()
{
}
public bool CalculateLootDrop()
{
return Random.Range(0, 100) < (extraDropChance * (1 + GameConstants.GameBalancing.IncreasedItemDropBasedOnDifficultyMultiplier * GameDifficultyController.Instance.GetCurrentDifficultyLevel()));
}
public void DropLoot(bool lootDrop)
{
spawnPosition = this.transform.position;
spawnPosition.y = 0f;
instantiatedCoinDrop = Instantiate(coinPrefab, spawnPosition, this.transform.rotation);
coinDrop = instantiatedCoinDrop.GetComponent<CoinDrop>();
finalCoinAmount = Mathf.RoundToInt(coinAmount * (1 + GameConstants.GameBalancing.IncreasedCoinDropBasedOnDifficultyMultiplier * GameDifficultyController.Instance.GetCurrentDifficultyLevel()));
coinDrop.Init(finalCoinAmount);
onCoinDrop.Raise(finalCoinAmount);
for (int i = 0; i < guaranteedItemDrop.Count; i++)
{
instantiatedDrop = Instantiate(interactableDropPrefab, spawnPosition, this.transform.rotation);
itemDrop = instantiatedDrop.GetComponent<EquippableItemDrop>();
itemDrop.itemDrop = guaranteedItemDrop[i];
}
if (!lootDrop) return;
/*
if (extraDrops.Count <= 0) return;
spawnPosition = this.transform.position;
spawnPosition.y = 0f;
instantiatedEquippableDrop = Instantiate(interactableDropPrefab, spawnPosition, this.transform.rotation);
equippableItemDrop = instantiatedDrop.GetComponent<EquippableItemDrop>();
equippableItemDrop.itemDrop = extraDrops[Random.Range(0, extraDrops.Count)];
if (nonEquippablesDrops.Count <= 0) return;
spawnPosition = this.transform.position + Vector3.one * 0.3f;
spawnPosition.y = 0f;
instantiatedDrop = Instantiate(interactableDropPrefab, spawnPosition, this.transform.rotation);
itemDrop = instantiatedDrop.GetComponent<EquippableItemDrop>();
itemDrop.itemDrop = nonEquippablesDrops[Random.Range(0, nonEquippablesDrops.Count)];*/
if (weightedDropLootTable.Count <= 0) return;
if (!WeightedDrop.HaveDropsForDifficulty(weightedDropLootTable, GameDifficultyController.Instance.GetCurrentDifficultyLevel())) return;
possibleItem = WeightedDrop.GetRandomDrop(weightedDropLootTable, GameDifficultyController.Instance.GetCurrentDifficultyLevel());
if (possibleItem == null) return;
spawnPosition = guaranteedItemDrop.Count > 0 ? this.transform.position + Vector3.one * 0.3f : this.transform.position;
spawnPosition.y = 0f;
instantiatedDrop = Instantiate(interactableDropPrefab, spawnPosition, this.transform.rotation);
itemDrop = instantiatedDrop.GetComponent<EquippableItemDrop>();
itemDrop.itemDrop = possibleItem;
}
}