Exemple #1
0
        public override IEnumerator OnLoad(Request request)
        {
            yield return(StartCoroutine(base.OnLoad(request)));

            if (Global.SUser.self.items == null)
            {
                SItem sItem = new SItem();
                yield return(StartCoroutine(sItem.RequestList()));

                Global.SUser.self.items = sItem.items;
            }
            items        = Global.SUser.self.items;
            useItemEvent = null;
            if (request.Has("useItemEvent"))
            {
                useItemEvent = request.Get <System.Action <int> >("useItemEvent");
            }
            if (request.Has("itemType"))
            {
                itemType = request.Get <App.Model.Master.MItem.ItemType>("itemType");
                items    = System.Array.FindAll(items, i => i.Master.item_type == itemType);
            }
            itemDetail.UseOnly = request.Has("useOnly") && request.Get <bool>("useOnly");
            ScrollViewSets(content, childItem, items);
            yield return(0);
        }
Exemple #2
0
        private IEnumerator SkillUnlockRun(int skill_id)
        {
            App.Model.Master.MCharacterSkill[] skills = CharacterCacher.Instance.Get(character.CharacterId).skills;
            App.Model.Master.MCharacterSkill   skill  = System.Array.Find(skills, s => s.skill_id == skill_id);
            if (Global.SUser.self.items == null)
            {
                SItem sItem = new SItem();
                yield return(StartCoroutine(sItem.RequestList()));

                Global.SUser.self.items = sItem.items;
            }
            App.Model.MItem mItem = System.Array.Find(Global.SUser.self.items, i => i.Master.item_type == App.Model.Master.MItem.ItemType.skillPoint);
            if (mItem == null || skill.skill_point > mItem.Cnt)
            {
                CConfirmDialog.Show("确认", "没有足够的技能书,无法解锁新技能!要购买技能书吗?", () => {
                });
                yield break;
            }
            SSkill sSkill = new SSkill();

            yield return(StartCoroutine(sSkill.RequestUnlock(character.CharacterId, skill_id)));

            character.Skills        = sSkill.skills;
            Global.SUser.self.items = sSkill.items;
        }
Exemple #3
0
        public void ShareLinkModelTest()
        {
            ShareLinkModel model = new ShareLinkModel()
            {
                created_at    = "created_at",
                expires_at    = "expires_at",
                id            = "id",
                title         = "title",
                type          = "type",
                limited_times = 1,
                item          = "item",
                password      = "******"
            };

            Assert.IsTrue(model.limited_times == 1);
            Assert.IsTrue(model.created_at == "created_at");
            Assert.IsTrue(model.expires_at == "expires_at");
            Assert.IsTrue(model.id == "id");
            Assert.IsTrue(model.title == "title");
            Assert.IsTrue(model.type == "type");
            Assert.IsTrue(model.item?.ToString() == "item");
            Assert.IsTrue(model.password == "password");

            SItem item = new SItem()
            {
                perm = 1
            };

            Assert.IsTrue(item.perm == 1);
        }
Exemple #4
0
    //从外部文件导入所有装备信息
    public void Init(string path)
    {
        if (!File.Exists(path))
        {
            Debug.Log("FILE ERROR");
            return;
        }
        allItemDic = new Dictionary <string, SItem>();
        XmlDocument doc = new XmlDocument();

        doc.Load(path);
        XmlNode root = doc.SelectSingleNode("Root");
        XmlNode item = root.SelectSingleNode("Item");

        while (item != null)
        {
            SItem temp = new SItem();
            temp.name        = item.Attributes["name"].Value;
            temp.iconName    = item.Attributes["iconName"].Value;
            temp.description = item.InnerText;
            temp.hp          = int.Parse(item.Attributes["hp"].Value);
            temp.mp          = int.Parse(item.Attributes["mp"].Value);
            temp.atk         = int.Parse(item.Attributes["atk"].Value);
            temp.def         = int.Parse(item.Attributes["def"].Value);
            temp.num         = int.Parse(item.Attributes["num"].Value);
            temp.canOverly   = int.Parse(item.Attributes["canOverly"].Value);

            allItemDic.Add(temp.name, temp);

            item = item.NextSibling;
        }
    }
