Esempio n. 1
0
        public Gamemap(Room room)
        {
            this.room = room;
            this.DiagonalEnabled = true;
            this.mStaticModel = ButterflyEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName, room.RoomId);
            if (mStaticModel == null)
                throw new Exception("No modeldata found for roomID " + room.RoomId);
            this.mDynamicModel = new DynamicRoomModel(this.mStaticModel);

            this.mCoordinatedItems = new Hashtable();

            this.gotPublicPool = room.RoomData.Model.gotPublicPool;
            this.mGameMap = new byte[Model.MapSizeX, Model.MapSizeY];
            this.mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY];
            userMap = new Hashtable();

            if (room.IsPublic)
                this.roomLinkInformation = ButterflyEnvironment.GetGame().GetRoomManager().getLinkedRoomData(room.RoomId);
        }
Esempio n. 2
0
        public Gamemap(Room room)
        {
            this.room            = room;
            this.DiagonalEnabled = true;
            this.mStaticModel    = ButterflyEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName, room.RoomId);
            if (mStaticModel == null)
            {
                throw new Exception("No modeldata found for roomID " + room.RoomId);
            }
            this.mDynamicModel = new DynamicRoomModel(this.mStaticModel);

            this.mCoordinatedItems = new Hashtable();


            this.gotPublicPool  = room.RoomData.Model.gotPublicPool;
            this.mGameMap       = new byte[Model.MapSizeX, Model.MapSizeY];
            this.mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY];
            userMap             = new Hashtable();

            if (room.IsPublic)
            {
                this.roomLinkInformation = ButterflyEnvironment.GetGame().GetRoomManager().getLinkedRoomData(room.RoomId);
            }
        }
Esempio n. 3
0
        internal void Destroy()
        {
            userMap.Clear();
            mDynamicModel.Destroy();
            mCoordinatedItems.Clear();
            if (roomLinkInformation != null)
            {
                roomLinkInformation.Clear();
            }

            Array.Clear(mGameMap, 0, mGameMap.Length);
            Array.Clear(mUserItemEffect, 0, mUserItemEffect.Length);
            Array.Clear(mItemHeightMap, 0, mItemHeightMap.Length);

            userMap             = null;
            mGameMap            = null;
            mUserItemEffect     = null;
            mItemHeightMap      = null;
            mCoordinatedItems   = null;
            roomLinkInformation = null;
            mDynamicModel       = null;
            room         = null;
            mStaticModel = null;
        }
