Пример #1
0
    public void OpenCategory(string filename, bool forward = true)
    {
        folderLevel = FolderLevel.PickBundle;
        AllNodeStrings.Clear();
        returnToMenu     = false;
        this.topCategory = (BundleItem.TopCategory)Enum.Parse(typeof(BundleItem.TopCategory), filename);
        bundleItems      = TODV2.GetItemByTopCategory(this.topCategory);



        foreach (BundleItem b in bundleItems)
        {
//                if (File.Exists(Globals.BUNDLEPATH + b.bundle.ToString().ToLower()))

            AllNodeStrings.Add(b.BundleName.ToString() + ".bundle");
        }

        AllNodeStrings = AllNodeStrings.Distinct().ToList();

        if (forward)
        {
            ResetCurrentPage();
        }
        else
        {
            GetSavedPage();
        }
        BuildNodes();
    }
Пример #2
0
    public void LoadFavList(List <int> fav)
    {
        folderLevel = FolderLevel.CustomList;
        nodeItems.Clear();
        AllNodeStrings.Clear();

        foreach (int i in fav)
        {
            nodeItems.Add(TODV2.GetItemByID(i));
            AllNodeStrings.Add(i.ToString() + ".prefab");
        }
        ResetCurrentPage();
        BuildNodes();
    }
Пример #3
0
    private void ReplacePH()
    {
        foreach (GameObject ph in placeholders)
        {
            DioramaObject dio = ph.GetComponent <DioramaObject>();
            BundleItem    t   = TODV2.GetItemByID(dio.todID);

            string path = t.TopFolder.ToString() + @"\";
            path += t.BundleName + @"\" + (t.FolderPath.Replace(",", @"\")) + @"\";
            path += t.prefabName.Replace(".prefab", "");
            path += " Rigged";
            GameObject next = GameObject.Instantiate(Resources.Load(path, typeof(GameObject)), ph.transform.position, ph.transform.rotation, ph.transform.parent) as GameObject;
            ph.SetActive(false);
        }
    }
Пример #4
0
    public void IControlUpdate()
    {
        manager.modeStringEnum = GameManager.ModeString.View_Mode;

        if (control.LB() && softSelected)
        {
            ignore.Add(softSelected);
        }

        if (control.RB())
        {
            if (softSelected)
            {
                PickupSelected();
                WorldBuilderMain.ChoosePlaceMode();
            }
            return;
        }

        if (control.RHY() != 0)
        {
            Vector3 pos = manager.pointerGroup.localPosition;
            pos.y -= control.RHY() * Time.deltaTime / 4f;
            pos.z += control.RHY() * Time.deltaTime / 4f;
            manager.pointerGroup.localPosition = pos;
        }


        if (control.RB2())
        {
            if (softSelected)
            {
                if (TODV2.GetItemByID(softSelected.GetComponent <DioramaObject>().todID).hasAnimation)
                {
                    PickupSelected();
                    PoserMode.Instance().SetupMode();
                    return;
                }

                IWorldEvent iwe = softSelected.GetComponent <IWorldEvent>();
                if (iwe != null)
                {
                    iwe.StartEvent(WorldBuilderMain.Instance());
                    return;
                }
            }
        }
    }
Пример #5
0
    public void LoadZoneList()
    {
        folderLevel = FolderLevel.CustomList;
        nodeItems.Clear();
        AllNodeStrings.Clear();
        nodeItems.Add(TODV2.GetItemByID(14803));
        AllNodeStrings.Add("New Zone.zone");
        foreach (Zone z in WorldBuilderMain.currentWorld.zones)
        {
            nodeItems.Add(TODV2.GetItemByID(14803));
            string s = z.zoneId + ":" + ((z.name == null || z.name.Length == 0) ? @"<No Name>" : z.name) + ".zone";
            AllNodeStrings.Add(s);
        }

        ResetCurrentPage();
        BuildNodes();
    }