Exemple #5
0
        /// <summary>
        /// 添加站点并不更新界面
        /// </summary>
        /// <param name="stationId"></param>
        /// <param name="name"></param>
        /// <param name="state"></param>
        public void AddStationWithoutNotify(string stationId, string name, EStationState state)
        {
            SItem item = new SItem();

            item.strName      = name;
            item.state        = state;
            item.strStationId = stationId;
            m_listAllStation.Add(item);
        }
Exemple #6
0
        public void AddStation(string stationId, string name, EStationState state)
        {
            SItem item = new SItem();

            item.strName      = name;
            item.state        = state;
            item.strStationId = stationId;
            m_listAllStation.Add(item);
            RefreshVisibleItem(); //刷新显示的内容项
        }
Exemple #7
0
        public static string FormatItemName(SItem item, bool displayName = false)
        {
            var sb = new StringBuilder();

            sb.Append(item.netID);
            if (displayName && ItemID.NetIdToName.ContainsKey(item.netID))
            {
                // This won't work, needs an alternative design
                sb.Append(": ").Append(ItemID.NetIdToName[item.netID]);
            }
            return(sb.ToString());
        }
Exemple #8
0
        private void Save(object sender, EventArgs e)
        {
            var IsFormValid = ValidateForm();

            CancelClicked = false;
            if (!IsFormValid)
            {
                return;
            }
            if (Mode == SongSelect.Modes.Create)
            {
                Song = new Song();
            }
            Song.Title      = SongTitle.Text;
            Song.Artist     = SongArtist.Text;
            Song.Instrument = SongInstrument.SelectedItem.ToString();
            Song.Key        = SongKey.SelectedItem.ToString();;
            Song.Major      = true;
            Song.Filepath   = SongFilename.Text;
            if (SongFirstNote.SelectedItem != null)
            {
                Song.FirstNote = SongFirstNote.SelectedItem.ToString();
            }
            else
            {
                Song.FirstNote = null;
            }
            if (Mode == SongSelect.Modes.Create)
            {
                SongLibrary.Songs.Add(Song);
            }
            // Another place where the small volume makes it not worth while to selectively remove.
            // Just remove them all and add them back in.
            foreach (var SItem in this.Libraries.Items)
            {
                var Library = SongLibrary.Libraries.Where(t => t.Title == SItem.ToString()).FirstOrDefault();
                if (Library.Songs.Contains(Song))
                {
                    Library.Songs.Remove(Song);
                }
            }
            foreach (var SItem in this.Libraries.SelectedItems)
            {
                var Library = SongLibrary.Libraries.Where(t => t.Title == SItem.ToString()).FirstOrDefault();
                if (!Library.Songs.Contains(Song))
                {
                    Library.Songs.Add(Song);
                }
            }
            SongLibrary.SaveChanges();
            Close();
        }
Exemple #9
0
        // Returns a Proxy element corresponding to the specified screen coordinates.
        internal override ProxySimple ElementProviderFromPoint(int x, int y)
        {
            for (SItem item = SItem.LargeDecrement; (int)item <= (int)SItem.LargeIncrement; item = (SItem)((int)item + 1))
            {
                NativeMethods.Win32Rect rc = new NativeMethods.Win32Rect(SliderItem.GetBoundingRectangle(_hwnd, item, _fHorizontal));

                if (Misc.PtInRect(ref rc, x, y))
                {
                    return(CreateSliderItem(item));
                }
            }

            return(null);
        }
Exemple #10
0
        /// <summary>
        /// Adds an item.
        /// </summary>
        ///
        public void AddItem(SItem item)
        {
            listItems.Add(item);
            if (OnListChanged != null)
            {
                OnListChanged.Invoke(this);
            }

            if (m_selectedItem < 0)
            {
                m_selectedItem = 0;
                CheckForChange();
            }
        }
Exemple #11
0
 private static int CompareById(SItem obj1, SItem obj2)
 {
     // 根据ID大小来排序
     // 只支持整形
     try
     {
         int id1 = int.Parse(obj1.strStationId);
         int id2 = int.Parse(obj2.strStationId);
         return(id1 - id2);
     }
     catch (System.Exception)
     {
     }
     return(0);
 }
