Esempio n. 1
0
    public void setCurrentRoom(RoomInterface nextRoom, string doorFrom)
    {
        if (!this.isPlayer())
        {
            setCurrentRoom(nextRoom.getXYZ());
        }
        else
        {
            Vector3 temPos;
            this.xyz = nextRoom.getXYZ();
            switch (doorFrom)
            {
            case "U":
                temPos = new Vector3(nextRoom.getNorthDoor().transform.position.x + 0.2f, nextRoom.getNorthDoor().transform.position.y - 2.5f, 0);
                this.transform.position = temPos;
                break;

            case "D":
                temPos = new Vector3(nextRoom.getNorthDoor().transform.position.x + 0.2f, nextRoom.getSouthDoor().transform.position.y + 2.5f, 0);
                this.transform.position = temPos;
                break;

            case "R":
                temPos = new Vector3(nextRoom.getWestDoor().transform.position.x + 1.9f, nextRoom.getWestDoor().transform.position.y, 0);
                this.transform.position = temPos;
                break;

            case "L":
                temPos = new Vector3(nextRoom.getEastDoor().transform.position.x - 1.9f, nextRoom.getEastDoor().transform.position.y, 0);
                this.transform.position = temPos;
                break;
            }
            this.findthisRoomNews(nextRoom.getXYZ());
        }
    }
Esempio n. 2
0
    /**
     * void OnCollisionEnter2D(Collision2D coll)
     * {
     *  Debug.Log(coll.gameObject.name);
     *  doClick();
     *
     * }
     * void OnMouseDown()
     *
     * {
     *
     *  if (!SystemUtil.IsTouchedUI())
     *  {
     *
     *      doClick();
     *
     *  }
     *
     *
     * }**/

    public override void doClick()
    {
        // 载入上楼图片...
        RoomInterface upStairBackRoom = roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_UPSTAIR);
        Character     chara           = roundController.getCurrentRoundChar();

        roomContraller.findRoomByXYZ(chara.getCurrentRoom()).removeChara(chara);
        this.roomContraller.setCharaInMiniMap(chara.getCurrentRoom(), this.roundController.getCurrentRoundChar(), false);
        upStairBackRoom.setChara(chara);
        chara.setCurrentRoom(upStairBackRoom.getXYZ());
        camCtrl.setTargetPos(upStairBackRoom.getXYZ(), RoomConstant.ROOM_Y_GROUND, true);
        this.roomContraller.setCharaInMiniMap(upStairBackRoom.getXYZ(), this.roundController.getCurrentRoundChar(), true);

        // 载入上楼图片结束。。。
    }
Esempio n. 3
0
    public bool excuteFallRoomEvent(EventInterface eventI, Character chara)
    {
        this.eventI = eventI;
        if (this.eventI != null)
        {
            if (chara.isPlayer())
            {
                fallRoomExecuted = false;
                this.chara       = chara;
                phase            = 1;
                messageUI.getResult().setDone(false);
                showMessageUi(eventI.getEventBeginInfo(), eventI.getSelectItem());
            }
            else
            {
                result = eventI.excute(chara, messageUI.getResult().getResult(), 0);

                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(upStairRoom.getXYZ(), RoomConstant.ROOM_Y_DOWN, true);
                }
                else
                {
                    RollDiceParam param = new RollDiceParam(this.eventI.getBadDiceNum());
                    rollVaue = uiManager.showRollDiceImmediately(param);
                    chara.getAbilityInfo()[0] = chara.getAbilityInfo()[0] - rollVaue;
                    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);
                }
            }
        }
        return(true);
    }
Esempio n. 4
0
    private void setRoomEvents(RoomInterface room)
    {
        //判定房间是处于什么位置 楼上 地面 楼下, 不能出现 有冲突的事件, 比如楼下不能出现掉落事件

        if (room.getXYZ()[2] == roomConstant.ROOM_TYPE_GROUND)
        {
            //  if () {
            //      room.setEvent(getRandomEvent());
            //  }
        }
        else if (room.getXYZ()[2] == roomConstant.ROOM_TYPE_UP)
        {
        }
        else
        {
        }
    }
Esempio n. 5
0
 public void excuteStayRoomEvent(RoomInterface ri, Character chara)
 {
     this.eventI = ri.getRoomEvent(EventConstant.STAY_EVENT);
     if (this.eventI != null)
     {
         EventInfo ei = new EventInfo();
         ei.RoomXyz = ri.getXYZ();
         ei.EffectedList.Add(chara.getName());
         this.stayEventList.Add(ei);
         eventI.excute(chara, null, 0);
     }
 }
