//RoomElement m_ele = null;
 //MonsterRoomData m_monsterData = null;
 public TrapRefresh(Transform trans, SceneRoom room, TrapData trapData)
 {
     m_refreshType = ENRefreshType.enTrapRefresh;
     m_room        = room;
     m_ObjectPred  = trans;
     m_trapData    = trapData;
 }
        public static void SpawnMe(SceneRoom room, TrapData trapData)
        {
            string     objName  = "trap_" + trapData.trapId + "_" + trapData.trapObjId;
            GameObject childObj = new GameObject(objName);

            childObj.transform.parent        = room.m_parentObj.transform;
            childObj.transform.localPosition = new Vector3(trapData.position.x * SM.SceneRoom.blockWidth, 0f, trapData.position.z * SM.SceneRoom.blockHeight);
            TrapRefresh trap = new TrapRefresh(childObj.transform, room, trapData);

            room.m_trapRefreshList.Add(trap);
        }
Beispiel #3
0
        public Actor GetTrapByID(int trapId)
        {
            TrapData data  = null;
            Actor    actor = null;

            if (mTrapDataDict.TryGetValue(trapId, out data))
            {
                actor = ActorManager.Singleton.Lookup(data.outDyncId);
                if (null == actor)
                {
                    return(null);
                }
            }
            return(actor);
        }
