Ejemplo n.º 1
0
        void Update()
        {
            bool inputJump = Input.GetButton("Jump");
            bool Grounded;

            if ((Time.time - lastGroundedTime) < CoyoteTime)
            {
                Grounded = true;
            }
            else
            {
                Grounded = CheckForGround();
                if (Grounded)
                {
                    lastGroundedTime = Time.time;
                }
            }
            playerRigidbody.velocity = MathW.SetVector(playerRigidbody.velocity, 1, playerRigidbody.velocity.y + (Time.deltaTime * Gravity * -1f));

            if (inputJump && Grounded)
            {
                Jump();
                lastGroundedTime = 0;
            }
        }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     playerRigidbody.velocity = MathW.SetVector(playerRigidbody.velocity, 1, playerRigidbody.velocity.y + (Time.deltaTime * Gravity * -1f));
     if (Input.GetKeyDown("space"))
     {
         Jump();
     }
 }
Ejemplo n.º 3
0
 public void Select(InputAction.CallbackContext context)
 {
     if (context.phase == InputActionPhase.Started)
     {
         SelectedCharacterID += (int)MathW.Sign(context.ReadValue <Vector2>().x);
         SelectedTeamID      += (int)MathW.Sign(context.ReadValue <Vector2>().y);
     }
 }
Ejemplo n.º 4
0
    public void RepeatSingleAnimation()
    {
        if (time < duration)
        {
            time += Time.deltaTime;
        }
        else
        {
            time = 0f;
        }

        time  = Mathf.Clamp(time, 0f, duration);
        value = MathW.Remap(time, 0f, duration, 0f, 1f);
    }
        //private float low = 0f, high = 1f;

        public void Visualize(List <float> _numbers, float _low = 0f, float _high = 1f)
        {
            //copy List
            numbers = new List <float>(_numbers);

            int       width  = resolution;
            int       height = resolution;//Mathf.Max(numbers);
            Texture2D tex    = new Texture2D(width, height);

            //clear texture
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    tex.SetPixel(x, y, backgroundColor);
                }
            }

            //draw samples
            foreach (var number in numbers)
            {
                var xPosition    = MathW.Remap(number, _low, _high, 1f, width - 2f);
                int xPositionInt = Mathf.RoundToInt(xPosition);

                for (int i = -sampleHeight / 2; i < sampleHeight / 2; i++)
                {
                    var currentPixelAlpha = tex.GetPixel(xPositionInt, height / 2 + i).a;
                    tex.SetPixel(xPositionInt, height / 2 + i, sampleColor.With(a: currentPixelAlpha + sampleColor.a));
                }
            }

            //draw border
            for (int i = -sampleHeight; i < sampleHeight; i++)
            {
                tex.SetPixel(0, height / 2 + i, borderColor);
                tex.SetPixel(width - 1, height / 2 + i, borderColor);
            }

            // apply some settings to make tex look better
            tex.Apply();
            tex.filterMode = FilterMode.Point;
            tex.wrapMode   = TextureWrapMode.Clamp;

            rawImage.texture = tex;
        }
Ejemplo n.º 6
0
    private void Visualize()
    {
        samples.Clear();
        samplesMapped.Clear();

        for (int i = 0; i < sampleCount; i++)
        {
            var nextFloat = (sampleFloatOrInt == FloatOrInt.Float) ? randomW.NextFloat() : randomW.NextInt();
            samples.Add(nextFloat);
            nextFloat = MathW.Remap(nextFloat, randomW.min, randomW.max, 0f, 1f);
            samplesMapped.Add(nextFloat);
        }

        visualizer.Visualize(samplesMapped);

        var minValue = samples.Min(t => t);
        var maxValue = samples.Max(t => t);

        Debug.Log("min value is: " + minValue + ", max value is: " + maxValue);
    }
Ejemplo n.º 7
0
    public void BounceAnimation()
    {
        if (time < duration && up)
        {
            time += Time.deltaTime;
        }
        else if (time > 0 && !up)
        {
            time -= Time.deltaTime;
        }

        if (up && time >= duration)
        {
            up = false;
        }
        else if (!up && time <= 0f)
        {
            up = true;
        }


        time  = Mathf.Clamp(time, 0f, duration);
        value = MathW.Remap(time, 0f, duration, 0f, 1f);
    }
Ejemplo n.º 8
0
 void Jump()
 {
     playerRigidbody.velocity = MathW.SetVector(playerRigidbody.velocity, 1, JumpHeight / JumpTime);
 }
Ejemplo n.º 9
0
        void Update()
        {
            var relativeSpeed = MathW.Remap(characterRigidbody.velocity.magnitude, 0f, maxSpeed, 0f, 1f);

            animator.SetFloat("WalkingSpeed", relativeSpeed);
        }