Exemplo n.º 1
0
    private void LineDestroy(ItemPos linePos,
                             Sprite line,
                             ItemPos[] destroyedPos)
    {
        Sprite[] destroyedSprites = destroyedPos
                                    .Select(p => _scene.ItemSprites[p.Pos.X, p.Pos.Y])
                                    .ToArray();

        var d1Body = (Node2D)_animTemplate.Duplicate();
        var d1     = new Destroyer(destroyedSprites, d1Body);

        line.GetParent().AddChild(d1);
        d1.Position = line.Position;
        //
        if (linePos.Item.Shape == ItemShape.VLine)
        {
            d1.RotationDegrees = 90f;
        }

        d1.Visible = true;

        var d2Body = (Node2D)_animTemplate.Duplicate();
        var d2     = new Destroyer(destroyedSprites, d2Body);

        line.GetParent().AddChild(d2);
        d2.Position = line.Position;
        //
        if (linePos.Item.Shape == ItemShape.HLine)
        {
            d2.RotationDegrees = 180f;
        }
        else if (linePos.Item.Shape == ItemShape.VLine)
        {
            d2.RotationDegrees = -90f;
        }

        d2.Visible = true;

        line.Visible = false; // removed later in Exec

        if (linePos.Item.Shape == ItemShape.HLine)
        {
            DestroyerLMovTween(d1);
            DestroyerRMovTween(d2);
        }
        else if (linePos.Item.Shape == ItemShape.VLine)
        {
            DestroyerUMovTween(d1);
            DestroyerDMovTween(d2);
        }

        d1.Connect(nameof(Destroyer.HitSignal), this, nameof(OnDestroyerHit));
        d2.Connect(nameof(Destroyer.HitSignal), this, nameof(OnDestroyerHit));
    }