示例#1
0
    void Update()
    {
        if (!leaveExecuted)
        {
            if (phase == 1 && messageUI.getResult().getDone())
            {
                Debug.Log("phase =1 and " + messageUI.getResult().getDone());
                phase = 2;
            }

            if (phase == 2 && !uiManager.getResult().getDone() && messageUI.isClosed())
            {
                Debug.Log("wait mesui end");
                RollDiceParam param = new RollDiceParam(chara.getAbilityInfo()[1] + chara.getDiceNumberBuffer());
                rollVaue = uiManager.showRollDiceImmediately(param);
                phase    = 3;
            }

            if (phase == 3 && !uiManager.isClosedPlane())
            {
                result = eventI.excute(chara, messageUI.getResult().getResult(), rollVaue);
                Debug.Log("event result is " + result);
                showMessageUi(eventI.getEventEndInfo(result.getResultCode()), null);
                phase = 4;
            }

            else if (phase == 4 && messageUI.getResult().getDone())
            {
                if (result.getResultCode() == EventConstant.LEAVE_EVENT_SAFE)
                {
                    this.door.playerOpenDoorResult(true);
                }
                else
                {
                    chara.updateActionPoint(0);
                    this.door.playerOpenDoorResult(false);
                }
                leaveExecuted = true;
            }
        }

        if (!this.sanCheckExecuted)
        {
            if (phase == 1 && messageUI.getResult().getDone())
            {
                Debug.Log("phase =1 and " + messageUI.getResult().getDone());
                phase = 2;
            }

            if (phase == 2 && !uiManager.getResult().getDone() && messageUI.isClosed())
            {
                Debug.Log("wait mesui end");
                RollDiceParam param = new RollDiceParam(chara.getAbilityInfo()[3] + chara.getDiceNumberBuffer());
                rollVaue = uiManager.showRollDiceImmediately(param);
                phase    = 3;
            }

            if (phase == 3 && !uiManager.isClosedPlane())
            {
                result = eventI.excute(chara, messageUI.getResult().getResult(), rollVaue);
                Debug.Log("event result is " + result);
                showMessageUi(eventI.getEventEndInfo(result.getResultCode()), null);
                phase = 4;
            }

            else if (phase == 4 && messageUI.getResult().getDone())
            {
                if (result.getResultCode() == EventConstant.SANCHECK_EVENT_BED)
                {
                    RollDiceParam param = new RollDiceParam(eventI.getBadDiceNum());
                    rollVaue = uiManager.showRollDiceImmediately(param);
                    chara.getAbilityInfo()[3] = chara.getAbilityInfo()[3] - rollVaue;
                }
                else if (result.getResultCode() == EventConstant.SANCHECK_EVENT_NORMAL)
                {
                    chara.getAbilityInfo()[3] = chara.getAbilityInfo()[3] + eventI.getNormalValue();
                }
                else
                {
                    chara.getAbilityInfo()[3] = chara.getAbilityInfo()[3] + eventI.getGoodValue();
                }
                sanCheckExecuted = true;
            }
        }

        if (!this.fallRoomExecuted)
        {
            // Debug.LogError(eventI);
            if (phase == 1 && messageUI.getResult().getDone())
            {
                Debug.Log("phase =1 and " + messageUI.getResult().getDone());

                if (eventI.getSelectItem() == null || eventI.getSelectItem().Count == 0)
                {
                    phase = 3;
                }
                else
                {
                    phase = 2;
                    this.selectedOptionCode = messageUI.getResult().getResult();
                    showMessageUi(eventI.getSelectItem()[this.selectedOptionCode][1]);
                }
            }
            else if (phase == 2 && messageUI.getResult().getDone())
            {
                phase = 3;
            }

            else if (phase == 3 && !uiManager.getResult().getDone() && messageUI.isClosed())
            {
                Debug.Log("wait mesui end");
                int rollNum;
                if (this.selectedOptionCode == EventConstant.OPTION_CODE_1)
                {
                    rollNum = chara.getAbilityInfo()[3];
                }
                else
                {
                    rollNum = chara.getAbilityInfo()[1];
                }
                RollDiceParam param = new RollDiceParam(rollNum + chara.getDiceNumberBuffer());
                rollVaue = uiManager.showRollDiceImmediately(param);
                phase    = 4;
            }
            else if (phase == 4 && !uiManager.isClosedPlane())
            {
                // Debug.LogError(eventI);
                // Debug.LogError(messageUI.getResult());
                result = eventI.excute(chara, this.selectedOptionCode, rollVaue);
                Debug.Log("event result is " + result);
                showMessageUi(eventI.getEventEndInfo(result.getResultCode()), null);
                phase = 5;
            }

            else if (phase == 5 && messageUI.getResult().getDone())
            {
                if (result.getResultCode() == EventConstant.FALL_DOWN__EVENT_GOOD)
                {
                }
                else if (result.getResultCode() == EventConstant.FALL_DOWN__EVENT_NORMAL)
                {
                    roomContraller.findRoomByXYZ(chara.getCurrentRoom()).removeChara(chara);
                    this.roomContraller.setCharaInMiniMap(chara.getCurrentRoom(), chara, false);
                    RoomInterface ri = roomContraller.getRandomDownRoom();
                    ri.setChara(chara);
                    chara.setCurrentRoom(ri.getXYZ());
                    this.roomContraller.setCharaInMiniMap(ri.getXYZ(), chara, true);
                    camCtrl.setTargetPos(ri.getXYZ(), RoomConstant.ROOM_Y_DOWN, true);
                    fallRoomExecuted = true;
                }
                else
                {
                    RollDiceParam param = new RollDiceParam(this.eventI.getBadDiceNum());
                    rollVaue = uiManager.showRollDiceImmediately(param) + 1;
                    chara.getAbilityInfo()[0]    = chara.getAbilityInfo()[0] - rollVaue;
                    chara.getMaxAbilityInfo()[3] = chara.getMaxAbilityInfo()[3] + rollVaue;
                    chara.getAbilityInfo()[3]    = chara.getAbilityInfo()[3] + rollVaue;
                    messageUI.getResult().setDone(false);
                    showMessageUi(new string[] { "你的力量下降:" + rollVaue + "点,神志上升:" + rollVaue + "点" }, null);
                    phase = 6;
                }
            }
            else if (phase == 6 && messageUI.getResult().getDone())
            {
                roomContraller.findRoomByXYZ(chara.getCurrentRoom()).removeChara(chara);
                this.roomContraller.setCharaInMiniMap(chara.getCurrentRoom(), chara, false);
                RoomInterface ri = roomContraller.getRandomDownRoom();
                ri.setChara(chara);
                chara.setCurrentRoom(ri.getXYZ());
                this.roomContraller.setCharaInMiniMap(ri.getXYZ(), chara, true);
                camCtrl.setTargetPos(ri.getXYZ(), RoomConstant.ROOM_Y_DOWN, true);
                if (ri.isLock())
                {
                    ri.setLock(false);
                }
                fallRoomExecuted = true;
            }
        }
    }