public void RemoveUserItemByPos(int pos, int id) { VolumeUserItem volume = GetVolumeUserItem(GetVolumeKey(id)); volume.RemoveUserItemByPos(id, volume.GetItemNumInPos(pos)); base.RemoveUserItem(id, volume.GetItemNumInPos(pos)); }
public override void RemoveUserItem(int id) { VolumeUserItem volume = GetVolumeUserItem(GetVolumeKey(id)); volume.RemoveUserItemById(id, GetUserItem(id).num); base.RemoveUserItem(id); }
public void Swap(int key, int posA, int posB) { VolumeUserItem volume = GetVolumeUserItem(key); if (volume != null) { volume.Swap(posA, posB); } }
//保证移除数量少于等于当前拥有量,否则不会移除 public override void RemoveUserItem(int id, int num) { VolumeUserItem volume = GetVolumeUserItem(GetVolumeKey(id)); if (num <= GetUserItem(id).num) { volume.RemoveUserItemById(id, num); base.RemoveUserItem(id, num); } }
//保证当前格能容纳添加数量,否则不会添加 public void AddUserItem(int pos, UserItem userItem) { VolumeUserItem volume = GetVolumeUserItem(GetVolumeKey(userItem.id)); if (volume.GetLeaveNum(pos, userItem) >= 0) { volume.AddUserItem(pos, userItem); base.AddUserItem(userItem); } }
//保证当前容量能容纳添加数量,否则不会添加 public override void AddUserItem(UserItem userItem) { VolumeUserItem volume = GetVolumeUserItem(GetVolumeKey(userItem.id)); if (volume.GetLeaveNum(userItem) >= 0) { volume.AddUserItem(userItem); base.AddUserItem(userItem); } }
public int GetNum(int key, int pos) { VolumeUserItem volume = GetVolumeUserItem(key); if (volume != null) { return(volume.GetItemNumInPos(pos)); } return(0); }
protected void RegisterVolume(int size, int key) { VolumeUserItem volume = new VolumeUserItem(size, key); if (!_volumeMap.ContainsKey(key)) { volume.On_VolumeChanged += HandleOn_VolumeChanged; _volumeMap.Add(key, volume); } }
public int GetSize(int key) { VolumeUserItem volume = GetVolumeUserItem(key); if (volume != null) { return(volume.size); } return(0); }
public override bool UseUserItem(int id, int num, params object[] param) { if (base.UseUserItem(id, num, param)) { VolumeUserItem volume = GetVolumeUserItem(GetVolumeKey(id)); volume.RemoveUserItemById(id, num); return(true); } return(false); }
//保证移除数量少于等于当前拥有的数量,否则不会移除 public void RemoveUserItemByPos(int pos, int id, int num) { VolumeUserItem volume = GetVolumeUserItem(GetVolumeKey(id)); if (volume.GetItemNumInPos(num) >= num) { volume.RemoveUserItemByPos(pos, num); base.RemoveUserItem(id, num); } }
public int GetLeaveNum(int pos, UserItem userItem) { VolumeUserItem volume = GetVolumeUserItem(GetVolumeKey(userItem.id)); return(volume.GetLeaveNum(pos, userItem)); }