Beispiel #1
0
    private static void AddRectsToDeadZone(List <Rect> drawRects1)
    {
        DrawRects.AddRects(drawRects1);

        var blah = GameObject.FindGameObjectsWithTag("SpritzTag");

        foreach (var rect in drawRects1)
        {
            for (int ii = 0; ii < blah.Length; ii++)
            {
                if (rect.Contains(blah[ii].transform.position))
                {
                    blah[ii].active = false;
                }
            }
        }
    }
Beispiel #2
0
    void FillDrawnArea()
    {
        SetLogStartTime();
        LogTimeDelta("Start");

        // Get dimensions
        int w = xVector3s.Count;
        int h = yVector3s.Count;

        // Work out edges.
        // @@ Issue: includes irrelevant internal edges
        bool[,] vsides = new bool[w - 1, h];
        bool[,] hsides = new bool[w, h - 1];
        MapLinesToSides(vsides, hsides, drawingLines);
        MapLinesToSides(vsides, hsides, lines);

        // Work out where our floo start Vector3s are.
        int fillx1;
        int filly1;
        int fillx2;
        int filly2;

        ExtractFloodStartVector3s(out fillx1, out filly1, out fillx2, out filly2);

        // Flood fill from each of the two places.
        List <Rect> drawRects1 = new List <Rect>();
        List <Rect> drawRects2 = new List <Rect>();
        float       area1      = 0.0f;
        float       area2      = 0.0f;

        bool baddyIn1;
        bool baddyIn2;

        Qix theQix = GameObject.Find("TheQix").GetComponent <Qix>();

        area1 = FloodFill(w, h, vsides, hsides, drawRects1, fillx1, filly1, out baddyIn1, theQix);
        area2 = FloodFill(w, h, vsides, hsides, drawRects2, fillx2, filly2, out baddyIn2, theQix);

        // Fill the appropriate area.
        // @@ Issue: we just do the smallest here - it should be the one without the baddy

        if (false)
        {
            if (area1 < area2)
            {
                DrawRects.AddRects(drawRects1);
            }
            else
            {
                DrawRects.AddRects(drawRects2);
            }
        }
        else
        {
            bool dump = false;

            if (!baddyIn1 && !baddyIn2)
            {
                MWRDebug.Log("In neither", MWRDebug.DebugLevels.INFLOOP1);
                dump = true;
            }
            else if (baddyIn1 && baddyIn2)
            {
                MWRDebug.Log("In both", MWRDebug.DebugLevels.INFLOOP1);
                dump = true;
            }

            if (dump)
            {
                string s = "Qix at " + theQix.position + "\r\n";

                s += "Rects1...(" + baddyIn1 + ")\r\n";

                foreach (Rect r in drawRects1)
                {
                    s += r;
                    s += (r.Contains(theQix.position));
                }

                s += "Rects2...(" + baddyIn2 + ")\r\n";

                foreach (Rect r in drawRects2)
                {
                    s += r;
                    s += (r.Contains(theQix.position));
                }

                MWRDebug.DumpToTraceFile(s);
            }

            if (baddyIn2)
            {
                AddRectsToDeadZone(drawRects1);
            }
            else
            {
                AddRectsToDeadZone(drawRects2);
            }
        }

        LogTimeDelta("End");
    }
Beispiel #3
0
 public static bool ValidToMoveTo(Vector3 newPos)
 {
     return(InGrid(newPos) && !DrawRects.InRects(newPos));
 }