예제 #1
0
 protected void BaseStartUS()
 {
     BuildDebug.Log(name + ": Beginning Update Search");
     loops = 0;
     path.Clear();
     line.positionCount      = 0;
     realTimeSolutionStarted = true;
     BreadcrumbManager.singleton.ResetCrumbs();
 }
예제 #2
0
    public static void Log(string message)
    {
        if (Instance == null)
        {
            Instance = (Instantiate(Resources.Load("BuildDebugCanvas")) as GameObject).transform.GetChild(1).GetComponent <BuildDebug>();
        }

        Instance.LogMessage(message);
    }
예제 #3
0
    public void Init(Environment Env)
    {
        BuildDebug.Log("Initializing " + name);
        SetDeltas();
        env       = Env;
        initState = env.startState;

        transform.position   = env.CellRepPos(initState);
        transform.localScale = new Vector2(Env.cellSize, Env.cellSize);
    }
예제 #4
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
예제 #5
0
 protected void BaseEndUS()
 {
     BuildDebug.Log("--------------------");
     BuildDebug.Log(name + ": Ending Update Search");
     BuildDebug.Log("Number of loops: " + loops);
     Debug.Log("About to Log path length");
     BuildDebug.Log("Path Length: " + path.Count);
     LogMemory();
     BuildDebug.Log("--------------------");
     realTimeSolutionStarted = false;
 }
예제 #6
0
    void Awake()
    {
        canvas = FindObjectOfType <Canvas>();
        BuildDebug.Log("Starting Load");
        string EnvDir = Save.GetDirectory();

        BuildDebug.Log("Loading Directory: " + EnvDir);
        rawEnv = Save.LoadEnvironment(EnvDir);
        GenerateGrid();
        GenerateEnvVisuals();
    }
예제 #7
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            BuildDebug.Log("Ending Program");
            Application.Quit();
        }

        if (Input.mouseScrollDelta != Vector2.zero)
        {
            cameraZoom               = Mathf.Clamp(cameraZoom - (Input.mouseScrollDelta.y * scrollSense), minCameraSize, maxCameraSize);
            cam.orthographicSize     = cameraZoom;
            textCam.orthographicSize = cameraZoom;
        }

        if (Input.GetMouseButtonDown(2))
        {
            cameraZoom               = Mathf.Clamp(cameraDefault, minCameraSize, maxCameraSize);
            cam.orthographicSize     = cameraZoom;
            textCam.orthographicSize = cameraZoom;
        }

        bool startedBot = false;

        for (int i = 0; i < robots.Count; ++i)
        {
            if (CheckKey(i + 1))
            {
                startedBot = true;
            }
            if (robots[i].moved)
            {
                BreadcrumbManager.singleton.PlaceCrumb(robots[i].transform.position, i);
            }
            robots[i].moved = false;
            robots[i].UpdateSolutionControl(CheckKey(i + 1));
        }

        if (startedBot)
        {
            for (int i = 0; i < robots.Count; ++i)
            {
                if (!CheckKey(i + 1))
                {
                    robots[i].SilentEndUS();
                }
                robots[i].gameObject.SetActive(CheckKey(i + 1));
            }
        }
    }
예제 #8
0
 public static string GetDirectory()
 {
     if (File.Exists("FileToLoad.txt"))
     {
         BuildDebug.Log("Directory instructions found");
         StreamReader SR = new StreamReader("FileToLoad.txt");
         return(SR.ReadLine());
     }
     else
     {
         BuildDebug.Log("Directory instructions missing!");
     }
     return("Environments/RobotNav-test.txt");
 }
예제 #9
0
 protected override void LogMemory()
 {
     BuildDebug.Log("End Memory Used: " + nodeQueue.Count + " Nodes in queue, " + triedNodes.Count + " Nodes in list = " + (nodeQueue.Count + triedNodes.Count));
 }
 protected override void LogMemory()
 {
     BuildDebug.Log("End Memory Used: " + BFSNodes.Count + " Nodes in tree");
 }
예제 #11
0
 protected virtual void LogMemory()
 {
     BuildDebug.Log("End Memory Used: Unknown");
 }
 protected override void LogMemory()
 {
     BuildDebug.Log("End Memory Used: " + usedNodes.Count + " Nodes in complete tree + "
                    + path.Count + " Nodes in main Branch = " + (path.Count + usedNodes.Count));
 }
예제 #13
0
    public static RawEnvironment LoadEnvironment(string path)
    {
        if (!File.Exists(path))
        {
            BuildDebug.Log("ERROR loading chosen directory. Swapping to default Environment");
            if (File.Exists("Environments/RobotNav-test.txt"))
            {
                path = "Environments/RobotNav-test.txt";
            }
            else
            {
                BuildDebug.Log("ERROR loading default directory.");
                path = "";
            }
        }

        if (File.Exists(path))
        {
            BuildDebug.Log("Loading Chosen Environment");
            RawEnvironment RE    = new RawEnvironment();
            List <string>  lines = new List <string>();
            StreamReader   SR    = new StreamReader(path);
            while (!SR.EndOfStream)
            {
                lines.Add(SR.ReadLine());
            }

            if (lines.Count < 3)
            {
                Debug.LogError("Environment file incomplete");
                return(new RawEnvironment());
            }

            RE.gridSize = lines[0].StringToV2();
            //Swap the x and y values to make later code simpler.
            int temp = RE.gridSize.x;
            RE.gridSize.x = RE.gridSize.y;
            RE.gridSize.y = temp;
            RE.startPos   = lines[1].StringToV2();

            string[] goals = lines[2].Split('|');
            RE.goalsPos = new List <Vector2Int>();

            foreach (string G in goals)
            {
                RE.goalsPos.Add(G.StringToV2());
            }
            lines.RemoveRange(0, 3);

            if (lines.Count == 0)
            {
                Debug.LogWarning("No walls in Environment");
                return(new RawEnvironment());
            }

            RE.wallRects = new List <Rect>();
            foreach (string wall in lines)
            {
                RE.wallRects.Add(wall.StringToRect());
            }

            return(RE);
        }
        return(new RawEnvironment());
    }
예제 #14
0
    protected override void CancelUpdateSolution()
    {
        BaseEndUS();

        BuildDebug.Log("Cancelling Depth First");
    }