// Über OnTriggerEnter checken wir, ob sich ein getagtes Item für Hand oder Laterne in Reichweite befindet. // In dem Fall wird dieses Item als ActiveItem gespeichert. // Auf dieses aktive Item greifen wir zu wenn wir dann eine Taste drücken. // In OnTriggerExit wird das ActiveItem wieder null gesetzt und es gibt nichts mehr zum Aufnehmen. void OnTriggerStay(Collider other) { if (other.tag == "ItemHand") { ActiveItemHand = other.gameObject; Jellyfish = other.GetComponent <Scr_Jellyfish>(); } else if (other.tag == "ItemLantern") { ActiveItemLantern = other.gameObject; Firefly = other.GetComponent <Scr_Firefly>(); } else if (other.tag == "TriggerJellyfish") { inTriggerJelly = true; Goal = other.transform; triggerLight = other.GetComponentInChildren <Scr_TriggerLight>(); ContainItem = other.GetComponent <Scr_ContainItem> (); } else if (other.tag == "TriggerFirefly") { inTriggerFirefly = true; Goal = other.transform; triggerLight = other.GetComponentInChildren <Scr_TriggerLight>(); ContainItem = other.GetComponent <Scr_ContainItem> (); } else if (other.tag == "TriggerDoubleFirefly") { inDoubleTrigger = true; Goal = other.transform; triggerLight = other.GetComponentInParent <Scr_TriggerLight>(); doubleLight = other.GetComponentInParent <Scr_DoubleLightSource>(); ContainItem = other.GetComponent <Scr_ContainItem> (); } else if (other.tag == "Sun" && endMusicOn == false) { endTime = Time.time; GetComponent <Scr_PlayerInput>().TurnOff(); Sun.GetComponent <Scr_Sunrise>().enabled = true; //camPlayer.tag = "Untagged"; //camSun.tag = "MainCamera"; camPlayer.enabled = false; camSun.enabled = true; lanternImage.enabled = false; changeEnd.TransitionTo(1f); Scr_Soundmanager.Sound.Play(endTrack, gameObject, 0.8f, 0.8f, 1f, 1f, 1000f, 0f); endMusicOn = true; } }
void HandToLight(GameObject item) { if (item.GetComponent <Scr_Jellyfish> () != null && ContainItem.containItemCount < 1 && counterJelly > 0) { Jellyfish = item.GetComponent <Scr_Jellyfish> (); item.tag = "ItemHand"; Jellyfish.Hand = null; Jellyfish.Goal = Goal; item.transform.position = Goal.position; //Jellyfish.JellyToGoal (); triggerLight.SwitchLightOn(); //GoalRemove = true; Jellyfish.inGoal = true; ContainItem.containItemCount += 1; counterJelly--; Scr_Soundmanager.Sound.Play(DropJelly[Random.Range(0, DropJelly.Length)], gameObject, 0.3f, 0.5f, 0.8f, 1.2f); } }
void HandToWorld(GameObject item) { if (counterJelly > 0) { Jellyfish = item.GetComponent <Scr_Jellyfish> (); item.tag = "ItemHand"; Jellyfish.Hand = null; Rigidbody[] rigidBodies = item.GetComponentsInParent <Rigidbody> (); foreach (Rigidbody rig in rigidBodies) { rig.velocity = Vector3.zero; //Jellyfish hat keine geschwindigkeit mehr (im falle von ablegen bei bewegung) rig.angularVelocity = Vector3.zero; } item.GetComponent <Rigidbody> ().velocity = Vector3.zero; //für letztes child item.GetComponent <Rigidbody> ().angularVelocity = Vector3.zero; counterJelly--; Scr_Soundmanager.Sound.Play(DropJelly[Random.Range(0, DropJelly.Length)], gameObject, 0.3f, 0.5f, 0.8f, 1.2f); } }