Esempio n. 1
0
 private void Excute()
 {
     if (AppConstant.ValidateInput(RegistrationNo))
     {
         try
         {
             var id = SlotID.Split('-').ToList();
             PMSService.Insert(new Vehicle_Parking()
             {
                 RegistrationId = RegistrationNo,
                 ArrivalTime    = EntryTime.ToLocalTime(),
                 DepartTime     = null,
                 SlotId         = Convert.ToInt16(id.ElementAtOrDefault(1)),
                 TotalFare      = null,
                 VehicleType    = VehicleType.ToString(),
                 Floor          = id.ElementAt(0).ToString()
             });
         }
         catch (Exception ex)
         {
             Debug.WriteLine(ex.Message);
         }
         MessageBoxResult messageBoxResult = MessageBox.Show("Data inserted Successfully!", "Saved", MessageBoxButton.OK);
         if (messageBoxResult == MessageBoxResult.OK)
         {
             ClearForm();
         }
     }
     else
     {
         MessageBox.Show("Enter valid Registration No!", "Oops");
     }
 }
Esempio n. 2
0
        public void SendCreateItems(Character carry, CreateItemType type)
        {
            SlotID start = 0;
            SlotID stop  = SlotID.BANK;

            if (type == CreateItemType.Other)
            {
                stop = SlotID.INBACKPACK;
            }
            if (type == CreateItemType.Bank)
            {
                start = SlotID.BANK;
                stop  = (SlotID)items.Length;
            }

            UpdateMask imask = new UpdateMask();

            while (start < stop)
            {
                Item item = carry.items[(int)start];
                if (item != null)
                {
                    item.SendCreateItem(this);

                    imask.Touch(UpdateFields.PLAYER_FIELD_INV_SLOT_HEAD + (ushort)((int)start * 2));
                    imask.Touch(UpdateFields.PLAYER_FIELD_INV_SLOT_HEAD + (ushort)((int)start * 2 + 1));
                }
                start++;
            }
            SendUpdate(carry.BuildUpdate(imask, UpdateType.Value, false));
        }
Esempio n. 3
0
    /// <summary>
    /// Swaps the content of two inventory slots with the given ids.
    /// </summary>
    /// <param name="slotA"></param>
    /// <param name="slotB"></param>
    public void Swap(SlotID slotA, SlotID slotB)
    {
        int posA = slotA.id;
        int posB = slotB.id;

        if (slotA.type == ItemEntry.ItemType.DESTROY)
        {
            Remove(posB);
        }
        else if (slotB.type == ItemEntry.ItemType.DESTROY)
        {
            Remove(posA);
        }

        // Debug.Log(string.Format("Swappy: {0} <> {1}", posA, posB));
        ItemEntry itemA = GetItem(posA);
        ItemEntry itemB = GetItem(posB);

        bool allowed = (slotA.allowAnyType || itemB == null || slotA.type == itemB.type) &&
                       (slotB.allowAnyType || itemA == null || slotB.type == itemA.type);

        if (!allowed)
        {
            return;
        }

        SetItem(posA, itemB);
        SetItem(posB, itemA);

        itemsChanged.Invoke();
    }
Esempio n. 4
0
 /// <summary>
 /// Updates the position of the item being dropped into this inventory slot.
 /// </summary>
 /// <param name="eventData"></param>
 public void OnDrop(PointerEventData eventData)
 {
     if (DragHandler.itemBeingDragged != null)
     {
         SlotID startID = DragHandler.itemBeingDragged.GetComponent <DragHandler>().start_id;
         Debug.Log("Dropped in slottype:  " + slot.slotID.type);
         if (slot.slotID.type == SlotType.DESTROY)
         {
             selectedItem.reference = null;
             invContainer.DestroyItem(startID);
         }
         else if (slot.slotID.type == SlotType.SHOP)
         {
             selectedItem.reference = null;
         }
         else if (slot.slotID.type == SlotType.SELL)
         {
             invContainer.SellItem(startID);
         }
         else if (startID.type == SlotType.SHOP)
         {
             invContainer.BuyItem(startID, slot.slotID);
         }
         else
         {
             if (invContainer.Swap(startID, slot.slotID))
             {
                 itemDroppedEvent.Invoke();
             }
         }
     }
 }
