コード例 #1
0
ファイル: Gamemap.cs プロジェクト: Kristopher-RZ/Firewind
        public GameMap(Room room)
        {
            this.room = room;
            this.DiagonalEnabled = true;
            this.mStaticModel = FirewindEnvironment.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.mGameMap = new byte[Model.MapSizeX, Model.MapSizeY];
            this.mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY];
            _unitMap = new Hashtable();
        }
コード例 #2
0
ファイル: RoomUnitManager.cs プロジェクト: Habbotard/Firewind
        internal void UpdateUserStatus(RoomUnit unit, bool cyclegameitems)
        {
            try
            {
                if (unit == null)
                {
                    return;
                }
                RoomUser user  = unit as RoomUser;
                bool     isBot = user == null;
                if (isBot)
                {
                    cyclegameitems = false;
                }

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

                if (unit.Statuses.ContainsKey("sign"))
                {
                    unit.Statuses.Remove("sign");
                    unit.UpdateNeeded = true;
                }

                //List<RoomItem> ItemsOnSquare = GetFurniObjects(User.X, User.Y);
                CoordItemSearch ItemSearch    = new CoordItemSearch(room.GetGameMap().CoordinatedItems);
                List <RoomItem> ItemsOnSquare = ItemSearch.GetAllRoomItemForSquare(unit.X, unit.Y);
                double          newZ;
                //if (user.isMounted == true && user.IsPet == false)
                //{
                //    newZ = room.GetGameMap().SqAbsoluteHeight(user.X, user.Y, ItemsOnSquare) + 1;
                //}
                //else
                {
                    newZ = room.GetGameMap().SqAbsoluteHeight(unit.X, unit.Y, ItemsOnSquare);
                }

                if (!isBot)
                {
                    if (newZ != user.Z)
                    {
                        user.Z = newZ;
                        if (user.IsFlying)
                        {
                            user.Z += 4 + (0.5 * Math.Sin(0.7 * user.FlyCounter));
                        }
                        user.UpdateNeeded = true;
                    }
                }

                DynamicRoomModel Model = room.GetGameMap().Model;
                if (Model.SqState[unit.X, unit.Y] == SquareState.SEAT)
                {
                    if (!unit.Statuses.ContainsKey("sit"))
                    {
                        unit.Statuses.Add("sit", "1.0");
                    }

                    unit.Z = Model.SqFloorHeight[unit.X, unit.Y];
                    if (!isBot && user.IsFlying)
                    {
                        user.Z += 4 + (0.5 * Math.Sin(0.7 * user.FlyCounter));
                    }
                    unit.RotHead = Model.SqSeatRot[unit.X, unit.Y];
                    unit.RotBody = Model.SqSeatRot[unit.X, unit.Y];

                    unit.UpdateNeeded = true;
                }

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

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

                        unit.Z = Item.GetZ;
                        if (!isBot && user.IsFlying)
                        {
                            user.Z += 4 + (0.5 * Math.Sin(0.7 * user.FlyCounter));
                        }
                        unit.RotHead = Item.Rot;
                        unit.RotBody = Item.Rot;

                        unit.UpdateNeeded = true;
                    }


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

                        unit.Z = Item.GetZ;
                        if (!isBot && user.IsFlying)
                        {
                            user.Z += 4 + (0.2 * 0.5 * Math.Sin(0.7 * user.FlyCounter));
                        }
                        unit.RotHead = Item.Rot;
                        unit.RotBody = Item.Rot;

                        unit.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)
                                {
                                    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(Outgoing.UpdateUserInformation);
                                        RoomUpdate.AppendInt32(user.VirtualID);
                                        RoomUpdate.AppendStringWithBreak(user.GetClient().GetHabbo().Look);
                                        RoomUpdate.AppendStringWithBreak(user.GetClient().GetHabbo().Gender.ToLower());
                                        RoomUpdate.AppendStringWithBreak(user.GetClient().GetHabbo().Motto);
                                        RoomUpdate.AppendInt32(user.GetClient().GetHabbo().AchievementPoints);
                                        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;
                            TeamManager t        = user.GetClient().GetHabbo().CurrentRoom.GetTeamManagerForBanzai();
                            AvatarEffectsInventoryComponent efectmanager = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent();

                            if (user.Team != Item.team)
                            {
                                if (t.CanEnterOnTeam(Item.team))
                                {
                                    if (user.Team != Team.none)
                                    {
                                        t.OnUserLeave(user);
                                    }
                                    user.Team = Item.team;
                                    t.AddUser(user);

                                    if (efectmanager.CurrentEffect != effectID)
                                    {
                                        efectmanager.ApplyCustomEffect(effectID);
                                    }
                                }
                            }
                            else
                            {
                                //usersOnTeam--;
                                t.OnUserLeave(user);
                                if (efectmanager.CurrentEffect == effectID)
                                {
                                    efectmanager.ApplyCustomEffect(0);
                                }
                                user.Team = Team.none;
                            }
                            //((StringData)Item.data).Data = usersOnTeam.ToString();
                            //Item.UpdateState(false, true);
                        }
                        break;
                    }

                    case InteractionType.freezeyellowgate:
                    case InteractionType.freezeredgate:
                    case InteractionType.freezegreengate:
                    case InteractionType.freezebluegate:
                    {
                        if (cyclegameitems)
                        {
                            int         effectID = (int)Item.team + 39;
                            TeamManager t        = user.GetClient().GetHabbo().CurrentRoom.GetTeamManagerForFreeze();
                            //int usersOnTeam = 0;
                            //if (((StringData)Item.data).Data != "")
                            //usersOnTeam = int.Parse(((StringData)Item.data).Data);
                            AvatarEffectsInventoryComponent efectmanager = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent();

                            if (user.Team != Item.team)
                            {
                                if (t.CanEnterOnTeam(Item.team))
                                {
                                    if (user.Team != Team.none)
                                    {
                                        t.OnUserLeave(user);
                                    }
                                    user.Team = Item.team;
                                    t.AddUser(user);

                                    if (efectmanager.CurrentEffect != effectID)
                                    {
                                        efectmanager.ApplyCustomEffect(effectID);
                                    }
                                }
                            }
                            else
                            {
                                //usersOnTeam--;
                                t.OnUserLeave(user);
                                if (efectmanager.CurrentEffect == effectID)
                                {
                                    efectmanager.ApplyCustomEffect(0);
                                }
                                user.Team = Team.none;
                            }
                            //((StringData)Item.data).Data = usersOnTeam.ToString();
                            //Item.UpdateState(false, true);

                            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);
                }
            }
            catch (Exception e)
            {
            }
        }