Esempio n. 6
0
    public void doNow(string gbCode)
    {
        GuangBoAction gb = eventGuangBoMap[gbCode];

        if (gb.getGuangBoType() == GuangBoConstant.GUANGBO_TYPE_MOVE_ROOM)
        {
            RoomInterface targetRoom = roomContraller.findRoomByRoomType(gb.getGuangBoTargetVaule());
            //targetRoom.getXYZ();
            camCtrl.setTargetPos(targetRoom.getXYZ(), targetRoom.getXYZ()[2], true);
            foreach (string name in gb.getWhiteList())
            {
                Character npc = roundController.getCharaByName(name);
                roomContraller.findRoomByXYZ(npc.getCurrentRoom()).removeChara(npc);
                this.roomContraller.setCharaInMiniMap(npc.getCurrentRoom(), npc, false);
                npc.setCurrentRoom(targetRoom.getXYZ());
                this.roomContraller.setCharaInMiniMap(targetRoom.getXYZ(), npc, true);
            }
            Character chara = roundController.getPlayerChara();
            roomContraller.findRoomByXYZ(chara.getCurrentRoom()).removeChara(chara);
            this.roomContraller.setCharaInMiniMap(chara.getCurrentRoom(), this.roundController.getCurrentRoundChar(), false);
            foreach (string name in gb.getWhiteList())
            {
                Character npc = roundController.getCharaByName(name);
                roomContraller.findRoomByXYZ(npc.getCurrentRoom()).removeChara(npc);
                this.roomContraller.setCharaInMiniMap(npc.getCurrentRoom(), npc, false);

                npc.setCurrentRoom(targetRoom.getXYZ());
                this.roomContraller.setCharaInMiniMap(targetRoom.getXYZ(), npc, true);
            }
            chara.setCurrentRoom(targetRoom.getXYZ());
            this.roomContraller.setCharaInMiniMap(targetRoom.getXYZ(), chara, true);
            Debug.Log("loading。。。ready to move room");

            //
        }
    }
Esempio n. 7
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;
            }
        }
    }
Esempio n. 8
0
 public void setCharaInHiddenRoom(RoomInterface room)
 {
     this.transform.position = new Vector3(RoomConstant.ROOM_X_X + (room.getXYZ()[0] * roomH - distance), xyz[1] * roomV + distance, 0);
 }
Esempio n. 9
0
 public void setCurrentRoom(RoomInterface nextRoom, string doorFrom)
 {
     setCurrentRoom(nextRoom.getXYZ());
 }