Esempio n. 5
0
        protected override bool Create(Character c, Hashtable data, ByteArrayBase moredata)
        {
            if (!base.Create(c, data, moredata))
            {
                return(false);
            }

            items = new Item[(int)data["containerslots"]];
            SetUpdateValue(UpdateFields.CONTAINER_FIELD_NUM_SLOTS, (uint)items.Length);

            while (moredata != null)
            {
                SlotID slot = (SlotID)moredata.GetByte();
                if (slot == SlotID.CHARACTER)
                {
                    break;
                }
                uint   e   = moredata.GetDWord();
                ushort len = moredata.GetWord();
                Item   n   = new Item(gameServer);
                n = n.Create(c, e, new ByteArray(moredata.GetArray(len)));
                if (n != null)
                {
                    n.SetUpdateValue(UpdateFields.ITEM_FIELD_CONTAINED, GUID);
                    //n.SetUpdateValue(UpdateFields.ITEM_FIELD_CONTAINED_01, GUID);
                    SetItem(slot, n);
                }
            }
            return(true);
        }
Esempio n. 6
0
 /// <summary>
 /// Sets the SlotID for the inventory slot.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="id"></param>
 public void SetID(ItemEntry.ItemType type, int id, bool allowAnyType)
 {
     slotID              = new SlotID();
     slotID.type         = type;
     slotID.id           = id;
     slotID.allowAnyType = allowAnyType;
 }
Esempio n. 7
0
 public Item GetItem(SlotID slot)
 {
     if ((int)slot >= items.Length)
     {
         return(null);
     }
     return(items[(int)slot]);
 }
Esempio n. 8
0
    /// <summary>
    /// Update function for the UI. Uses the inventory to update the images of all the inventory slots.
    /// </summary>
    public void UpdateUI()
    {
        //Update money
        moneyText.text = "Money:  " + totalMoney.value.ToString();

        //Update the inventories
        for (int i = 0; i < equipSlots.Length; i++)
        {
            if (invItemEquip.values[i] != null)
            {
                equipSlots[i].AddItem(invItemEquip.values[i]);
            }
            else
            {
                equipSlots[i].ClearSlot();
            }
        }

        int currentPos = inventoryOffset.value;

        for (int i = 0; i < bagSlots.Length; i++)
        {
            if (invItemBag.values[currentPos] != null)
            {
                bagSlots[i].AddItem(invItemBag.values[currentPos]);
            }
            else
            {
                bagSlots[i].ClearSlot();
            }
            currentPos++;
        }

        int pos = 0;

        for (int i = 0; i < invItemShop.values.Length; i++)
        {
            if (invItemShop.values[i] != null && SlotID.SameType(currentSellType, invItemShop.values[i].equipType))
            {
                shopSlots[pos].AddItem(invItemShop.values[i]);
                shopSlots[pos].SetID(SlotType.SHOP, i);
                shopSlots[pos].GetComponentInChildren <Text>().text = invItemShop.values[i].cost.ToString();
                pos++;
            }
        }
        for (int i = pos; i < shopSlots.Length; i++)
        {
            shopSlots[i].SetID(SlotType.SHOP, -1);
            shopSlots[i].GetComponentInChildren <Text>().text = "";
            shopSlots[i].ClearSlot();
        }

        scrollUpButton.SetActive(inventoryOffset.value != 0);
        scrollDownButton.SetActive(inventoryOffset.value != Constants.GEAR_BAG_SPACE - bagSlots.Length);
    }
Esempio n. 9
0
    /// <summary>
    /// Destroys the dropped item if applicable.
    /// </summary>
    /// <param name="start"></param>//
    public void DestroyItem(SlotID start)
    {
        if (start.type != SlotType.EQUIP && start.type != SlotType.BAG)
        {
            return;
        }

        Remove(start);
        Debug.Log("Destroyed the item");
        itemsChanged.Invoke();
    }
