public Boolean AddItem(FloorItem aItem) { if (aItem == null) { return(false); } if (FloorItems.ContainsKey(aItem.Id)) { return(false); } FloorItems.TryAdd(aItem.Id, aItem); BroadcastBlockMsg(aItem, new MsgMapItem(aItem, MsgMapItem.Action.Create)); // add item to all player screens var players = (from entity in Entities.Values where entity.IsPlayer() && MyMath.CanSee(aItem.X, aItem.Y, entity.X, entity.Y, MyMath.NORMAL_RANGE) select(Player) entity); foreach (var player in players) { player.Screen.Add(aItem, false); } return(true); }
public void Add(FloorItem aItem, Boolean aSend) { if (!mFloorItems.ContainsKey(aItem.Id)) { mFloorItems.TryAdd(aItem.Id, aItem); if (aSend) { mPlayer.Send(new MsgMapItem(aItem, MsgMapItem.Action.Create)); } } }
public static void BroadcastRoomMsg(FloorItem aItem, Msg aMsg) { var players = from entity in aItem.Map.Entities.Values where entity.IsPlayer() select(Player) entity; foreach (Player player in players) { if (MyMath.CanSee(player.X, player.Y, aItem.X, aItem.Y, MyMath.NORMAL_RANGE + 5)) { player.Send(aMsg); } } }
public void Remove(FloorItem aItem, Boolean aSend) { if (mFloorItems.ContainsKey(aItem.Id)) { FloorItem item = null; mFloorItems.TryRemove(aItem.Id, out item); } if (aSend) { mPlayer.Send(new MsgMapItem(aItem, MsgMapItem.Action.Delete)); } }
public Boolean DelItem(FloorItem aItem) { if (aItem == null) { return(false); } if (!FloorItems.ContainsKey(aItem.Id)) { return(false); } FloorItem Tmp = null; FloorItems.TryRemove(aItem.Id, out Tmp); BroadcastBlockMsg(aItem, new MsgMapItem(aItem, MsgMapItem.Action.Delete)); return(true); }