Пример #6
0
    private void OpenBundle(string filename, bool forward = true)
    {
        folderLevel = FolderLevel.SubFolderLevelOne;
        AllNodeStrings.Clear();
        currentPath.Add(filename);

        this.bundleName = (BundleItem.BundleNames)Enum.Parse(typeof(BundleItem.BundleNames), filename);
        //  AssetBundleRequest req = AssetBundleManager.RequestBundle(this.bundleName);

        AssetBundleCreateRequest a = AssetBundleManager.GetAssetBundle(this.bundleName);

        ab = a.assetBundle;

        bundleItems = TODV2.GetItemByBundle(this.bundleName);

        foreach (BundleItem b in bundleItems)
        {
            string[] tokens = b.path.Split(',');
            string   next;
            if (currentFolderIndex < tokens.Length)
            {
                next = tokens[currentFolderIndex];
                if (next.ToLower() != "hidden" || Application.isEditor || Debug.isDebugBuild)
                {
                    AllNodeStrings.Add(next + ".subfolder");
                }
            }
        }

        AllNodeStrings = AllNodeStrings.Distinct().ToList();

        if (forward)
        {
            ResetCurrentPage();
        }
        else
        {
            GetSavedPage();
        }

        BuildNodes();
    }
Пример #7
0
    void Start()
    {
        KeyboardMode.Hook();

        int i = Application.dataPath.LastIndexOf("/");

        Globals.WORLDPATH = Application.dataPath.Substring(0, i) + "/Worlds/";
        Directory.CreateDirectory(Globals.WORLDPATH);

        Globals.BACKUPS = Application.dataPath.Substring(0, i) + "/BackupFiles/";
        Directory.CreateDirectory(Globals.BACKUPS);

        Globals.BUNDLEPATH = Application.dataPath.Substring(0, i) + "/ArtPacks/";
        Directory.CreateDirectory(Globals.BUNDLEPATH);

        Globals.TEMPFOLDER = Application.dataPath.Substring(0, i) + "/DWTemp/";
        Directory.CreateDirectory(Globals.TEMPFOLDER);

        Globals.TODPATH = Application.dataPath.Substring(0, i) + "/tod2.tbl";

        Globals.LEGACYPATH = Application.dataPath.Substring(0, i) + "/all.tbl";

        Globals.FAVPATH = Application.dataPath.Substring(0, i) + "/dw.fav";
        favorites       = TODV2.LoadGeneric <List <int> >(Globals.FAVPATH);
        if (favorites == default(List <int>))
        {
            favorites = new List <int>();
        }

        if (Application.isEditor)
        {
            AssetBundleCreateRequest a = AssetBundleManager.Polygon_Adventure;
        }
        else
        {
            AssetBundleManager.Prewarm();
        }

        SL.Add <GameManager>(this);
        SL.Add <Keyboard>(keyboard);

        hmd = rig.GetComponent <IVRHmd>();
        hmd.Init();
        SL.Add <IVRHmd>(hmd);

        control = rig.GetComponent <IVRControl>();
        control.Init(this);
        SL.Add <IVRControl>(control);

        poserWidget.SetActive(false);

        if (control.GetControlStyle() == ControlerStyle.ViveWand)
        {
            lb1 = "Down";
            lb2 = "Up";
            rb1 = "Down";
            rb2 = "Up";
        }
        else if (control.GetControlStyle() == ControlerStyle.RiftTouch)
        {
            lb1 = "X";
            lb2 = "Y";
            rb1 = "A";
            rb2 = "B";
        }

        activeFM.Init(this);
        SL.Add <FileManagerV2>(activeFM);

        SetPrefs();
        DeactivateStarter();

        mode = WorldBuilderMain.Instance();

        if (startPoint.position == Vector3.zero)
        {
            CalibrationMode.Instance().SetupMode();
        }
        else
        {
            TitleScreenMode.Instance().SetupMode();
        }
    }