Esempio n. 10
0
 public ulong GetItemGUID(SlotID slot)
 {
     if ((int)slot >= items.Length)
     {
         return(0);
     }
     if (items[(int)slot] == null)
     {
         return(0);
     }
     return(items[(int)slot].GUID);
 }
Esempio n. 11
0
        bool AddItem(SlotID slot, Item item)
        {
            UpdateMask mask = new UpdateMask();

            item.BuildCreateMask(mask, true);
            SendUpdate(item.BuildUpdate(mask, UpdateType.All, false));

            items[(int)slot] = item;

            SetUpdateValue(UpdateFields.PLAYER_FIELD_INV_SLOT_HEAD + (ushort)((int)slot * 2), item.GUID);
            return(true);
        }
Esempio n. 12
0
    /// <summary>
    /// Updates the position of the item being dropped into this inventory slot.
    /// </summary>
    /// <param name="eventData"></param>
    public void OnDrop(PointerEventData eventData)
    {
        if (DragHandler.itemBeingDragged != null)
        {
            SlotID start_id = DragHandler.itemBeingDragged.GetComponent <DragHandler>().start_id;
            if (slot.slotID.type == SlotID.SlotType.DESTROY)
            {
                selectedItem.reference = null;
            }

            invContainer.Swap(start_id, slot.slotID);
        }
    }
 public void OnBeginDrag(PointerEventData eventData)
 {
     if (!slot.moveable)
     {
         return;
     }
     itemBeingDragged       = gameObject;
     selectedItem.reference = slot.item;
     start_id            = slot.slotID;
     image.raycastTarget = false;
     transform.parent.transform.SetAsLastSibling();
     invParent.SetAsLastSibling();
 }
Esempio n. 14
0
 /// <summary>
 /// Removes the item at index position.
 /// Equipped items use negative indexing starting at -1
 /// </summary>
 /// <param name="index"></param>
 private void Remove(SlotID index)
 {
     if (index.type == SlotType.EQUIP)
     {
         equippedItems.values[index.id] = null;
     }
     else if (index.type == SlotType.SHOP)
     {
         shopItems.values[index.id] = null;
     }
     else
     {
         bagItems.values[index.id + inventoryOffset.value] = null;
     }
 }
Esempio n. 15
0
    /// <summary>
    /// Sells the dropped item if applicable.
    /// </summary>
    /// <param name="start"></param>
    public void SellItem(SlotID start)
    {
        if (start.type != SlotType.EQUIP && start.type != SlotType.BAG)
        {
            return;
        }

        ItemEntry item = GetItem(start);

        currentMoney.value += item.cost / 2;
        Remove(start);
        Debug.Log("Sold the item");
        sellItemEvent.Invoke();
        itemsChanged.Invoke();
    }
Esempio n. 16
0
    /// <summary>
    /// Retrieves the item at the current index.
    /// </summary>
    /// <param name="index"></param>
    /// <returns></returns>
    private ItemEntry GetItem(SlotID index)
    {
        if (index.type == SlotType.EQUIP)
        {
            return((index.id < equippedItems.values.Length) ? equippedItems.values[index.id] : null);
        }
        else if (index.type == SlotType.SHOP)
        {
            return((index.id < shopItems.values.Length) ? shopItems.values[index.id] : null);
        }
        else if (index.type == SlotType.BAG)
        {
            return((index.id + inventoryOffset.value < bagItems.values.Length) ? bagItems.values[index.id + inventoryOffset.value] : null);
        }

        return(null);
    }
Esempio n. 17
0
    /// <summary>
    /// Buys the dropped item if applicable.
    /// </summary>
    /// <param name="start"></param>
    public void BuyItem(SlotID start, SlotID dropped)
    {
        if (dropped.type != SlotType.EQUIP && dropped.type != SlotType.BAG)
        {
            return;
        }

        ItemEntry item = GetItem(start);

        if (currentMoney.value >= item.cost && !GetItem(dropped) && dropped.CanUse(item))
        {
            currentMoney.value -= item.cost;
            Debug.Log("Bought the item");
            SetItem(dropped, item);
            // AddBag(item);
            buyItemEvent.Invoke();
            itemsChanged.Invoke();
        }
    }
