Ejemplo n.º 1
0
        public virtual void OnDyingAnimation(ElementBase el)
        {
            if (DyingMax == 0)
            {
                return;
            }
            var lerp = DFMath.Lerp((DyingMax - DyingTick) / (float)DyingMax, 1, 0);

            if (el is Sprite s)
            {
                s.TintColor = Color.FromArgb(255, (int)(lerp * 255), (int)(lerp * 255));
                Location   += Vector.Right * lerp;
            }
        }
Ejemplo n.º 2
0
        private IEnumerator DisplayTextParticleCoroutine(string text, Vector position)
        {
            var drawable = new TextDrawable(text)
            {
                Location = position
            };

            Root.Add(drawable);

            var time = 0f;

            while (time < 2)
            {
                drawable.Location += Vector.Up * 16 * Time.DeltaTime;
                drawable.Color     = Color.FromArgb((int)DFMath.Lerp(time / 2, 255, 0), 255, 255, 255);
                time += Time.DeltaTime;
                yield return(null);
            }
            Root.Remove(drawable);
        }
Ejemplo n.º 3
0
        private void HandleKey()
        {
            var w = DFKeyboard.W;
            var a = DFKeyboard.A;
            var s = DFKeyboard.S;
            var d = DFKeyboard.D;

            var target =
                w && a ? 225 :
                w && d ? 315 :
                s && a ? 135 :
                s && d ? 45 :
                w ? 270 :
                a ? 180 :
                s ? 90 :
                d ? 0 : -1;

            if (w || a || s || d)
            {
                currentDegree = DFMath.Lerp(0.3f, currentDegree, target);
                cursor       += Forward * 128 * Time.DeltaTime;
            }
        }