Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!updatedSceneToServer && GlobalController.Instance.getConnectionStatus())
        {
            sender.prepareNewMessage4Server(MessageType.Scene);
            updatedSceneToServer = true;
        }

        uiController.debugText.text = curPhase.ToString();
        if (curPhase != prevPhase)
        {
            GlobalController.Instance.curEntryPhase = curPhase;
            Debug.Log("EntryPhase changed: " + prevPhase + " -> " + curPhase);
            prevPhase = curPhase;
        }

        if (curPhase == WelcomePhase.in_entry_scene)
        {
            uiController.setConnectionInfoVisibility(false);
            uiController.setLabInfoVisibility(false, false);
            switchPhase(WelcomePhase.wait_for_input_serverip);
        }
        else if (curPhase == WelcomePhase.wait_for_input_serverip)
        {
            // wait
        }
        else if (curPhase == WelcomePhase.detect_connect_status)
        {
            if (GlobalController.Instance.getConnectionStatus())
            {
                uiController.setConnectionInfoVisibility(true);
                switchPhase(WelcomePhase.wait_for_server_set_lab);
                uiController.setLabInfoVisibility(true, false);
            }
        }
        else if (curPhase == WelcomePhase.wait_for_server_set_lab)
        {
            if (GlobalController.Instance.serverCmdQueue.Count != 0 &&
                GlobalController.Instance.serverCmdQueue.Peek() == ServerCommand.server_set_target_lab)
            {
                uiController.setLabInfoVisibility(true, true);
                finishCurrentServerCmdExcution();
                GlobalController.Instance.isLabInfoSet = true;
                switchPhase(WelcomePhase.check_server_scene);
            }
        }
        else if (curPhase == WelcomePhase.check_server_scene)
        {
            uiController.setLabInfoVisibility(true, true);
            if (GlobalController.Instance.curServerScene == LabScene.Entry_scene)
            {
                switchPhase(WelcomePhase.wait_for_server_accept_acc);
            }
        }
        else if (curPhase == WelcomePhase.wait_for_server_accept_acc)
        {
            if (GlobalController.Instance.serverCmdQueue.Count != 0 &&
                GlobalController.Instance.serverCmdQueue.Peek() == ServerCommand.server_begin_to_receive_acc)
            {
                finishCurrentServerCmdExcution();
                switchPhase(WelcomePhase.deliver_angle_info);
            }
        }
        else if (curPhase == WelcomePhase.deliver_angle_info)
        {
            GlobalController.Instance.setAngleDetectStatus(true);
            if (GlobalController.Instance.serverCmdQueue.Count != 0 &&
                GlobalController.Instance.serverCmdQueue.Peek() == ServerCommand.server_confirm_block_conditions)
            {
                finishCurrentServerCmdExcution();
                GlobalController.Instance.setAngleDetectStatus(false);
                switchPhase(WelcomePhase.ready_to_enter_lab);
            }
        }
        else if (curPhase == WelcomePhase.ready_to_enter_lab)
        {
            if (GlobalController.Instance.serverCmdQueue.Count != 0 &&
                GlobalController.Instance.serverCmdQueue.Peek() == ServerCommand.server_say_enter_lab)
            {
                finishCurrentServerCmdExcution();
                switchPhase(WelcomePhase.out_entry_scene);
            }
        }
        else if (curPhase == WelcomePhase.out_entry_scene)
        {
            SceneManager.LoadScene(GlobalController.Instance.getTargetLabName());
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!updatedSceneToClient && GlobalController.Instance.getConnectionStatus())
        {
            sender.prepareNewMessage4Client(MessageType.Scene);
            updatedSceneToClient = true;
        }

        uiController.debugText.text = curPhase.ToString();
        uiController.setServerip();

        if (curPhase != prevPhase)
        {
            GlobalController.Instance.curEntryPhase = curPhase;
            Debug.Log("EntryPhase changed: " + prevPhase + " -> " + curPhase);
            prevPhase = curPhase;
        }

        if (curPhase == WelcomePhase.in_entry_scene)
        {
            uiController.setEnterLabBtnVisibility(false);
            switchPhase(WelcomePhase.wait_for_input_information);

        }
        else if (curPhase == WelcomePhase.wait_for_input_information)
        {
            uiController.setUserLabInfoVisibility(false);
            uiController.setBlockInfoVisibility(false, false, false);
        }
        else if (curPhase == WelcomePhase.set_target_lab)
        {
            if(GlobalController.Instance.getConnectionStatus())
            {
                GlobalController.Instance.isUserLabInfoSet = true;
                sender.prepareNewMessage4Client(MessageType.Block);
                GlobalController.Instance.excuteCommand(ServerCommand.server_set_target_lab);
                switchPhase(WelcomePhase.check_client_scene);
            }
        }
        else if (curPhase == WelcomePhase.check_client_scene)
        {
            if (GlobalController.Instance.curClientScene == LabScene.Entry_scene)
            {
                switchPhase(WelcomePhase.assign_block_conditions);
            }
        }
        else if (curPhase == WelcomePhase.assign_block_conditions)
        {
            uiController.setBlockInfoContent(GlobalController.Instance.curBlockid);
            switchPhase(WelcomePhase.accept_acc_from_now);
        }
        else if (curPhase == WelcomePhase.accept_acc_from_now)
        {
            GlobalController.Instance.excuteCommand(ServerCommand.server_begin_to_receive_acc);
            GlobalController.Instance.angleProcessor.setReceivingAccStatus(true);
            uiController.setUserLabInfoVisibility(true);
            uiController.setBlockInfoVisibility(true, false, false);
            uiController.setEnterLabBtnVisibility(false);
            switchPhase(WelcomePhase.adjust_block_conditions);
        }
        else if (curPhase == WelcomePhase.adjust_block_conditions)
        {
            uiController.setAngleInfoContent(GlobalController.Instance.curAngle);
            if (debugOnPC || checkAngleValidation())
            {
                uiController.setBlockInfoVisibility(true, true, false);
            }
            else
            {
                uiController.setBlockInfoVisibility(true, false, false);
            }
        }
        else if(curPhase == WelcomePhase.confirm_block_conditions)
        {
            GlobalController.Instance.excuteCommand(ServerCommand.server_confirm_block_conditions);
            GlobalController.Instance.angleProcessor.setReceivingAccStatus(false);
            uiController.setBlockInfoVisibility(true, true, true);
            uiController.btnEnterLab.gameObject.SetActive(true);
            switchPhase(WelcomePhase.ready_to_enter_lab);
        }
        else if (curPhase == WelcomePhase.ready_to_enter_lab)
        {
            
            // then wait to click the "Enter Lab" Button
        }
        else if (curPhase == WelcomePhase.in_lab_scene)
        {
            GlobalController.Instance.excuteCommand(ServerCommand.server_say_enter_lab);
            GlobalController.Instance.writeCurrentBlockConditionToFile();
            string sceneToLoad = GlobalController.Instance.getLabSceneToEnter();
            SceneManager.LoadScene(sceneToLoad);
        }
    }