Multiple needs handling and zombie shit

This commit is contained in:
2024-04-06 18:30:26 +02:00
parent 12b856e6e1
commit bddedc2bf7
17 changed files with 1698 additions and 23 deletions

View File

@ -123,6 +123,8 @@ public class Developer : MonoBehaviour
[SerializeField, ShowOnly]
private float _talkTimer;
private List<GameObject> _needList = new List<GameObject>();
void Start()
{
_developerNeeds = gameObject.GetComponent<DeveloperNeeds>();
@ -179,6 +181,8 @@ public class Developer : MonoBehaviour
if (_caffeineNeed != null && _caffeineLevel > GameManager.Instance.NeedNotificationThreshold)
{
UpdateNeedPositions(_caffeineNeed);
_needList.Remove(_caffeineNeed);
NeedFullfilled(_caffeineNeed);
_caffeineNeed = null;
}
@ -209,6 +213,8 @@ public class Developer : MonoBehaviour
if (_hungerNeed != null && _hungerLevel > GameManager.Instance.NeedNotificationThreshold)
{
UpdateNeedPositions(_hungerNeed);
_needList.Remove(_hungerNeed);
NeedFullfilled(_hungerNeed);
_hungerNeed = null;
}
@ -239,6 +245,8 @@ public class Developer : MonoBehaviour
if (_toiletNeed != null && _urgeToUrinateLevel > GameManager.Instance.NeedNotificationThreshold)
{
UpdateNeedPositions(_toiletNeed);
_needList.Remove(_toiletNeed);
NeedFullfilled(_toiletNeed);
_toiletNeed = null;
}
@ -271,20 +279,23 @@ public class Developer : MonoBehaviour
if (Random.Range(0.0f, 1.0f) > 0.5f)
{
_caffeineNeed = _developerNeeds.SpawnMateNeed();
_caffeineNeed = _developerNeeds.SpawnMateNeed(_needList.Count);
_wantedDrink = WantedConsumable.Mate;
_needList.Add(_caffeineNeed);
}
else
{
_caffeineNeed = _developerNeeds.SpawnCoffeeNeed();
_caffeineNeed = _developerNeeds.SpawnCoffeeNeed(_needList.Count);
_wantedDrink = WantedConsumable.Coffee;
_needList.Add(_caffeineNeed);
}
}
if (_hungerLevel < GameManager.Instance.NeedNotificationThreshold && _hungerNeed == null)
{
_hungerNeed = _developerNeeds.SpawnHungerNeed();
_hungerNeed = _developerNeeds.SpawnHungerNeed(_needList.Count);
_wantedFood = WantedConsumable.Pizza;
_needList.Add(_hungerNeed);
}
if (_urgeToUrinateLevel < GameManager.Instance.NeedNotificationThreshold && _toiletNeed == null)
@ -293,7 +304,8 @@ public class Developer : MonoBehaviour
Debug.Log("Ich muss aufs Klo!");
_toiletNeed = _developerNeeds.SpawnToiletNeed();
_toiletNeed = _developerNeeds.SpawnToiletNeed(_needList.Count);
_needList.Add(_toiletNeed);
}
if (_hungerLevel <= 0.0)
@ -302,6 +314,23 @@ public class Developer : MonoBehaviour
}
}
private void UpdateNeedPositions(GameObject reference)
{
int referenceIndex = _needList.IndexOf(reference);
if (referenceIndex == -1)
{
Debug.LogError("Reference GameObject not in List.");
return;
}
for (int i = referenceIndex + 1; i < _needList.Count; i++)
{
GameObject currentItem = _needList[i];
currentItem.GetComponent<SpinningSpinner>().originalY -= 0.5f;
}
}
private void NeedFullfilled(GameObject needObject)
{
Instantiate(GameManager.Instance.NeedFullfilledParticleEffect, needObject.transform.position, needObject.transform.rotation);

View File

@ -24,14 +24,14 @@ public class DeveloperNeeds : MonoBehaviour
// TODO: Enums statt strings verwenden
// TODO: Multiple Needs möglich übereinander anzeigen?
public GameObject SpawnCoffeeNeed() => spawnNeed("coffee");
public GameObject SpawnMateNeed() => spawnNeed("mate");
public GameObject SpawnToiletNeed() => spawnNeed("toilet");
public GameObject SpawnHungerNeed() => spawnNeed("hunger");
public GameObject SpawnMoneyNeed() => spawnNeed("money");
public GameObject spawnNeed(string needName)
public GameObject SpawnCoffeeNeed(int numNeeds) => spawnNeed("coffee", numNeeds);
public GameObject SpawnMateNeed(int numNeeds) => spawnNeed("mate", numNeeds);
public GameObject SpawnToiletNeed(int numNeeds) => spawnNeed("toilet", numNeeds);
public GameObject SpawnHungerNeed(int numNeeds) => spawnNeed("hunger", numNeeds);
public GameObject SpawnMoneyNeed(int numNeeds) => spawnNeed("money", numNeeds);
public GameObject spawnNeed(string needName, float numNeeds)
{
GameObject spawnedNeed = null;
@ -40,20 +40,20 @@ public class DeveloperNeeds : MonoBehaviour
switch (needName)
{
case "coffee":
spawnedNeed = Instantiate(Needs[0], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
context = "The NPC wants coffee";
spawnedNeed = Instantiate(Needs[0], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), Needs[0].transform.rotation);
context = "The Developer wants coffee";
break;
case "mate":
spawnedNeed = Instantiate(Needs[1], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
context = "The NPC wants a Blub Mate (Yes, its a drink called Blub Mate)";
spawnedNeed = Instantiate(Needs[1], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), Needs[0].transform.rotation);
context = "The Developer wants a Blub Mate (Yes, its a drink called Blub Mate)";
break;
case "toilet":
spawnedNeed = Instantiate(Needs[2], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
context = "The NPC wants to go to the toilet, toilet is clogged and dirty";
spawnedNeed = Instantiate(Needs[2], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), Needs[0].transform.rotation);
context = "The Developer wants to go to the toilet, toilet is clogged and dirty";
break;
case "money":
spawnedNeed = Instantiate(Needs[3], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
context = "The NPC wants a raise, The NPC needs more money";
case "hunger":
spawnedNeed = Instantiate(Needs[3], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), Needs[0].transform.rotation);
context = "The Developer wants a pizza";
break;
default:
Debug.LogError($"Unbekannter need \"{needName}\"");

View File

@ -126,7 +126,7 @@ public class NPC_Behavior : MonoBehaviour
need = needName;
}
_currentNeed = _developerNeeds.spawnNeed(need);
_currentNeed = _developerNeeds.spawnNeed(need, 0);
HasNeed = true;
_lastTenNeeds.Add(need);
if (_lastTenNeeds.Count > 10)

View File

@ -8,7 +8,7 @@ public class SpinningSpinner : MonoBehaviour
public float hoverSpeed = 1.5f;
public float hoverHeight = 0.1f;
private float originalY;
public float originalY;
void Start()

View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Zombie : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

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

View File

@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Utility;
public class ZombieSpawner : MonoBehaviour
{
[SerializeField]
GameObject ZombiePrefab;
[SerializeField]
private float _spawnRate = 1.0f;
[SerializeField, ShowOnly]
private float _spawnTimer;
// Start wird aufgerufen, bevor das erste Frame gezeichnet wird
void Start()
{
_spawnTimer = 60 / _spawnRate;
}
// Update wird einmal pro Frame aufgerufen
void Update()
{
_spawnTimer -= Time.deltaTime;
if (_spawnTimer <= 0)
{
Instantiate(ZombiePrefab, transform.position, Quaternion.identity);
_spawnTimer = 60 / _spawnRate;
}
}
}

View File

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