コード例 #1
0
    private void OnTriggerEnter(Collider otherCollider)
    {
        Cauldron cauldron = otherCollider.GetComponent <Cauldron>();

        if (cauldron != null && cauldron.GetPotionType() != PotionType.NONE)
        {
            type = cauldron.GetPotionType();
            cauldron.Reset();
            Debug.Log("The cauldron is of type: " + cauldron.GetPotionType());
            Debug.Log("This bottle is now of type " + type);
            switch (type)
            {
            case PotionType.GREEN:
                ChangeColor("greenMat");
                break;

            case PotionType.BLUE:
                ChangeColor("blueMat");
                break;

            case PotionType.RED:
                ChangeColor("redMat");
                break;

            case PotionType.MISTAKE:
                ChangeColor("mistake");
                break;

            default:
                ChangeColor("default");
                break;
            }
        }
    }
コード例 #2
0
    void ResetEverything()
    {
        Destroy(ingredients);
        GameObject newIngredients = Resources.Load("ingredients", typeof(GameObject)) as GameObject;

        ingredients = Instantiate(newIngredients, newIngredients.transform.position, newIngredients.transform.rotation);

        Destroy(bottles);
        GameObject newBottles = Resources.Load("Bottles", typeof(GameObject)) as GameObject;

        bottles = Instantiate(newBottles, newBottles.transform.position, newBottles.transform.rotation);

        potion.Reset();
        cauldron.Reset();
    }