Exemple #1
0
    public static void zoom_out_building(string input)
    {
        string par_city_path = input;

        // city_class tmpCity = initCity(par_city_path);
        foreach (building_class i in curr_city.building_list)
        {
            if (i.obj.tag != "Base")
            {
                // print("Destroying " + i.obj.tag);
                Destroy(i.obj);
            }
            else
            {
                i.obj.GetComponent <MeshRenderer>().enabled = true;
                i.obj.layer = LayerMask.NameToLayer("Default");
            }
        }
        Destroy(curr_city.par_bldng.obj);
        // Destroy(newPlatform.GetComponent<build_prop>().parent_class.city_of.par_bldng);
        // curr_city = tmpCity;
        curr_city = initCity(par_city_path);

        // returnCity(newPlatform);
        return;
    }
Exemple #2
0
    public static void zoom_to_building(GameObject new_plat)
    {
        // runZoomAnimation();
        GameObject newPlatform = new_plat;
        // clearCity(new_plat);

        // Debug.Log("Going to "+ newPlatform.GetComponent<build_prop>().parent_class.path + "=============================");

        city_class tmpCity = initCity(newPlatform.GetComponent <build_prop>().parent_class.path);

        //Destroy previous city objects n stuff
        foreach (building_class i in curr_city.building_list)
        {
            if (i.obj.tag != "Base")
            {
                // print("Destroying " + i.obj.tag);
                Destroy(i.obj);
            }
            else
            {
                i.obj.GetComponent <MeshRenderer>().enabled = true;
                i.obj.layer = LayerMask.NameToLayer("Default");
            }
        }
        Destroy(curr_city.par_bldng.obj);
        // Destroy(newPlatform.GetComponent<build_prop>().parent_class.city_of.par_bldng);
        curr_city = tmpCity;

        // returnCity(newPlatform);
        return;
    }
Exemple #3
0
 void Start()
 {
     pathForCity = Intro.userDirInput;
     Debug.Log("We're in! " + pathForCity);
     updateUI(pathForCity);
     curr_city = initCity(pathForCity, true);
     //set up camera rotate point
     camRotPoint = new GameObject();
     camRotPoint.transform.position = new Vector3(curr_city.par_bldng.obj.transform.position.x, curr_city.par_bldng.obj.transform.position.y, curr_city.par_bldng.obj.transform.position.z);
     camRotPoint.transform.Rotate(0, 135, 0);
     GameObject.Find("Main Camera").transform.parent = camRotPoint.transform;
 }