Esempio n. 10
0
    public new void defaultAction()
    {
        //  Debug.Log("run default aciont");
        if (waitPlan)
        {
            if (this.getGuangBoAction().isPlanSuccess())
            {
                this.sendMessageToPlayer(new string[] { "我这里有新线索发现,都来听我分析。" });
                if (this.getGuangBoAction().isGuangBoActionEnd())
                {
                    waitPlan = false;
                }
            }
            else
            {
                this.sendMessageToPlayer(new string[] { "你们这群呆逼,都不来算了。" });
                waitPlan = false;
            }
        }
        else
        {
            if (this.getTargetRoomList().Count <= 0)
            {
                NPC ben = (NPC)FindObjectOfType <Ben>();
                if (ben.isDead())
                {
                    Debug.Log("随便找个房间看看");
                    this.getTargetRoomList().Enqueue(roomContraller.getRandomRoom());
                }
                else
                {
                    if (AutoMoveManager.move(this, roomContraller, eventController, diceRoll, aPathManager, ben.getCurrentRoom()))
                    {
                        Debug.Log("kate 开始跟踪冒险家");
                        if (this.getAbilityInfo()[3] <= 1)
                        {
                            Debug.Log("kate 疯了, 准备杀人了");
                            ben.sendMessageToPlayer(new string[] { "侦探疯了,他要杀死所有人!", " 大家快跑。。。", "啊。。。" });
                            ben.getAbilityInfo()[0]  = 0;
                            this.getAbilityInfo()[3] = 1;

                            if (storyController.checkStoryStartBySPEvnet(bss, this, roundController, roomContraller.findRoomByXYZ(this.getCurrentRoom())))
                            {
                                Debug.Log(" 黑色征兆 剧本开启");
                                this.sendMessageToPlayer(new string[] { "啊!啊!啊!。。。", "冒险家被我杀死了。。。" });
                                this.getAbilityInfo()[3] = 3;
                            }
                            else
                            {
                                Debug.Log(" 剧本开启失败");
                            }
                        }
                        else
                        {
                            Debug.Log("kate 没疯,暗中观察");
                            //this.setClickMessage(new string[] { SystemConstant.P2_NAME + ", 让我看一下你当年手术的地方吧?" });
                        }
                    }
                }
            }
            else
            {
                RoomInterface target = this.getTargetRoomList().Peek();
                if (target == null)
                {
                    Debug.Log("target is null !!!!error");
                }
                if (target.getRoomType() == RoomConstant.ROOM_TYPE_HOSPITAIL_TRI_OPERATION && isTargetRoomLocked())
                {
                    Debug.Log("NPC发现手术室被锁着 去保安室找钥匙");

                    if (AutoMoveManager.move(this, roomContraller, eventController, diceRoll, aPathManager, RoomConstant.ROOM_TYPE_HOSPITAIL_SECURITY))
                    {
                        Debug.Log("达到保安室");
                        H_securityRoom surgeryRoom = (H_securityRoom)roomContraller.findRoomByXYZ(this.getCurrentRoom());
                        Item           item        = surgeryRoom.getKeysCabinet().GetComponent <KeysCabinet>().getItem(this);
                        if (item != null)
                        {
                            this.getBag().insertItem(item);
                            this.setTargetRoomLocked(false);
                        }
                        else
                        {
                            //没有找到钥匙, 直接判断手术室有没有被打开
                            H_tridOperationRoom tridOperationRoom = (H_tridOperationRoom)roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_HOSPITAIL_TRI_OPERATION);
                            if (tridOperationRoom.isLock())
                            {
                                Debug.Log("第3手术室锁着, 我又没钥匙,暂定瞎逛");
                                AutoMoveManager.move(this, roomContraller, eventController, diceRoll, aPathManager, roomContraller.getRandomRoom().getRoomType());
                            }
                            else
                            {
                                this.setTargetRoomLocked(false);
                            }
                        }
                    }
                }
                else
                {
                    // Debug.Log("targetRoom is " + target.getXYZ()[0] + "," + target.getXYZ()[1] + "," + target.getXYZ()[2]);
                    if (AutoMoveManager.move(this, roomContraller, eventController, diceRoll, aPathManager, target.getXYZ()))
                    {
                        //  Debug.Log("reached the targetRoom is " + target.getXYZ()[0] + "," + target.getXYZ()[1] + "," + target.getXYZ()[2]);
                        this.getTargetRoomList().Dequeue();
                        if (target.getRoomType() == RoomConstant.ROOM_TYPE_HOSPITAIL_SURGERY)
                        {
                            Debug.Log("达到外科室");
                            H_surgeryRoom surgeryRoom = (H_surgeryRoom)roomContraller.findRoomByXYZ(this.getCurrentRoom());
                            Item          item        = surgeryRoom.getBookTable().GetComponent <BookTable>().getItem(this);
                            if (item != null)
                            {
                                string guangBoCode = this.getName() + "_" + RoomConstant.ROOM_TYPE_HOSPITAIL_SURGERY + "_gb";
                                getTargetChara().Add(SystemConstant.P2_NAME);
                                setGuangBoAction(new EveryoneGoTargetRoom(this.getName(), RoomConstant.ROOM_TYPE_HOSPITAIL_SURGERY, getTargetChara(), 8, guangBoCode));
                                guangBoController.insertGuangBo(this.getGuangBoAction());
                                waitPlan = true;
                                this.sendMessageToPlayer(new string[] { SystemConstant.P2_NAME + ", 这个病例上有你的名字", " 你最好来看看" }, guangBoCode);
                                this.getBag().insertItem(item);
                            }
                        }
                        else if (target.getRoomType() == RoomConstant.ROOM_TYPE_HOSPITAIL_TRI_OPERATION)
                        {
                            Debug.Log("到达第3手术室");
                            H_tridOperationRoom tridOperationRoom = (H_tridOperationRoom)roomContraller.findRoomByXYZ(this.getCurrentRoom());
                            Item item = tridOperationRoom.getOperatingTable().GetComponent <OperatingTable>().getItem(this);
                            if (item != null)
                            {
                                this.getBag().insertItem(item);
                                this.sendMessageToPlayer(new string[] { SystemConstant.P1_NAME + ", 你最好解释下这个解剖样本,这个是什么病?" });
                            }
                            else
                            {
                                Debug.Log("这个解剖手术太奇怪了,我一定错过了什么。我要好好检查下。");
                                this.sendMessageToPlayer(new string[] { "这个解剖手术太奇怪了,我一定错过了什么。", "我要好好检查下。" });
                            }
                            //  this.setClickMessage(tridOperationRoom.findSomethingNews(this).ToArray());
                        }
                        else if (target.getRoomType() == RoomConstant.ROOM_TYPE_HOSPITAIL_MORGUE)
                        {
                            Debug.Log("到达停尸房");
                            this.sendMessageToPlayer(new string[] { "这里有好多尸体都标明了实验失败的标签", "而且实验人全是写的你医生的名字", "大家把医生抓住啊,他有重大嫌疑!" });
                        }
                        else if (target.getRoomType() == RoomConstant.ROOM_TYPE_HOSPITAIL_STORE)
                        {
                            Debug.Log("到达储藏室");
                            H_storeRoom storeRoom = (H_storeRoom)roomContraller.findRoomByXYZ(this.getCurrentRoom());
                            Item        item      = storeRoom.getSafeCabinet().GetComponent <SafeCabinet>().getItem(this);
                            if (item != null)
                            {
                                this.getBag().insertItem(item);
                                this.getAbilityInfo()[3] = 1;
                                //发疯后行动力加强
                                this.getAbilityInfo()[0] = this.getAbilityInfo()[0] + 3;
                                this.getAbilityInfo()[1] = this.getAbilityInfo()[1] + 4;
                            }
                            else
                            {
                                if (!isCrazy())
                                {
                                    //this.sendMessageToPlayer(target.findSomethingNews(this.getName()).ToArray());
                                    // this.setClickMessage(target.findSomethingNews(this).ToArray());
                                }
                            }
                        }
                        else
                        {
                            Debug.Log("找路失败了");
                        }
                    }
                }
                //this.setClickMessage(this.roomContraller.findRoomByXYZ(this.getCurrentRoom()).findSomethingNews(this).ToArray());
            }
        }
        endRound();
    }
