Heroes_of_Hiis/Assets/Project Files/Scripts/JonasB/LootTable.cs

35 lines
1.2 KiB
C#
Raw Permalink Normal View History

2022-05-02 11:28:44 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LootTable : MonoBehaviour
{
public List<GameObject> specialLootItems;
public List<GameObject> defaultLootItems;
public void SpawnLoot() {
float r = Random.value;
Debug.LogWarning(r);
Vector3 spawnLocation = this.transform.position;
spawnLocation.y += 3;
if ( r > 0.50) //%50 percent chance -> special loot chance + default loot
{
int specialloot = Random.Range(0, specialLootItems.Count);
int defaultloot = Random.Range(0, defaultLootItems.Count);
Debug.LogWarning("special loot spawned");
Instantiate(specialLootItems[specialloot], spawnLocation, Quaternion.identity);
Instantiate(defaultLootItems[defaultloot], spawnLocation, Quaternion.identity);
}
if (r > 0.2) //%80 percent chance -> default loot chance loot chance
{
Debug.LogWarning("default loot spawned");
int defaultloot = Random.Range(0, defaultLootItems.Count);
Instantiate(defaultLootItems[defaultloot], this.transform);
}
}
}