protected override void FrameUpdate(FrameEventArgs eventArgs)
            {
                base.FrameUpdate(eventArgs);
                ScreenCoordinates screenCoords;

                if (Entity == null)
                {
                    screenCoords = _eyeManager.CoordinatesToScreen(InitialPos);
                }
                else if (_entityManager.TryGetComponent(Entity.Value, out TransformComponent? xform) &&
                         xform.MapID == _eyeManager.CurrentMap)
                {
                    screenCoords = _eyeManager.CoordinatesToScreen(xform.Coordinates);
                }
                else
                {
                    Visible = false;
                    if (Entity != null && _entityManager.Deleted(Entity))
                    {
                        TotalTime += PopupLifetime;
                    }
                    return;
                }

                Visible = true;
                var position = screenCoords.Position / UIScale - DesiredSize / 2;

                LayoutContainer.SetPosition(this, position - (0, 20 * (TotalTime * TotalTime + TotalTime)));
            }
Esempio n. 2
0
        protected override void FrameUpdate(FrameEventArgs args)
        {
            base.FrameUpdate(args);

            if (AttachedEntity?.IsValid() != true || !AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent))
            {
                return;
            }

            var doAfters = doAfterComponent.DoAfters;

            // Nothing to render so we'll hide.
            if (doAfters.Count == 0 && _cancelledDoAfters.Count == 0)
            {
                _firstDraw = true;
                Visible    = false;
                return;
            }

            // Set position ready for 2nd+ frames.
            _playerPosition = _eyeManager.CoordinatesToScreen(AttachedEntity.Transform.Coordinates);
            LayoutContainer.SetPosition(this, new Vector2(_playerPosition.X - Width / 2, _playerPosition.Y - Height - 30.0f));

            if (_firstDraw)
            {
                _firstDraw = false;
                return;
            }

            Visible = true;
            var currentTime = _gameTiming.CurTime;
            var toCancel    = new List <byte>();

            // Cleanup cancelled DoAfters
            foreach (var(id, cancelTime) in _cancelledDoAfters)
            {
                if ((currentTime - cancelTime).TotalSeconds > DoAfterSystem.ExcessTime)
                {
                    toCancel.Add(id);
                }
            }

            foreach (var id in toCancel)
            {
                RemoveDoAfter(id);
            }

            // Update 0 -> 1.0f of the things
            foreach (var(id, message) in doAfters)
            {
                if (_cancelledDoAfters.ContainsKey(id) || !_doAfterControls.ContainsKey(id))
                {
                    continue;
                }

                var doAfterBar = _doAfterBars[id];
                doAfterBar.Ratio = MathF.Min(1.0f,
                                             (float)(currentTime - message.StartTime).TotalSeconds / message.Delay);
            }
        }
Esempio n. 3
0
            protected override void FrameUpdate(FrameEventArgs eventArgs)
            {
                TimeLeft += eventArgs.DeltaSeconds;

                var position = Entity == null
                    ? InitialPos
                    : (_eyeManager.CoordinatesToScreen(Entity.Transform.Coordinates).Position / UIScale) - DesiredSize / 2;

                LayoutContainer.SetPosition(this, position - (0, 20 * (TimeLeft * TimeLeft + TimeLeft)));

                if (TimeLeft > 0.5f)
                {
                    Modulate = Color.White.WithAlpha(1f - 0.2f * (float)Math.Pow(TimeLeft - 0.5f, 3f));
                }
            }
Esempio n. 4
0
        public override void Update(float frameTime)
        {
            base.Update(frameTime);
            if (_tooltips == 0)
            {
                if (_aiBoxes.Count > 0)
                {
                    foreach (var(_, panel) in _aiBoxes)
                    {
                        panel.Dispose();
                    }

                    _aiBoxes.Clear();
                }
                return;
            }

            var deletedEntities = new List <IEntity>(0);

            foreach (var(entity, panel) in _aiBoxes)
            {
                if (entity.Deleted)
                {
                    deletedEntities.Add(entity);
                    continue;
                }

                if (!_eyeManager.GetWorldViewport().Contains(entity.Transform.WorldPosition))
                {
                    panel.Visible = false;
                    continue;
                }

                var(x, y) = _eyeManager.CoordinatesToScreen(entity.Transform.Coordinates).Position;
                var offsetPosition = new Vector2(x - panel.Width / 2, y - panel.Height - 50f);
                panel.Visible = true;

                LayoutContainer.SetPosition(panel, offsetPosition);
            }

            foreach (var entity in deletedEntities)
            {
                _aiBoxes.Remove(entity);
            }
        }
        protected override void FrameUpdate(FrameEventArgs args)
        {
            base.FrameUpdate(args);

            if (Entity.Deleted ||
                _eyeManager.CurrentMap != Entity.Transform.MapID)
            {
                Visible = false;
                return;
            }

            Visible = true;

            var screenCoordinates = _eyeManager.CoordinatesToScreen(Entity.Transform.Coordinates);
            var playerPosition    = new ScreenCoordinates(screenCoordinates.X / UIScale, screenCoordinates.Y / UIScale);

            LayoutContainer.SetPosition(this, new Vector2(playerPosition.X - Width / 2, playerPosition.Y - Height - 30.0f));
        }
        protected override void FrameUpdate(FrameEventArgs args)
        {
            base.FrameUpdate(args);

            MoreFrameUpdate(args);

            if (_entities.Deleted(Entity) || _eyeManager.CurrentMap != _entities.GetComponent <TransformComponent>(Entity).MapID)
            {
                Visible = false;
                return;
            }

            Visible = true;

            var screenCoordinates = _eyeManager.CoordinatesToScreen(_entities.GetComponent <TransformComponent>(Entity).Coordinates);
            var playerPosition    = UserInterfaceManager.ScreenToUIPosition(screenCoordinates);

            LayoutContainer.SetPosition(this, new Vector2(playerPosition.X - Width / 2, playerPosition.Y - Height - 30.0f));
        }