//Coroutine che elimina l'oggetto raccolto e, dopo 2 secondi, disabilita le scritte a schermo IEnumerator DisableAfterSomeSeconds(GameObject g) { Destroy(g); yield return(new WaitForSeconds(2f)); hud.centralBoxEnabler(false); hud.sideBoxEnabler(false); }
// Use this for initialization void Start() { hud = GameObject.FindGameObjectWithTag("HUD").GetComponent <HUDSystem>(); player = GameObject.FindGameObjectWithTag("Player"); hud.centralBoxEnabler(false); hud.sideBoxEnabler(false); animator = player.GetComponent <Animator>(); inventario = player.GetComponent <InventorySystem>(); //AxeSpawn=GameObject.FindGameObjectWithTag("AxeEnemySpawn"); //PistolSpawn=GameObject.FindGameObjectWithTag("PistolEnemySpawn"); //ChainSpawn = GameObject.FindGameObjectWithTag("ChainEnemySpawn"); //CutterSpawn = GameObject.FindGameObjectWithTag("CutterEnemySpawn"); //SmgSpawn = GameObject.FindGameObjectWithTag("SmgEnemySpawn"); munizioni_ammobox = start_ammo;//Setto le munizioni contenute nell'ammo box misc = player.GetComponent <Misc>(); }
public void OnTriggerExit(Collider other) { if (other.gameObject.CompareTag("Player")) { hud.sideBoxEnabler(true); hud.sideBoxText("Checkpoint raggiunto!"); Save_(); //Valido solo per il primo livello if (SceneManager.GetActiveScene().name.Equals("Scena 1 - Il massiccio")) { if (!AxeSpawnActive) { AxeSpawn.SetActive(false); } if (!PistolSpawnActive) { PistolSpawn.SetActive(false); } if (!ChainSpawnActive) { ChainSpawn.SetActive(false); } if (!CutterSpawnActive) { CutterSpawn.SetActive(false); } if (!SmgSpawnActive) { SmgSpawn.SetActive(false); } } } }
public void OnTriggerStay(Collider other) { if (Input.GetButtonDown("Open Door") && other.gameObject.CompareTag("Player")) { if (gameObject.name.Equals("la Torcia") && onetime) { onetime = false; //onetime serve a non entrare nell'if piĆ¹ volte EquipTorch(); hud.centralBoxEnabler(false); //disattivo la scritta centrale nell'hud inventario.setTorcia(true); player.GetComponent <SwitchWeapon>().getTorch = true; Destroy(GameObject.Find("MuroInvisibile1")); hud.sideBoxEnabler(true); //attivo la scritta laterale nell'hud hud.sideBoxText("Hai raccolto la torcia"); //Disattivo i nemici da spawnare AxeSpawn.SetActive(false); PistolSpawn.SetActive(false); ChainSpawn.SetActive(false); CutterSpawn.SetActive(false); SmgSpawn.SetActive(false); misc.supportFunction(gameObject); } if (gameObject.name.Equals("l'ascia") && onetime) { if (animator.GetBool("Torch")) { animator.SetBool("Torch", false); } if (animator.GetBool("Pistol")) { animator.SetBool("Pistol", false); } if (animator.GetBool("Smg")) { animator.SetBool("Smg", false); } animator.SetBool("Axe", true); onetime = false; hud.centralBoxEnabler(false); inventario.setAscia(true); player.GetComponent <SwitchWeapon>().getAxe = true; hud.sideBoxEnabler(true); hud.sideBoxText("Hai raccolto l'ascia (Tasto 1)"); AxeSpawn.SetActive(true); misc.supportFunction(gameObject); } if (gameObject.name.Equals("P226") && onetime) { //Equipaggio l'arma appena raccolta if (animator.GetBool("Axe")) { animator.SetBool("Axe", false); } if (animator.GetBool("Torch")) { animator.SetBool("Torch", false); } if (animator.GetBool("Smg")) { animator.SetBool("Smg", false); } inventario.changeWeaponHUD(0); animator.SetBool("Pistol", true); onetime = false; hud.centralBoxEnabler(false); inventario.startAmmo(0); player.GetComponent <SwitchWeapon>().getPistol = true; hud.sideBoxEnabler(true); hud.sideBoxText("Hai raccolto la P226 (Tasto 2)"); PistolSpawn.SetActive(true); misc.supportFunction(gameObject); } if (gameObject.name.Equals("MP5") && onetime) { if (animator.GetBool("Axe")) { animator.SetBool("Axe", false); } if (animator.GetBool("Torch")) { animator.SetBool("Torch", false); } if (animator.GetBool("Pistol")) { animator.SetBool("Pistol", false); } inventario.changeWeaponHUD(2); animator.SetBool("Smg", true); onetime = false; hud.centralBoxEnabler(false); inventario.startAmmo(2); player.GetComponent <SwitchWeapon>().getSmg = true; hud.sideBoxEnabler(true); hud.sideBoxText("Hai raccolto l'MP5 (Tasto 3)"); SmgSpawn.SetActive(true); misc.supportFunction(gameObject); } if ((gameObject.CompareTag("Ammo_9mm") || gameObject.CompareTag("Ammo_smg")) && onetime) { hud.sideBoxEnabler(true); if (gameObject.CompareTag("Ammo_9mm")) { hud.sideBoxText("Hai raccolto " + munizioni_ammobox + " colpi per la pistola"); munizioni_ammobox = inventario.ammoPickup(munizioni_ammobox, 0, arma_attuale); } if (gameObject.CompareTag("Ammo_smg")) { hud.sideBoxText("Hai raccolto " + munizioni_ammobox + " colpi per l'mp5"); munizioni_ammobox = inventario.ammoPickup(munizioni_ammobox, 2, arma_attuale); } onetime = false; if (munizioni_ammobox == 0) { hud.centralBoxEnabler(false); munizioni_ammobox = start_ammo; misc.supportFunction(gameObject); } } if (gameObject.CompareTag("FirstAid") && onetime) { if (inventario.medkitPickup()) { hud.centralBoxEnabler(false); hud.sideBoxEnabler(true); hud.sideBoxText("Hai raccolto un kit medico"); misc.supportFunction(gameObject); onetime = false; } } } }
public void OnTriggerStay(Collider other) { //Se collide col giocatore, se preme "E" e se le cesoie esistono nella scena, allora ho raccolto la "chiave", disattivo il testo assocciato alle cesoie // e disattivo le cesoie if (other.CompareTag("Player") && Input.GetButton("Open Door") && gameObject.CompareTag("Cutter")) { key = true; GameObject.Find("chain").GetComponent <KeyScript>().key = true; hud.centralBoxEnabler(false); hud.sideBoxEnabler(true); hud.sideBoxText("Hai raccolto le cesoie"); CutterSpawn.SetActive(true); misc.supportFunction(gameObject); } if (other.CompareTag("Player") && Input.GetButton("Open Door") && gameObject.CompareTag("FinalKey")) { key = true; GameObject.FindGameObjectWithTag("FinalDoor").GetComponent <KeyScript>().key = true; hud.centralBoxEnabler(false); hud.sideBoxEnabler(true); hud.sideBoxText("Hai raccolto le chiavi"); misc.supportFunction(gameObject); } //Se spezzo la catena quando ho le cesoie e apro la recinzione if (gameObject.name.Equals("chain")) { if (other.gameObject.CompareTag("Player")) { if (key && Input.GetButtonDown("Open Door") && onetime) { gameObject.AddComponent <Rigidbody>(); gameObject.AddComponent <BoxCollider>(); hud.centralBoxEnabler(false); GameObject.FindGameObjectWithTag("Recinzione").GetComponent <Animator>().SetBool("Open", true); ChainSpawn.SetActive(true); onetime = false; Destroy(GameObject.Find("chain"), 2f); } } } if (gameObject.CompareTag("FinalDoor")) { if (other.gameObject.CompareTag("Player")) { if (key && Input.GetButtonDown("Open Door") && onetime) { hud.centralBoxEnabler(false); gameObject.AddComponent <Rigidbody>(); gameObject.GetComponent <Rigidbody>().AddForce(Vector3.forward * 15f, ForceMode.Impulse); onetime = false; foreach (BoxCollider collider in gameObject.GetComponents <BoxCollider>()) { if (collider.isTrigger) { Destroy(collider); } } //Destroy(gameObject.GetComponent<Rigidbody>()); } } } }