コード例 #1
0
    private void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Crystal")
        {
            CrystalCount       += 1;
            Crystalcollect.text = "Crystals: " + CrystalCount;
            col.gameObject.SetActive(false);
        }

        if (col.tag == "crytal 2")
        {
            CrystalCount       += 1;
            Crystalcollect.text = "Crystals: " + CrystalCount;
            col.gameObject.SetActive(false);
            if (CrystalCount == 11)
            {
                levelComplete.gameObject.SetActive(true);
                Cursor.visible = true;
            }
        }

        if (col.tag == "Ammo")
        {
            if (!gun.fullyLoaded)
            {
                gun.AddAmmo(30);
                col.gameObject.SetActive(false);
                gun.noAmmo.gameObject.SetActive(false);
            }
        }

        if (col.tag == "Health")
        {
            if (currentHealth < maxHealth)
            {
                currentHealth  = currentHealth + 50;
                bloodHUD.color = new Color(bloodHUD.color.r, bloodHUD.color.g, bloodHUD.color.b, 1 - 0.01f * currentHealth);
                col.gameObject.SetActive(false);
                if (currentHealth > maxHealth)
                {
                    currentHealth = maxHealth;
                }
            }
        }

        if (col.gameObject.tag == "NextLevel")
        {
            levelComplete.gameObject.SetActive(true);
            Cursor.visible    = true;
            character.enabled = false;
        }
    }