Esempio n. 11
0
    public GameObject genRoom(int[] xyz, int[] door)
    {
        //房间Prefab所在文件夹路径
        string roomType = groundRoomType.Dequeue();
        string url      = "Prefabs/" + roomType;

        //仅用Resources.Load会永久修改原形Prefab。应该用Instatiate,操作修改原形的克隆体
        GameObject room = Instantiate(Resources.Load(url)) as GameObject;

        if (room == null)
        {
            Debug.Log("cant find room Prefab !!!");
        }
        else
        {
            RoomInterface ri = room.GetComponent(System.Type.GetType(roomType)) as RoomInterface;
            ri.setXYZ(xyz);

            //根据这房间门的数据,生成对应的门
            if (door [0] == 1)
            {
                //门启用
                ri.northDoorEnable();
                //门属于这个房间
                GameObject doorGo = ri.getNorthDoor();
                doorGo.GetComponent <DoorInterface> ().setRoom(ri);
                //门外有相邻房间的坐标为
//				错误代码int[] nextRoomXYZ = xyz;
//				错误代码nextRoomXYZ [2] += 1原因:一维数组是引用类型,+1会导致xyz[]的修改;
//				体现为  房间的map坐标!=房间的getXYZ

                //修正为
                int[] nextRoomXYZ = new int[3];
                nextRoomXYZ [0]  = xyz [0];
                nextRoomXYZ [1]  = xyz [1];
                nextRoomXYZ [2]  = xyz [2];
                nextRoomXYZ [1] += 1;

                doorGo.GetComponent <DoorInterface> ().setNextRoomXYZ(nextRoomXYZ);
            }
            if (door [1] == 1)
            {
                //门启用
                ri.southDoorEnable();
                //门属于这个房间
                GameObject doorGo = ri.getSouthDoor();
                doorGo.GetComponent <DoorInterface> ().setRoom(ri);
                //门外有相邻房间的坐标为
                int[] nextRoomXYZ = new int[3];
                nextRoomXYZ [0]  = xyz [0];
                nextRoomXYZ [1]  = xyz [1];
                nextRoomXYZ [2]  = xyz [2];
                nextRoomXYZ [1] -= 1;

                doorGo.GetComponent <DoorInterface> ().setNextRoomXYZ(nextRoomXYZ);
            }
            if (door [2] == 1)
            {
                //门启用
                ri.westDoorEnable();
                //门属于这个房间
                GameObject doorGo = ri.getWestDoor();
                doorGo.GetComponent <DoorInterface> ().setRoom(ri);
                //门外有相邻房间的坐标为
                int[] nextRoomXYZ = new int[3];
                nextRoomXYZ [0]  = xyz [0];
                nextRoomXYZ [1]  = xyz [1];
                nextRoomXYZ [2]  = xyz [2];
                nextRoomXYZ [0] -= 1;

                doorGo.GetComponent <DoorInterface> ().setNextRoomXYZ(nextRoomXYZ);
            }
            if (door [3] == 1)
            {
                //门启用
                ri.eastDoorEnable();
                //门属于这个房间
                GameObject doorGo = ri.getEastDoor();
                doorGo.GetComponent <DoorInterface> ().setRoom(ri);
                //门外有相邻房间的坐标为
                int[] nextRoomXYZ = new int[3];
                nextRoomXYZ [0]  = xyz [0];
                nextRoomXYZ [1]  = xyz [1];
                nextRoomXYZ [2]  = xyz [2];
                nextRoomXYZ [0] += 1;

                doorGo.GetComponent <DoorInterface> ().setNextRoomXYZ(nextRoomXYZ);
            }
            roomList.Add(ri.getXYZ(), ri);
        }

        return(room);
    }