Exemple #4
0
    public static city_class initCity(string input, bool starter = false)
    {
        //to find parent and make path conform to windows path api (only accepts one slash at the moment)
        Debug.Log("Line 88: " + input);
        int    par_path_index = 0;
        int    slashA         = 0;
        int    slashB         = 0;
        int    slashCount     = 0;
        int    k        = 0;
        bool   winSytax = false;
        string par_path = "_";

        if (input[input.Length - 1] == ':')
        {
            input = input + @"\";
            // Debug.Log("Line 101: " + input + " => this is a Disk!");
            par_path = Path.GetFullPath(input);
        }
        else
        {
            try{
                slashA = input.LastIndexOf(@"\") - 1;
                Debug.Log(slashA);
                par_path = input.Substring(0, slashA);
            }catch (ArgumentOutOfRangeException) {
                par_path = Path.GetPathRoot(input);
            }
        }
        Debug.Log("parent_path = " + par_path + " slashCount = " + slashCount);
        Debug.Log("new input = " + input);
        city_class new_city = new city_class();

        file_rtvr.FetchAll(input);

        //prepare platform/host building
        new_city.par_bldng     = new building_class();
        new_city.par_bldng.obj = GameObject.CreatePrimitive(PrimitiveType.Cube);
        // new_city.par_bldng.obj.tag = "par_bld";
        // Debug.Log("ADDING PATH: " + par_path +  "ADDING INPUT: " + input);
        if (par_path != "_")
        {
            // Debug.Log("&&&&&&&&&&&&&&&&&&&&&&&&&");
            new_city.par_bldng.obj.name = input;
            new_city.par_bldng.path     = par_path;
        }
        else
        {
            Debug.Log("AYO LOOK HERE: " + input + "parentpath is: " + par_path);
            // input = input + "\\\\"; //TODO when going backwards, the drive is saved as D: and not D:\\ therefore, when the retriever searches for "D:\X", it probably wont find X.
            new_city.par_bldng.obj.name = input;
            new_city.par_bldng.path     = input;
        }
        new_city.par_bldng.obj.AddComponent <build_prop>().parent_city = new_city;
        new_city.par_bldng.city_of = par_path;

        //finding city size =================================================
        int   city_list_size = file_rtvr.FilesAndDirectories.Count;
        float x = 1f;

        while (x * x < city_list_size)
        {
            x = x + 1f;
        }
        new_city.par_bldng.obj.transform.localScale = new Vector3(GlobalSize(x), GlobalSize(0.29f), GlobalSize(x));
        new_city.par_bldng.obj.transform.position   = new Vector3(GlobalSize(x / 2), -GlobalSize(0.1f), GlobalSize(x / 2));
        new_city.par_bldng.obj.GetComponent <Renderer>().material.SetColor("_Color", Color.red);
        // new_city.par_bldng.obj.AddComponent<build_prop>().child_city = new_city;
        new_city.par_bldng.obj.tag = "Base";
        new_city.par_bldng.obj.AddComponent <build_prop>();
        new_city.par_bldng.obj.GetComponent <build_prop>().fileName     = Path.GetFullPath(input);
        new_city.par_bldng.obj.GetComponent <build_prop>().parent_class = new_city.par_bldng;


        //================City Creation======================================
        new_city.building_list = new List <building_class>();
        //finding max size
        float max = 0.0f;

        for (int i = 0; i < file_rtvr.FilesAndDirectories.Count; i++)
        {
            if ((float)file_rtvr.FilesAndDirectories[i].ByteSize > max)
            {
                max = (float)file_rtvr.FilesAndDirectories[i].ByteSize;
            }
            // Debug.Log(file_rtvr.FilesAndDirectories[i].ToString());
        }

        GlobalNormalizer = GlobalNormalizer_orig / max;
        // Debug.Log("GlobalNormalizer: " + GlobalNormalizer);
        int a = 0;
        int b = 0;

        for (int i = 0; i < file_rtvr.FilesAndDirectories.Count; i++)
        {
            new_city.building_list.Add(new building_class());
            new_city.building_list[i].path = input + "\\\\" + file_rtvr.FilesAndDirectories[i].Name;
            new_city.building_list[i].item = file_rtvr.FilesAndDirectories[i];

            //different initializations depending on file type
            if (file_rtvr.FilesAndDirectories[i].IsType == PathItem.Type.File)
            {
                new_city.building_list[i].obj      = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                new_city.building_list[i].obj.tag  = "File";
                new_city.building_list[i].obj.name = file_rtvr.FilesAndDirectories[i].Name;
                new_city.building_list[i].obj.GetComponent <Renderer>().material.color = Color.grey;
                new_city.building_list[i].obj.transform.localScale = new Vector3(GlobalUnit * 0.7f, Norm(GlobalSize((float)new_city.building_list[i].item.ByteSize)) / 2, GlobalUnit * 0.7f);
                new_city.building_list[i].obj.transform.position   = new Vector3(GlobalSize(a + 0.5f), (((new_city.building_list[i].obj.transform.localScale.y)) + ((GlobalSize(0.1f)) / 2)), GlobalSize(b + 0.5f));
            }
            else if (file_rtvr.FilesAndDirectories[i].IsType == PathItem.Type.Directory)
            {
                new_city.building_list[i].obj      = GameObject.CreatePrimitive(PrimitiveType.Cube);
                new_city.building_list[i].obj.tag  = "Directory";
                new_city.building_list[i].obj.name = file_rtvr.FilesAndDirectories[i].Name;
                // new_city.building_list[i].obj.GetComponent<Renderer>().material.color = Color.white;
                if (Norm(GlobalSize((float)new_city.building_list[i].item.ByteSize)) / 2 < 0.1)
                {
                    new_city.building_list[i].obj.transform.localScale = new Vector3(GlobalUnit * 0.7f, 0.1f, GlobalUnit * 0.7f);
                }
                else
                {
                    new_city.building_list[i].obj.transform.localScale = new Vector3(GlobalUnit * 0.7f, Norm(GlobalSize((float)new_city.building_list[i].item.ByteSize)) / 2, GlobalUnit * 0.7f);
                }
                // new_city.building_list[i].obj.transform.localScale = new Vector3(GlobalUnit * 0.7f, Norm(GlobalSize((float)new_city.building_list[i].item.ByteSize))/2, GlobalUnit * 0.7f);
                // Debug.Log(new_city.building_list[i].obj.transform.localScale.y);
                new_city.building_list[i].obj.transform.position = new Vector3(GlobalSize(a + 0.5f), (((new_city.building_list[i].obj.transform.localScale.y) / 2) + ((GlobalSize(0.1f)) / 2)), GlobalSize(b + 0.5f));
            }
            new_city.building_list[i].obj.AddComponent <build_prop>();
            new_city.building_list[i].obj.GetComponent <build_prop>().fileName     = file_rtvr.FilesAndDirectories[i].Name;
            new_city.building_list[i].obj.GetComponent <build_prop>().parent_class = new_city.building_list[i];
            new_city.building_list[i].obj.GetComponent <build_prop>().size         = (float)file_rtvr.FilesAndDirectories[i].ByteSize;

            //city iterator
            b++;
            if (b >= x)
            {
                a++;
                b = 0;
            }
        }
        Debug.Log("New city made");
        return(new_city);
    }