示例#1
0
文件: Player.cs 项目: SvenSchmid/Loop
    /// Retracts the segment towards the new player dot and removes the old one
    void RemoveDot(bool removeDot0)
    {
        //StartCoroutine(RadiusFade(true));

        bool switchSegmentDirection = false;

        if (removeDot0 && dot0 != null)
        {
            dot0.Remove();
            dot0 = null;

            if (dot1 != null)
            {
                if (newestDot == DotType.Dot1)
                {
                    switchSegmentDirection = true;
                }
                newestDot = DotType.Dot1;
                FadeRadius(true);
            }
            else
            {
                FadeRadius(false);
            }
        }
        else if (!removeDot0 && dot1 != null)
        {
            dot1.Remove();
            dot1 = null;

            if (dot0 != null)
            {
                if (newestDot == DotType.Dot0)
                {
                    switchSegmentDirection = true;
                }
                newestDot = DotType.Dot0;
                FadeRadius(true);
            }
            else
            {
                FadeRadius(false);
            }
        }

        // both dots are gone => Death/Restart
        if (dot1 == null && dot0 == null)
        {
            Game.SetState(Game.State.Death);
            radius        = 0;
            radiusOpacity = 0;
            newestDot     = DotType.None;
        }


        // empty the segment in between those two dots
        playerSegment.EmptySegment(switchSegmentDirection);
    }