public override 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)) { int cracks = 0; if (Yupi.IsNum(item.ExtraData)) { cracks = Convert.ToInt16(item.ExtraData); } cracks++; item.ExtraData = Convert.ToString(cracks); item.UpdateState(false, true); return; } roomUser.MoveTo(item.SquareInFront); }
internal ServerMessage GetServerMessage(ServerMessage message, RoomItem item) { int cracks = 0; int cracksMax = MaxCracks(item.GetBaseItem().Name); if (Yupi.IsNum(item.ExtraData)) { cracks = Convert.ToInt16(item.ExtraData); } string state = "0"; if (cracks >= cracksMax) { state = "14"; } else if (cracks >= cracksMax * 6 / 7) { state = "12"; } else if (cracks >= cracksMax * 5 / 7) { state = "10"; } else if (cracks >= cracksMax * 4 / 7) { state = "8"; } else if (cracks >= cracksMax * 3 / 7) { state = "6"; } else if (cracks >= cracksMax * 2 / 7) { state = "4"; } else if (cracks >= cracksMax * 1 / 7) { state = "2"; } message.AppendInteger(7); message.AppendString(state); //state (0-7) message.AppendInteger(cracks); //actual message.AppendInteger(cracksMax); //max return(message); }