Пример #8
0
    IEnumerator RebuildGo(DioramaObjectSaver dos, Transform transform, bool addCollider = true)
    {
        GameObject go = null;

        if (dos.todID >= 0)
        {
            BundleItem t = TODV2.GetItemByID(dos.todID);

            string path = t.TopFolder.ToString() + @"\";
            path += t.BundleName + @"\" + (t.FolderPath.Replace(",", @"\")) + @"\";
            path += t.prefabName.Replace(".prefab", "");

            if (t.loadFromResources)
            {
                go = GameObject.Instantiate(Resources.Load(path, typeof(GameObject))) as GameObject;
            }
            else
            {
                try
                {
                    AssetBundle ab = AssetBundleManager.GetAssetBundle(t.BundleName).assetBundle;
                    go = Instantiate(ab.LoadAsset(t.PrefabName, typeof(GameObject))) as GameObject;
                    Common.ReassignTextures(go, t.HasLight);
                }
                catch (Exception e)
                {
                    Debug.Log(t.prefabName + " ID: " + t.id + " failed to load -- " + e.StackTrace);
                }
            }
            Common.ReassignTextures(go, t.HasLight);

            go.name                    = "Object";
            go.transform.parent        = transform;
            go.transform.localPosition = dos.savedPos;
            go.transform.localRotation = dos.savedRot;
            go.transform.localScale    = dos.savedScale;


            DioramaObject newDio = go.AddComponent <DioramaObject>();
            newDio.todID      = dos.todID;
            newDio.savedPos   = dos.savedPos;
            newDio.savedRot   = dos.savedRot;
            newDio.savedScale = dos.savedScale;

            newDio.gridScale = t.gridScale;
            newDio.layer     = dos.layer == 0 ? 1 : dos.layer;

            Common.DestroyAll(go);

            CheckAnimation(go);
            List <CharPose> pose     = dos.savedCharPose;
            Transform[]     allTrans = go.GetComponentsInChildren <Transform>();
            for (int i = 0; i < allTrans.Count(); i++)
            {
                CharPose next = pose[i];
                allTrans[i].localPosition = next.savedPos;
                allTrans[i].localRotation = next.savedRot;
            }

            TextMeshPro tmp = go.GetComponentInChildren <TextMeshPro>();
            if (tmp)
            {
                tmp.text = dos.text;
            }

            if (go.tag == "Untagged")
            {
                go.tag = "TableObject";
            }

            //IEventScale ies = go.GetComponentInChildren<IEventScale>();
            //if (ies != null)
            //{
            //    go.transform.localScale = Vector3.one;
            //    for (int i = 0; i < dos.savedScale.x; i++)
            //    {
            //        ies.ScaleUp();
            //    }
            //}
        }
        yield return(null);
    }
