Ejemplo n.º 1
0
    private void overlayGrid()
    {
        int startW = (int)-GameManager.instance.halfWidth + (int)Camera.main.transform.position.x;
        int endW   = (int)GameManager.instance.halfWidth + (int)Camera.main.transform.position.x;
        int startH = (int)-GameManager.instance.halfHeight + (int)Camera.main.transform.position.y;
        int endH   = (int)GameManager.instance.halfHeight + (int)Camera.main.transform.position.y;


        int count = 0;

        for (int i = startW; i <= endW; i++)
        {
            LineDrawer ld = new LineDrawer();
            ld.DrawLineInGameView(new Vector3(startW + count, startH, 0), new Vector3(startW + count, endH, 0), Color.yellow);
            lines.Enqueue(ld);
            count++;
        }
        count = 0;
        for (int i = startH; i <= endH; i++)
        {
            LineDrawer ld = new LineDrawer(0.05f);
            ld.DrawLineInGameView(new Vector3(startW, startH + count, 0), new Vector3(endW, startH + count, 0), Color.yellow);
            lines.Enqueue(ld);
            count++;
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        // m_pointerEvent.position = LaserPointer.
        Vector3 r = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTrackedRemote).eulerAngles;
        Vector3 e = new Vector3(r.x, r.y + 90, r.z);

        transform.rotation = Quaternion.Euler(e);
        OVRInput.Update();
        if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTrackedRemote))
        {
            //trigger button
            //select button
        }

        if (OVRInput.GetDown(OVRInput.Button.Back, OVRInput.Controller.RTrackedRemote))
        {
            //back button
            //show map
        }

        //line renderer
        lineDrawer.DrawLineInGameView(LaserStart.transform.position,
                                      LaserStart.transform.position + LaserStart.transform.forward * 50,
                                      Color.blue);
    }
Ejemplo n.º 3
0
    //Iterates through the tree of noise paths, and at every point draws debug lines to all children
    private void drawNoise(NoiseSource src)
    {
        foreach (TreeNode <NoiseSource> child in src.node.Children)
        {
            Vector3 start = src.origin;
            Vector3 end   = child.Value.origin;
            float   width = lineWidth;

            Color lineColor = Color.cyan;
            lineColor.a = 0.3f;

            //If world is miniaturized, change width and color so that they fit but are still visible.
            if (downscaled)
            {
                width       = width * scaleFactor * 2;
                lineColor.a = 0.6f;
            }


            //Diffraction
            if (child.Value.type == NoiseSource.HitType.DIFFRACTION_V ||
                child.Value.type == NoiseSource.HitType.DIFFRACTION_H)
            {
                //lineDrawer.DrawLineInGameView(start, end, width, Color.blue, lineContainer);
                lineDrawer.DrawLineInGameView(start, end, width, lineColor, lineContainer);
            }
            //Reflection
            if (child.Value.type == NoiseSource.HitType.REFLECTION)
            {
                //lineDrawer.DrawLineInGameView(start, end, width, Color.yellow, lineContainer);
                lineDrawer.DrawLineInGameView(start, end, width, lineColor, lineContainer);
            }
            //Final hit
            if (child.Value.type == NoiseSource.HitType.DIRECT)
            {
                //lineDrawer.DrawLineInGameView(start, end + Vector3.down, width, Color.green, lineContainer);
                lineDrawer.DrawLineInGameView(start, end + Vector3.down, width, lineColor, lineContainer);
            }
        }
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        Vector3    fwd = transform.TransformDirection(Vector3.forward);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 100))
        {
            lineDrawer.DrawLineInGameView(transform.position, hit.point, Color.green);
            if (hit.transform.GetComponent <Collider>())
            {
                Debug.Log("something hits");
                hit.collider.isTrigger = true;//trigger collider
                Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
            }
        }
    }
    public void DrawDebugLines()
    {
        float minx = -boxSize.x / 2;
        float miny = -boxSize.y / 2;
        float maxx = boxSize.x / 2;
        float maxy = boxSize.y / 2;

        Vector2 bl = transform.TransformPoint(new Vector2(minx, miny));
        Vector2 br = transform.TransformPoint(new Vector2(maxx, miny));
        Vector2 tl = transform.TransformPoint(new Vector2(minx, maxy));
        Vector2 tr = transform.TransformPoint(new Vector2(maxx, maxy));

        lineDrawerBottom.DrawLineInGameView(bl, br, lineColor);
        lineDrawerRight.DrawLineInGameView(br, tr, lineColor);
        lineDrawerTop.DrawLineInGameView(tr, tl, lineColor);
        lineDrawerLeft.DrawLineInGameView(tl, bl, lineColor);
    }
