loot table added - AI improved a bit
This commit is contained in:
34
Assets/Project Files/Scripts/JonasB/LootTable.cs
Normal file
34
Assets/Project Files/Scripts/JonasB/LootTable.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Project Files/Scripts/JonasB/LootTable.cs.meta
Normal file
11
Assets/Project Files/Scripts/JonasB/LootTable.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a29d148fe20acce4c9eb0eae410c0fd1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -31,6 +31,10 @@ public class Projectile : MonoBehaviour
|
||||
if (collision.gameObject.tag != "IceBolt" && collision.gameObject.tag != "Player" && !collided)
|
||||
{
|
||||
collided = true;
|
||||
if (collision.gameObject.tag == "Slime")
|
||||
{
|
||||
collision.gameObject.GetComponent<SlimeAI>().GetHit((int)damage);
|
||||
}
|
||||
if (collision.gameObject.name == "Dummy") Destroy(collision.gameObject); //REPLACE WITH ENEMY TAG CHECK AND DAMAGE CHECKING
|
||||
Destroy(gameObject);
|
||||
}
|
||||
@@ -44,10 +48,11 @@ public class Projectile : MonoBehaviour
|
||||
collided = true;
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else if (other.gameObject.name == "Dummy")
|
||||
if (other.gameObject.name == "Dummy")
|
||||
{
|
||||
Destroy(other.gameObject);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user