Ejemplo n.º 1
0
    public virtual void RenderUpdate(SpriteLeaser spriteLeaser, WorldCamera camera)
    {
        if (world != null)
        {
            FSprite sprite = spriteLeaser.sprites[0];

            if (element != null)
            {
                sprite.isVisible = true;
                sprite.element   = element;
            }
            else
            {
                sprite.isVisible = false;
            }
            sprite.SetPosition(camera.GetScreenPosition(worldPosition) + _positionOffset);
            sprite.rotation = _rotation;
            sprite.scaleX   = scale.x;
            sprite.scaleY   = scale.y;
            if (doesFlip)
            {
                sprite.scaleX *= (camera.GetFlipXByViewAngle(viewAngle) ? -1f : 1f);
            }
            sprite.sortZ = camera.GetSortZ(worldPosition) + sortZOffset;
            sprite.color = color; // new Color(worldPosition.x, worldPosition.y, worldPosition.z);
        }
        else
        {
            spriteLeaser.Erase();
        }
    }
Ejemplo n.º 2
0
        public void SetConstructionGuide(WorldCamera worldCamera, Player player, Vector3 worldPosition, Vector3 hitDirection, bool inRange)
        {
            _previewSprite.SetPosition(worldCamera.GetScreenPosition(worldPosition + hitDirection));
            _previewSprite.sortZ = worldCamera.GetSortZ(worldPosition) + 0.1f;

            _previewSprite.color = inRange ? Color.cyan : Color.red;
            _previewSprite.alpha = Mathf.Sin(menu.time * Mathf.PI) * 0.25f + 0.5f;

            _previewSprite.element = player.pickItemStack.item.element;
        }
Ejemplo n.º 3
0
    public void SetSpriteByTile(FSprite target, Tile tile, WorldCamera camera, bool optimizeColor = false)
    {
        Vector3 spritePosition = tile.coordination + Vector3.one * 0.5f;

        target.SetPosition(camera.GetScreenPosition(spritePosition));
        target.sortZ = camera.GetSortZ(spritePosition);

        if (optimizeColor)
        {
            target.color = new Color(tile.coordination.x, tile.coordination.y, tile.coordination.z);
        }
    }
Ejemplo n.º 4
0
        public void SetConstructionGuide(WorldCamera worldCamera, Player player, Vector3Int tilePosition, bool inRange, float progress)
        {
            Vector3 worldPosition = tilePosition + Vector3.one * 0.5f;

            _previewSprite.SetPosition(worldCamera.GetScreenPosition(worldPosition));
            _previewSprite.sortZ = worldCamera.GetSortZ(worldPosition) + 0.1f;

            // _previewSprite.color = Color.Lerp(inRange ? Color.cyan : Color.red, Color.black, progress);
            // _previewSprite.alpha = Mathf.Sin(menu.time * Mathf.PI) * 0.25f + 0.5f;

            _previewSprite.alpha   = progress > 0f ? 1f : 0f;
            _previewSprite.element = _destroyElements[Mathf.FloorToInt(Mathf.Clamp01(progress) * 7f)];
        }