Ejemplo n.º 6
0
    public static void DrawLine(Vector3 position1, Vector3 position2, Color?color = null, float consistTime = 0, float lineSize = 0.2f)
    {
        if (Instance == null)
        {
            return;
        }
        var ld = new LineDrawer();

        Color defualtColor = Color.white;

        if (color.HasValue)
        {
            defualtColor = color.Value;
        }

        ld.DrawLineInGameView(position1, position2, defualtColor, lineSize);
        ld.SetTime(consistTime);
        Instance.listLineDrawer.Add(ld);
    }
Ejemplo n.º 7
0
    public void DrawPointsAndLines()
    {
        for (int i = 0; i < PointClouds.Count; i++)
        {
            Instantiate(sphere, PointClouds[i], Quaternion.identity);
        }


        foreach (DelaunayCell <Vertex2> cell in delaunay.Cells)
        {
            List <Vector3> triangleVertices = GetWorldCoordinate(cell.Simplex);
            LineDrawer     lineDrawer1      = new LineDrawer();
            LineDrawer     lineDrawer2      = new LineDrawer();
            LineDrawer     lineDrawer3      = new LineDrawer();
            lineDrawer1.DrawLineInGameView(triangleVertices[0], triangleVertices[1], new Color(248f / 255f, 197f / 255f, 48f / 255f, 1.0f));
            lineDrawer2.DrawLineInGameView(triangleVertices[1], triangleVertices[2], new Color(1f, 91f / 255f, 0f, 1.0f));
            lineDrawer3.DrawLineInGameView(triangleVertices[2], triangleVertices[0], Color.red);
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Draws the line from the end of the fishing rod to the top of the fishing hook
    /// TODO: Replace with more complex code drawing a texture
    /// </summary>
    private void DrawFishingLine()
    {
        // Draw the fishing line redder with more stress on it
        float lineStress = hookedFish.Count / maxFishOnHook;

        if (lineWeight / lineStrength > lineStress)
        {
            lineStress = lineWeight / lineStrength;
        }
        lineStress = (lineStress - 0.50f) * 2.0f;
        if (lineStress < 0.0f)
        {
            lineStress = 0.0f;
        }
        if (lineStress > 1.0f)
        {
            lineStress = 1.0f;
        }
        fishingLine.DrawLineInGameView(transform.position, hookPosition, new Color(1, 1 - lineStress, 1 - lineStress, 1));
    }
Ejemplo n.º 9
0
 void Update()
 {
     // every tick, cast a ray
     rayOrigin = transform.position;
     forward   = transform.forward;
     Physics.Raycast(rayOrigin, forward, out hit, range);
     // show it if we want to
     if (showLine)
     {
         l.DrawLineInGameView(rayOrigin, forward * 5 + rayOrigin, currColor);
     }
     // if a different color has been set, iterate downwards until it changes back to default
     if (colorCooldown > 0)
     {
         colorCooldown--;
     }
     else
     {
         currColor = Color.blue;
     }
 }
Ejemplo n.º 10
0
    public double[] GetSensorData()
    {
        //frontCenterHitDetection = Physics2D.Linecast(frontCenterSensorStart.position, frontCenterSensorLength.position, 1 << LayerMask.NameToLayer("InnerBoundary"));
        //frontRightHitDetection = Physics2D.Linecast(frontRightAngleSensorStart.position, frontRightAngleSensorLength.position, 1 << LayerMask.NameToLayer("InnerBoundary"));
        //frontLeftHitDetection = Physics2D.Linecast(frontLeftAngleSensorStart.position, frontLeftAngleSensorLength.position, 1 << LayerMask.NameToLayer("InnerBoundary"));
        //backCenterHitDetection = Physics2D.Linecast(backCenterSensorStart.position, backCenterSensorLength.position, 1 << LayerMask.NameToLayer("InnerBoundary"));
        //backRightHitDetection = Physics2D.Linecast(backRightAngleSensorStart.position, backRightAngleSensorLength.position, 1 << LayerMask.NameToLayer("InnerBoundary"));
        //backLeftHitDetection = Physics2D.Linecast(backLeftAngleSensorStart.position, backLeftAngleSensorLength.position, 1 << LayerMask.NameToLayer("InnerBoundary"));
        double[] sensorData = new double[6];
        float    fraction   = 0; //Percentage of distance to the nearest wall;

        Alpha = (byte)(GetComponent <Respawn>().isAlive ? 92 : 24);
        Blue  = 0;

        //Front Center Hit Detection
        frontCenterDistanceHitDetector = Physics2D.Linecast(frontCenterSensorStart.position, frontCenterSensorStart.position + frontCenterSensorStart.up * sensorLength, 1 << LayerMask.NameToLayer("InnerBoundary"));
        fraction = frontCenterDistanceHitDetector.collider != null ? frontCenterDistanceHitDetector.fraction : 1.0f;    //On hit, fraction is based on RayCast. But if no hit occured, it is 100%, meaning no obsticale along the distance of sensor.
        Green    = (byte)(fraction * 255);
        Red      = (byte)(255 - Green);
        if (levelManager.isDebugMode)
        {
            frontCenterLineDrawer.DrawLineInGameView(frontCenterSensorStart.position, frontCenterSensorStart.position + frontCenterSensorStart.up * sensorLength, new Color32(Red, Green, Blue, Alpha));
        }
        else
        {
            frontCenterLineDrawer.Destroy();
        }
        //if (frontCenterHitDetection)
        //{
        //    Debug.Log(frontCenterDistanceHitDetector.fraction);
        //}
        sensorData[0] = Functions.Map(fraction, 0.0, 1.0, -1.0, 1.0);

        //Front Right Angle Hit Detection
        frontRightDistanceHitDetector = Physics2D.Linecast(frontRightAngleSensorStart.position, frontRightAngleSensorStart.position + frontRightAngleSensorStart.up * sensorLength, 1 << LayerMask.NameToLayer("InnerBoundary"));
        fraction = frontRightDistanceHitDetector.collider != null ? frontRightDistanceHitDetector.fraction : 1.0f;
        Green    = (byte)(fraction * 255);
        Red      = (byte)(255 - Green);
        if (levelManager.isDebugMode)
        {
            frontRightLineDrawer.DrawLineInGameView(frontRightAngleSensorStart.position, frontRightAngleSensorStart.position + frontRightAngleSensorStart.up * sensorLength, new Color32(Red, Green, Blue, Alpha));
        }
        else
        {
            frontRightLineDrawer.Destroy();
        }
        //if (frontRightHitDetection)
        //{
        //    //Debug.Log(frontRightDistanceHitDetector.fraction);
        //}
        sensorData[1] = Functions.Map(fraction, 0.0, 1.0, -1.0, 1.0);

        //Front Left Angle Hit Detection
        frontLeftDistanceHitDetector = Physics2D.Linecast(frontLeftAngleSensorStart.position, frontLeftAngleSensorStart.position + frontLeftAngleSensorStart.up * sensorLength, 1 << LayerMask.NameToLayer("InnerBoundary"));
        fraction = frontLeftDistanceHitDetector.collider != null ? frontLeftDistanceHitDetector.fraction : 1.0f;
        Green    = (byte)(fraction * 255);
        Red      = (byte)(255 - Green);
        if (levelManager.isDebugMode)
        {
            frontLeftLineDrawer.DrawLineInGameView(frontLeftAngleSensorStart.position, frontLeftAngleSensorStart.position + frontLeftAngleSensorStart.up * sensorLength, new Color32(Red, Green, Blue, Alpha));
        }
        else
        {
            frontLeftLineDrawer.Destroy();
        }
        //if (frontLeftHitDetection)
        //{
        //    Debug.Log(frontLeftDistanceHitDetector.fraction);
        //}
        sensorData[2] = Functions.Map(fraction, 0.0, 1.0, -1.0, 1.0);

        //Back Center Hit Detection
        backCenterDistanceHitDetector = Physics2D.Linecast(backCenterSensorStart.position, backCenterSensorStart.position + backCenterSensorStart.up * sensorLength, 1 << LayerMask.NameToLayer("InnerBoundary"));
        fraction = backCenterDistanceHitDetector.collider != null ? backCenterDistanceHitDetector.fraction : 1.0f;
        Green    = (byte)(fraction * 255);
        Red      = (byte)(255 - Green);
        if (levelManager.isDebugMode)
        {
            backCenterLineDrawer.DrawLineInGameView(backCenterSensorStart.position, backCenterSensorStart.position + backCenterSensorStart.up * sensorLength, new Color32(Red, Green, Blue, Alpha));
        }
        else
        {
            backCenterLineDrawer.Destroy();
        }
        //if (backCenterHitDetection)
        //{
        //    Debug.Log(backCenterDistanceHitDetector.fraction);
        //}
        sensorData[3] = Functions.Map(fraction, 0.0, 1.0, -1.0, 1.0);

        //Back Right Angle Hit Detection
        backRightDistanceHitDetector = Physics2D.Linecast(backRightAngleSensorStart.position, backRightAngleSensorStart.position + backRightAngleSensorStart.up * sensorLength, 1 << LayerMask.NameToLayer("InnerBoundary"));
        fraction = backRightDistanceHitDetector.collider != null ? backRightDistanceHitDetector.fraction : 1.0f;
        Green    = (byte)(fraction * 255);
        Red      = (byte)(255 - Green);
        if (levelManager.isDebugMode)
        {
            backRightLineDrawer.DrawLineInGameView(backRightAngleSensorStart.position, backRightAngleSensorStart.position + backRightAngleSensorStart.up * sensorLength, new Color32(Red, Green, Blue, Alpha));
        }
        else
        {
            backRightLineDrawer.Destroy();
        }
        //if (backRightHitDetection)
        //{
        //    Debug.Log(backRightDistanceHitDetector.fraction);
        //}
        sensorData[4] = Functions.Map(fraction, 0.0, 1.0, -1.0, 1.0);

        //Back Left Angle Hit Detection
        backLeftDistanceHitDetector = Physics2D.Linecast(backLeftAngleSensorStart.position, backLeftAngleSensorStart.position + backLeftAngleSensorStart.up * sensorLength, 1 << LayerMask.NameToLayer("InnerBoundary"));
        fraction = backLeftDistanceHitDetector.collider != null ? backLeftDistanceHitDetector.fraction : 1.0f;
        Green    = (byte)(fraction * 255);
        Red      = (byte)(255 - Green);
        if (levelManager.isDebugMode)
        {
            backLeftLineDrawer.DrawLineInGameView(backLeftAngleSensorStart.position, backLeftAngleSensorStart.position + backLeftAngleSensorStart.up * sensorLength, new Color32(Red, Green, Blue, Alpha));
        }
        else
        {
            backLeftLineDrawer.Destroy();
        }
        //if (backLeftDistanceHitDetector)
        //{
        //    Debug.Log(backLeftDistanceHitDetector.fraction);
        //}
        sensorData[5] = Functions.Map(fraction, 0.0, 1.0, -1.0, 1.0);

        return(sensorData);
    }