Esempio n. 18
0
        public bool AutoEquipItem(SlotID srcBagID, SlotID srcSlot)
        {
            itemErrorGUID1 = itemErrorGUID2 = 0;

            IContainer srcBag = this;

            if (srcBagID != SlotID.CHARACTER)
            {
                if (items[(int)srcBagID] == null)
                {
                    return(ItemError(ItemErrorNo.NOT_A_BAG));
                }
                itemErrorGUID1 = items[(int)srcBagID].GUID;
                if (!(items[(int)srcBagID] is IContainer))
                {
                    return(ItemError(ItemErrorNo.NOT_A_BAG));
                }
                srcBag = items[(int)srcBagID] as IContainer;
            }
            if (srcSlot >= srcBag.ItemCount)
            {
                return(ItemError(ItemErrorNo.WRONG_SLOT));
            }

            Item n = srcBag.GetItem(srcSlot);

            if (n == null)
            {
                return(ItemError(ItemErrorNo.WRONG_EQ_SLOT));
            }
            itemErrorGUID1 = n.GUID;

            SlotID destSlot = WornSlot(n.WornType);

            if (destSlot == SlotID.BANK)
            {
                return(ItemError(ItemErrorNo.NEVER));
            }
            return(SwapItem(srcBagID, srcSlot, SlotID.CHARACTER, destSlot));
        }
Esempio n. 19
0
    /// <summary>
    /// Swaps the content of two inventory slots with the given ids.
    /// Returns a bool that shows if it was a success.
    /// </summary>
    /// <param name="start"></param>
    /// <param name="drop"></param>
    public bool Swap(SlotID start, SlotID drop)
    {
        if (start.type != SlotType.EQUIP && start.type != SlotType.BAG)
        {
            return(false);
        }


        // Debug.Log(string.Format("Swappy: {0} <> {1}", posA, posB));
        ItemEntry temp = GetItem(start);

        if (!drop.CanUse(temp) || !start.CanUse(GetItem(drop)))
        {
            return(false);
        }

        SetItem(start, GetItem(drop));
        SetItem(drop, temp);

        itemsChanged.Invoke();
        return(true);
    }
Esempio n. 20
0
    /// <summary>
    /// Swaps the content of two inventory slots with the given ids.
    /// </summary>
    /// <param name="slotA"></param>
    /// <param name="slotB"></param>
    public void Swap(SlotID slotA, SlotID slotB)
    {
        int posA = slotA.id;
        int posB = slotB.id;

        if (slotA.type == SlotID.SlotType.DESTROY)
        {
            Remove(posB);
        }
        else if (slotB.type == SlotID.SlotType.DESTROY)
        {
            Remove(posA);
        }

        // Debug.Log(string.Format("Swappy: {0} <> {1}", posA, posB));
        ItemEntry temp = GetItem(posA);

        SetItem(posA, GetItem(posB));
        SetItem(posB, temp);

        itemsChanged.Invoke();
    }
Esempio n. 21
0
 /// <summary>
 /// Sets the given item in the slot at the index.
 /// </summary>
 /// <param name="index"></param>
 /// <param name="item"></param>
 /// <returns></returns>
 private void SetItem(SlotID index, ItemEntry item)
 {
     if (index.type == SlotType.EQUIP)
     {
         if (index.id < equippedItems.values.Length)
         {
             equippedItems.values[index.id] = item;
         }
     }
     else if (index.type == SlotType.SHOP)
     {
         if (index.id < shopItems.values.Length)
         {
             shopItems.values[index.id] = item;
         }
     }
     else if (index.type == SlotType.BAG)
     {
         if (index.id + inventoryOffset.value < bagItems.values.Length)
         {
             bagItems.values[index.id + inventoryOffset.value] = item;
         }
     }
 }
 /// <summary>
 /// Sets the SlotID for the inventory slot.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="id"></param>
 public void SetID(SlotID.SlotType type, int id)
 {
     slotID      = new SlotID();
     slotID.type = type;
     slotID.id   = id;
 }
