示例#1
0
    //遊戲初始化(重置遊戲)
    private void GameInitialize()
    {
        SetOperationState(false); //操作狀態設為禁止
        leverCanSnap = false;

        nowSlotLevel = PlayerPrefs.GetInt("GAME_SLOTLEVEL", 0);                               //拉霸等級初始化

        SlotLevel _defaultSlot = ScrollManager.Instance.slotLevelLayoutSetting[nowSlotLevel]; //取得預設拉霸等級設定資訊

        BetController.Instance.Initialize();                                                  //下注控制腳本初始化

        LotteryLineSetting _lineSetting = _defaultSlot.lineSetting;

        StartCoroutine(ScrollManager.Instance.Cor_SetScrollPanel(ScrollManager.Instance.defaultElementChain, false, _lineSetting)); //設置捲軸區域UI

        PrizeTableSetting _prizeTable = _defaultSlot.prizeTable;                                                                    //取得初始支付表

        PrizeTableManager.Instance.Initiailze(_prizeTable);                                                                         //支付表初始化

        ScrollManager.Instance.RouletteInitialize();                                                                                //輪盤初始化

        MoneyManager.Instance.Initialize();                                                                                         //金錢管理腳本初始化

        SpinLevelPanel.Instance.Initialize();                                                                                       //拉霸等級介面初始化

#if UNITY_EDITOR
        TestPanelManager.Instance.ProbabilityInitialize(); //測試工具初始化 : 機率設定
        TestPanelManager.Instance.SimulationInitialize();  //測試工具初始化 : 拉霸模擬
#endif

        StartCoroutine(Cor_GameStart());
    }
示例#2
0
    //初始化
    public void Initiailze(PrizeTableSetting setting)
    {
        if (setting == null || setting.m_data.Count == 0)
        {
            return;           //若支付表尚未設定則直接結束程序
        }
        prizeTable = setting; //套用設定

        //調整UI
        int   _total         = prizeTable.m_data.Count;                                                               //取得項目總數
        float _holderHeight  = combinationHolder.gameObject.GetComponent <RectTransform>().rect.height;               //取得視窗高度
        float _elementHeight = combinationHolder.cellSize.y;                                                          //取得項目元素高度
        float _spacing       = defultSpacing;                                                                         //取得預設間隔
        int   _max           = CalculateMaxCount(ItemColumnCount, _holderHeight, _elementHeight, _spacing);           //取得項目可容納最大數量

        if (_total > _max)                                                                                            //若欲顯示的項目數超過可容納最大數, 則壓縮間隔(Spacing)
        {
            int   _inputCount = (Mathf.CeilToInt((float)(_total - _max) / ItemColumnCount) * ItemColumnCount) + _max; //取得欲計算最適間距的項目數
            float _newSpacing = CalculateFitSpacing(_inputCount, ItemColumnCount, _holderHeight, _elementHeight);     //計算適當間距

            combinationHolder.spacing = new Vector2(combinationHolder.spacing.x, _newSpacing);                        //套用新的項目間隔
        }
        else
        {
            combinationHolder.spacing = new Vector2(combinationHolder.spacing.x, defultSpacing); //設定項目間隔
        }

        //創建圖案字典
        if (Dict_imageTable == null) //若字典尚未建立, 則建立之
        {
            Dict_imageTable = new Dictionary <ElementImageType, Sprite>();
            List <ElementAttributeData> _data = ScrollManager.Instance.elementAttribute.m_data;

            for (int i = 0; i < _data.Count; i++)
            {
                Dict_imageTable.Add(_data[i].imgType, _data[i].simpleSprite);
            }
        }

        //列表重新整理&排序
        List <PrizeCombination> _sortedList = new List <PrizeCombination>(); //排列完成列表

        _sortedList = new List <PrizeCombination>();

        List <List <PrizeCombination> > repetitionSortList = CombinationSort(prizeTable.m_data, CombinationSortType.純元素與否); //依純元素or混和元素分割列表

        for (int i = 0; i < repetitionSortList.Count; i++)
        {
            if (i == 0)                                                                                                             //純元素
            {
                List <List <PrizeCombination> > patternSortList = CombinationSort(repetitionSortList[i], CombinationSortType.花色與否); //依花色分割列表
                for (int j = 0; j < patternSortList.Count; j++)
                {
                    patternSortList[j].Sort(SortByAmount); //依圖案數量排序
                }

                patternSortList.Sort(SortByAveragePrize);       //依集合平均獎金排序

                for (int j = 0; j < patternSortList.Count; j++) //逐一加入輸出列表
                {
                    _sortedList.AddRange(patternSortList[j]);
                }
            }
            if (i == 1)                                  //混和元素
            {
                repetitionSortList[i].Sort(SortByPrize); //依照獎金多寡排序
                _sortedList.AddRange(repetitionSortList[i]);
            }
        }

        //物件創立
        if (combinationList == null)
        {
            combinationList = new List <Combination>();                         //若組合項目列表不存在則建立之
        }
        for (int i = 0; i < _sortedList.Count; i++)
        {
            if (combinationList.Count < _sortedList.Count) //組合項目物件不足時, 創建之
            {
                GameObject  _go   = Instantiate(CombinationPrefab, combinationHolder.transform);
                Combination _comb = _go.GetComponent <Combination>(); //取得腳本

                combinationList.Add(_comb);                           //加入列表
            }

            Color _color = _sortedList[i].freeOrder ? freeOrderColor : defaultColor; //取得背景色
            combinationList[i].Initialize(_sortedList[i].combinations, _sortedList[i].prizeMoney, _color, Dict_imageTable);
        }

        for (int i = _sortedList.Count; i < combinationList.Count; i++) //暫時隱藏多餘的支付表項目
        {
            combinationList[i].Invalid();
        }
    }