Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        nextParbola = false;

        if (Animation && parabolaFly != null && animationTime < parabolaFly.GetDuration())
        {
            int parabolaIndexBefore;
            int parabolaIndexAfter;
            parabolaFly.GetParabolaIndexAtTime(animationTime, out parabolaIndexBefore);
            animationTime += Time.deltaTime;
            parabolaFly.GetParabolaIndexAtTime(animationTime, out parabolaIndexAfter);

            transform.position = parabolaFly.GetPositionAtTime(animationTime);

            if (parabolaIndexBefore != parabolaIndexAfter)
            {
                nextParbola = true;
            }

            //if (transform.position.y > HighestPoint.y)
            //HighestPoint = transform.position;
        }
        else if (Animation && parabolaFly != null && animationTime > parabolaFly.GetDuration())
        {
            animationTime = float.MaxValue;
            Animation     = false;
        }
        else if (!objName.Equals(ParabolaRoot.name))
        {
            parabolaFly = new ParabolaFly(ParabolaRoot.transform);
            RefreshTransforms(Speed);
            FollowParabola();
            objName = ParabolaRoot.name;
        }
    }
Exemplo n.º 2
0
    void OnDrawGizmos()
    {
        if (gizmo == null)
        {
            if (ParabolaRoot == null)
            {
                return;
            }

            gizmo = new ParabolaFly(ParabolaRoot.transform, max, min);
        }

        gizmo.RefreshTransforms(1f);
        if ((gizmo.Points.Length - 1) % 2 != 0)
        {
            return;
        }

        int     accur   = 50;
        Vector3 prevPos = gizmo.Points[0].position;

        for (int c = 1; c <= accur; c++)
        {
            float   currTime = c * gizmo.GetDuration() / accur;
            Vector3 currPos  = gizmo.GetPositionAtTime(currTime);
            float   mag      = (currPos - prevPos).magnitude * 2;
            Gizmos.color = new Color(mag, 0, 0, 1);
            Gizmos.DrawLine(prevPos, currPos);
            Gizmos.DrawSphere(currPos, 0.01f);
            prevPos = currPos;
        }
    }
    // Use this for initialization
    void Start()
    {
        parabolaFly = new ParabolaFly(ParabolaRoot.transform);

        if (Autostart)
        {
            RefreshTransforms(Speed);
            FollowParabola();
        }
    }
    public void FollowParabola()
    {
        parabolaFly = new ParabolaFly(ParabolaRoot.transform);

        RefreshTransforms(Speed);
        animationTime      = 0f;
        transform.position = parabolaFly.Points[0].position;
        Animation          = true;
        //HighestPoint = points[0].position;
    }
Exemplo n.º 5
0
    public void SetNewParabola()
    {
        parabolaFly = new ParabolaFly(ParabolaParent.GetChild(mCurrIndex).transform);
        mCurrIndex++;
        if (mCurrIndex > ParabolaParent.childCount - 1)
        {
            mCurrIndex = 0;
        }

        gizmo = null;
    }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        finish      = new UnityEvent();
        parabolaFly = new ParabolaFly(ParabolaRoot.transform);

        if (Autostart)
        {
            RefreshTransforms(Speed);
            FollowParabola();
        }
    }
Exemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     parabolaFly = new ParabolaFly(ParabolaRoot.transform);
     objName     = ParabolaRoot.name;
     //Debug.Log(objName);
     if (Autostart)
     {
         RefreshTransforms(Speed);
         FollowParabola();
     }
 }
    // Use this for initialization
    void Start()
    {
        car = GetComponent <Car>();

        if (Autostart)
        {
            parabolaFly = new ParabolaFly(ParabolaRoot.transform);
            RefreshTransforms(Speed);
            FollowParabola();
        }
    }
Exemplo n.º 9
0
    public void OnParabola()
    {
        parabolaFly = new ParabolaFly(ParabolaRoot.transform);

        if (Autostart)
        {
            //inParabola = true;
            RefreshTransforms(Speed);
            FollowParabola();
        }
    }
