Exemplo n.º 1
0
    void PredictLaunch()
    {
        endSpot = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
        float shiftX;
        float shiftY;

        HeroArrow.transform.localRotation.eulerAngles.Set(0, 0, 0);



        //ANGLE
        shiftX = -(startSpot.x - endSpot.x);
        shiftY = -(startSpot.y - endSpot.y);
        float angle = Mathf.Atan2(shiftY, shiftX);

        //SCALE
        float distance = Vector2.Distance(startSpot, endSpot);

        distance = (distance - stableDistance);
        if (distance > stableDistance)
        {
            distance = stableDistance;
        }
        float modifiedDistance = distance / stableDistance;

        if (modifiedDistance >= 0)
        {
            ArrowFull.transform.localScale    = new Vector3((.05f + (.15f * modifiedDistance)), (1), (.1f + (.3f * modifiedDistance)));
            ArrowFull.transform.localPosition = new Vector3(0, 0, (-10 * (ArrowFull.transform.localScale.z / 2)));

            ArrowDull.transform.localScale    = ArrowFull.transform.localScale;
            ArrowDull.transform.localPosition = ArrowFull.transform.localPosition;

            ArrowEdge.transform.localScale    = ArrowFull.transform.localScale;
            ArrowEdge.transform.localPosition = ArrowFull.transform.localPosition;

            //Predict
            shiftX = Mathf.Cos(angle) * 10;
            shiftY = Mathf.Sin(angle) * 10;

            HeroArrowDirector.transform.position = new Vector3((Self.transform.position.x + shiftX), Self.transform.position.y, (Self.transform.position.z + shiftY));
            HeroArrow.transform.LookAt(HeroArrowDirector.transform.position);


            //Render
            if (canShift)
            {
                ArrowDull.SetActive(false);
                ArrowEdge.SetActive(true);
                ArrowFull.SetActive(true);
            }
            else if (!canShift)
            {
                ArrowFull.SetActive(false);
                ArrowEdge.SetActive(true);
                ArrowDull.SetActive(true);
            }
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        //Arrow Blank Start
        HeroArrow.SetActive(false);
        ArrowFull.SetActive(false);
        ArrowDull.SetActive(false);
        HeroSelectionFull.SetActive(false);
        HeroSelectionDull.SetActive(false);

        //Movement Baselines
        Vector3 translateSpot = MainCamera.camera.WorldToScreenPoint(Self.transform.position);

        startSpot = new Vector2(translateSpot.x, translateSpot.y);
        float distance = (startSpot.y / screenFraction);

        stableDistance = distance;

        //Gravity Modification
        Physics.gravity = new Vector3(0, -60, 0);
    }