Inheritance: MonoBehaviour
示例#1
0
        public ConstructCursor(PlayerInterface menu, WorldCamera worldCamera) : base(menu)
        {
            _worldCamera = worldCamera;

            _previewSprite        = new FSprite(Item.GetItemByID(0).element);
            _previewSprite.shader = FShader.Additive;
        }
示例#2
0
    public World(IsometricGame game, string worldName)
    {
        _game      = game;
        _worldName = worldName;

        _worldCamera = new WorldCamera(this);

        _worldTime = 0f;

        _chunkGenerator = new ChunkGenerator(this);
        _chunks         = new LinkedList <Chunk>();
        _chunkMap       = new Dictionary <int, Chunk>(256);

        _cosmeticDrawables = new LinkedList <CosmeticRenderer>();

        _targets = new List <ITarget>();

        player = new Player();

        _cameraHUD = new CameraHUDMenu(_game, _worldCamera);
        game.AddSubLoopFlow(_cameraHUD);

        _worldProfiler = new WorldProfiler(this);

        _epicenters = new Queue <Vector4>(NumMaxEpicenters);
        UpdateEpicenters();
    }
示例#3
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();
        }
    }
示例#4
0
    public void Render(WorldCamera camera, int elapsedMs, Vector3 from, Vector3 normal)
    {
        if (MathF.Abs(normal.Y) > 0.001f)
        {
            throw new ArgumentException("Assumed the lightning bolt to be on the X,Z plane, but got normal: " +
                                        normal);
        }

        var segments = MaxLineSegments;

        CalculateLineJitter(elapsedMs, segments, LineSegmentLength, 0);

        // Normal perpendicular to the line segment's direction (counter-clockwise, left)
        var perpenNormal = new Vector3(-normal.Z, 0, normal.X);

        // Ramp alpha 1->0 over the duration using the cosine function
        var timeFade = MathF.Cos((elapsedMs % ChainLightningRenderer.Duration) /
                                 (float)(ChainLightningRenderer.Duration - 1) * MathF.PI / 2);

        var to = from + normal * segments * LineSegmentLength;

        RenderMainArc(camera, from, to, segments, perpenNormal, timeFade);

        var forks = segments / 64;

        for (var i = 0; i < forks; i++)
        {
            RenderFork(camera, from, to, segments, perpenNormal, timeFade, 16, 196);
        }

        RenderStartingCap(camera, from, normal, perpenNormal, timeFade);
    }
