Komplett Lauffähig + Vibration + Boni + Enemie "Jumpscares" - Audio
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Timers;
|
||||
using UnityEngine;
|
||||
|
||||
public class FieScript : MonoBehaviour
|
||||
@@ -12,15 +13,15 @@ public class FieScript : MonoBehaviour
|
||||
[SerializeField] GameObject SPRight;
|
||||
[SerializeField] GameObject SPDeath;
|
||||
|
||||
bool spawn1 = false;
|
||||
bool spawn2 = false;
|
||||
public bool spawnLeft = false;
|
||||
public bool spawn2 = false;
|
||||
|
||||
[Header("Character")]
|
||||
|
||||
[SerializeField] GameObject Fiefetti;
|
||||
//[SerializeField] int damageDealt = 1; //hat aktuell keinen Zweck
|
||||
|
||||
[SerializeField] public float stateTime = 10f;
|
||||
[SerializeField] public float stateTime = 5f;
|
||||
public bool fieKill;
|
||||
|
||||
[Header("Scripts")]
|
||||
@@ -28,23 +29,35 @@ public class FieScript : MonoBehaviour
|
||||
[SerializeField] GameObject scriptPile;
|
||||
[SerializeField] GameObject door1; //1 is always Left
|
||||
[SerializeField] GameObject door2;
|
||||
[SerializeField] GameObject levelScript;
|
||||
|
||||
[SerializeField] GameObject eSilv;
|
||||
[SerializeField] GameObject eHai;
|
||||
|
||||
LevelBehavior level;
|
||||
ChangeHealth healthScript;
|
||||
Door doorSwitch;
|
||||
Door doorSwitch2;
|
||||
|
||||
SilvScript silv;
|
||||
HaiScript hai;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
healthScript = scriptPile.GetComponent<ChangeHealth>();
|
||||
doorSwitch = door1.GetComponent<Door>();
|
||||
doorSwitch2 = door2.GetComponent<Door>();
|
||||
level = levelScript.GetComponent<LevelBehavior>();
|
||||
|
||||
silv = eSilv.GetComponent<SilvScript>();
|
||||
hai = eHai.GetComponent<HaiScript>();
|
||||
}
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
button.SetActive(false); //zum vorherigen Debuggen genutzt
|
||||
spawn1 = false;
|
||||
spawn2 = false;
|
||||
spawnLeft = false;
|
||||
|
||||
|
||||
//StateOne();
|
||||
@@ -69,7 +82,7 @@ public class FieScript : MonoBehaviour
|
||||
|
||||
IEnumerator WanderAround()
|
||||
{
|
||||
|
||||
float elapsed = 0f;
|
||||
Debug.Log("Fiefetti: Wandering around");
|
||||
|
||||
button.SetActive(false);
|
||||
@@ -82,14 +95,18 @@ public class FieScript : MonoBehaviour
|
||||
int random = Random.Range(1, 3);
|
||||
if (random == 1) //1 bedeutet immer left
|
||||
{
|
||||
spawn1 = true;
|
||||
spawnLeft = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
spawn2 = true;
|
||||
spawnLeft = false;
|
||||
}
|
||||
Debug.Log("random = " + random);
|
||||
Debug.Log("random = " + random);
|
||||
|
||||
while (elapsed < stateTime)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
}
|
||||
yield return new WaitForSeconds(stateTime);
|
||||
|
||||
StartCoroutine(WanderClose());
|
||||
@@ -97,20 +114,28 @@ public class FieScript : MonoBehaviour
|
||||
|
||||
IEnumerator WanderClose()
|
||||
{
|
||||
if (spawn1 == true) //1 bedeutet immer left
|
||||
float elapsed2 = 0;
|
||||
|
||||
if (spawnLeft == true) //1 bedeutet immer left
|
||||
{
|
||||
Fiefetti.transform.position = SPLeft.transform.position;
|
||||
Debug.Log("Ich stehe links.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Fiefetti.transform.position = SPRight.transform.position;
|
||||
Debug.Log("Ich stehe rechts.");
|
||||
}
|
||||
|
||||
StartCoroutine(WanderAround());
|
||||
|
||||
//einen von zwei Punkten aussuchen
|
||||
Debug.Log("Fiefetti: Komme näher");
|
||||
|
||||
while (elapsed2 < stateTime)
|
||||
{
|
||||
elapsed2 += Time.deltaTime;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(stateTime);
|
||||
|
||||
StartCoroutine(GetTooClose());
|
||||
@@ -118,39 +143,67 @@ public class FieScript : MonoBehaviour
|
||||
|
||||
IEnumerator GetTooClose()
|
||||
{
|
||||
float elapsed3 = 0;
|
||||
|
||||
if (doorSwitch.isOpen == true)
|
||||
float stickAround = 0f;
|
||||
|
||||
if (spawnLeft && doorSwitch.isOpen == true)
|
||||
{
|
||||
Fiefetti.transform.position = SPDeath.transform.position;
|
||||
Debug.Log("Fiefetti: Hab dich!");
|
||||
//reingehen
|
||||
HitPlayer();
|
||||
//StateOne();
|
||||
|
||||
silv.silvKill = false;
|
||||
hai.haiKill = false;
|
||||
fieKill = true;
|
||||
stickAround += Time.deltaTime;
|
||||
if (stickAround >= 2f)
|
||||
{
|
||||
Fiefetti.transform.position = SPBack.transform.position;
|
||||
stickAround = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
else if (doorSwitch2.isOpen == true)
|
||||
else if (!spawnLeft && doorSwitch2.isOpen == true)
|
||||
{
|
||||
Fiefetti.transform.position = SPDeath.transform.position;
|
||||
Debug.Log("Fiefetti: Hab dich!");
|
||||
//reingehen
|
||||
HitPlayer();
|
||||
//StateOne();
|
||||
|
||||
silv.silvKill = false;
|
||||
hai.haiKill = false;
|
||||
fieKill = true;
|
||||
stickAround += Time.deltaTime;
|
||||
if (stickAround >= 2f)
|
||||
{
|
||||
Fiefetti.transform.position = SPBack.transform.position;
|
||||
stickAround = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//AudioSpielen
|
||||
fieKill = false;
|
||||
|
||||
level.earnedGems += level.earnGems;
|
||||
Debug.Log("Du hast bereits " + level.earnedGems + " Gems verdient.");
|
||||
Debug.Log("Fiefetti: Och menno");
|
||||
Fiefetti.transform.position = SPBack.transform.position;
|
||||
|
||||
}
|
||||
|
||||
spawn1 = false;
|
||||
spawn2 = false;
|
||||
spawnLeft = false;
|
||||
//StateOne();
|
||||
|
||||
while (elapsed3 < stateTime)
|
||||
{
|
||||
elapsed3 += Time.deltaTime;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(stateTime);
|
||||
|
||||
StartCoroutine(WanderAround());
|
||||
|
||||
Reference in New Issue
Block a user