Esempio n. 12
0
    public Stack <Node> findPath(RoomInterface intiRoom, RoomInterface targetNode, RoomContraller roundController)
    {
        openList.Clear();
        closeList.Clear();
        //   Debug.Log(" intiRoom Room is " + intiRoom.getXYZ()[0] + "," + intiRoom.getXYZ()[1]);
        //   Debug.Log(" targetNode Room is " + targetNode.getXYZ()[0] + "," + targetNode.getXYZ()[1]);
        bool finded   = false;
        Node initNode = new Node(intiRoom.getXYZ()[0], intiRoom.getXYZ()[1], intiRoom.getXYZ()[2]);

        initNode.G = 10;
        initNode.H = (System.Math.Abs(initNode.xy[0] - targetNode.getXYZ()[0]) + System.Math.Abs(initNode.xy[1] - targetNode.getXYZ()[1])) * 10;
        initNode.F = initNode.G + initNode.H;
        openList.Add(initNode);

        while (!finded)
        {
            //计算起始位置周围的F值
            currentNode = getLessestNode(openList);
            //      Debug.Log(" currentNode Room is " + currentNode.xy[0] + "," + currentNode.xy[1]);
            closeList.Add(currentNode);
            if (currentNode.xy[0] == targetNode.getXYZ()[0] && currentNode.xy[1] == targetNode.getXYZ()[1])
            {
                //           Debug.Log("I got the targetRoom!!!!");
                finded = true;
                break;
            }

            RoomInterface currentRoom = roundController.findRoomByXYZ(currentNode.xy);
            //      Debug.Log(" currentRoom Room is " + currentRoom.getXYZ()[0] + "," + currentRoom.getXYZ()[1]);
            if (currentRoom.getNorthDoor().GetComponent <DoorInterface>().getShowFlag())
            {
                node = new Node(currentRoom.getXYZ()[0], currentRoom.getXYZ()[1] + 1, currentRoom.getXYZ()[2]);
                if (!this.containClose(node, closeList))
                {
                    node.G = 10 + currentNode.G;
                    node.H = (System.Math.Abs(node.xy[0] - targetNode.getXYZ()[0]) + System.Math.Abs(node.xy[1] - targetNode.getXYZ()[1])) * 10;
                    if (roundController.findRoomByXYZ(node.xy).isLock())
                    {
                        node.H = node.H + 50;
                    }
                    node.F      = node.G + node.H;
                    node.parent = currentNode;
                    openList.Add(node);
                }
            }
            if (currentRoom.getSouthDoor().GetComponent <DoorInterface>().getShowFlag())
            {
                node = new Node(currentRoom.getXYZ()[0], currentRoom.getXYZ()[1] - 1, currentRoom.getXYZ()[2]);
                if (!this.containClose(node, closeList))
                {
                    node.G = 10 + currentNode.G;
                    node.H = (System.Math.Abs(node.xy[0] - targetNode.getXYZ()[0]) + System.Math.Abs(node.xy[1] - targetNode.getXYZ()[1])) * 10;
                    if (roundController.findRoomByXYZ(node.xy).isLock())
                    {
                        node.H = node.H + 50;
                    }
                    node.F      = node.G + node.H;
                    node.parent = currentNode;
                    openList.Add(node);
                }
            }
            if (currentRoom.getEastDoor().GetComponent <DoorInterface>().getShowFlag())
            {
                node = new Node(currentRoom.getXYZ()[0] + 1, currentRoom.getXYZ()[1], currentRoom.getXYZ()[2]);
                if (!this.containClose(node, closeList))
                {
                    node.G = 10 + currentNode.G;
                    node.H = (System.Math.Abs(node.xy[0] - targetNode.getXYZ()[0]) + System.Math.Abs(node.xy[1] - targetNode.getXYZ()[1])) * 10;
                    if (roundController.findRoomByXYZ(node.xy).isLock())
                    {
                        node.H = node.H + 50;
                    }

                    node.F      = node.G + node.H;
                    node.parent = currentNode;
                    openList.Add(node);
                }
            }
            if (currentRoom.getWestDoor().GetComponent <DoorInterface>().getShowFlag())
            {
                node = new Node(currentRoom.getXYZ()[0] - 1, currentRoom.getXYZ()[1], currentRoom.getXYZ()[2]);
                if (!this.containClose(node, closeList))
                {
                    node.G = 10 + currentNode.G;
                    node.H = (System.Math.Abs(node.xy[0] - targetNode.getXYZ()[0]) + System.Math.Abs(node.xy[1] - targetNode.getXYZ()[1])) * 10;
                    if (roundController.findRoomByXYZ(node.xy).isLock())
                    {
                        node.H = node.H + 50;
                    }
                    node.F      = node.G + node.H;
                    node.parent = currentNode;
                    openList.Add(node);
                }
            }
            //     Debug.Log("openList.Count  " + openList.Count);
        }


        Stack <Node> paths = genPath(initNode, currentNode);

        return(paths);
    }
