loot table added - AI improved a bit

This commit is contained in:
2022-05-02 14:28:44 +03:00
parent a748b342a8
commit 6571056d18
78 changed files with 4065 additions and 1895 deletions

View File

@@ -19,6 +19,8 @@ public class SlimeAI : MonoBehaviour
private bool isRotatingRight = false;
private bool isWalking = false;
public UnityEvent onDeathComplete;
//[SerializeField]
//private UnityEvent onAttack;
@@ -27,7 +29,7 @@ public class SlimeAI : MonoBehaviour
{
animator = GetComponent<Animator>();
player = GameObject.FindWithTag("Player");
HP = 10;
HP = 2;
}
@@ -73,9 +75,6 @@ public class SlimeAI : MonoBehaviour
//Idle
StartCoroutine("Wander");
}
Debug.Log(isWandering);
Debug.Log(isRotatingLeft);
Debug.Log(isRotatingRight);
if (isRotatingRight == true)
{
animator.SetBool("Wandering", false);
@@ -94,13 +93,17 @@ public class SlimeAI : MonoBehaviour
if (HP <= 0)
{
animator.SetBool("Dead", true);
}
if (animator.GetBool("DeathComplete"))
if (animator.GetBool("Dead"))
{
print("asd");
Destroy(this.gameObject);
onDeathComplete.Invoke();
}
}
void Rotate()

View 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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a29d148fe20acce4c9eb0eae410c0fd1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}

View File

@@ -18,7 +18,7 @@ public class PlayerInfo : MonoBehaviour
{
Instance = this;
health = 5;
essence_basic = 0;
essence_basic = 1000;
rightHandHeld = null;
leftHandHeld = null;
}