Esempio n. 1
0
        public Game() : base(640, 480, new GraphicsMode(32, 24, 0, 8), "Alchemy")
        {
            FontRenderer.Init();

            Init();

            _doubleClickTimer = new Timer
            {
                Interval = SystemInformation.DoubleClickTime / 2
            };

            _doubleClickTimer.Tick += (o, e) =>
            {
                _clicks = 0;
                _doubleClickTimer.Stop();
            };
        }
Esempio n. 2
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            var partialTicks = (float)(_updateTimer.Elapsed.TotalMilliseconds / (TargetUpdatePeriod * 1000f));

            _trashEntity?.SetShown(_holding != null && _trashEntity.MouseOverDestination && !_inventoryGui.IsShown());
            _trashEntity?.Render(partialTicks);

            for (var index = 0; index < _elementEntities.Count; index++)
            {
                var entity = _elementEntities[index];

                if (entity != _holding)
                {
                    entity?.Render(partialTicks);
                }
            }

            _holding?.Render(partialTicks);

            var offsetY = 0f;

            if (_toastQueue.Count > 0)
            {
                var toast = _toastQueue.First();

                if (toast != null)
                {
                    toast.Render(partialTicks);
                    offsetY = toast.CurrentY;
                }
            }

            var baseCount = ElementRegistry.GetBaseElements().Length;

            FontRenderer.DrawTextCentered(Width / 2f, 16 - offsetY, $"DISCOVERED {_learntElements.Count - baseCount}/{ElementRegistry.GetTotalCount() - baseCount}");

            _inventoryGui?.SetShown(_holding == null && (_inventoryGui.MouseOverTrigger || _inventoryGui.IsShown() && _inventoryGui.MouseOverRectangle));
            _inventoryGui?.Render(partialTicks);

            SwapBuffers();
        }
Esempio n. 3
0
        public void Render(float partialTicks)
        {
            var partialTick = _ticksLast + (_ticks - _ticksLast) * partialTicks;
            var progress    = Math.Min(partialTick, _maxTicks) / _maxTicks;

            GL.Translate(X, Y, 0);
            GL.Scale(ElementIconSize, ElementIconSize, 1);

            GL.BindTexture(TextureTarget.Texture2D, Element.TextureId);

            GL.Begin(PrimitiveType.Quads);
            GL.Color4(1f, 1, 1, progress);
            VertexUtil.PutQuad();
            GL.End();

            GL.Scale(1f / ElementIconSize, 1f / ElementIconSize, 1);
            GL.Translate(-X, -Y, 0);

            FontRenderer.DrawTextCentered(X, Y + ElementIconSize / 1.5f + 5, Element.ToString());
        }
Esempio n. 4
0
        public void Render(float partialTicks)
        {
            var partialAngle = Math.Min(_ticksMax, _ticksLast + (_ticks - _ticksLast) * partialTicks) / _ticksMax * MathHelper.PiOver2;

            if (partialAngle <= 0.1)
            {
                return;
            }

            var x = _game.Width - (float)Math.Sin(partialAngle) * _size;

            GL.BindTexture(TextureTarget.Texture2D, 0);

            GL.Translate(x, 32, 0);
            GL.Scale(_size, _game.Height, 1);

            //render background
            GL.Begin(PrimitiveType.Quads);
            GL.Color4(0, 0.75, 1, 0.15f);
            VertexUtil.PutQuad(false);
            GL.End();

            GL.Begin(PrimitiveType.LineLoop);
            GL.Color4(0, 0.75, 1, 0.5f);
            VertexUtil.PutQuad(false);
            GL.End();
            GL.Scale(1 / _size, 1f / _game.Height, 1);

            //render elements
            var count = (int)(_size / _iconSize);

            _lastOver = null;

            for (int i = 0; i < _elementEntities.Count; i++)
            {
                var e = _elementEntities[i];

                var x1 = i % count * _iconSize;
                var y1 = i / count * _iconSize;

                if (IsPointInRectangle(x + x1, y1 + 32, _iconSize, _iconSize, _lastMouse.X, _lastMouse.Y))
                {
                    _lastOver = e;
                }

                GL.BindTexture(TextureTarget.Texture2D, e.TextureId);

                var newSize = _iconSize - _iconGap * 2;

                GL.Translate(x1 + _iconSize / 2, y1 + _iconSize / 2, 0);
                GL.Scale(newSize, newSize, 1);

                GL.Translate(2 / newSize, 2 / newSize, 0);
                GL.Color3(0, 0, 0);
                GL.Begin(PrimitiveType.Quads);
                VertexUtil.PutQuad();
                GL.End();
                GL.Translate(-2 / newSize, -2 / newSize, 0);

                GL.Color3(1, 1, 1f);
                GL.Begin(PrimitiveType.Quads);
                VertexUtil.PutQuad();
                GL.End();

                GL.Scale(1f / newSize, 1f / newSize, 1);
                GL.Translate(-x1 - _iconSize / 2, -y1 - _iconSize / 2, 0);
            }

            FontRenderer.DrawTextCentered(128, -16, "DISCOVERED");

            GL.Translate(-x, -32, 0);
        }
Esempio n. 5
0
        public void Render(float partialTicks)
        {
            if (IsDead)
            {
                return;
            }

            float progress;

            var partialTick = _ticksLast + (_ticks - _ticksLast) * partialTicks;

            if (partialTick >= _maxTicks - 5)
            {
                progress = (float)Math.Cos(Math.Min(5 - _maxTicks - partialTick, 5) / 5f * MathHelper.PiOver2);
            }
            else
            {
                progress = -(float)Math.Sin(Math.Min(partialTick, 10) / 10f * MathHelper.PiOver2);
            }

            var centerX = _game.Width / 2;
            var centerY = -32 - (CurrentY = 64 * progress);

            GL.Translate(centerX, centerY, 0);

            //render toast texture
            GL.BindTexture(TextureTarget.Texture2D, _toastTextureId);

            GL.Color4(1f, 1, 1, 1);
            GL.Scale(256, 64, 1);
            GL.Begin(PrimitiveType.Quads);
            VertexUtil.PutQuad();
            GL.End();
            GL.Scale(1f / 256, 1f / 64, 1);

            //render icon shadow
            GL.BindTexture(TextureTarget.Texture2D, _iconTextureId);

            GL.Color4(0f, 0, 0, 1);
            GL.Translate(-94.5F, 2, 0);
            GL.Scale(49, 49, 1);
            GL.Begin(PrimitiveType.Quads);
            VertexUtil.PutQuad();
            GL.End();
            GL.Scale(1f / 49, 1f / 49, 1);
            GL.Translate(94.5F, -2, 0);

            //render icon
            GL.Color4(1f, 1, 1, 1);
            GL.Translate(-96.5F, 0, 0);
            GL.Scale(49, 49, 1);
            GL.Begin(PrimitiveType.Quads);
            VertexUtil.PutQuad();
            GL.End();
            GL.Scale(1f / 49, 1f / 49, 1);
            GL.Translate(96.5F, 0, 0);

            //render title
            GL.Color4(0, 0.65f, 1, 1);
            GL.Scale(0.9f, 0.9f, 1);
            FontRenderer.DrawTextWithShadow(-67, -28, Title);
            GL.Scale(1 / 0.9f, 1 / 0.9f, 1);

            //render text
            GL.Color4(1f, 1, 1, 1);
            GL.Scale(0.9f, 0.9f, 1);
            FontRenderer.DrawTextWithShadow(-67, -4, MessageText);
            GL.Scale(1 / 0.9f, 1 / 0.9f, 1);

            GL.Translate(-centerX, -centerY, 0);
        }