public bool CanEquip(PlayerItem item, CostumeSlot slot) { //using (_sync.Lock()) { // ReSharper disable once UseNullPropagation if (item == null) return false; if (item.ItemNumber.Category != ItemCategory.Costume) return false; if (slot > CostumeSlot.Pet || slot < CostumeSlot.Hair) return false; if (_items[(int)slot] != null) // Slot needs to be empty return false; var plr = _character.CharacterManager.Player; if (plr.Room != null && plr.RoomInfo.State != PlayerState.Lobby) // Cant change items while playing return false; foreach (var @char in plr.CharacterManager) if (@char.Costumes.GetItems().Any(i => i?.Id == item.Id) ) // Dont allow items that are already equipped on a character return false; return true; } }
public static DefaultItem Get(this IEnumerable <DefaultItem> defaultItems, CharacterGender gender, CostumeSlot slot, byte variation) { return(defaultItems.FirstOrDefault(item => item.Gender == gender && item.Variation == variation && item.ItemNumber.SubCategory == (byte)slot)); }
// Use this for initialization void Start() { if (!IsInited) { priceDic = new Dictionary <SkinType, Dictionary <string, int> >(); buyCheck = new Dictionary <SkinType, Dictionary <string, bool> >(); shoppingList = new Dictionary <SkinType, GameObject[]>(); for (int i = 1; i <= 5; i += 1) { var objs = Resources.LoadAll <GameObject>("Prefabs/Shop/" + ((SkinType)i).ToString() + "/"); shoppingList.Add((SkinType)i, objs); if ((SkinType)i != SkinType.Costume) { Dictionary <string, bool> checkDic = new Dictionary <string, bool>(); Dictionary <string, int> priceNameDic = new Dictionary <string, int>(); for (int j = 0; j < objs.Length; j += 1) { ShopSlot slot = objs[j].GetComponent <ShopSlot>(); slot.GetSpriteName(); // 세이브 기능 구현시 고쳐야 할 부분 checkDic.Add(slot.SpriteName, false); priceNameDic.Add(slot.SpriteName, slot.Price); } buyCheck.Add((SkinType)i, checkDic); priceDic.Add((SkinType)i, priceNameDic); } else { Dictionary <string, bool> checkDic = new Dictionary <string, bool>(); Dictionary <string, int> priceNameDic = new Dictionary <string, int>(); for (int j = 0; j < objs.Length; j += 1) { CostumeSlot slot = objs[j].GetComponent <CostumeSlot>(); // 세이브 기능 구현시 고쳐야 할 부분 checkDic.Add(slot.CostumeCode.ToString(), false); priceNameDic.Add(slot.CostumeCode.ToString(), slot.Price); } buyCheck.Add((SkinType)i, checkDic); priceDic.Add((SkinType)i, priceNameDic); } } effecters = FindObjectsOfType <ScaleEffecter>(); if (preShopPopup == null) { Debug.LogWarning("The Prefab NOT PREPARED"); } } }
public void Equip(PlayerItem item, CostumeSlot slot, bool silent = false) { // using (_sync.Lock()) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (!CanEquip(item, slot)) { throw new CharacterException($"Cannot equip item {item.ItemNumber} on slot {slot}"); } switch (slot) { case CostumeSlot.Hair: case CostumeSlot.Face: case CostumeSlot.Shirt: case CostumeSlot.Pants: case CostumeSlot.Gloves: case CostumeSlot.Shoes: case CostumeSlot.Accessory: case CostumeSlot.Pet: if (_items[(int)slot] != item) { _character.NeedsToSave = true; _items[(int)slot] = item; } break; default: throw new CharacterException("Invalid slot: " + (byte)slot); } var plr = _character.CharacterManager.Player; if (!silent) { plr.Session.SendAsync(new ItemUseItemAckMessage { CharacterSlot = _character.Slot, ItemId = item?.Id ?? 0, Action = UseItemAction.Equip, EquipSlot = (byte)slot }); } } }
public PlayerItem GetItem(CostumeSlot slot) { switch (slot) { case CostumeSlot.Hair: case CostumeSlot.Face: case CostumeSlot.Shirt: case CostumeSlot.Pants: case CostumeSlot.Gloves: case CostumeSlot.Shoes: case CostumeSlot.Accessory: return(_items[(int)slot]); default: throw new CharacterException("Invalid slot: " + slot); } }
public void UnEquip(CostumeSlot slot) { // using (_sync.Lock()) { var plr = _character.CharacterManager.Player; if (plr.Room != null && plr.RoomInfo.State != PlayerState.Lobby) // Cant change items while playing { throw new CharacterException("Can't change items while playing"); } PlayerItem item; switch (slot) { case CostumeSlot.Hair: case CostumeSlot.Face: case CostumeSlot.Shirt: case CostumeSlot.Pants: case CostumeSlot.Gloves: case CostumeSlot.Shoes: case CostumeSlot.Accessory: case CostumeSlot.Pet: item = _items[(int)slot]; if (item != null) { _character.NeedsToSave = true; _items[(int)slot] = null; } break; default: throw new CharacterException("Invalid slot: " + slot); } plr.Session.SendAsync(new ItemUseItemAckMessage { CharacterSlot = _character.Slot, ItemId = item?.Id ?? 0, Action = UseItemAction.UnEquip, EquipSlot = (byte)slot }); } }
public bool CanEquip(PlayerItem item, CostumeSlot slot) { // ReSharper disable once UseNullPropagation if (item == null) { return(false); } if (item.ItemNumber.Category != ItemCategory.Costume) { return(false); } if (slot > CostumeSlot.Accessory || slot < CostumeSlot.Hair) { return(false); } if (_items[(int)slot] != null) // Slot needs to be empty { return(false); } var plr = _character.CharacterManager.Player; if (plr.Room != null && plr.RoomInfo.State != PlayerState.Lobby) // Cant change items while playing { return(false); } foreach (var @char in plr.CharacterManager) { if (@char.Costumes.GetItems().Any(i => i?.Id == item.Id)) // Dont allow items that are already equipped on a character { return(false); } } return(true); }
public UserDataItemDto[] GetUserDataDto() { var UserData = new List <UserDataItemDto>(); for (CostumeSlot i = 0; i < CostumeSlot.Max; i++) { var xx = new UserDataItemDto { ItemNumber = Player.CharacterManager.CurrentCharacter.Costumes.GetItem(i)?.ItemNumber ?? 0, PriceType = Player.CharacterManager.CurrentCharacter.Costumes.GetItem(i)?.PriceType ?? 0, Unk2 = 0, Unk3 = 0, Color = Player.CharacterManager.CurrentCharacter.Costumes.GetItem(i)?.Color ?? 0, Effects = Player.CharacterManager.CurrentCharacter.Costumes.GetItem(i)?.GetItemEffectsInt() ?? new uint[0], Unk4 = 0, Unk5 = 0 }; UserData.Add(xx); } return(UserData.ToArray()); }
public void CAvatarChangeReq(GameSession session, CAvatarChangeReqMessage message) { var plr = session.Player; Logger.Debug() .Account(session) .Message($"Avatar sync - {JsonConvert.SerializeObject(message.Unk1, Formatting.Indented)}") .Write(); if (message.Unk2.Length > 0) { Logger.Warn() .Account(session) .Message($"Unk2: {JsonConvert.SerializeObject(message.Unk2, Formatting.Indented)}") .Write(); } var @char = plr.CharacterManager.CurrentCharacter; var unk1 = new ChangeAvatarUnk1Dto { AccountId = plr.Account.Id, Skills = @char.Skills.GetItems().Select(item => item?.ItemNumber ?? 0).ToArray(), Weapons = @char.Weapons.GetItems().Select(item => item?.ItemNumber ?? 0).ToArray(), Costumes = new ItemNumber[(int)CostumeSlot.Max], Unk5 = message.Unk1.Unk5, Unk6 = message.Unk1.Unk6, Unk7 = message.Unk1.Unk7, Unk8 = message.Unk1.Unk8, Gender = plr.CharacterManager.CurrentCharacter.Gender, HP = plr.GetMaxHP(), Unk11 = message.Unk1.Unk11 }; // If no item equipped use the default item the character was created with for (CostumeSlot slot = 0; slot < CostumeSlot.Max; slot++) { var item = plr.CharacterManager.CurrentCharacter.Costumes.GetItem(slot)?.ItemNumber ?? 0; switch (slot) { case CostumeSlot.Hair: if (item == 0) { item = @char.Hair.ItemNumber; } break; case CostumeSlot.Face: if (item == 0) { item = @char.Face.ItemNumber; } break; case CostumeSlot.Shirt: if (item == 0) { item = @char.Shirt.ItemNumber; } break; case CostumeSlot.Pants: if (item == 0) { item = @char.Pants.ItemNumber; } break; case CostumeSlot.Gloves: if (item == 0) { item = @char.Gloves.ItemNumber; } break; case CostumeSlot.Shoes: if (item == 0) { item = @char.Shoes.ItemNumber; } break; } unk1.Costumes[(int)slot] = item; } plr.Room.Broadcast(new SAvatarChangeAckMessage(unk1, message.Unk2)); }
public DefaultItem GetDefaultItem(CharacterGender gender, CostumeSlot slot, byte variation) { return(DefaultItems.FirstOrDefault(item => item.Gender == gender && item.Variation == variation && item.ItemNumber.SubCategory == (byte)slot)); }