示例#5
0
        void UISimInit()
        {
            Vitaboy.Avatar.DefaultTechnique = GlobalSettings.Default.Lighting ? 3 : 0;
            Camera = new WorldCamera(GameFacade.GraphicsDevice)
            {
                Zoom       = Zoom,
                CenterTile = new Vector3(-1, -1, 0) * FSOEnvironment.DPIScaleFactor
            };
            Scene = new _3DTargetScene(GameFacade.GraphicsDevice, Camera,
                                       new Point((int)(140 * FSOEnvironment.DPIScaleFactor), (int)(200 * FSOEnvironment.DPIScaleFactor)),
                                       GlobalSettings.Default.AntiAlias ? 8 : 0)
            {
                ID = "UISim"
            };

            GameFacade.Game.GraphicsDevice.DeviceReset += new EventHandler <EventArgs>(GraphicsDevice_DeviceReset);

            Avatar = new AdultVitaboyModel
            {
                Scene = Scene
            };
            var scale = FSOEnvironment.DPIScaleFactor;

            Avatar.Scale = new Vector3(scale, scale, scale);

            Scene.Add(Avatar);
        }
    public void Render(WorldCamera camera, int elapsedMs, Vector3 target)
    {
        // Increasing the line segment length here will essentially increase the frequency,
        // which leads to a better look compared to vanilla. We can't replicate the original 1:1
        // because we actually draw the lightning in screen space
        CalculateLineJitter(elapsedMs, LineSegments, LineSegmentLength * 1.5f, 0);

        // Call lightning ramps alpha from 1->0 in 127 millisecond intervals using cosine to create quick
        // "flashes" of lightning.
        // You can visualize the ramp in Wolfram Alpha:
        // https://www.wolframalpha.com/input/?i=plot+cos%28%28x+mod+127%29+%2F+254+*+PI%29+from+x%3D0+to+768
        var alphaRamp = MathF.Cos(elapsedMs % 127 / 127f * 0.5f * MathF.PI);
        var alpha     = (byte)(alphaRamp * 255);
        var color     = new PackedLinearColorA(alpha, alpha, alpha, alpha);

        // These are normals for screen-space pixels
        var(right, up) = camera.GetBillboardNormals();

        // Vector used to extrude the line to it's intended screen-space width
        var extrudeVec = ArcWidth / 2 * right;

        for (var i = 0; i < LineSegments; i++)
        {
            ref var leftVertex  = ref Vertices[i * 2];
            ref var rightVertex = ref Vertices[i * 2 + 1];
示例#7
0
    public bool CheckIfUserCameraInput()
    {
        bool keyboardMove;
        bool mouseMove;
        bool canMove;

        if (WorldCamera.AreCameraKeyButtonsPressed())
        {
            keyboardMove = true;
        }
        else
        {
            keyboardMove = false;
        }

        if (WorldCamera.IsMousePositionWithinBoundaries())
        {
            mouseMove = true;
        }
        else
        {
            mouseMove = false;
        }

        if (keyboardMove || mouseMove)
        {
            canMove = true;
        }
        else
        {
            canMove = false;
        }

        return(canMove);
    }
示例#8
0
    public void Bind([MaybeNull] WorldCamera camera, RenderingDevice device, IList <Light3d> lights,
                     MdfRenderOverrides overrides = null)
    {
        device.SetMaterial(mDeviceMaterial);

        BindShader(camera, device, lights, overrides);
    }
    public void Render(WorldCamera camera, int targetIndex, int elapsedMs, Vector3 from, Vector3 to)
    {
        var line       = to - from;
        var lineLength = line.Length();

        // Normal perpendicular to the line (points to the "left") on the X,Z plane which is the floor
        var perpenNormal = new Vector3(-line.Z / lineLength, 0, line.X / lineLength);

        // Ramp the color from alpha 1->0 over the duration using the cosine function
        var colorRamp = MathF.Cos((elapsedMs % Duration) / (float)(Duration - 1) * MathF.PI / 2);

        var segments = Math.Min(MaxLineSegments, (int)MathF.Round(lineLength / LineSegmentLength));

        // This causes the noise to be sampled in a different grid-cell per target
        var targetNoiseOffset = 0.5f * targetIndex;

        CalculateLineJitter(elapsedMs, segments, LineSegmentLength, targetNoiseOffset);

        RenderMainArc(camera, from, to, segments, perpenNormal, colorRamp);

        for (var i = 0; i < ForkCount; i++)
        {
            RenderFork(camera, from, to, segments, perpenNormal, colorRamp, MinForkSegments, segments);
        }
    }
示例#10
0
        void KeyboardManager_KeyDown(object sender, Input.KeyboardEvent e)
        {
            if (e.Key == Keys.PageUp)
            {
                if (layeredit < Level.RenderManager.Layers.Count - 1)
                {
                    layeredit++;
                }
                else
                {
                    normaldraw = true;
                }

                if (Level.RenderManager.getLayer(LayerEdit).HasMap)
                {
                    WorldCamera.setLimit(0, 0, Level.RenderManager.getLayer(LayerEdit).Map.Width *GFX.Tile.STANDARD_GTILE_WIDTH - (int)Game.Resolution.Scene.X, Level.RenderManager.getLayer(LayerEdit).Map.Height *GFX.Tile.STANDARD_GTILE_HEIGHT - (int)Game.Resolution.Scene.Y);
                }
            }
            else if (e.Key == Keys.PageDown)
            {
                if (layeredit > 0 && !normaldraw)
                {
                    layeredit--;
                }

                if (normaldraw)
                {
                    normaldraw = false;
                }

                if (Level.RenderManager.getLayer(LayerEdit).HasMap)
                {
                    WorldCamera.setLimit(0, 0, Level.RenderManager.getLayer(LayerEdit).Map.Width *GFX.Tile.STANDARD_GTILE_WIDTH - (int)Game.Resolution.Scene.X, Level.RenderManager.getLayer(LayerEdit).Map.Height *GFX.Tile.STANDARD_GTILE_HEIGHT - (int)Game.Resolution.Scene.Y);
                }
            }
            else if (e.Key == Keys.Enter)
            {
                Console.WriteLine("Wpisz argumenty mapy: W H XS YS WW HW AXS AYS");
                string[] args = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                if (args.Length == 8)
                {
                    GFX.MapLayer layer = Level.RenderManager.getLayer(LayerEdit);
                    layer.Map         = new GFX.TileMap(int.Parse(args[0]), int.Parse(args[1]), Level.RenderManager.getEntityLayer().Map.TileSet);
                    layer.AutoXScroll = float.Parse(args[6]);
                    layer.AutoYScroll = float.Parse(args[7]);
                    layer.YSpeed      = float.Parse(args[3]);
                    layer.XSpeed      = float.Parse(args[2]);
                    layer.WidthWrap   = bool.Parse(args[4]);
                    layer.HeightWrap  = bool.Parse(args[5]);

                    Console.WriteLine("Stworzono mapę!");
                }
            }
            else if (e.Key == Keys.Insert)
            {
                Engine.Files.LevelFile.saveLevel(Level, "TestWorld.glv", "TS.gts");
            }
        }
示例#11
0
    public virtual void OnInitializeSprite(SpriteLeaser spriteLeaser, WorldCamera camera)
    {
        FSprite sprite = new FSprite(element == null ? Futile.whiteElement : element);

        sprite.shader = shader;

        spriteLeaser.sprites.Add(sprite);
    }
示例#12
0
    public override void OnInitializeSprite(SpriteLeaser spriteLeaser, WorldCamera camera)
    {
        if (_sprites == null)
        {
            LoadSprites();
        }

        base.OnInitializeSprite(spriteLeaser, camera);
    }
示例#13
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;
        }
示例#14
0
    public SpriteLeaser(WorldCamera camera, IRenderer owner)
    {
        _camera    = camera;
        this.owner = owner;

        sprites     = new List <FSprite>();
        spriteIndex = 0;

        _showing = false;
    }
示例#15
0
    public void UpdateTileRender(SpriteLeaser spriteLeaser, WorldCamera camera)
    {
        while (_tilesQueue.Count > 0)
        {
            Tile tile = _tilesQueue.Dequeue();

            if (tile != null)
            {
                bool showing = false;

                if (tile.block.sprite != null)
                {
                    if (GetTileShowing(tile))
                    {
                        showing = true;
                    }
                }

                int index = _drawTiles.IndexOf(tile);

                if (showing)
                {
                    FSprite sprite;

                    if (index < 0)
                    {
                        sprite        = new FSprite(tile.block.sprite);
                        sprite.shader = _shader;

                        _drawTiles.Add(tile);
                        spriteLeaser.sprites.Add(sprite);
                    }
                    else
                    {
                        sprite         = spriteLeaser.sprites[index];
                        sprite.element = tile.block.sprite;
                    }

                    SetSpriteByTile(sprite, tile, camera, true);
                }
                else
                {
                    if (index < 0)
                    {
                        continue;
                    }

                    _drawTiles.RemoveAt(index);

                    spriteLeaser.sprites[index].RemoveFromContainer();
                    spriteLeaser.sprites.RemoveAt(index);
                }
            }
        }
    }
    public bool CheckIfUserCameraInput()
    {
        bool keyboardMove;
        bool mouseMove;
        bool canMove;

        keyboardMove = WorldCamera.AreCameraKeyboardButtonPressed();
        mouseMove    = WorldCamera.IsMousePositionWithinBoundaries();

        return(keyboardMove || mouseMove);
    }
示例#17
0
        public void Init()
        {
            this.inited = true;
            CameraManager cameraManager = Service.Get <CameraManager>();

            this.uxCamera          = cameraManager.UXCamera;
            this.activeWorldCamera = cameraManager.MainCamera;
            Service.Get <EventManager>().RegisterObserver(this, EventId.DenyUserInput, EventPriority.Default);
            Service.Get <EventManager>().RegisterObserver(this, EventId.ApplicationPauseToggled, EventPriority.Default);
            this.Enable(false);
        }
示例#18
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);
        }
    }
