Ejemplo n.º 1
0
        static public void Equip(int[] items, EquipSlot startSlot)
        {
            RestoreEquip();
            var df            = DateFile.instance;
            var actorDate     = df.actorsDate[df.mianActorId];
            var actorsDateKey = (int)startSlot.ToActorsDateKey();

            // 紀錄並脫下原本的裝備
            for (int i = 0; i < items.Length; i++)
            {
                int key    = (int)(actorsDateKey + i);
                int itemId = int.Parse(actorDate[key]);
                if (itemId == 0)
                {
                    continue;
                }
                _originEquitments.Add(new EquipDetails(key, itemId, ItemFrom.Equip));
                ControlHelper.TakeoffEquip(key);
            }
            // 穿起裝備
            // 紀錄來源 身上(背包) 或是 倉庫
            foreach (var item in items)
            {
                if (item == 0)
                {
                    continue;
                }
                var itemFrom = df.ItemFrom(item);
                _equipDetails.Add(new EquipDetails(actorsDateKey, item, itemFrom));
                switch (itemFrom)
                {
                case ItemFrom.Equip:
                    break;

                case ItemFrom.Bag:
                    ControlHelper.WearEquip(actorsDateKey, item);
                    break;

                case ItemFrom.Warehouse:
                    df.actorItemsDate[-999].Remove(item);
                    actorDate[actorsDateKey] = item.ToString();
                    break;

                case ItemFrom.Unknow:
                default:
                    throw new Exception($"Unknow item from: {item}");
                }
                actorsDateKey++;
//#if (DEBUG)
//                Main.Logger.Log($"Equip:{item}");
//#endif
            }
        }