Esempio n. 1
0
 void initHeroList()
 {
     if (GameData.user == null)
     {
         return;
     }
     for (int i = 0; i < GameData.user.heroList.Count; i++)
     {
         int        id = GameData.user.heroList[i];
         GameObject g  = Instantiate <GameObject>(heroBtn);
         HeroGrid   hg = g.GetComponent <HeroGrid>();
         hg.setData(id);
         RectTransform rtf = g.transform as RectTransform;
         rtf.parent        = heroList;
         rtf.localScale    = Vector3.one;
         rtf.localPosition = new Vector3(i % 10 * 44 + 25, -i / 10 * 44 + 3);
         myGrid.Add(id, hg);
     }
 }
Esempio n. 2
0
    private void initHeroList()
    {
        if (GameData.user == null)
        {
            return;
        }
        int index = 0;

        foreach (int item in GameData.user.heroList)
        {
            //创建英雄头像并添加进选择列表
            GameObject btn  = Instantiate <GameObject>(heroBtn);
            HeroGrid   grid = btn.GetComponent <HeroGrid>();
            grid.init(item);
            btn.transform.parent        = listParent;
            btn.transform.localScale    = Vector3.one;
            btn.transform.localPosition = new Vector3(48 - 262 + 72 * (index % 7), -42 + 150 + index / 7 * -72);
            gridMap.Add(item, grid);
            index++;
        }
    }
Esempio n. 3
0
    /// <summary>
    ///     初始化英雄列表
    /// </summary>
    private void InitHeroList()
    {
        if (GameData.user == null)
        {
            return;
        }
        int index = 0;

        //通过计算加载英雄列表
        foreach (int item   in GameData.user.HeroList)
        {
            GameObject btn  = Instantiate <GameObject>(heroBtn);
            HeroGrid   grid = btn.GetComponent <HeroGrid>();
            grid.Init(item);
            btn.transform.parent        = listParent;
            btn.transform.localScale    = Vector3.one;
            btn.transform.localPosition = new Vector3(50 - 275 + 75 * (index % 7), -42 + 135 + index / 7 * -72, 0);
            gridMap.Add(item, grid);
            index++;
        }
    }