示例#19
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)];
        }
示例#20
0
        public ChatBubble(WorldCamera camera, IPositionable behaviour, string text, MenuFlow menu) : base(menu)
        {
            _camera = camera;

            _behaviour = behaviour;
            _text      = text;
            _duration  = 10f;

            _rect  = new RoundedRect(menu, true);
            _label = new FLabel("font", string.Empty);

            AddElement(_rect);
            AddElement(_label);
        }
示例#21
0
文件: UISim.cs 项目: pepster98/FreeSO
        private void UISimInit()
        {
            Camera            = new WorldCamera(GameFacade.GraphicsDevice);
            Camera.Zoom       = LotView.WorldZoom.Near;
            Camera.CenterTile = new Vector2(-1, -1);
            Scene             = new _3DTargetScene(GameFacade.Game.GraphicsDevice, Camera, new Point(140, 200), (GlobalSettings.Default.AntiAlias)?8:0);
            Scene.ID          = "UISim";

            GameFacade.Game.GraphicsDevice.DeviceReset += new EventHandler <EventArgs>(GraphicsDevice_DeviceReset);

            Avatar       = new AdultVitaboyModel();
            Avatar.Scene = Scene;

            Scene.Add(Avatar);
        }
示例#22
0
        public DestructCursor(PlayerInterface menu, WorldCamera worldCamera) : base(menu)
        {
            _worldCamera = worldCamera;

            _progress = 0f;

            _destroyElements = new FAtlasElement[8];

            for (int index = 0; index < _destroyElements.Length; index++)
            {
                _destroyElements[index] = Futile.atlasManager.GetElementWithName("destroy" + index);
            }

            _previewSprite = new FSprite(_destroyElements[0]);
        }
