Beispiel #1
0
    /// <summary>
    /// Frame when Deltaflyer entered an airstream
    /// </summary>
    /// <param name="movingDirection"></param>
    public void enteredAirstream(AirStream stream)
    {
        Debug.Log("entered an airstream");
        stream.inAirstream.Add(this);
        currentAirStream  = stream;
        detectedAirStream = stream;

        Transform movingDir = stream.getMovingToPoint(this);

        foreach (AirStream tempStream in detectedAirStreams)
        {
            tempStream.enterParticleStream(this, stream.getOtherPoint(movingDir));
        }
        detectedAirStream.enterParticleStream(this, movingDir);

        inputMngr.velocity *= 2;

        foreach (ContactPoint cp in contactPoints)
        {
            cp.force = 40;
        }

        //foreach (AirStream tmpAs in detectedAirStreams)
        //{
        //    tmpAs.notifyParticles.gameObject.SetActive(true);
        //}
    }
Beispiel #2
0
    public void enteredDetectionRange(AirStream stream)
    {
        if (!isInDetectionRange)
        {
            //user is not in detection range yet, so entering detection range
            detectedAirStream = stream;
        }
        else if (!isInAirstream && detectedAirStream != stream)
        {
            if (stream.isClostestAirstream(this, stream, detectedAirStream))
            {
                //user detected an airstream that is closest. user is not in an airstream
                detectedAirStream = stream;
            }
            else
            {
                //user detected an airstream but it is NOT closest. user is not in an airstream
            }
        }
        if (isInAirstream && !detectedAirStreams.Contains(stream) && stream != detectedAirStream)
        {
            //user is in an airstream and detected by another airstream
            stream.enterParticleStream(this, stream.getOtherPoint(detectedAirStream.ps.transform));
        }

        detectedAirStreams.Add(stream);
        stream.inDetectionRange.Add(this);

        detectedAirstreamsCount++;
    }
Beispiel #3
0
    /// <summary>
    /// Action when Deltaflyer detects an Airstream
    /// </summary>
    /// <param name="stream"></param>
    /// <param name="closestPointOnLine"></param>
    public void detectAirstream(AirStream stream, Vector3 closestPointOnLine)
    {
        detectedAirStream = stream;
        RaycastHit hit;
        Vector3    direction = (this.raptor.raptorCollider.transform.position - closestPointOnLine).normalized;
        Ray        ray       = new Ray(closestPointOnLine, direction);

        rayToDeltaflyer = ray;
        int layer = 1 << LayerMask.NameToLayer("RaptorCollider");

        Physics.Raycast(ray, out hit, 9999999999999999999, layer);
        Vector3 closestImpactPoint = hit.point;

        gizClosesImpactPoint = closestImpactPoint;

        float dist     = Vector3.Distance(closestPointOnLine, closestImpactPoint) - stream.thickness;
        float range    = stream.thickness * stream._AlertMultiplyer - stream.thickness;
        float distPerc = (100 - (dist / (range / 100))) / 100;

        float radiusRange = maxImpactRadius - minImpactRadius;

        float radius = (radiusRange * distPerc) + minImpactRadius;

        impactRadius = radius;


        List <ContactPoint> points = contactPoints.Where(p => Vector3.Distance(p.transform.position, closestImpactPoint) <= radius).ToList();

        foreach (ContactPoint c in points)
        {
            c.force = getForce(stream.force, c.transform.position, closestImpactPoint, stream._MinAlertForcePerc, radius);
        }
    }
Beispiel #4
0
 public bool isClostestAirstream(DeltaFlyer df, AirStream CompareAirstream, AirStream CompareToAirstream)
 {
     if (getDistOfClosestPoint(df, CompareAirstream) < getDistOfClosestPoint(df, CompareToAirstream))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #5
0
    public void leftDetectionRange(AirStream stream)
    {
        if (!isInAirstream)
        {
            resetMotors();
        }
        if (detectedAirStream == stream)
        {
            detectedAirStream = null;
        }
        detectedAirStreams.Remove(stream);
        stream.inDetectionRange.Remove(this);
        stream.leaveParticleStream(this);

        detectedAirstreamsCount--;
    }
Beispiel #6
0
    /// <summary>
    /// Frame when Deltaflyer left an airstream
    /// </summary>
    public void leftAirstream()
    {
        foreach (AirStream stream in detectedAirStreams)
        {
            stream.leaveParticleStream(this);
        }

        currentAirStream.leaveParticleStream(this);
        currentAirStream.inAirstream.Remove(this);
        currentAirStream = null;

        inputMngr.velocity /= 2;

        //foreach (AirStream tmpAs in detectedAirStreams)
        //{
        //    tmpAs.notifyParticles.gameObject.SetActive(false);
        //}
    }
Beispiel #7
0
 public float getDistOfClosestPoint(DeltaFlyer df, AirStream stream)
 {
     return(Vector3.Distance(getClosestPoint(df, stream), df.transform.position));
 }
Beispiel #8
0
 public Vector3 getClosestPoint(DeltaFlyer df, AirStream stream)
 {
     return(ClosestPointOnLine(stream.startPoint.position, stream.endPoint.position, df.transform.position));
 }