示例#1
0
        public void OnWillDelete(long id)
        {
            // 刪除前的物件
            Room room = RoomMemorySync.Get <Room>(id);

            if (room == null)
            {
                // GG跑到這邊表示有問題
                Log.Error($"Room[{id}] has removed!");
            }
            else
            {
                switch (room.Type)
                {
                case RoomType.Roaming:
                    room = OtherHelper.Search(RoamingList, r => r.Id == id);
                    if (room != null)
                    {
                        RoamingList.Remove(room);
                    }
                    break;

                case RoomType.Team:
                    room = OtherHelper.Search(TeamList, r => r.Id == id);
                    if (room != null)
                    {
                        TeamList.Remove(room);
                    }
                    break;
                }
            }
        }
示例#2
0
        public void OnCreate(long id)
        {
            Room room  = RoomMemorySync.Get <Room>(id);
            Room first = null;

            // 房間創建同步完成
            if (room != null)
            {
                switch (room.Type)
                {
                case RoomType.Roaming:
                    first = OtherHelper.Search(RoamingList, r => r.Id == id);
                    if (first == null)
                    {
                        RoamingList.Add(room);
                    }
                    break;

                case RoomType.Team:
                    first = OtherHelper.Search(TeamList, r => r.Id == id);
                    if (first == null)
                    {
                        TeamList.Add(room);
                    }
                    break;
                }
            }
            else
            {
                // GG跑到這邊表示有問題
                Log.Error($"Room[{id}] is missing!");
            }
        }
        public void Leave(MapUnit mapUnit, bool isLeaveRoom)
        {
            if (!IsOnSameRoom(mapUnit))
            {
                return;
            }

            mapUnit.SendChannel = null;

            var obj = OtherHelper.Search(PositionMambers, e => e.Uid == mapUnit.Uid);

            if (obj != null)
            {
                PositionMambers.Remove(mapUnit);
            }

            if (isLeaveRoom)
            {
                //如果MapUnit是離開Room,要告知MapUnitDestroy
                m2C_MapUnitDestroy.MapUnitId = mapUnit.Id;
                SendMessage(m2C_MapUnitDestroy);
            }
            else
            {
                //如果MapUnit是離開Block,不就要告知觀看者MapUnitDestroy
                for (int i = 0; i < mapUnit.LookAtSources.Count; i++)
                {
                    Unlook(mapUnit.LookAtSources[i]);
                }
                m2C_MapUnitDestroy.MapUnitId = mapUnit.Id;
                SendMessage(m2C_MapUnitDestroy);
            }
        }
        public void Unlook(MapUnit mapUnit)
        {
            var obj = OtherHelper.Search(ReceviceMambers, e => e.Uid == mapUnit.Uid);

            if (obj != null)
            {
                ReceviceMambers.Remove(mapUnit);
            }
        }
        public void Look(MapUnit mapUnit)
        {
            if (!IsOnSameRoom(mapUnit))
            {
                return;
            }

            var obj = OtherHelper.Search(ReceviceMambers, e => e.Uid == mapUnit.Uid);

            if (obj == null)
            {
                ReceviceMambers.Add(mapUnit);
            }
        }
示例#6
0
        public void OnCreate(long id)
        {
            //if (MemorySync.IsMine(id))
            //    return;
            Room room  = MemorySync.Get <Room>(id);
            Room first = null;

            // 房間創建同步完成
            if (room != null)
            {
                // 初始化同步用控制器
                switch (room.Type)
                {
                case RoomType.Roaming:
                    first = OtherHelper.Search(RoamingList, r => r.Id == id);
                    if (first == null)
                    {
                        RoamingList.Add(room);
                        RoamingSettingDict.Add(room.info.RoadSettingId, room);
                    }
                    break;

                case RoomType.Team:
                    first = OtherHelper.Search(TeamList, r => r.Id == id);
                    if (first == null)
                    {
                        TeamList.Add(room);
                    }
                    break;
                }
            }
            else
            {
                // GG跑到這邊表示有問題
                Log.Error($"Room[{id}] is missing!");
            }
        }
        public void Enter(MapUnit mapUnit, double position)
        {
            if (!IsOnSameRoom(mapUnit))
            {
                return;
            }

            mapUnit.SendChannel = this;

            var obj = OtherHelper.Search(PositionMambers, e => e.Uid == mapUnit.Uid);

            if (obj == null)
            {
                PositionMambers.Add(mapUnit);
            }
            m2C_MapUnitCreate.MapUnitInfo = mapUnit.Info;
            SendMessage(m2C_MapUnitCreate);
            var lookAtSources = mapUnit.GetLookAtSources();

            for (int i = 0; i < lookAtSources.Count; i++)
            {
                Look(lookAtSources[i]);
            }
        }