Exemple #12
0
        // ------------------------------------------------------
        //
        // Private methods
        //
        // ------------------------------------------------------

        #region Private Methods

        private ProxySimple CreateSliderItem(SItem item)
        {
            return(new SliderItem(_hwnd, this, (int)item, _fHorizontal));
        }
Exemple #13
0
 private static int CompareByStateReverse(SItem ojb1, SItem obj2)
 {
     return(obj2.state - ojb1.state);
 }
Exemple #14
0
 public static void ItemPurchase(this BankLog log, BankAccount account, SItem item)
 {
     purchase(log, account, $"{item.stack} {(item.prefix > 0 ? item.GetPrefixName() + " " : "")}{item.GetName()}", item.cost);
 }
 private void UpdateSelectedItem(SItem item)
 {
     this.itemSelector.SelectedIndex = ItemID.NetIdToName.Keys.ToList().IndexOf(item.netID);
     this.stackText.Text             = item.netID.ToString();
     this.costText.Text = item.cost.ToString();
 }
Exemple #16
0
        // ------------------------------------------------------
        //
        // Private methods                                             
        //
        // ------------------------------------------------------

        #region Private Methods

        private ProxySimple CreateSliderItem (SItem item)
        {
            return new SliderItem (_hwnd, this, (int) item, _fHorizontal);
        }
Exemple #17
0
        // Returns the previous sibling element in the raw hierarchy.
        // Peripheral controls have always negative values.
        // Returns null is no previous
        internal override ProxySimple GetPreviousSibling(ProxySimple child)
        {
            SItem item = (SItem)(child._item - 1);

            return(item >= SItem.LargeDecrement ? CreateSliderItem(item) : null);
        }
Exemple #18
0
        // Returns the next sibling element in the raw hierarchy.
        // Peripheral controls have always negative values.
        // Returns null if no next child
        internal override ProxySimple GetNextSibling(ProxySimple child)
        {
            SItem item = (SItem)(child._item + 1);

            return(item <= SItem.LargeIncrement ? CreateSliderItem(item) : null);
        }
    //从xml文件中给玩家背包导入信息
    public void InitBag(string characterName)
    {
        //给玩家背包列表申请内存
        bagList = new List <SItem>();

        //根据账号的信息查看背包的储存,这里先做测试
        string path = Application.streamingAssetsPath + "/CharacterItem.xml";

        if (!File.Exists(path))
        {
            Debug.Log("ERROR");
            return;
        }

        XmlDocument doc = new XmlDocument();

        doc.Load(path);//文件要保存成UTF-8编码
        XmlNode root      = doc.SelectSingleNode("Bag");
        XmlNode character = root.SelectSingleNode("Character");

        while (character != null)
        {
            if (character.Attributes["name"].Value.Equals(characterName))
            {
                XmlNode item = character.SelectSingleNode("Item");

                int _bagID = 0;
                while (item != null)
                {
                    string itemName = item.Attributes["name"].Value;
                    //根据名字从所有道具的容器中找到数据
                    SItem itemStruct = ItemManager.Instance.allItemDic[itemName];
                    //在ItemManager中已经为其他属性赋值完毕,这里只需赋值数量和背包所在编号就好
                    itemStruct.num   = int.Parse(item.Attributes["num"].Value);
                    itemStruct.bagID = _bagID;

                    //如果这个物品不可以叠加
                    if (itemStruct.canOverly == 0)
                    {
                        for (int i = 0; i < itemStruct.num; i++)
                        {
                            SItem tmp = itemStruct;
                            tmp.num   = 1;
                            tmp.bagID = _bagID;
                            _bagID++;
                            //添加进玩家背包链表
                            PlayerStaticInfo.Instance.bagList.Add(tmp);
                        }
                    }
                    else
                    {
                        //添加进玩家背包链表
                        PlayerStaticInfo.Instance.bagList.Add(itemStruct);
                    }

                    item = item.NextSibling;
                    _bagID++;
                }

                break;
            }

            character = character.NextSibling;
        }
    }
 public void UpdateItem(SItem item)
 {
     Instance.UpdateSelectedItem(item);
 }