Ejemplo n.º 1
0
    private void SpawnBelt(Vector2 offset, bool down)
    {
        var wayPoints = new Vector2[BeltLength + 1];

        for (int i = 0; i < BeltLength + 1; i++)
        {
            wayPoints[i] = offset + new Vector2(0, -(down ? i : (BeltLength - i)));
        }

        var spritePositions = new Vector2[BeltLength];

        for (int i = 0; i < BeltLength; i++)
        {
            spritePositions[i] = offset + new Vector2(0, -.5f - (down ? i : (BeltLength - 1 - i)));
        }

        wayPoints[wayPoints.Length - 1] = offset + new Vector2(0, down ? -BeltLength : 0);

        var beltSystem = new BeltSystem(wayPoints, spritePositions)
        {
            Down = down
        };

        for (int i = 1; i < BeltLength - 1; i++)
        {
            beltSystem.PushItemRaw(new ItemOnBelt(i));
        }

        Manager.Belts.Add(beltSystem);
        Manager.Objects.Insert(beltSystem);
    }