Esempio n. 4
0
        internal void UpdateUserStatus(RoomUser User, bool cyclegameitems)
        {
            if (User == null)
            {
                return;
            }
            bool isBot = User.IsBot;

            if (isBot)
            {
                cyclegameitems = false;
            }

            if (User.Statusses.ContainsKey("lay") || User.Statusses.ContainsKey("sit"))
            {
                User.Statusses.Remove("lay");
                User.Statusses.Remove("sit");
                User.UpdateNeeded = true;
            }

            //List<RoomItem> ItemsOnSquare = GetFurniObjects(User.X, User.Y);
            CoordItemSearch ItemSearch    = new CoordItemSearch(room.GetGameMap().CoordinatedItems);
            List <RoomItem> ItemsOnSquare = ItemSearch.GetAllRoomItemForSquare(User.X, User.Y);
            double          newZ          = room.GetGameMap().SqAbsoluteHeight(User.X, User.Y, ItemsOnSquare);

            if (newZ != User.Z)
            {
                User.Z = newZ;
                if (User.isFlying)
                {
                    User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk));
                }
                User.UpdateNeeded = true;
            }

            DynamicRoomModel Model = room.GetGameMap().Model;

            if (Model.SqState[User.X, User.Y] == SquareState.SEAT)
            {
                if (!User.Statusses.ContainsKey("sit"))
                {
                    User.Statusses.Add("sit", "1.0");
                }

                User.Z = Model.SqFloorHeight[User.X, User.Y];
                if (User.isFlying)
                {
                    User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk));
                }
                User.RotHead = Model.SqSeatRot[User.X, User.Y];
                User.RotBody = Model.SqSeatRot[User.X, User.Y];

                User.UpdateNeeded = true;
            }

            foreach (RoomItem Item in ItemsOnSquare)
            {
                if (cyclegameitems)
                {
                    Item.UserWalksOnFurni(User);
                }

                if (Item.GetBaseItem().IsSeat)
                {
                    if (!User.Statusses.ContainsKey("sit"))
                    {
                        User.Statusses.Add("sit", TextHandling.GetString(Item.GetBaseItem().Height));
                    }

                    User.Z = Item.GetZ;
                    if (User.isFlying)
                    {
                        User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk));
                    }
                    User.RotHead = Item.Rot;
                    User.RotBody = Item.Rot;

                    User.UpdateNeeded = true;
                }


                switch (Item.GetBaseItem().InteractionType)
                {
                case InteractionType.bed:
                {
                    if (!User.Statusses.ContainsKey("lay"))
                    {
                        User.Statusses.Add("lay", TextHandling.GetString(Item.GetBaseItem().Height) + " null");
                    }

                    User.Z = Item.GetZ;
                    if (User.isFlying)
                    {
                        User.Z += 4 + (0.2 * 0.5 * Math.Sin(0.7 * User.flyk));
                    }
                    User.RotHead = Item.Rot;
                    User.RotBody = Item.Rot;

                    User.UpdateNeeded = true;
                    break;
                }

                case InteractionType.fbgate:
                {
                    if (cyclegameitems)
                    {
                        if (User.team != Item.team)
                        {
                            User.team = Item.team;
                        }

                        else if (User.team == Item.team)
                        {
                            User.team = Team.none;
                        }

                        if (!string.IsNullOrEmpty(Item.Figure))
                        {
                            //User = GetUserForSquare(Item.Coordinate.X, Item.Coordinate.Y);
                            if (User != null && !User.IsBot)
                            {
                                if (User.Coordinate == Item.Coordinate)
                                {
                                    if (User.GetClient().GetHabbo().Gender != Item.Gender && User.GetClient().GetHabbo().Look != Item.Figure)
                                    {
                                        User.GetClient().GetHabbo().tempGender = User.GetClient().GetHabbo().Gender;
                                        User.GetClient().GetHabbo().tempLook   = User.GetClient().GetHabbo().Look;

                                        User.GetClient().GetHabbo().Gender = Item.Gender;
                                        User.GetClient().GetHabbo().Look   = Item.Figure;
                                    }
                                    else
                                    {
                                        User.GetClient().GetHabbo().Gender = User.GetClient().GetHabbo().tempGender;
                                        User.GetClient().GetHabbo().Look   = User.GetClient().GetHabbo().tempLook;
                                    }

                                    ServerMessage RoomUpdate = new ServerMessage(266);
                                    RoomUpdate.AppendInt32(User.VirtualId);
                                    RoomUpdate.AppendStringWithBreak(User.GetClient().GetHabbo().Look);
                                    RoomUpdate.AppendStringWithBreak(User.GetClient().GetHabbo().Gender.ToLower());
                                    RoomUpdate.AppendStringWithBreak(User.GetClient().GetHabbo().Motto);
                                    room.SendMessage(RoomUpdate);
                                }
                            }
                        }
                    }

                    break;
                }

                //33: Red
                //34: Green
                //35: Blue
                //36: Yellow

                case InteractionType.banzaigategreen:
                case InteractionType.banzaigateblue:
                case InteractionType.banzaigatered:
                case InteractionType.banzaigateyellow:
                {
                    if (cyclegameitems)
                    {
                        int effectID = (int)Item.team + 32;
                        AvatarEffectsInventoryComponent efectmanager = User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent();

                        if (User.team != Item.team)
                        {
                            User.team = Item.team;

                            if (efectmanager.CurrentEffect != effectID)
                            {
                                efectmanager.ApplyCustomEffect(effectID);
                            }
                        }
                        else
                        {
                            if (efectmanager.CurrentEffect == effectID)
                            {
                                efectmanager.ApplyCustomEffect(0);
                            }
                            User.team = Team.none;
                        }
                    }
                    break;
                }

                case InteractionType.freezeyellowgate:
                case InteractionType.freezeredgate:
                case InteractionType.freezegreengate:
                case InteractionType.freezebluegate:
                {
                    if (cyclegameitems)
                    {
                        int effectID = (int)Item.team + 39;
                        AvatarEffectsInventoryComponent efectmanager = User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent();

                        if (User.team != Item.team)
                        {
                            User.team = Item.team;

                            if (efectmanager.CurrentEffect != effectID)
                            {
                                efectmanager.ApplyCustomEffect(effectID);
                            }
                        }
                        else
                        {
                            if (efectmanager.CurrentEffect == effectID)
                            {
                                efectmanager.ApplyCustomEffect(0);
                            }
                            User.team = Team.none;
                        }

                        ServerMessage message = new ServerMessage(700);
                        message.AppendBoolean((User.team != Team.none));

                        User.GetClient().SendMessage(message);
                    }
                    break;
                }

                case InteractionType.banzaitele:
                {
                    room.GetGameItemHandler().onTeleportRoomUserEnter(User, Item);
                    break;
                }
                }
            }

            if (cyclegameitems)
            {
                if (room.GotSoccer())
                {
                    room.GetSoccer().OnUserWalk(User);
                }

                if (room.GotBanzai())
                {
                    room.GetBanzai().OnUserWalk(User);
                }

                //if (room.GotFreeze())
                room.GetFreeze().OnUserWalk(User);
            }
        }