Esempio n. 23
0
        public bool SwapItem(SlotID srcBagID, SlotID srcSlot, SlotID destBagID, SlotID destSlot)
        {
            itemErrorGUID1 = itemErrorGUID2 = 0;

            IContainer srcBag = this;

            if (srcBagID != SlotID.CHARACTER)
            {
                if (items[(int)srcBagID] == null)
                {
                    return(ItemError(ItemErrorNo.NOT_A_BAG));
                }
                itemErrorGUID1 = items[(int)srcBagID].GUID;
                if (!(items[(int)srcBagID] is IContainer))
                {
                    return(ItemError(ItemErrorNo.NOT_A_BAG));
                }
                srcBag = items[(int)srcBagID] as IContainer;
            }
            if (srcSlot >= srcBag.ItemCount)
            {
                return(ItemError(ItemErrorNo.WRONG_SLOT));
            }
            Item src = srcBag.GetItem(srcSlot);

            itemErrorGUID1 = src.GUID;

            IContainer destBag = this;

            if (destBagID != SlotID.CHARACTER)
            {
                if (items[(int)destBagID] == null)
                {
                    return(ItemError(ItemErrorNo.NOT_A_BAG));
                }
                itemErrorGUID2 = items[(int)destBagID].GUID;
                if (!(items[(int)destBagID] is IContainer))
                {
                    return(ItemError(ItemErrorNo.NOT_A_BAG));
                }
                destBag = items[(int)destBagID] as IContainer;
            }
            if (destSlot == SlotID.CHARACTER)
            {
                for (destSlot = 0; destSlot < destBag.ItemCount; destSlot++)
                {
                    if (destBag.GetItem(destSlot) == null)
                    {
                        break;
                    }
                }
                if (destSlot == destBag.ItemCount)
                {
                    return(ItemError(ItemErrorNo.BAG_FULL));
                }
            }
            if (destSlot >= destBag.ItemCount)
            {
                return(ItemError(ItemErrorNo.WRONG_SLOT));
            }

            Item dest = destBag.GetItem(destSlot);

            if (dest != null)
            {
                itemErrorGUID2 = dest.GUID;
            }

            ItemErrorNo n;

            if ((n = srcBag.SetItem(srcSlot, dest)) != ItemErrorNo.NONE)
            {
                return(ItemError(n));
            }

            if ((n = destBag.SetItem(destSlot, src)) != ItemErrorNo.NONE)
            {
                srcBag.SetItem(srcSlot, src);
                return(ItemError(n));
            }

            SendUpdate();
            return(true);
        }
Esempio n. 24
0
 public Item GetItem(SlotID id)
 {
     return(items[(int)id]);
 }
Esempio n. 25
0
 public liveSlot(RegisterSet Registers = default, StackOffset StackOffset = default, SlotID slot = default)
 {
     this.Registers   = Registers;
     this.StackOffset = StackOffset;
     this.slot        = slot;
 }
