Beispiel #1
0
    void Awake()
    {
        Dispatcher.AddListener(MenuController.kEventNewBlob, ClearMeshes);

        m_trans         = transform;
        m_cameraTrans   = Camera.main.transform;
        m_deltaFuture   = new Stack <IDelta>();
        m_deltaHistory  = new Stack <IDelta>();
        m_enabledMeshes = new List <VoxelMesh>();

        if (useTestBlob)
        {
            m_blob = VoxelBlob.NewTestDisc();
        }
        else if (useFpsTestBlob)
        {
            m_blob = VoxelBlob.NewFpsTestBlob();
        }
        else
        {
            m_blob = new VoxelBlob(VoxelBlob.kTestSize, VoxelBlob.kTestSize, VoxelBlob.kTestSize, true);
        }

        string[] launchArguments = System.Environment.GetCommandLineArgs();
        if (launchArguments != null)
        {
            for (int i = launchArguments.Length - 1; i > -1; i--)
            {
                if (launchArguments[i].Contains(".radiant") || launchArguments[i].Contains(".Radiant"))
                {
                    if (System.IO.File.Exists(launchArguments[i]))
                    {
                        Dispatcher <string> .Broadcast(MenuController.kEventLoadScene, launchArguments[i]);

                        i = -1;
                    }
                }
            }
        }

        m_colliderCache        = new BoxCollider[kColliderCacheDim * kColliderCacheDim * kColliderCacheDim];
        m_chunkPositionCurrent = WorldToChunk(m_cameraTrans.position);

        // NOTE: When we load data in the future, we'll need to find a suitable
        // location for the player.
        CreateCollisionCache();
        Scheduler.StartCoroutine(LoadVisualChunks());
        Scheduler.StartCoroutine(UpdateVisualChunks());
        Dispatcher.Broadcast(kOnForceRefresh);
    }
Beispiel #2
0
    void NormalMenu()
    {
        float yInitial   = (Screen.height - (kButtonHeight + kMargin) * 6) / 2.0f;
        Rect  buttonRect = new Rect((Screen.width - kButtonWidth) / 4.0f,
                                    yInitial, kButtonWidth, kButtonHeight);

        // Left column ////////////////////////////////////////////////////////
        if (GUI.Button(buttonRect, m_workingPrinter.isAwake ? "Sleep" : "Wake"))
        {
            if (!m_workingPrinter.isAwake)
            {
                pc.WakePrinter(m_workingPrinter);
            }
            else
            {
                pc.SleepPrinter(m_workingPrinter);
            }
        }

        buttonRect.y += kButtonHeight + kMargin;
        if (GUI.Button(buttonRect, "Print Test"))
        {
            // Print
            pc.SchedulePrint(VoxelBlob.NewTestDisc());
            HandleMenu = PrintingMenu;
            Dispatcher <float> .AddListener(PrinterController.kOnPrintingProgress, OnPrintingProgress);
        }

        buttonRect.y += kButtonHeight + kMargin;
        if (GUI.Button(buttonRect, @"Print Test Scene"))
        {
            string   filePath;
            string[] extensions     = new string[] { "radiant" };
            string[] extensionNames = new string[] { "Radiant scene" };

            if (FileDialogs.ShowOpenFileDialog(out filePath, extensions, extensionNames))
            {
                System.IO.FileStream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
                VoxelBlob            blob   = VoxelBlob.NewFromFile(stream, false);
                pc.SchedulePrint(blob);
                HandleMenu = PrintingMenu;
                Dispatcher <float> .AddListener(PrinterController.kOnPrintingProgress, OnPrintingProgress);
            }
            else
            {
                Text.Log(@"Aborted opening.");
            }
        }

        /*
         * buttonRect.y += kButtonHeight + kMargin;
         * if (GUI.Button(buttonRect, "Request Token Test")) {
         *      StartCoroutine(OAuth1.GetRequestToken(ExternalSite.ShapeWays, RequestResponse));
         *      HandleMenu = AuthorizationMenu;
         * }
         */

        /*
         * GUI.enabled = !m_isSaved;
         * buttonRect.y += kButtonHeight + kMargin;
         * if (GUI.Button(buttonRect, "Save")) {
         *      string filePath = NativePanels.SaveFileDialog("model.radiant", "radiant");
         *      SaveBlob(filePath);
         *      Text.Log("Saved " + filePath);
         *      m_isSaved = true;
         *      Dispatcher<Sfx>.Broadcast(AudioManager.kPlaySfx, Sfx.Select);
         * }
         *
         * GUI.enabled = true;
         * buttonRect.y += kButtonHeight + kMargin;
         * if (GUI.Button(buttonRect, "Load")) {
         *      //PlayerPrefs.SetString(VoxelBlob.kSerializedKey, serializedBlob);
         *      string filePath = NativePanels.OpenFileDialog(new string[]{"radiant"});
         *      LoadBlob(filePath);
         *      m_isSaved = true;
         *      Dispatcher<Sfx>.Broadcast(AudioManager.kPlaySfx, Sfx.Select);
         * }
         */

        // Right column ///////////////////////////////////////////////////////
        buttonRect.x      = (Screen.width - kButtonWidth) * 0.75f;
        buttonRect.y      = yInitial;
        buttonRect.height = kButtonHeight;
        buttonRect.width  = kButtonWidth / 3.0f;
        buttonRect.x     += buttonRect.width + kMargin;
        if (GUI.Button(buttonRect, "^"))
        {
            pc.BeginMotorChanges(m_workingPrinter);
            pc.MoveVerticallyBy(-10.0f, Change.Execute);
            pc.EndMotorChanges();
        }

        buttonRect.y += kButtonHeight + kMargin;
        buttonRect.x  = buttonRect.x - buttonRect.width - kMargin;
        if (GUI.Button(buttonRect, "<"))
        {
            pc.BeginMotorChanges(m_workingPrinter);
            pc.MoveHorizontallyBy(10.0f, Change.Execute);
            pc.EndMotorChanges();
        }

        buttonRect.x += buttonRect.width + kMargin;
        if (GUI.Button(buttonRect, "v"))
        {
            pc.BeginMotorChanges(m_workingPrinter);
            pc.MoveVerticallyBy(10.0f, Change.Execute);
            pc.EndMotorChanges();
        }

        buttonRect.x += buttonRect.width + kMargin;
        if (GUI.Button(buttonRect, ">"))
        {
            pc.BeginMotorChanges(m_workingPrinter);
            pc.MoveHorizontallyBy(-10.0f, Change.Execute);
            pc.EndMotorChanges();
        }
    }