Esempio n. 5
0
        internal RoomUser DeployBot(RoomBot Bot, Pet PetData)
        {
            RoomUser BotUser    = new RoomUser(0, room.RoomId, primaryPrivateUserID++, room, false);
            int      PersonalID = secondaryPrivateUserID++;

            BotUser.InternalRoomID = PersonalID;
            //this.UserList[PersonalID] = BotUser;
            userlist.Add(PersonalID, BotUser);
            DynamicRoomModel Model = room.GetGameMap().Model;

            if ((Bot.X > 0 && Bot.Y > 0) && Bot.X < Model.MapSizeX && Bot.Y < Model.MapSizeY)
            {
                BotUser.SetPos(Bot.X, Bot.Y, Bot.Z);
                BotUser.SetRot(Bot.Rot, false);
            }
            else
            {
                Bot.X = Model.DoorX;
                Bot.Y = Model.DoorY;

                BotUser.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ);
                BotUser.SetRot(Model.DoorOrientation, false);
            }

            BotUser.BotData = Bot;
            BotUser.BotAI   = Bot.GenerateBotAI(BotUser.VirtualId);

            if (BotUser.IsPet)
            {
                BotUser.BotAI.Init((int)Bot.BotId, BotUser.VirtualId, room.RoomId, BotUser, room);
                BotUser.PetData           = PetData;
                BotUser.PetData.VirtualId = BotUser.VirtualId;
            }
            else
            {
                BotUser.BotAI.Init(-1, BotUser.VirtualId, room.RoomId, BotUser, room);
            }

            UpdateUserStatus(BotUser, false);
            BotUser.UpdateNeeded = true;

            ServerMessage EnterMessage = new ServerMessage(28);

            EnterMessage.AppendInt32(1);
            BotUser.Serialize(EnterMessage, room.GetGameMap().gotPublicPool);
            room.SendMessage(EnterMessage);

            BotUser.BotAI.OnSelfEnterRoom();

            if (BotUser.BotData.AiType == AIType.Guide)
            {
                room.guideBotIsCalled = true;
            }
            if (BotUser.IsPet)
            {
                if (pets.ContainsKey(BotUser.PetData.PetId)) //Pet allready placed
                {
                    pets[BotUser.PetData.PetId] = BotUser;
                }
                else
                {
                    pets.Add(BotUser.PetData.PetId, BotUser);
                }

                petCount++;
            }

            return(BotUser);
        }
