Beispiel #1
0
    public void breakChain(bool hurt = false, int chainLength = 0)
    {
        //Once the chain has started breaking we must recursively break every link
        //We use breakingChain because we have a half second coroutine delay
        breakingChain = false;
        if (followedBy)
        {
            followedBy.breakChain(hurt, chainLength);
        }
        following  = null;
        followedBy = null;

        switch (groundAction)
        {
        //This is for collecting starFragments
        case Actions.CheckFive:
            if (chainLength >= 5)
            {
                GameObject starSwirler = GameObject.Find("StarSwirler");
                if (!starSwirler)
                {
                    Debug.LogWarning("No star swirler!");
                }
                else
                {
                    transform.parent = starSwirler.transform;
                    enabled          = false;
                }
            }
            else
            {
                SoundManager.Instance.playClip("Collectibles/dropStarShards");
            }
            break;

        case Actions.Collect:
            if (!hurt)
            {
                collectiblesController cc = GetComponent <collectiblesController>();
                if (cc)
                {
                    cc.collect();
                    enabled = false;
                }
            }
            break;

        default:
            break;
        }
    }