示例#1
0
        public void OnAddItem(UISkillItem item)
        {
            Sprite sp = IconsAssetHolder.Instance.GetIconByID(1);

            if (!System.Object.ReferenceEquals(null, sp))
            {
                BtnList[0].sprite = sp;
            }
        }
示例#2
0
        public void LoadContent()
        {
            //var skill = new RiseupSkill();

            //TextSB.Append(Application.dataPath);
            //TextSB.Append("/Images/PureImages/Board-Games.png");

            //skill.Icon = TextSB.ToString();
            //AddItem(0, skill, false);

            //var skill1 = new SuckBloodSkill();
            //skill1.Icon = TextSB.ToString();
            //AddItem(1, skill1, false);

            //var skill2 = new RiseupSkill();
            //skill2.Icon = TextSB.ToString();
            //AddItem(2, skill2, false);

            {
                UISkillItem usi = new UISkillItem();
                usi.Index = 0;
                usi.Count = 1;
                usi.Data  = SKillMananger.Instance.GetSkillData(10008);

                AddItem(usi, false);
            }

            //{
            //    UISkillItem usi = new UISkillItem();
            //    usi.Index = 1;
            //    usi.Data = SKillMananger.Instance.GetSkillData(10002);
            //    AddItem(usi, false);
            //}

            {
                UISkillItem usi = new UISkillItem();
                usi.Index = 2;
                usi.Count = 1;
                usi.Data  = SKillMananger.Instance.GetSkillData(10003);
                AddItem(usi, false);
            }

            //var dataItem1 = ItemManager.Instance.GetItemData(1000001);
            //AddItem(2, dataItem1, false);

            {
                UISkillItem usi = new UISkillItem();
                usi.Index = 3;
                usi.Count = 5;
                usi.Data  = ItemManager.Instance.GetItemData(1000003);
                AddItem(usi, false);
            }
        }
示例#3
0
        //private Sprite LoadSprite(string path,
        //    float pixelsPerUnit = 100.0f)
        //{
        //    //Sprite newsp = new Sprite();
        //    Texture2D sptx = LoadTex(path);
        //    if (!System.Object.ReferenceEquals(sptx, null))
        //    {
        //        Sprite newsp = Sprite.Create(sptx,
        //            new Rect(0, 0,
        //            sptx.width, sptx.height),
        //            new Vector2(0, 0),
        //            pixelsPerUnit);

        //        return newsp;
        //    }
        //    else
        //    {
        //        TinyLogger.Instance.DebugLog("$failed to load tex: " + path);
        //    }

        //    return null;
        //}

        //private Texture2D LoadTex(string path)
        //{
        //    Texture2D tex;
        //    byte[] fileData;

        //    if (File.Exists(path))
        //    {
        //        //TinyLogger.Instance.ErrorLog("$file: " + path + " exits");
        //        fileData = File.ReadAllBytes(path);
        //        tex = new Texture2D(2, 2);

        //        if (fileData.Length == 0)
        //        {
        //            TinyLogger.Instance.ErrorLog("$ load no bytes data");
        //        }

        //        if (tex.LoadImage(fileData))
        //        {
        //            //TinyLogger.Instance.ErrorLog("$ yet load image");
        //            return tex;
        //        }
        //        else
        //        {
        //            TinyLogger.Instance.ErrorLog("$ failed to load image");
        //        }
        //    }
        //    else
        //    {
        //        TinyLogger.Instance.ErrorLog("$file: " + path + " not exits");
        //    }

        //    return null;
        //}

        public void OnAddItem(UISkillItem item)
        {
            //OnAddItem(item.Index, item.Data);

            var index = item.Index;
            var data  = item.Data;

            if (!System.Object.ReferenceEquals(null, data))
            {
                //if (!System.Object.ReferenceEquals(null, data.Icon))
                {
                    // change the element with given texture.
                    if (index < BtnList.Count)
                    {
                        //Sprite sp = MineResource.Instance.LoadSprite(data.Icon);

                        //Sprite sp = MineResource.Instance.LoadSpriteFromAB(Application.dataPath + "/AssetBundles/skillicons",
                        //    data.Icon);

                        IconData icd = IconManager.Instance.GetIconData(data.IconID);
                        if (!System.Object.ReferenceEquals(icd, null))
                        {
                            Sprite sp = MineResource.Instance.LoadSpriteFromAB(icd.Path,
                                                                               icd.Name);

                            if (!System.Object.ReferenceEquals(null, sp))
                            {
                                BtnList[index].sprite = sp;

                                if (item.Count <= 1)
                                {
                                    Texts[index].enabled = false;
                                }
                                else
                                {
                                    Texts[index].enabled = true;
                                    //Texts[index].

                                    Texts[index].text = item.Count.ToString();
                                }
                            }
                            else
                            {
                                TinyLogger.Instance.DebugLog("$ failed to load sprite!");
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        public void AddItem(UISkillItem item, bool alterUI = true)
        {
            var index = item.Index;

            ItemIndexes.Add(index);

            if (Items.Count <= index)
            {
                Items.Add(index, item);
            }
            else
            {
                Items[index] = item;
            }

            if (alterUI)
            {
                TheView.OnAddItem(item);
            }
        }