Esempio n. 1
0
    public void RenderUpdate(SpriteLeaser spriteLeaser, WorldCamera camera)
    {
        bool inRange = ((_chunk.coordination + Vector2.one * 0.5f) * Chunk.Length - new Vector2(_chunk.world.player.worldPosition.x, _chunk.world.player.worldPosition.z)).sqrMagnitude < 1024f;

        if (_showing && !inRange)
        {
            spriteLeaser.RemoveFromContainer();
            _showing = false;
        }
        else if (!_showing && inRange)
        {
            _showing = true;
        }

        if (_showing)
        {
            UpdateTileRender(spriteLeaser, camera);

            for (int index = 0; index < _drawTiles.Count; index++)
            {
                Tile    tile   = _drawTiles[index];
                FSprite sprite = spriteLeaser.sprites[index];

                // if (camera.turning)
                SetSpriteByTile(sprite, tile, camera, true);

                bool inScreenRect = spriteLeaser.InScreenRect(sprite);

                if (sprite.container != null && !inScreenRect)
                {
                    sprite.RemoveFromContainer();
                }
                else if (sprite.container == null && inScreenRect)
                {
                    camera.worldContainer.AddChild(sprite);
                }
            }
        }
    }
Esempio n. 2
0
 public virtual bool GetShownByCamera(SpriteLeaser spriteLeaser, WorldCamera camera)
 {
     return(spriteLeaser.InScreenRect(spriteLeaser.sprites[0]));
 }