public bool Decode(BinaryDecoder decoder) { if (!BinaryCodec.Decode(decoder, out _itemID)) { return(false); } if (!BinaryCodec.DecodeUnicodeString(decoder, out _itemName)) { return(false); } if (!BinaryCodec.DecodeUnicodeString(decoder, out _itemDesc)) { return(false); } if (!BinaryCodec.Decode(decoder, out _iconName)) { return(false); } if (!BinaryCodec.Decode(decoder, out _price)) { return(false); } if (!BinaryCodec.Decode(decoder, out _option)) { return(false); } { int enumValue = 0; if (!BinaryCodec.Decode(decoder, out enumValue)) { return(false); } _itemType = (E_ItemType)enumValue; } { int enumValue = 0; if (!BinaryCodec.Decode(decoder, out enumValue)) { return(false); } _itemKindType = (E_ItemKindType)enumValue; } if (!BinaryCodec.Decode(decoder, out _isConsume)) { return(false); } { int enumValue = 0; if (!BinaryCodec.Decode(decoder, out enumValue)) { return(false); } _scopeType = (E_ScopeType)enumValue; } { int enumValue = 0; if (!BinaryCodec.Decode(decoder, out enumValue)) { return(false); } _occasionType = (E_OccasionType)enumValue; } return(true); }
/// <summary> /// Generate an <see cref="AbstractItem"/> of the specified kind starting from a specified correct item. /// The every element of <see cref="E_ItemType"/> is associated an index of the <see cref="attPopulationMatrix"/> /// so that the vector corresponding to the passed index is used in creating the new <see cref="AbstractItem"/> /// </summary> /// <param name="CorrectItem">The <see cref="AbstractItem"/> which is considered as correct</param> /// <param name="ItemTypeToGenerate">The <see cref="E_ItemType"/> which must be generated</param> /// <returns></returns> private AbstractItem InvertByItemType(AbstractItem CorrectItem, E_ItemType ItemTypeToGenerate) { ItemGraficalProperty wvIgp; AbstractItem wvInvertedAbstractItem = new AbstractItem(ItemTypeToGenerate, CorrectItem.ItemKind); bool[] wvVctor = attPopulationMatrix[(int)ItemTypeToGenerate]; for(int i = 0; i<CorrectItem.PropertiesCount; i++) { ItemGraficalProperty wvProperty = new ItemGraficalProperty(); wvIgp = CorrectItem.ItemProperties[i]; if(wvVctor[i]) { wvProperty.SetContent(wvIgp.PropertyKind, wvIgp.Content); } else { wvProperty.SetContent(InvertProperty(wvIgp)); } wvInvertedAbstractItem.AddProperty(wvProperty); } return wvInvertedAbstractItem; }