Пример #9
0
    public void ButtonActivate(Node n, bool shift = false)
    {
        if (n.nodeType == "prefab")
        {
            if (shift)
            {
                if (!manager.favorites.Contains(n.todID))
                {
                    manager.favorites.Add(n.todID);
                    manager.SetToolTip("Added " + n.fileName + " to favorites.");
                }
                else
                {
                    manager.favorites.Remove(n.todID);
                    manager.SetToolTip("Removed " + n.fileName + " from favorites.");
                }
                TODV2.SaveGeneric <List <int> >(Globals.FAVPATH, manager.favorites);
            }
            else
            {
                SpawnNewObject(n);
                ChoosePlaceMode();
            }
        }
        else if (n.nodeType == "zone")
        {
            int id       = -1;
            int lastChar = n.fileName.IndexOf(":");
            if (lastChar < 0 || !int.TryParse(n.fileName.Substring(0, lastChar), out id))
            {
                id = currentWorld.zones.Max(x => x.zoneId) + 1;
            }


            if (shift)
            {
                currentZoneId = id;
                LoadZone();
                manager.activeFM.LoadZoneList();
                return;
            }

            SpawnNewObject(n);
            TextMeshPro tmp = selectedObject.GetComponentInChildren <TextMeshPro>();
            if (tmp)
            {
                tmp.text = id.ToString();
            }
            manager.activeFM.CloseFolder();
            ChoosePlaceMode();
        }
        else if (n.nodeType == "button")
        {
            switch (n.fileName)
            {
            case "QUALITYUP":
                manager.quality++;
                if (manager.quality >= QualitySettings.names.Length)
                {
                    manager.quality = QualitySettings.names.Length - 1;
                }
                QualitySettings.SetQualityLevel(manager.quality, true);
                manager.SetToolTip(QualitySettings.names[manager.quality] + " Setting Selected (For this session only)");
                return;

            case "QUALITYDOWN":
                manager.quality--;
                if (manager.quality < 0)
                {
                    manager.quality = 0;
                }
                QualitySettings.SetQualityLevel(manager.quality, true);
                manager.SetToolTip(QualitySettings.names[manager.quality] + " Setting Selected (For this session only)");
                return;

            case "EXPLORE":
                ExploreMode.Instance().SetupMode();
                return;

            case "LIGHTSETUP":
                LightSetupMode.Instance().SetupMode();
                return;

            case "RESETLIGHT":
                TOD_Sky.Instance.Day.LightIntensity   = 1;
                TOD_Sky.Instance.Night.LightIntensity = 5;
                TOD_Sky.Instance.Cycle.Hour           = 12;
                PlayerPrefs.SetFloat("DayIntensity", TOD_Sky.Instance.Day.LightIntensity);
                PlayerPrefs.SetFloat("NightIntensity", TOD_Sky.Instance.Night.LightIntensity);
                PlayerPrefs.SetFloat("TimeOfDay", TOD_Sky.Instance.Cycle.Hour);
                PlayerPrefs.Save();
                return;

            case "VIEWPOINT":
                manager.SetToolTip("Coming Soon");
                return;

            case "UpFolder":
                manager.activeFM.CloseFolder();
                return;

            case "NextPage":
                manager.activeFM.NextPage();
                break;

            case "LastPage":
                manager.activeFM.LastPage();
                break;

            case "FavTest":
                manager.activeFM.LoadFavList(manager.favorites);
                break;

            case "ZONES":
                manager.activeFM.LoadZoneList();
                break;


            //WristTop
            case "SAVE":
                SaveWorld();
                break;

            case "ZONENAME":
                manager.keyboard.gameObject.SetActive(true);
                manager.builderObjects.SetActive(false);
                manager.Diorama.SetActive(false);
                manager.StartCoroutine(ZoneNameWait());
                break;

            case "ZONETAG":
                CycleZoneTag();
                break;

            case "UNLOCKLOCK":
                PlaceObjectMode.posLock = PlaceObjectMode.PosLock.Free;
                manager.SetToolTip("Position Unlocked");
                break;

            case "ROTATIONLOCK":
                PlaceObjectMode.posLock = PlaceObjectMode.PosLock.RotLock;
                manager.SetToolTip("Rotation Locked");
                break;

            case "GRIDLOCK":
                PlaceObjectMode.posLock = PlaceObjectMode.PosLock.Grid;
                if (selectedObject)
                {
                    Vector3 e = selectedObject.transform.localRotation.eulerAngles;
                    objAngleY = Mathf.RoundToInt(e.y / 90) * 90;
                    objAngleX = 0f;
                    objAngleZ = 0f;
                    selectedObject.transform.localRotation = Quaternion.Euler(new Vector3(objAngleX, objAngleY, objAngleZ));
                }
                manager.SetToolTip("Grid Mode Activated");
                break;

            case "LAYERDOWN":
                ChangeLayer(-1);
                break;

            case "LAYERVISIBLE":
                manager.SetToolTip("Coming Soon");
                break;

            case "LAYERUP":
                ChangeLayer(1);
                break;

            //Botton Menu
            case "SAVEEXIT":
                SaveWorld();
                manager.DestroyDioReset();
                TitleScreenMode.Instance().SetupMode();
                break;

            case "SPAWNMODE":
                SaveWorld();
                AdventureTester.Instance().SetupMode();
                manager.SetToolTip("Play Test Mode Activated");
                break;

            case "TOGGLEGRID":
                manager.grid.SetActive(!manager.grid.activeInHierarchy);
                manager.SetToolTip("Grid " + (manager.grid.activeInHierarchy ? "Visible" : "Hidden"));
                break;

            //Front Menu
            case "EXITNOSAVE":
                Application.Quit();
                return;


            //case "Clear All Viewpoints":
            //    currentZone.viewpoints.Clear();
            //    break;

            //case "Show Help Panels On":
            //    manager.showControls = false;
            //    PlayerPrefs.SetInt("BM Show Controls", (manager.showControls ? 0 : 1));
            //    PlayerPrefs.Save();

            //    break;
            //case "Show Help Panels Off":
            //    manager.showControls = true;
            //    PlayerPrefs.SetInt("BM Show Controls", (manager.showControls ? 0 : 1));
            //    PlayerPrefs.Save();

            //    break;

            //case "SetView":
            //    SetView();
            //    //manager.UpdateLog("View Saved");
            //    break;
            //case "LoadView":
            //    LoadView();
            //    break;
            default:
                n.ActivateNode();
                break;
            }
        }
        else
        {
            n.ActivateNode();
        }
    }