Enemy Logik erstellt Weitere Kommentare: Ich werde herausfinden, wer Coroutinen erfunden hat und diese Person auf dieselbe Art knechten, wie ich es in den letzten 5 Stunden wurde. WaitForSeconds(5) aber alles 4000 Mal in 3 Sekunden durchlaufen, mein Arsch.

This commit is contained in:
2026-02-17 00:23:17 +01:00
parent 0b781ccb0f
commit 8b0452b1ed
32 changed files with 4665 additions and 2685 deletions

View File

@@ -19,7 +19,7 @@ public class DevScript : MonoBehaviour
//private KeyCode secretCode = KeyCode.G;
Vector3 ort = new Vector3();
//Vector3 ort = new Vector3();
private void Update()
{

View File

@@ -26,17 +26,20 @@ public class GameOver : MonoBehaviour
[Header("ScriptPile")]
[SerializeField] GameObject scriptPile;
[SerializeField] GameObject eFie;
InventoryScript inventory;
ChangeHealth healthScript;
HandleEnergy battery;
FieScript fie;
private void Awake()
{
inventory = scriptPile.GetComponent<InventoryScript>();
healthScript = scriptPile.GetComponent<ChangeHealth>();
battery = scriptPile.GetComponent<HandleEnergy>();
fie = eFie.GetComponent<FieScript>();
}
void Start()
@@ -62,10 +65,12 @@ public class GameOver : MonoBehaviour
public void ShowDeathScreen()
{
fie.StopAllCoroutines();
//Time.timeScale = 0;
timerOn = true;
timer = 10f;
deathPanel.SetActive(true);
LeanTween.scale(deathPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
SpeakEnemy();
costText.text = cost.ToString(); //ZUM DEBUGGEN
CheckDeathTime();
@@ -107,11 +112,13 @@ public class GameOver : MonoBehaviour
inventory.Energy += battery.addEnergyValue;
}
LeanTween.scale(deathPanel, transform.localScale * 0f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
deathPanel.SetActive(false);
//Time.timeScale = 1;
//Logik: bei Retry, soll der Player nochmal neue Energie bekommen
fie.StartStuff();
}
public void CheckDeathTime()
@@ -136,17 +143,25 @@ public class GameOver : MonoBehaviour
public void CalculateCost()
{
cost = healthScript.deathCounter * 100;
if (cost == 300)
{
infoText.text = "You must really like being here.";
}
if (cost >= 1000)
{
cost = 900;
infoText.text = "But you refused.";
}
}
public bool fieKill;
public bool silvKill;
public bool haiKill;
public void SpeakEnemy()
{
if (fieKill)
if (fie.fieKill)
{
infoText.text = "HAAHAHAHAHAAHAHAHAHAHAHAHAHA";
}

View File

@@ -21,9 +21,9 @@ public class ShopScript : MonoBehaviour
[Header("Scripte")]
InventoryScript inventory;
ChangeHealth healthScript;
HandleEnergy battery;
[SerializeField] InventoryScript inventory;
[SerializeField] ChangeHealth healthScript;
[SerializeField] HandleEnergy battery;
[Header("BuyValues")]

View File

@@ -0,0 +1,9 @@
using UnityEngine;
public class Tester : MonoBehaviour
{
void Start()
{
Vibrator.Vibrate();
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8a33b90cbb5eaa341a2a0a790cc41e77

View File

@@ -10,7 +10,7 @@ public class TweenScript : MonoBehaviour
//private KeyCode secretCode = KeyCode.G;
Vector3 ort = new Vector3();
//Vector3 ort = new Vector3();
public void Start()
{

View File

@@ -0,0 +1,48 @@
using UnityEditor;
using UnityEngine;
public static class Vibrator
{
#if UNITY_ANDROID && !UNITY_EDITOR
public static AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
public static AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
public static AndroidJavaObject vibrator = currentActivity.Call<AndroidJavaObject>("getSystemService", "vibrator");
#else
public static AndroidJavaClass unityPlayer;
public static AndroidJavaObject currentActivity;
public static AndroidJavaObject vibrator;
#endif
public static void Vibrate(long milliseconds = 250)
{
if (IsAndroid())
{
vibrator.Call("vibrate", milliseconds);
}
else
{
{
Handheld.Vibrate();
}
}
}
public static void Cancel()
{
if (IsAndroid())
{
vibrator.Call("cancel");
}
}
public static bool IsAndroid()
{
#if UNITY_ANDROID
return true;
#else
return false;
#endif
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4b80c76f630d82047a40f8febee4add3

View File

@@ -18,7 +18,7 @@ public class CameraSystem : MonoBehaviour
for (int i = 0; i < cams.Length; i++) {
cams[i].SetActive(false);
}
mainCam.SetActive(true);
mainCam.SetActive(true); //enabled
}
// Update is called once per frame

View File

@@ -4,7 +4,20 @@ public class DoorController : MonoBehaviour
{
[SerializeField] private Door door;
private void OnMouseDown() {
door.isOpen = !door.isOpen;
private void OnMouseDown()
{
if (door.isOpen == true)
{
door.isOpen = false;
Debug.Log("Hier kommt niemand rein");
}
else
{
door.isOpen = true;
Debug.Log("Es zieht uUunheimlich");
}
//door.isOpen = !door.isOpen;
}
}

View File

@@ -0,0 +1,237 @@
using System.Collections;
using UnityEngine;
public class FieScript : MonoBehaviour
{
[SerializeField] GameObject button;
[Header("Spawn Points")]
[SerializeField] GameObject SPBack;
[SerializeField] GameObject SPLeft;
[SerializeField] GameObject SPRight;
[SerializeField] GameObject SPDeath;
bool spawn1 = false;
bool spawn2 = false;
[Header("Character")]
[SerializeField] GameObject Fiefetti;
//[SerializeField] int damageDealt = 1; //hat aktuell keinen Zweck
[SerializeField] public float stateTime = 10f;
public bool fieKill;
[Header("Scripts")]
[SerializeField] GameObject scriptPile;
[SerializeField] GameObject door1; //1 is always Left
[SerializeField] GameObject door2;
ChangeHealth healthScript;
Door doorSwitch;
Door doorSwitch2;
private void Awake()
{
healthScript = scriptPile.GetComponent<ChangeHealth>();
doorSwitch = door1.GetComponent<Door>();
doorSwitch2 = door2.GetComponent<Door>();
}
void Start()
{
button.SetActive(false); //zum vorherigen Debuggen genutzt
spawn1 = false;
spawn2 = false;
//StateOne();
StartStuff();
}
void Update()
{
}
public void HitPlayer()
{
healthScript.GetHit();
}
public void StartStuff()
{
Debug.Log("I´m starting stuff.");
StartCoroutine(WanderAround());
}
IEnumerator WanderAround()
{
Debug.Log("Fiefetti: Wandering around");
button.SetActive(false);
Fiefetti.transform.position = SPBack.transform.position;
//Hauptposition
Debug.Log("Fiefetti: Bin hinten");
int random = Random.Range(1, 3);
if (random == 1) //1 bedeutet immer left
{
spawn1 = true;
}
else
{
spawn2 = true;
}
Debug.Log("random = " + random);
yield return new WaitForSeconds(stateTime);
StartCoroutine(WanderClose());
}
IEnumerator WanderClose()
{
if (spawn1 == true) //1 bedeutet immer left
{
Fiefetti.transform.position = SPLeft.transform.position;
}
else
{
Fiefetti.transform.position = SPRight.transform.position;
}
StartCoroutine(WanderAround());
//einen von zwei Punkten aussuchen
Debug.Log("Fiefetti: Komme näher");
yield return new WaitForSeconds(stateTime);
StartCoroutine(GetTooClose());
}
IEnumerator GetTooClose()
{
if (doorSwitch.isOpen == true)
{
Fiefetti.transform.position = SPDeath.transform.position;
Debug.Log("Fiefetti: Hab dich!");
//reingehen
HitPlayer();
//StateOne();
fieKill = true;
}
else if (doorSwitch2.isOpen == true)
{
Fiefetti.transform.position = SPDeath.transform.position;
Debug.Log("Fiefetti: Hab dich!");
//reingehen
HitPlayer();
//StateOne();
fieKill = true;
}
else
{
//AudioSpielen
fieKill = false;
Debug.Log("Fiefetti: Och menno");
}
spawn1 = false;
spawn2 = false;
//StateOne();
yield return new WaitForSeconds(stateTime);
StartCoroutine(WanderAround());
}
/*
public void StateOne()
{
button.SetActive(false);
Fiefetti.transform.position = SPBack.transform.position;
//Hauptposition
Debug.Log("Fiefetti: Bin hinten");
int random = Random.Range(1, 3);
if (random == 1) //1 bedeutet immer left
{
spawn1 = true;
}
else
{
spawn2 = true;
}
Debug.Log("random = " + random);
//StartCoroutine(WanderClose());
}*/
/*
public void StateTwo()
{
if (spawn1 == true) //1 bedeutet immer left
{
Fiefetti.transform.position = SPLeft.transform.position;
}
else
{
Fiefetti.transform.position = SPRight.transform.position;
}
StartCoroutine(WanderAround());
//einen von zwei Punkten aussuchen
Debug.Log("Fiefetti: Komme näher");
//StateThree();
}*/
/*
public void StateThree()
{
if (doorSwitch.isOpen == true)
{
Fiefetti.transform.position = SPDeath.transform.position;
Debug.Log("Fiefetti: Hab dich!");
//reingehen
HitPlayer();
//StateOne();
fieKill = true;
}
else if (doorSwitch2.isOpen == true)
{
Fiefetti.transform.position = SPDeath.transform.position;
Debug.Log("Fiefetti: Hab dich!");
//reingehen
HitPlayer();
//StateOne();
fieKill = true;
}
else
{
//AudioSpielen
fieKill = false;
Debug.Log("Fiefetti: Och menno");
}
StartCoroutine(WanderAround());
spawn1 = false;
spawn2 = false;
//StateOne();
}*/
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ab49087e743bd3340abb63a63b18df51

View File

@@ -0,0 +1,58 @@
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelBehavior : MonoBehaviour
{
[SerializeField] GameObject eFie;
[SerializeField] GameObject eSilv;
[SerializeField] GameObject eHai;
FieScript fie;
private void Awake()
{
fie = eFie.GetComponent<FieScript>();
}
void Start()
{
// Create a temporary reference to the current scene.
Scene currentScene = SceneManager.GetActiveScene();
// Retrieve the name of this scene.
string sceneName = currentScene.name;
if (sceneName == "Day2")
{
fie.stateTime = 5;
// Do something...
}
else if (sceneName == "Day6")
{
fie.stateTime = 3;
// Do something...
}
// Retrieve the index of the scene in the project's build settings.
int buildIndex = currentScene.buildIndex;
//// Check the scene name as a conditional.
//switch (buildIndex)
//{
// case 0:
// // Do something...
// break;
// case 1:
// // Do something...
// break;
//}
}
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 789c5e421b7b01c4daeb8d1c0c13a358

View File

@@ -53,6 +53,20 @@ public class ChangeHealth : MonoBehaviour
}
}
public void GetHitHard() //MUSS NOCH MIT ENEMIES VERKNÜPFT WERDEN
{
if (inventory.Health > 0)
{
inventory.Health -= 2; //MAGIC NUMBER BITTE BEACHTEN
}
Debug.Log("Ouch, you bastardo.");
if (inventory.Health <= 0)
{
Die();
}
}
public void Die()
{
@@ -62,7 +76,6 @@ public class ChangeHealth : MonoBehaviour
//Time.timeScale = 0; //Wieder umlegen
end.ShowDeathScreen();
Debug.Log("rest in pizza");
}