Esempio n. 26
0
        public bool AddItem(uint id)
        {
            itemErrorGUID1 = itemErrorGUID2 = 0;

            Item n = new Item(gameServer);

            n = n.Create(this, id, null);
            if (n == null)
            {
                return(ItemError(ItemErrorNo.NEVER));
            }
            itemErrorGUID1 = n.GUID;

            // find a empty bag & slot
            SlotID     slot;
            IContainer srcBag = this;

            for (slot = SlotID.INBACKPACK; slot < SlotID.BANK; slot++)
            {
                if (srcBag.GetItem(slot) == null)
                {
                    break;
                }
            }
            if (slot == SlotID.BANK)
            {
                for (SlotID bag = SlotID.BAG1; bag <= SlotID.BAG4; bag++)
                {
                    if (GetItem(bag) == null)
                    {
                        continue;
                    }
                    srcBag = GetItem(bag) as IContainer;

                    for (slot = 0; slot < srcBag.ItemCount; slot++)
                    {
                        if (srcBag.GetItem(slot) == null)
                        {
                            break;
                        }
                    }
                    if (slot < srcBag.ItemCount)
                    {
                        break;
                    }
                    slot = SlotID.BANK;
                }
            }
            if (slot == SlotID.BANK)
            {
                return(ItemError(ItemErrorNo.ITEM_TOO_MANY));
            }

            UpdateMask mask = new UpdateMask();

            n.BuildCreateMask(mask, true);
            SendUpdate(n.BuildUpdate(mask, UpdateType.All, false));

            srcBag.SetItem(slot, n);
            return(true);
        }
Esempio n. 27
0
        public ItemErrorNo SetItem(eWoW.SlotID id, Item newItem)
        {
            if ((int)id >= items.Length)
            {
                return(ItemErrorNo.WRONG_SLOT);
            }

            if (newItem != null)
            {
                if ((id >= SlotID.BAG1 && id <= SlotID.BAG4) || (id >= SlotID.BANKBAGS))
                {
                    if (!newItem.IsType(TYPE.CONTAINER))
                    {
                        return(ItemErrorNo.NOT_A_BAG);
                    }
                }

                if (newItem is IContainer && id > SlotID.BAG4)
                {
                    IContainer p = newItem as IContainer;
                    for (SlotID i = 0; i < p.ItemCount; i++)
                    {
                        if (p.GetItem(i) != null)
                        {
                            return(ItemErrorNo.BAG_IN_BAG);
                        }
                    }
                }

                if (id < SlotID.BAG1)                 // equip
                {
                    SlotID expect = WornSlot(newItem.WornType);

                    if (expect == SlotID.BANK && id < SlotID.BAG1)
                    {
                        return(ItemErrorNo.WRONG_EQ_SLOT);
                    }
                    if (expect != id)
                    {
                        bool ok = false;
                        if (expect == SlotID.FINGERL && id == SlotID.FINGERR)
                        {
                            ok = true;
                        }
                        if (expect == SlotID.TRINKETL && id == SlotID.TRINKETR)
                        {
                            ok = true;
                        }
                        if (newItem.WornType == WORN.H1 && id == SlotID.OFFHAND)
                        {
                            ok = true;
                        }
                        if (!ok)
                        {
                            return(ItemErrorNo.WRONG_EQ_SLOT);
                        }
                    }
                    if (newItem.WornType == WORN.H2 && id == SlotID.MAINHAND)                 // check offhand
                    {
                        if (items[(int)SlotID.OFFHAND] != null)
                        {
                            return(ItemErrorNo.WRONG_EQ_SLOT);
                        }
                    }
                }
            }


            items[(int)id] = newItem;
            if (newItem != null)
            {
                SetUpdateValue(UpdateFields.PLAYER_FIELD_INV_SLOT_HEAD + (ushort)((byte)id * 2), newItem.GUID);
            }
            else
            {
                SetUpdateValue(UpdateFields.PLAYER_FIELD_INV_SLOT_HEAD + (ushort)((byte)id * 2), (ulong)0);
            }

            if (id < SlotID.BAG1)
            {
                UpdateItemStats();
            }
            return(ItemErrorNo.NONE);
        }
