public void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights)
        {
            RoomUser roomUser = null;

            if (session != null)
            {
                roomUser = item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id);
            }
            if (roomUser == null)
            {
                return;
            }
            if (Gamemap.TilesTouching(item.X, item.Y, roomUser.X, roomUser.Y))
            {
                var cracks = 0;
                if (Plus.IsNum(item.ExtraData))
                {
                    cracks = Convert.ToInt16(item.ExtraData);
                }
                cracks++;
                item.ExtraData = Convert.ToString(cracks);
                item.UpdateState(false, true);
                return;
            }
            roomUser.MoveTo(item.SquareInFront);
        }
Example #2
0
        internal ServerMessage GetServerMessage(ServerMessage message, RoomItem item)
        {
            var cracks     = 0;
            var cracks_max = MaxCracks(item.GetBaseItem().Name);

            if (Plus.IsNum(item.ExtraData))
            {
                cracks = Convert.ToInt16(item.ExtraData);
            }
            var state = "0";

            if (cracks >= cracks_max)
            {
                state = "14";
            }
            else if (cracks >= cracks_max * 6 / 7)
            {
                state = "12";
            }
            else if (cracks >= cracks_max * 5 / 7)
            {
                state = "10";
            }
            else if (cracks >= cracks_max * 4 / 7)
            {
                state = "8";
            }
            else if (cracks >= cracks_max * 3 / 7)
            {
                state = "6";
            }
            else if (cracks >= cracks_max * 2 / 7)
            {
                state = "4";
            }
            else if (cracks >= cracks_max * 1 / 7)
            {
                state = "2";
            }
            message.AppendInteger(7);
            message.AppendString(state);       //state (0-7)
            message.AppendInteger(cracks);     //actual
            message.AppendInteger(cracks_max); //max
            return(message);
        }