Exemplo n.º 1
0
    private void blinkPlayer()
    {
        if (marker != null)
        {
            Destroy(marker);
        }

        Vector3 currentPosition = playerView.transform.position;

        currentPosition.y = transform.position.y;

        if (Input.GetAxis(verticalJoystick) == 0 && inBlink && Input.GetAxis(horizontalJoystick) == 0)
        {
            //check for release of blink
            inBlink               = false;
            arcLine.enabled       = false;
            arcLine.positionCount = 0;


            if (blink.validateBlink(currentPosition, newPosition, normal))
            {
                Vector3 offset = transform.position - currentPosition;


                transform.position = newPosition + offset;
                blinked            = true;
            }
        }
        else
        {
            //draw curve and update marker position


            if (drawArc(blink.origin.position, blink.origin.forward, out newPosition, out normal))
            {
                //returns a value

                if (blink.validateBlink(currentPosition, newPosition, normal))
                {
                    //valid spot
                    marker = Instantiate(blink.blinkMarker, newPosition, getJoystickRotation());
                    arc.setValid(arcLine);
                }
                else
                {
                    arc.setInvalid(arcLine);
                }
            }
            else
            {
                arc.setInvalid(arcLine);
            }
        }
    }