コード例 #3
0
ファイル: Gamemap.cs プロジェクト: Kristopher-RZ/Firewind
        internal void Destroy()
        {
            _unitMap.Clear();
            mDynamicModel.Destroy();
            mCoordinatedItems.Clear();

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

            _unitMap = null;
            mGameMap = null;
            mUserItemEffect = null;
            mItemHeightMap = null;
            mCoordinatedItems = null;
            mDynamicModel = null;
            room = null;
            mStaticModel = null;
        }
コード例 #4
0
ファイル: RoomUnitManager.cs プロジェクト: Habbotard/Firewind
        private void UnitList_onAdd(object sender, EventArgs args)
        {
            try
            {
                KeyValuePair <int, RoomUnit> userPair = (KeyValuePair <int, RoomUnit>)sender;
                RoomUser user = userPair.Value as RoomUser;

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

                GameClient session = user.GetClient();

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

                DynamicRoomModel Model = room.GetGameMap().Model;
                user.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ);
                user.SetRot(Model.DoorOrientation, false);

                user.CurrentItemEffect = ItemEffectType.None;

                if (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;
                        ((StringData)Item.data).Data = "2";
                        Item.UpdateState(false, true);
                    }
                }

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

                ServerMessage EnterMessage = new ServerMessage(Outgoing.SetRoomUser);
                EnterMessage.AppendInt32(1);
                user.Serialize(EnterMessage);
                room.SendMessage(EnterMessage);


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

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

                foreach (RoomUnit unit in UnitList.Values)
                {
                    RoomAI ai = unit as RoomAI;
                    if (ai == null)
                    {
                        continue;
                    }

                    ai.BaseAI.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());
            }
        }