Beispiel #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            print(gameObject.tag);
            if (gameObject.tag.Equals("Ammo_9mm"))
            {
                name = "9mm";
            }
            else if (gameObject.tag.Equals("Ammo_smg"))
            {
                name = "9mmSmg";
            }
            else if (gameObject.tag.Equals("FirstAid"))
            {
                name = "KitMedico (K)";
            }
            else
            {
                name = gameObject.name;
            }


            hud.centralBoxText("Premi \"E\" per raccogliere " + name);
            hud.centralBoxEnabler(true);
        }
    }
    //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);
    }
Beispiel #3
0
    // 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 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>());
                }
            }
        }
    }
    public void OnTriggerEnter(Collider other)
    {
        if (gameObject.CompareTag("Serranda"))
        {
            if (other.gameObject.CompareTag("Player"))
            {
                hud.centralBoxText("Premi \"Left Ctrl\" per abbassarti");
                hud.centralBoxEnabler(true);
            }
        }

        if (gameObject.name.Equals("chain"))
        {
            if (other.gameObject.CompareTag("Player"))
            {
                if (!access_cutter.key)
                {
                    hud.centralBoxText("Ti servono delle cesoie per spezzare il lucchetto");
                }
                else
                {
                    hud.centralBoxText("Premi \"E\" per spezzare il lucchetto");
                }
                hud.centralBoxEnabler(true);
            }
        }

        if (gameObject.CompareTag("FinalDoor"))
        {
            if (other.gameObject.CompareTag("Player"))
            {
                if (!access_key.key)
                {
                    hud.centralBoxText("Ti serve una chiave per procedere");
                }
                else
                {
                    hud.centralBoxText("Premi \"E\" per usare la chiave");
                }
                hud.centralBoxEnabler(true);
            }
        }

        if (gameObject.CompareTag("Cutter"))
        {
            if (other.gameObject.CompareTag("Player"))
            {
                hud.centralBoxText("Premi \"E\" per raccogliere le cesoie");
                hud.centralBoxEnabler(true);
            }
        }

        if (gameObject.CompareTag("FinalKey"))
        {
            if (other.gameObject.CompareTag("Player"))
            {
                hud.centralBoxText("Premi \"E\" per raccogliere le chiavi");
                hud.centralBoxEnabler(true);
            }
        }

        if (gameObject.name.Equals("Corsa"))
        {
            if (other.gameObject.CompareTag("Player"))
            {
                hud.centralBoxText("Premi \"Left Shit\" per correre");
                hud.centralBoxEnabler(true);
            }
        }

        if (gameObject.name.Equals("Camminata"))
        {
            if (other.gameObject.CompareTag("Player"))
            {
                hud.centralBoxText("Premi \"W\" per avanzare");
                hud.centralBoxEnabler(true);
            }
        }

        if (gameObject.name.Equals("TorciaHint"))
        {
            if (other.gameObject.CompareTag("Player"))
            {
                hud.centralBoxText("Premi \"F\" per accendere e spegnere la torcia");
                hud.centralBoxEnabler(true);
            }
        }

        if (gameObject.name.Equals("KitmedicoHint"))
        {
            hud.centralBoxText("Premi \"E\" per raccogliere " + gameObject.name + "e premi \"K\" per usarlo");
            hud.centralBoxEnabler(true);
        }

        if (gameObject.CompareTag("Axe"))
        {
            hud.centralBoxText("Premi \"E\" per raccogliere l'ascia");
            hud.centralBoxEnabler(true);
        }
    }