Beispiel #4
0
        // 根据服务器发送过来的字符串构建房间tree data
        public void BuildTree(JsonData data, SceneRoomInfoTree parent, string roomkey)
        {
            m_nextActiveRoom.Clear();
            m_parent = parent;
            if (!data.Keys.Contains(roomkey))
            {
                //return;
            }
            else
            {
                data = data[roomkey];
                // char position
                if (data.Keys.Contains(scharPosition))
                {
                    m_charPosition.x = int.Parse(data[scharPosition][sposx].ToString());
                    m_charPosition.z = int.Parse(data[scharPosition][sposy].ToString());
                }
                m_GUID      = int.Parse(data[sroomId].ToString());
                m_roomObjID = int.Parse(data[sroomObjId].ToString());
                if (data.Keys.Contains(sroonName))
                {
                    m_roomName = data[sroonName].ToString();
                }

                SceneRoomInfo roomInfo = GameTable.SceneRoomTableAsset.Lookup(m_roomObjID);
                if (null != roomInfo)
                {
                    m_RoomPrefabName = roomInfo.prefabName;
                }
                //TextAsset asset = GameData.Load<TextAsset>(obstacleFileName);
                //m_obstacleData = new SceneObstacleData();
                //if (asset == null)
                //{
                //    Debug.Log("obstacleFileName=" + obstacleFileName);
                //}
                //m_obstacleData.Load(asset.bytes);
                // teleport data
                if (data.Keys.Contains(steleportGate))
                {
                    m_teleportData            = new TeleportData();
                    m_teleportData.objId      = int.Parse(data[steleportGate][steleportObjId].ToString());
                    m_teleportData.position.x = int.Parse(data[steleportGate][sposition][sposx].ToString());
                    m_teleportData.position.z = int.Parse(data[steleportGate][sposition][sposy].ToString());
                    m_teleportData.target     = data[steleportGate][starget].ToString();
                }
                //gates info
                JsonData gatesItem = data[sgates];
                if (gatesItem.IsArray)
                {
                    for (int i = 0; i < gatesItem.Count; i++)
                    {
                        Gate gate = new Gate();
                        gate.gateId             = int.Parse(gatesItem[i][sgateId].ToString());
                        gate.gateObjId          = int.Parse(gatesItem[i][sgateObjId].ToString());
                        gate.isGateOpen         = (int.Parse(gatesItem[i][sisGateOpen].ToString()) == 1);
                        gate.gateDirectionIndex = i;
                        if (gate.isGateOpen)
                        {
                            gate.gateOpenCondId = (ENGateOpenCondType)int.Parse(gatesItem[i][sgateOpenCondId].ToString());
                            // open gate condition param
                            if (gatesItem[i].Keys.Contains(sgateOpenCondParam))
                            {
                                if (gatesItem[i][sgateOpenCondParam].IsArray)
                                {
                                    for (int n = 0; n < gatesItem[i][sgateOpenCondParam].Count; n++)
                                    {
                                        gate.gateOpenCondParam.Add(int.Parse(gatesItem[i][sgateOpenCondParam][n].ToString()));
                                    }
                                }
                            }
                            if (gatesItem[i].Keys.Contains(sgateOpenCondCount))
                            {
                                if (gatesItem[i][sgateOpenCondCount].IsArray)
                                {
                                    for (int n = 0; n < gatesItem[i][sgateOpenCondCount].Count; n++)
                                    {
                                        gate.gateOpenCondCount.Add(int.Parse(gatesItem[i][sgateOpenCondCount][n].ToString()));
                                    }
                                }
                            }
                            //bridge info
                            if (gatesItem[i].Keys.Contains(sbridge))
                            {
                                JsonData bridgeItem = gatesItem[i][sbridge];
                                if (bridgeItem.IsObject)
                                {
                                    gate.BridgeData                    = new Bridge();
                                    gate.BridgeData.bridgeObjId        = int.Parse(bridgeItem[sbridgeObjId].ToString());
                                    gate.BridgeData.bridgeCenterLength = int.Parse(bridgeItem[sbridgeCenterLength].ToString());
                                    SceneRoomInfoTree childInfo = new SceneRoomInfoTree();
                                    childInfo.BuildTree(bridgeItem, this, stargetRoom);
                                    gate.BridgeData.nextRoomNode = childInfo;
                                    m_nextActiveRoom.Add(childInfo);
                                }
                            }
                        }
                        m_gateList.Add(gate);
                    }
                }
                // monsters
                if (data.Keys.Contains(smonsters))
                {
                    JsonData monsterDataItem = data[smonsters];
                    if (monsterDataItem.IsArray)
                    {
                        for (int i = 0; i < monsterDataItem.Count; i++)
                        {
                            MonsterRoomData monsterData = new MonsterRoomData();
                            monsterData.monsterId    = int.Parse(monsterDataItem[i][smonsterId].ToString());
                            monsterData.monsterObjId = int.Parse(monsterDataItem[i][smonsterObjId].ToString());
                            monsterData.position.x   = int.Parse(monsterDataItem[i][sposition][sposx].ToString());
                            monsterData.position.z   = int.Parse(monsterDataItem[i][sposition][sposy].ToString());
                            monsterData.appearCondId = (ENMonsterAppearType)int.Parse(monsterDataItem[i][sappearCondId].ToString());
                            if (monsterDataItem[i].Keys.Contains(sdropList))
                            {
                                for (int j = 0; j < monsterDataItem[i][sdropList].Count; j++)
                                {
                                    monsterData.dropList.Add(int.Parse(monsterDataItem[i][sdropList][j].ToString()));
                                }
                            }
                            m_monsterDataList.Add(monsterData);
                        }
                    }
                }

                //解析Json每个房间中的宝箱的数据
                if (data.Keys.Contains(sTreasure))
                {
                    JsonData treasureDataItem = data[sTreasure];
                    if (treasureDataItem.IsArray)
                    {
                        for (int i = 0; i < treasureDataItem.Count; i++)
                        {
                            MonsterRoomData treasureData = new MonsterRoomData();
                            treasureData.monsterId    = int.Parse(treasureDataItem[i][sTreasureId].ToString());
                            treasureData.monsterObjId = int.Parse(treasureDataItem[i][sTreasureObjId].ToString());
                            treasureData.position.x   = int.Parse(treasureDataItem[i][sposition][sposx].ToString());
                            treasureData.position.z   = int.Parse(treasureDataItem[i][sposition][sposy].ToString());
                            //treasureData.appearCondId = (ENMonsterAppearType)int.Parse(treasureDataItem[i][sappearCondId].ToString());
                            m_treasureDataList.Add(treasureData);
                        }
                    }
                }
                {
//                     TrapData trapData = new TrapData();
//                     trapData.trapId = 201;
//                     trapData.trapObjId = 2;
//                     trapData.position.x = 5;
//                     trapData.position.z = 5;
//                     trapData.mTrapState = (RMESchemeEdit.BeginState)1;
//                     //treasureData.appearCondId = (ENMonsterAppearType)int.Parse(treasureDataItem[i][sappearCondId].ToString());
//                     m_trapDataList.Add(trapData);
//                     trapData = new TrapData();
//                     trapData.trapId = 202;
//                     trapData.trapObjId = 2;
//                     trapData.position.x = 7;
//                     trapData.position.z = 7;
//                     trapData.mTrapState = (RMESchemeEdit.BeginState)1;
//                     //treasureData.appearCondId = (ENMonsterAppearType)int.Parse(treasureDataItem[i][sappearCondId].ToString());
//                     m_trapDataList.Add(trapData);
                }
                //解析Json每个房间中的机关的数据
                if (data.Keys.Contains(sTrap))
                {
                    JsonData trapDataItem = data[sTrap];
                    if (trapDataItem.IsArray)
                    {
                        for (int i = 0; i < trapDataItem.Count; i++)
                        {
                            TrapData trapData = new TrapData();
                            trapData.trapId     = int.Parse(trapDataItem[i][sTrapId].ToString());
                            trapData.trapObjId  = int.Parse(trapDataItem[i][sTrapObjId].ToString());
                            trapData.position.x = int.Parse(trapDataItem[i][sposition][sposx].ToString());
                            trapData.position.z = int.Parse(trapDataItem[i][sposition][sposy].ToString());
                            trapData.beginState = int.Parse(trapDataItem[i][sBeginState].ToString()) == 1;
                            trapData.beginEable = int.Parse(trapDataItem[i][sBeginEable].ToString()) == 1;
                            trapData.mTrapState = (Trap.TrapState) int.Parse(trapDataItem[i][sBeginState].ToString());
                            //treasureData.appearCondId = (ENMonsterAppearType)int.Parse(treasureDataItem[i][sappearCondId].ToString());
                            m_trapDataList.Add(trapData);
                        }
                    }
                }
                //当前房间是否要用到钥匙
//                 if ()
//                 {
//                     mIsNeedKey = true;
//                 }
            }
        }