Exemplo n.º 1
0
        internal bool RemoveFromMap(RoomItem item, bool handleGameItem)
        {
            if (handleGameItem)
            {
                RemoveSpecialItem(item);
            }

            if (room.GotSoccer())
            {
                room.GetSoccer().onGateRemove(item);
            }

            bool isRemoved = false;

            foreach (Point coord in item.GetCoords)
            {
                if (RemoveCoordinatedItem(item, coord))
                {
                    isRemoved = true;
                }
            }

            Hashtable items = new Hashtable();

            foreach (Point tile in item.GetCoords)
            {
                Point point = new Point(tile.X, tile.Y);
                if (mCoordinatedItems.ContainsKey(point))
                {
                    List <RoomItem> __items = (List <RoomItem>)mCoordinatedItems[point];
                    if (!items.ContainsKey(tile))
                    {
                        items.Add(tile, __items);
                    }
                }
                SetDefaultValue(tile.X, tile.Y);
            }

            foreach (Point coord in items.Keys)
            {
                if (!items.ContainsKey(coord))
                {
                    continue;
                }

                List <RoomItem> _items = (List <RoomItem>)items[coord];

                foreach (RoomItem _item in _items)
                {
                    ConstructMapForItem(_item, coord);
                }
            }

            items.Clear();
            items = null;
            return(isRemoved);
        }
Exemplo n.º 2
0
        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)
            {
            }
        }