예제 #1
0
    public void Pop()
    {
        //Spawn Level + 4 amount of Candies
        int amount = Candy.GetCandyCount();

        for (int i = 0; i < amount; i++)
        {
            //Spawn them on the bag's position
            var newPos = transform.position;
            newPos.x += Random.Range(-0.01f, 0.01f);
            newPos.y += Random.Range(-0.01f, 0.01f);
            Candy.InstantiateAtPos(newPos);
        }

        //activate point effector for cool physics effect in action
        Sprite.SetActive(false);
        pe.forceMagnitude = 30;
        Destroy(this.gameObject, 0.1f);
    }
예제 #2
0
    public void Pop()
    {
        var a = Instantiate(GameControl.Instance.bagPop, transform.position, Quaternion.identity);

        Destroy(a, 2.0f);
        int amount = Candy.GetCandyCount();

        for (int i = 0; i < amount; i++)
        {
            //Spawn them on the bag's position
            var newPos = transform.position;
            newPos.x += Random.Range(-0.01f, 0.01f);
            newPos.y += Random.Range(-0.01f, 0.01f);
            Candy.InstantiateAtPos(newPos);
        }

        //activate point effector for cool physics effect in action
        Sprite.SetActive(false);
        pe.forceMagnitude = 15;
        Destroy(this.gameObject, 0.1f);

        //Decrement total number of bag count
        GameControl.Instance.DecrementBagCount();
    }