Esempio n. 13
0
    public new void defaultAction()
    {
        // Debug.Log("run default aciont");
        if (waitPlan)
        {
            if (this.getGuangBoAction().isPlanSuccess())
            {
                this.sendMessageToPlayer(new string[] { "快点来,我的大刀已经饥渴难耐了。" });
            }
            else
            {
                this.sendMessageToPlayer(new string[] { "你们都不来吗? 那我等会再来问问" });
                waitPlan = false;
            }
        }
        else
        {
            if (this.getTargetRoomList().Count <= 0)
            {
                Debug.Log("随便找个房间看看");
                this.getTargetRoomList().Enqueue(roomContraller.getRandomRoom());
            }
            RoomInterface target = this.getTargetRoomList().Peek();

            if (AutoMoveManager.move(this, roomContraller, eventController, diceRoll, aPathManager, target.getXYZ()))
            {
            }
        }

        endRound();
    }
Esempio n. 14
0
    public static bool doMove(Character chara, RoomContraller roomContraller, EventController eventController, DiceRollCtrl diceRoll, APathManager aPathManager, RoomInterface targetRoom, bool goUpOrDown)
    {
        if (chara.ActionPointrolled() || chara.getActionPoint() > 0)
        {
            Stack <Node> path = null;

            RoomInterface currentRoom = roomContraller.findRoomByXYZ(chara.getCurrentRoom());
            //如果当前房间不是目标房间
            //开始找路
            if (chara.getCurrentRoom()[0] != targetRoom.getXYZ()[0] || chara.getCurrentRoom()[1] != targetRoom.getXYZ()[1] || chara.getCurrentRoom()[2] != targetRoom.getXYZ()[2])
            {
                //  Debug.Log("如果当前房间不是目标房间");
                //判定是否同层
                if (chara.getCurrentRoom()[2] != targetRoom.getXYZ()[2])
                {
                    //   Debug.Log("如果目标房间是楼下, 先定位到下楼梯口房间, 如果目标是楼上,先定位到上楼梯口房间");
                    // 如果目标房间是楼下, 先定位到下楼梯口房间, 如果目标是楼上,先定位到上楼梯口房间
                    if (targetRoom.getXYZ()[2] == RoomConstant.ROOM_Z_UP)
                    {
                        //    Debug.Log("目标是楼上,先定位到上楼梯口房间");
                        // targetRoom = roomContraller.findRoomByType(RoomConstant.);
                        if (chara.getCurrentRoom()[2] == RoomConstant.ROOM_Z_GROUND)
                        {
                            //    Debug.Log("当前房间 是地面, 只要到向上楼梯房间");
                            if (!AutoMoveManager.move(chara, roomContraller, eventController, diceRoll, aPathManager, RoomConstant.ROOM_TYPE_UPSTAIR, true))
                            {
                                return(false);
                            }
                            else
                            {
                                //      Debug.Log("当前房间 是楼上, 寻找目标房间");
                                path = aPathManager.findPath(roomContraller.findRoomByXYZ(chara.getCurrentRoom()), targetRoom, roomContraller);
                            }
                        }
                        else
                        {
                            if (!AutoMoveManager.move(chara, roomContraller, eventController, diceRoll, aPathManager, RoomConstant.ROOM_TYPE_DOWNSTAIR_BACK, true))
                            {
                                return(false);
                            }
                            else
                            {
                                if (!AutoMoveManager.move(chara, roomContraller, eventController, diceRoll, aPathManager, RoomConstant.ROOM_TYPE_UPSTAIR, true))
                                {
                                    return(false);
                                }
                                else
                                {
                                    //     Debug.Log("现在同层了。。可以找最终目标房间了 :" + targetRoom);
                                    path = aPathManager.findPath(roomContraller.findRoomByXYZ(chara.getCurrentRoom()), targetRoom, roomContraller);
                                }
                            }
                        }
                    }
                    else if (targetRoom.getXYZ()[2] == RoomConstant.ROOM_Z_GROUND)
                    {
                        if (chara.getCurrentRoom()[2] == RoomConstant.ROOM_Z_UP)
                        {
                            if (!AutoMoveManager.move(chara, roomContraller, eventController, diceRoll, aPathManager, RoomConstant.ROOM_TYPE_UPSTAIR_BACK, true))
                            {
                                return(false);
                            }
                            else
                            {
                                //   Debug.Log("现在同层了。。可以找最终目标房间了 :" + targetRoom);
                                path = aPathManager.findPath(roomContraller.findRoomByXYZ(chara.getCurrentRoom()), targetRoom, roomContraller);
                            }
                        }
                        else
                        {
                            if (!AutoMoveManager.move(chara, roomContraller, eventController, diceRoll, aPathManager, RoomConstant.ROOM_TYPE_DOWNSTAIR_BACK, true))
                            {
                                return(false);
                            }
                            else
                            {
                                //   Debug.Log("现在同层了。。可以找最终目标房间了 :" + targetRoom);
                                path = aPathManager.findPath(roomContraller.findRoomByXYZ(chara.getCurrentRoom()), targetRoom, roomContraller);
                            }
                        }
                    }

                    else if (targetRoom.getXYZ()[2] == RoomConstant.ROOM_Z_DOWN)
                    {
                        // Debug.Log("目标是楼下,先定位到下楼梯口房间");
                        if (chara.getCurrentRoom()[2] == RoomConstant.ROOM_Z_GROUND)
                        {
                            //   Debug.Log("当前房间 是地面, 只要到向下楼梯房间");
                            if (!AutoMoveManager.move(chara, roomContraller, eventController, diceRoll, aPathManager, RoomConstant.ROOM_TYPE_DOWNSTAIR, true))
                            {
                                return(false);
                            }
                            else
                            {
                                //
                                //     Debug.Log("现在同层了。。可以找最终目标房间了 :" + targetRoom);

                                path = aPathManager.findPath(roomContraller.findRoomByXYZ(chara.getCurrentRoom()), targetRoom, roomContraller);
                            }
                        }
                        else
                        {
                            if (!AutoMoveManager.move(chara, roomContraller, eventController, diceRoll, aPathManager, RoomConstant.ROOM_TYPE_UPSTAIR_BACK, true))
                            {
                                return(false);
                            }
                            else
                            {
                                if (!AutoMoveManager.move(chara, roomContraller, eventController, diceRoll, aPathManager, RoomConstant.ROOM_TYPE_DOWNSTAIR, true))
                                {
                                    return(false);
                                }
                                else
                                {
                                    Debug.Log("现在同层了。。可以找最终目标房间了 :" + targetRoom);
                                    path = aPathManager.findPath(roomContraller.findRoomByXYZ(chara.getCurrentRoom()), targetRoom, roomContraller);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (chara.ActionPointrolled())
                    {
                        //  Debug.Log("如果目标房间同层,直接找路");
                        int speed = chara.getAbilityInfo()[1] + chara.getDiceNumberBuffer();
                        int res   = diceRoll.calculateDice(speed) + chara.getDiceValueBuffer();
                        chara.updateActionPoint(res);
                        chara.setActionPointrolled(false);
                    }
                    path = aPathManager.findPath(currentRoom, targetRoom, roomContraller);
                }
                while (chara.getActionPoint() > 0 && path.Count > 0)
                {
                    Node nextRoom = path.Peek();
                    bool opened   = false;
                    //判断向什么方向的房间
                    GameObject targetDoor = null;
                    if (chara.getCurrentRoom()[0] == nextRoom.xy[0] && chara.getCurrentRoom()[1] - nextRoom.xy[1] < 0)
                    {
                        //up room
                        //调用AI 专用方法

                        targetDoor = currentRoom.getNorthDoor();
                        //开门成功
                    }
                    else if (chara.getCurrentRoom()[0] == nextRoom.xy[0] && chara.getCurrentRoom()[1] - nextRoom.xy[1] > 0)
                    {
                        //down room
                        targetDoor = currentRoom.getSouthDoor();
                    }
                    else if (chara.getCurrentRoom()[1] == nextRoom.xy[1] && chara.getCurrentRoom()[0] - nextRoom.xy[0] < 0)
                    {
                        //east room
                        targetDoor = currentRoom.getEastDoor();
                    }
                    else
                    {
                        //west room
                        targetDoor = currentRoom.getWestDoor();
                    }

                    if (roomContraller.findRoomByXYZ(nextRoom.xy).checkOpen(chara))
                    {
                        //     Debug.Log("没有锁,可以开门");
                        opened = targetDoor.GetComponent <WoodDoor>().openDoor(chara);
                        //开门成功
                    }
                    else
                    {
                        //     Debug.Log("有锁,不可以开门");
                        if (typeof(NPC).IsAssignableFrom(chara.GetType()))
                        {
                            //      Debug.Log("我是npc,我要去找钥匙开门");
                            NPC npc = (NPC)chara;
                            npc.checkTargetRoomLocked(roomContraller.findRoomByXYZ(nextRoom.xy).getRoomType());
                            return(false);
                        }
                        else
                        {
                            //      Debug.Log("怪物无法发言,只能等门被打开。");
                        };
                    }


                    //如果进入房间是目标房间 暂时回合结束
                    if (opened)
                    {
                        bool result = eventController.excuteLeaveRoomEvent(currentRoom, chara);

                        //非正式测试用,只考虑行动力足够

                        if (result == true)
                        {
                            //离开门成功
                            path.Pop();
                            currentRoom.removeChara(chara);
                            roomContraller.setCharaInMiniMap(chara.getCurrentRoom(), chara, false);
                            //当前人物坐标移动到下一个房间
                            chara.setCurrentRoom(nextRoom.xy);
                            roomContraller.findRoomByXYZ(nextRoom.xy).setChara(chara);
                            roomContraller.setCharaInMiniMap(nextRoom.xy, chara, true);

                            //触发进门事件
                            //	eventController.excuteEnterRoomEvent (nextRoom, roundController.getCurrentRoundChar ());  暂时禁用 运行时有异常
                        }
                        else
                        {
                            //离开失败
                            //   Debug.Log("WoodDoor.cs OnMouseDown 离开房间失败");
                        }
                    }
                }

                //找到房间后, 如果还有体力值, 判定是否是上下楼的房间,如果是 直接上下楼
                if (chara.getActionPoint() > 0)
                {
                    if (targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_UPSTAIR_BACK ||
                        targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_DOWNSTAIR || targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_DOWNSTAIR_BACK)
                    {
                        //   Debug.Log("找到目标房间了,但是行动力没有用完,直接上下楼");
                        RoomInterface stairRoom;
                        if (targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_UPSTAIR)
                        {
                            stairRoom = roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_UPSTAIR_BACK);
                        }
                        else if (targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_UPSTAIR_BACK)
                        {
                            stairRoom = roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_UPSTAIR);
                        }
                        else if (targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_DOWNSTAIR)
                        {
                            stairRoom = roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_DOWNSTAIR_BACK);
                        }
                        else
                        {
                            stairRoom = roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_DOWNSTAIR);
                        }

                        targetRoom.removeChara(chara);
                        roomContraller.setCharaInMiniMap(chara.getCurrentRoom(), chara, false);
                        stairRoom.setChara(chara);
                        chara.setCurrentRoom(stairRoom.getXYZ());
                        chara.updateActionPoint(chara.getActionPoint() - SystemConstant.UPStairActionPoint);
                        roomContraller.setCharaInMiniMap(stairRoom.getXYZ(), chara, true);


                        return(true);
                    }
                }
            }
            else
            {
                if (chara.ActionPointrolled())
                {
                    // Debug.Log("如果目标房间同层,直接找路");
                    int speed = chara.getAbilityInfo()[1] + chara.getDiceNumberBuffer();
                    int res   = diceRoll.calculateDice(speed) + chara.getDiceValueBuffer();
                    chara.updateActionPoint(res);
                    chara.setActionPointrolled(false);
                }

                if (goUpOrDown && (targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_UPSTAIR || targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_UPSTAIR_BACK ||
                                   targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_DOWNSTAIR || targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_DOWNSTAIR_BACK))
                {
                    //  Debug.Log("当前房间是上或者下楼口");
                    //找到房间后, 如果还有体力值, 判定是否是上下楼的房间,如果是 直接上下楼
                    if (chara.getActionPoint() > 0)
                    {
                        //     Debug.Log("找到目标房间了,但是行动力没有用完,直接上下楼");
                        RoomInterface stairRoom;
                        if (targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_UPSTAIR)
                        {
                            stairRoom = roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_UPSTAIR_BACK);
                        }
                        else if (targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_UPSTAIR_BACK)
                        {
                            stairRoom = roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_UPSTAIR);
                        }
                        else if (targetRoom.getRoomType() == RoomConstant.ROOM_TYPE_DOWNSTAIR)
                        {
                            stairRoom = roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_DOWNSTAIR_BACK);
                        }
                        else
                        {
                            stairRoom = roomContraller.findRoomByRoomType(RoomConstant.ROOM_TYPE_DOWNSTAIR);
                        }

                        targetRoom.removeChara(chara);
                        roomContraller.setCharaInMiniMap(chara.getCurrentRoom(), chara, false);
                        stairRoom.setChara(chara);
                        chara.setCurrentRoom(stairRoom.getXYZ());
                        chara.updateActionPoint(chara.getActionPoint() - SystemConstant.UPStairActionPoint);
                        roomContraller.setCharaInMiniMap(stairRoom.getXYZ(), chara, true);

                        return(true);
                    }
                    else
                    {
                        //   Debug.Log("没有体力行动了");
                        return(false);
                    }
                }

                // Debug.Log("和目标房间 一起");
                return(true);
            }
        }
        else
        {
            Debug.Log("你已经丢过行动力骰子");
            return(false);
        }
        return(false);
    }