/// <summary>
    /// Call this method to tally a nut and trigger the appropriate animation.
    /// </summary>
    /// <param name="nut">The type of nut collected.</param>
    /// <param name="worldPosition">The world position of the nut that was collected.</param>
    virtual public void OnNutCollect(NutProperties nut)
    {
        nuts += (int)nut.type;
        Vector2 pos = camera.WorldToViewportPoint(nut.worldPosition);

        pos = new Vector2(
            ((pos.x * canvasRect.sizeDelta.x) - (canvasRect.sizeDelta.x * 0.5f)),
            ((pos.y * canvasRect.sizeDelta.y) - (canvasRect.sizeDelta.y * 0.5f)));
        acornCtrl.OnNutCollect(nut, pos);
    }
Exemple #2
0
    public void OnNutCollect(NutProperties nut, Vector2 viewportPosition)
    {
        int value = (int)nut.type;

        switch (nut.type)
        {
        case NutType.GOLDENACORN:
            float deltaAngle = (2 * Mathf.PI) / value;

            for (int i = 0; i < value; ++i)
            {
                StartCoroutine(GoldenFlyup(viewportPosition, acornIcon.localPosition, deltaAngle * i, OnFlyupComplete));
            }
            break;

        case NutType.ACORN:
        default:
            StartCoroutine(StandardFlyup(viewportPosition, acornIcon.localPosition, OnFlyupComplete, value));
            break;
        }
        Destroy(nut.gameObject);
    }
 public override void OnNutCollect(NutProperties nut)
 {
     base.OnNutCollect(nut);
     nutSpawn();
     timer.SendMessage("addTime");
 }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Pick Up"))
        {
            other.gameObject.SetActive(false);
            count += 1;
            //SetCountText ();
        }

        if (other.gameObject.CompareTag("Nut"))
        {
            random_pickup();
            NutProperties nut = other.GetComponent <NutProperties>();
            if (nut != null)
            {
                lvlctrl.OnNutCollect(nut);
            }
            else
            {
                Debug.LogError("SquirrelController: A nut was collected that did not have a NutProperties component attached.");
            }
            //Destroy(other.gameObject);
        }

        /*
         * if (other.gameObject.CompareTag("Golden Acorn"))
         * {
         *              nutSounds [0].Play ();
         *  //lvlctrl.OnNutCollect(NutType.GOLDENACORN, other.gameObject.transform.position);
         *  Destroy(other.gameObject);
         * }*/

        if (other.gameObject.tag == "Car")
        {
            squish();
        }

        if (other.gameObject.tag == "Timeberry")
        {
            random_pickup();
            Instantiate(timeberry_particle, other.transform.position, other.transform.rotation);
            other.gameObject.SetActive(false);
            timeBerryAction();
        }

        if (other.gameObject.tag == "Tutorial1")
        {
            lvlctrl.SendMessage("tutorial", 1);
        }
        if (other.gameObject.tag == "Tutorial2")
        {
            lvlctrl.SendMessage("tutorial", 2);
        }
        if (other.gameObject.tag == "Tutorial3")
        {
            lvlctrl.SendMessage("tutorial", 3);
        }
        if (other.gameObject.tag == "Tutorial4")
        {
            lvlctrl.SendMessage("tutorial", 4);
        }
        if (other.gameObject.tag == "Tutorial5")
        {
            lvlctrl.SendMessage("tutorial", 5);
        }
        if (other.gameObject.tag == "Tutorial6")
        {
            lvlctrl.SendMessage("tutorial", 6);
        }
    }