Exemplo n.º 10
0
    //void OnDrawGizmos()
    //{
    //    if (gizmo == null)
    //    {
    //        gizmo = new ParabolaFly(ParabolaRoot.transform);
    //    }

    //    gizmo.RefreshTransforms(1f);
    //    if ((gizmo.Points.Length - 1) % 2 != 0)
    //        return;

    //    int accur = 50;
    //    Vector3 prevPos = gizmo.Points[0].position;
    //    for (int c = 1; c <= accur; c++)
    //    {
    //        float currTime = c * gizmo.GetDuration() / accur;
    //        Vector3 currPos = gizmo.GetPositionAtTime(currTime);
    //        float mag = (currPos - prevPos).magnitude * 2;
    //        Gizmos.color = new Color(mag, 0, 0, 1);
    //        Gizmos.DrawLine(prevPos, currPos);
    //        Gizmos.DrawSphere(currPos, 0.01f);
    //        prevPos = currPos;
    //    }
    //}


    // Use this for initialization
    void Start()
    {
        ParabolaRoot = GameObject.Find("PointFamily");
        parabolaFly  = new ParabolaFly(ParabolaRoot.transform);

        if (Autostart)
        {
            RefreshTransforms(Speed);
            FollowParabola();
        }
    }
Exemplo n.º 11
0
    /*void DrawLine()
     * {
     *  int accur = 50;
     *  Vector3 prevPos = gizmo.Points[0].position;
     *  for (int c = 1; c <= accur; c++)
     *  {
     *      float currTime = c * GetDuration() / accur;
     *      Vector3 currPos = GetPositionAtTime(currTime);
     *      float mag = (currPos - prevPos).magnitude * 2;
     *      line.SetPosition(c, prevPos);
     *      //Gizmos.color = new Color(mag, 0, 0, 1);
     *      //Gizmos.DrawLine(prevPos, currPos);
     *      //Gizmos.DrawSphere(currPos, 0.01f);
     *      prevPos = currPos;
     *  }
     * }
     */

    // Use this for initialization
    void Start()
    {
        line   = GetComponent <LineRenderer>();
        player = GetComponentInParent <PlayerMovement>();

        parabolaFly = new ParabolaFly(ParabolaRoot.transform, this);

        if (Autostart)
        {
            RefreshTransforms(Speed);
            FollowParabola();
        }
    }
Exemplo n.º 12
0
 void Start()
 {
     parabolaFly = new ParabolaFly(ParabolaRoot.transform, max, min);
     RefreshTransforms(Speed);
 }
Exemplo n.º 13
0
 public void Reset() //when a new round starts, change the position of all
 {
     parabolaFly = new ParabolaFly(ParabolaRoot.transform, max, min);
     RefreshTransforms(Speed);
 }
Exemplo n.º 14
0
 public void ResetParabolaFly()
 {
     parabolaFly = new ParabolaFly(ParabolaRoot.transform);
 }
Exemplo n.º 15
0
    /*void OnDrawGizmos()
     * {
     *  if (gizmo == null)
     *  {
     *      gizmo = new ParabolaFly(ParabolaRoot.transform);
     *  }
     *
     *  gizmo.RefreshTransforms(1f);
     *  if ((gizmo.Points.Length - 1) % 2 != 0)
     *      return;
     *
     *  int accur = 50;
     *  Vector3 prevPos = gizmo.Points[0].position;
     *  for (int c = 1; c <= accur; c++)
     *  {
     *      float currTime = c * gizmo.GetDuration() / accur;
     *      Vector3 currPos = gizmo.GetPositionAtTime(currTime);
     *      float mag = (currPos - prevPos).magnitude * 2;
     *      Gizmos.color = new Color(mag, 0, 0, 1);
     *      Gizmos.DrawLine(prevPos, currPos);
     *      Gizmos.DrawSphere(currPos, 0.01f);
     *      prevPos = currPos;
     *  }
     * }*/

    // Use this for initialization

    /*void Start()
     * {
     *
     *  parabolaFly = new ParabolaFly(ParabolaRoot.transform);
     *
     *  if (Autostart)
     *  {
     *      RefreshTransforms(Speed);
     *      FollowParabola();
     *  }
     * }*/
    public void initParabola()
    {
        parabolaFly = new ParabolaFly(ParabolaRoot.transform);
    }