示例#23
0
        public void Render()
        {
            UniformBuffers.DirectionLightBuffer.Update(lightBufferData);
            WorldCamera.Update();
            for (var index = 0; index < loadedEntities.Count; index++)
            {
                loadedEntities[index].Render();
            }

            for (var index = 0; index < loadedChunks.Count; index++)
            {
                loadedChunks[index].Render();
            }

            Skybox.Render();
        }
示例#24
0
        public override void PrepareLighting()
        {
            base.PrepareLighting();

            var frontDir    = WorldCamera.FrontDirection();
            var lightOffset = -GetWallOffset() * 6 / (6 * 75);

            if (Light != null)
            {
                lightOffset *= Light.InvMapLayout;
            }
            WorldContent._2DWorldBatchEffect.Parameters["LightOffset"].SetValue(lightOffset);
            WorldContent.GrassEffect.Parameters["LightOffset"].SetValue(lightOffset);
            Avatar.Effect.Parameters["LightOffset"].SetValue(lightOffset);
            WorldContent.RCObject.Parameters["LightOffset"].SetValue(lightOffset);
        }
示例#25
0
        public DamageIndicator(WorldCamera camera, IPositionable positionable, Damage damage, MenuFlow menu) : base(menu)
        {
            _camera       = camera;
            _positionable = positionable;

            string text = ((int)damage.amount).ToString();

            _label       = new ShadowedLabel(menu, text);
            _label.scale = Vector2.one * 3f;

            AddElement(_label);

            _time = 0f;

            _colors = new Color[] { Color.white, Color.red, Color.yellow };
        }
示例#26
0
        public override void Initialize()
        {
            // Set to true by default, let subclasses enable/disable.
            UsingTracking = true;

            m_needsSetAnchor = true;

            m_objStates = new Dictionary<LocationARWorldObject, TrackedWorldObjectState>();

            if (!CameraGyro)
            {
                CameraGyro = WorldCamera.GetComponent<CameraGyroscope>();
            }

            base.Initialize();

            EnableTracking();
        }