Esempio n. 6
0
        private void OnUserAdd(object sender, EventArgs args)
        {
            try
            {
                KeyValuePair <int, RoomUser> userPair = (KeyValuePair <int, RoomUser>)sender;
                RoomUser user = userPair.Value;

                if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null)
                {
                    return;
                }

                GameClient session = user.GetClient();

                if (session == null || session.GetHabbo() == null)
                {
                    return;
                }

                if (userCount >= room.UsersMax && user.GetClient().GetHabbo().Rank < 4)
                {
                    ServerMessage msg = new ServerMessage(33);
                    msg.AppendInt32(4008);
                    session.SendMessage(msg);
                    return;
                }

                if (session.GetHabbo() != null && session.GetHabbo().userGroup != null)
                {
                    Group group = session.GetHabbo().userGroup;
                    if (!room.groups.ContainsKey(group.groupID))
                    {
                        room.groups.Add(group.groupID, group);
                    }
                }

                if (!user.IsSpectator)
                {
                    DynamicRoomModel Model = room.GetGameMap().Model;
                    if (room.IsPublic && session.SetDoorPos)
                    {
                        user.SetPos(session.newDoorPos.X, session.newDoorPos.Y, room.GetGameMap().StaticModel.SqFloorHeight[session.newDoorPos.X, session.newDoorPos.Y]);
                        user.SetRot(Model.DoorOrientation, false);
                        session.SetDoorPos = false;
                    }
                    else
                    {
                        user.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ);
                        user.SetRot(Model.DoorOrientation, false);
                    }

                    if (room.CheckRights(session, true))
                    {
                        user.AddStatus("flatcrtl", "useradmin");
                    }
                    else if (room.CheckRights(session))
                    {
                        user.AddStatus("flatcrtl", "");
                    }
                    user.CurrentItemEffect = ItemEffectType.None;

                    //UpdateUserEffect(User, User.X, User.Y);

                    if (!user.IsBot && user.GetClient().GetHabbo().IsTeleporting)
                    {
                        RoomItem Item = room.GetRoomItemHandler().GetItem(user.GetClient().GetHabbo().TeleporterId);

                        if (Item != null)
                        {
                            user.SetPos(Item.GetX, Item.GetY, Item.GetZ);
                            user.SetRot(Item.Rot, false);

                            Item.InteractingUser2 = session.GetHabbo().Id;
                            Item.ExtraData        = "2";
                            Item.UpdateState(false, true);
                        }
                    }

                    user.GetClient().GetHabbo().IsTeleporting = false;
                    user.GetClient().GetHabbo().TeleporterId  = 0;

                    ServerMessage EnterMessage = new ServerMessage(28);
                    EnterMessage.AppendInt32(1);
                    user.Serialize(EnterMessage, room.GetGameMap().gotPublicPool);
                    room.SendMessage(EnterMessage);


                    if (room.Owner != session.GetHabbo().Username&& !room.IsPublic)
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(user.GetClient(), HabboHotel.Quests.QuestType.SOCIAL_VISIT);
                    }
                }

                if (session.GetHabbo().GetMessenger() != null)
                {
                    session.GetHabbo().GetMessenger().OnStatusChanged(true);
                }


                if (!user.IsSpectator)
                {
                    foreach (RoomUser roomUser in UserList.Values)
                    {
                        if (!user.IsBot)
                        {
                            continue;
                        }

                        roomUser.BotAI.OnUserEnterRoom(user);
                    }
                }

                user.GetClient().GetMessageHandler().OnRoomUserAdd();

                if (OnUserEnter != null)
                {
                    OnUserEnter(user, null);
                }

                if (room.GotMusicController())
                {
                    room.GetRoomMusicController().OnNewUserEnter(user);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException(e.ToString());
            }
        }
Esempio n. 7
0
        internal void Destroy()
        {
            userMap.Clear();
            mDynamicModel.Destroy();
            mCoordinatedItems.Clear();
            if (roomLinkInformation != null)
                roomLinkInformation.Clear();

            Array.Clear(mGameMap, 0, mGameMap.Length);
            Array.Clear(mUserItemEffect, 0, mUserItemEffect.Length);
            Array.Clear(mItemHeightMap, 0, mItemHeightMap.Length);

            userMap = null;
            mGameMap = null;
            mUserItemEffect = null;
            mItemHeightMap = null;
            mCoordinatedItems = null;
            roomLinkInformation = null;
            mDynamicModel = null;
            room = null;
            mStaticModel = null;
        }
Esempio n. 8
0
		public Gamemap(Room room)
		{
			this.room = room;
			this.DiagonalEnabled = true;
			this.mStaticModel = ButterflyEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName, room.RoomId);
            if (mStaticModel == null)
            {
                Logging.LogMessage("The room model " + room.ModelName + " could not be found for room " + room.RoomId);
                room.ModelName = "model_a";
                this.mStaticModel = ButterflyEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName, room.RoomId);
            }

            if (mStaticModel == null)
                throw new Exception("No modeldata found for roomID " + room.RoomId);

			if(room.ModelName == "custom")
				room.ModelName = "model_custom" + room.RoomId;
			this.mDynamicModel = new DynamicRoomModel(this.mStaticModel);

			this.mCoordinatedItems = new Hashtable();
			this.coordinatedItemEvents = new Hashtable();


		//	this.gotPublicPool = room.RoomData.Model.gotPublicPool;
			this.mGameMap = new byte[Model.MapSizeX, Model.MapSizeY];
			this.mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY];
			userMap = new Hashtable();
		}