Exemplo n.º 1
0
    /*void Update ()
     * {
     *      Vector3 origin = transform.position;
     *      Vector3 target = Conversion.mouseToMetres2D ();
     *      refresh = false;
     *      time += Time.deltaTime;
     *      if (time >= majorRefreshRate) {refresh = true; time = 0;}
     *      if (lengthScaling) {
     *              float distance = Vector3.Distance (origin, target) / 5;
     *              turb = turblulence * distance;
     *              turbNoise = turbalanceNoise * distance;
     *              line.widthMultiplier = width * distance;
     *      } else
     *      {
     *              turb = turblulence;
     *              line.widthMultiplier = width;
     *              turbNoise = turbalanceNoise;
     *      }
     *      target = Conversion.mouseToMetres2D ();
     *      positions [0] = origin;
     *      positions [positions.Length-1] =  target;
     *
     *      float minorTurb = turb * ratio;
     *      float minorNoise = turbNoise * ratio;
     *      for (int i = 1; i <= majorSegments; i++)
     *      {
     *              if (refresh)
     *              {
     *                      Vector3 position = (target - origin) * i / (majorSegments) + origin;
     *                      position += RandomOffset (turb, turbNoise);
     *                      positions [i * minorSegments] = position;
     *              }
     *              Vector3 minorOrigin = positions [(i - 1)*minorSegments];
     *              Vector3 minorTarget = positions [i*minorSegments];
     *              for (int a = 1; a <= minorSegments; a++)
     *              {
     *                      Vector3 minorPosition = (minorTarget-minorOrigin) * a / (minorSegments) + minorOrigin;
     *                      minorPosition += RandomOffset(minorTurb,minorNoise);
     *                      positions [(i - 1)*minorSegments + a] = minorPosition;
     *              }
     *      }
     *      line.positionCount = positions.Length;
     *      line.SetPositions (positions);
     * }*/
    public void Strike(Vector3 origin, Vector3 target)
    {
        LightningData ld = GetPreset(-1);

        ld.SetPath(origin, target);
        ld.Render();
    }
Exemplo n.º 2
0
 IEnumerator MajorNoise(Transform source, Transform destination, LightningData ld)
 {
     while (true)
     {
         ld.SetPath(source.position, destination.position);
         yield return(new WaitForSeconds(ld.Delay()));
     }
 }
Exemplo n.º 3
0
    IEnumerator MaintainTether(Transform source, Transform destination, LightningData ld, Condition condition)
    {
        ld.SetPath(source.position, destination.position);
        IEnumerator minor = MinorNoise(ld);

        StartCoroutine(minor);
        IEnumerator major = MajorNoise(source, destination, ld);

        StartCoroutine(major);
        while (condition())
        {
            ld.positions [0] = source.position;
            ld.positions [ld.positions.Length - 1] = destination.position;
            ld.Render();
            yield return(null);
        }
        StopCoroutine(minor);
        StopCoroutine(major);
        ld.renderer.reserved = false;
        yield return(new WaitForEndOfFrame());
    }