示例#27
0
        public override void Update(GameTime gt)
        {
            if (normaldraw)
            {
                base.Update(gt);
            }
            else
            {
                Level.TileManager.Update(gt);
            }

            //RenderManager.Update(gt);
            //EntityManager.UpdateEntities(gt);


            int fac = InputManager.KeyboardManager.State.IsKeyDown(Keys.RightShift) ? 3 : 1;

            if (InputManager.KeyboardManager.State.IsKeyDown(Keys.Left))
            {
                WorldCamera.moveTranslation(-2 * fac, 0);
            }
            if (InputManager.KeyboardManager.State.IsKeyDown(Keys.Right))
            {
                WorldCamera.moveTranslation(2 * fac, 0);
            }
            if (InputManager.KeyboardManager.State.IsKeyDown(Keys.Up))
            {
                WorldCamera.moveTranslation(0, -2 * fac);
            }
            if (InputManager.KeyboardManager.State.IsKeyDown(Keys.Down))
            {
                WorldCamera.moveTranslation(0, 2 * fac);
            }

            Vector2 position = new Vector2(InputManager.MouseManager.State.X, InputManager.MouseManager.State.Y);

            if (InputManager.MouseManager.State.LeftButton == ButtonState.Pressed)
            {
                if (Level.RenderManager.getLayer(LayerEdit).HasMap)
                {
                    Level.RenderManager.getLayer(LayerEdit).Map.getTile(getAppToWorld(position)).ID = tiledata;
                }
            }
        }
示例#28
0
        private void UISimInit()
        {
            Vitaboy.Avatar.DefaultTechnique = (GlobalSettings.Default.Lighting) ? 3 : 0;
            Camera            = new WorldCamera(GameFacade.GraphicsDevice);
            Camera.Zoom       = Zoom;
            Camera.CenterTile = new Vector3(-1, -1, 0) * FSOEnvironment.DPIScaleFactor;
            Scene             = new _3DTargetScene(GameFacade.GraphicsDevice, Camera,
                                                   new Point(140 * FSOEnvironment.DPIScaleFactor, 200 * FSOEnvironment.DPIScaleFactor),
                                                   (GlobalSettings.Default.AntiAlias)?8:0);
            Scene.ID = "UISim";

            GameFacade.Game.GraphicsDevice.DeviceReset += new EventHandler <EventArgs>(GraphicsDevice_DeviceReset);

            Avatar       = new AdultVitaboyModel();
            Avatar.Scene = Scene;
            var scale = FSOEnvironment.DPIScaleFactor;

            Avatar.Scale = new Vector3(scale, scale, scale);

            Scene.Add(Avatar);
        }
示例#29
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);
                }
            }
        }
    }
示例#30
0
        public WorldCameraUI(WorldCamera worldCamera)
        {
            _worldCamera = worldCamera;

            _axisContainer = new FContainer();
            _axisContainer.SetPosition(Futile.screen.halfWidth - 36f, Futile.screen.halfHeight - 20f);
            _axisContainer.scaleY = 0.5f;
            Futile.stage.AddChild(_axisContainer);

            _axisSprites = new FSprite[4];
            for (int index = 0; index < _axisSprites.Length; index++)
            {
                _axisSprites[index]         = new FSprite("Futile_White");
                _axisSprites[index].color   = index == 3 ? Color.red : Color.black;
                _axisSprites[index].anchorY = 0f;
                _axisSprites[index].scaleY  = 0f;
                _axisSprites[index].scaleX  = 0.15f;
                _axisContainer.AddChild(_axisSprites[index]);
            }

            _axisShowFactor = 0f;
        }
示例#31
0
 protected void Awake() {
     _cam = GetComponent<WorldCamera>();
 }
示例#32
0
 // Use this for initialization
 void Start()
 {
     worldCamera = worldCameraObj.GetComponent<WorldCamera>();
     //box = gameObject.GetComponent<BoxCollider2D>();
 }
示例#33
0
 void Awake()
 {
     Instance = this;
 }