Example #1
0
    private void CreatCell(int index)
    {
        if (index < 0 || index > _cellCount - 1)
        {
            return;
        }
        if (_dictCell.ContainsKey(index))
        {
            return;
        }
        CellData   _data = _listCellData[index];
        GameObject _c;

        if (_pool.Count > 0)
        {
            _c = _pool.Dequeue();
            _c.SetActive(true);
        }
        else
        {
            _c = GameObject.Instantiate(_cell);
        }
        _c.transform.Find("Text").GetComponent <Text>().text = index.ToString();
        _c.transform.SetParent(_contentTransform);
        (_c.transform as RectTransform).anchoredPosition = new Vector2(0, -cellHeight * index);
        _c.transform.localScale = Vector2.one;
        UIBtn uiBtn = _c.GetComponent <UIBtn>() == null?_c.AddComponent <UIBtn>() : _c.GetComponent <UIBtn>();

        uiBtn.cellData = _data;
        _c.name        = "cell  " + index;
        _dictCell.Add(index, _c);
    }
Example #2
0
 public void StageStartUp(UIBtn uIBtn)
 {
     //如果 目標Stage = 當前Stage(已開啟)
     if (uIBtn.launchStageCode == currentStageCode && StageIsActive)
     {
         CloseCurrentStage();
     }
     else
     {
         currentStageCode = uIBtn.launchStageCode;
         CloseOtherStage();
         //啟動目標 Stage
         foreach (var st in stages) //找到目標Stage
         {
             if (st.stagecode == uIBtn.launchStageCode)
             {
                 st.StageShow();
             }
         }
         StageIsActive = true;
     }
 }