Exemple #1
0
        public void LeaveRoom(RoomUnit roomUnit)
        {
            roomUnit.StopMoving();
            roomUnit.CurrentTile.UsersOnTile.Remove(roomUnit.VirtualID);

            this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.UserLeaved, new ValueHolder("VirtualID", roomUnit.VirtualID)));

            this.RoomUsers.Remove(roomUnit.VirtualID, roomUnit.GetType());
            this.MovingUsers.TryRemove(roomUnit.VirtualID, out RoomUnit trash);
            this.Room.UpdateUsersCount();

            if (roomUnit.IsRealUser && roomUnit is RoomUnitUser realUser)
            {
                foreach (BotAI bot in this.GetBots())
                {
                    bot.OnUserLeaveRoom(realUser);
                }

                FreezePlayer player = this.Room.RoomFreezeManager.TryGetFreezePlayer(realUser.UserID);
                if (player != null)
                {
                    this.Room.RoomFreezeManager.LeaveGame(player, false);
                }
                this.Room.RoomGameManager.LeaveTeam(realUser);
                this.Room.RoomGameManager.LeaveTag(realUser);

                this.Room.GetTradeByUserId(realUser.UserID)?.Cancel(realUser.Session);

                if (this.Room.RoomData.IsPublicRoom)
                {
                    this.Room.RoomGameManager.RoomWobbleSquabbleManager.Leave(realUser);

                    foreach (RoomGameboard board in this.Room.RoomGameManager.Gameboards.Values)
                    {
                        board.Leave(realUser);
                    }
                }
            }

            if (roomUnit is BotAI bot_)
            {
                bot_.OnSelfLeaveRoom(false);
            }
        }
Exemple #2
0
        public override void OnWalkOn(RoomUnit user)
        {
            this.ExtraData = "1";
            this.UpdateState(false, true);
            this.DoUpdate(1);

            IEnumerable <RoomItem> battleBanzaiTeleports = this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemBattleBanzaiRandomTeleport)).Where(i => i.ID != this.ID);

            if (battleBanzaiTeleports.Count() > 0)
            {
                RoomItem item = battleBanzaiTeleports.ElementAt(RandomUtilies.GetRandom(0, battleBanzaiTeleports.Count() - 1));
                item.ExtraData = "1";
                item.UpdateState(false, true);
                item.DoUpdate(1);

                user.StopMoving();
                user.SetLocation(item.X, item.Y, item.Z); //set new location
                user.UpdateState();
            }
        }