Esempio n. 28
0
        protected void UpdateItemStats()
        {
            for (int i = 0; i < stat.Length; i++)
            {
                stat[i] -= (byte)nstat[i];
            }

            mhealth = (uint)(mhealth - nhealth);
            if (powerType == PowerType.MANA)
            {
                mpower[0] = (uint)(mpower[0] - nmana);
            }
            nhealth = 0;
            nmana   = 0;

            nstat = new char[5];
            res   = new int[7];

            for (SlotID id = 0; id < SlotID.BAG1; id++)
            {
                Item p = GetItem(id);
                if (p == null)
                {
                    continue;
                }

                for (int i = 0; i < p.resData.Length; i++)
                {
                    res[i] += p.resData[i];
                }

                if (p.bonusData != null)
                {
                    for (int i = 0; i < p.bonusData.Length / 2; i++)
                    {
                        int idx = p.bonusData[i * 2];
                        switch (idx)
                        {
                        case 0: nhealth += p.bonusData[i * 2 + 1]; break;

                        case 1: nmana += p.bonusData[i * 2 + 1]; break;

                        case 3: nstat[1] += (char)p.bonusData[i * 2 + 1]; break;

                        case 4: nstat[0] += (char)p.bonusData[i * 2 + 1]; break;

                        case 5: nstat[3] += (char)p.bonusData[i * 2 + 1]; break;

                        case 6: nstat[4] += (char)p.bonusData[i * 2 + 1]; break;

                        case 7: nstat[2] += (char)p.bonusData[i * 2 + 1]; break;
                        }
                    }
                }
            }

            for (int i = 0; i < stat.Length; i++)
            {
                stat[i] += (byte)nstat[i];
            }

            for (ushort i = 0; i < res.Length; i++)
            {
                SetUpdateValue(UpdateFields.UNIT_FIELD_RESISTANCES + i, (uint)res[i]);
            }

            for (ushort i = 0; i < nstat.Length; i++)
            {
                SetUpdateValue(UpdateFields.PLAYER_FIELD_POSSTAT0 + i, (uint)(int)nstat[i]);
                SetUpdateValue(UpdateFields.UNIT_FIELD_STAT0 + i, (uint)stat[i]);
            }

            Item sword = GetItem(SlotID.MAINHAND);

            if (sword == null || sword.damageData == null)
            {
                minDamage   = stat[0] / 5;
                maxDamage   = stat[0] / 5 + 1;
                attackTime0 = 3000;
                attackTime1 = 3000;
            }
            else
            {
                minDamage = 0;
                maxDamage = 0;
                for (int i = 0; i < sword.damageData.Length / 3; i++)
                {
                    if (sword.damageData[i * 3] == 0)
                    {
                        minDamage = sword.damageData[i * 3 + 1];
                        maxDamage = sword.damageData[i * 3 + 2];
                    }
                }

                minDamage  += stat[0] / 5;
                maxDamage  += stat[0] / 5 + 1;
                attackTime0 = (uint)sword.delay;
                attackTime1 = (uint)sword.delay;
            }

            attack = (uint)(level + (stat[1] + nstat[1]) * 2);

            mhealth = (uint)(mhealth + nhealth);
            if (health > mhealth)
            {
                health = mhealth;
            }

            if (powerType == PowerType.MANA)
            {
                mpower[0] = (uint)(mpower[0] + nmana);
                if (power[0] > mpower[0])
                {
                    power[0] = mpower[0];
                }
            }


            SetUpdateValue(UpdateFields.UNIT_FIELD_HEALTH, health);
            SetUpdateValue(UpdateFields.UNIT_FIELD_MAXHEALTH, mhealth);

            SetUpdateValue(UpdateFields.UNIT_FIELD_ATTACKPOWER, attack);

            SetUpdateValue((UpdateFields)(UpdateFields.UNIT_FIELD_POWER1 + (ushort)powerType), power[(int)powerType]);
            SetUpdateValue((UpdateFields)(UpdateFields.UNIT_FIELD_MAXPOWER1 + (ushort)powerType), mpower[(int)powerType]);

            SetUpdateValue(UpdateFields.UNIT_FIELD_BASEATTACKTIME, attackTime0);
            SetUpdateValue(UpdateFields.UNIT_FIELD_BASEATTACKTIME + 1, attackTime1);

            SetUpdateValueFloat(UpdateFields.UNIT_FIELD_MINDAMAGE, minDamage);
            SetUpdateValueFloat(UpdateFields.UNIT_FIELD_MAXDAMAGE, maxDamage);
        }