Exemplo n.º 1
0
 private void Init()
 {
     //	slot.layouter.Refresh();
     slot.Validate();
     for (int x = 0; x < reelLength; x++)
     {
         reels.Add(new Symbol[symbolsPerReel]);
         scores.Add(new Symbol[rows]);
     }
     foreach (Line line in lines)
     {
         line.OnGenInit();
     }
     log = new SymbolGenLog(this);
 }
Exemplo n.º 2
0
 public void Generate()
 {
     if (!targetParent)
     {
         Debug.Log("Target parent transform must be specified.");
         return;
     }
     slot.Validate();
     Util.DestroyChildren <PayTableItem>(targetParent);
     Symbol[] symbols = slot.symbolManager.symbols;
     foreach (Symbol symbol in symbols)
     {
         PayTableItem item = Util.InstantiateAt <PayTableItem>(slot.skin.paytableItem, targetParent);
         item.Init(symbol, slot, this);
     }
 }
Exemplo n.º 3
0
        public void Refresh(bool rebuild = true)
        {
            if (Application.isPlaying)
            {
                SetActiveLayout(true);
            }
            SymbolManager   symbolManager = slot.symbolManager;
            LineManager     lineManager   = slot.lineManager;
            SlotConfig      config        = slot.config;
            GridLayoutGroup reel          = slot.layoutReel;
            GridLayoutGroup row           = slot.layoutRow;

            if (rebuild)
            {
                slot.Validate();
                if (config.symbolsPerReel < config.totalRows)
                {
                    Debug.Log("[Error] Symbols per reel must be higher than total rows(including hidden rows).");
                    return;
                }
            }

            reel.cellSize = sizeSymbol;
            reel.spacing  = spacingSymbol;
            int px = (int)(spacingSymbol.x * 0.5f), py = (int)(spacingSymbol.y * 0.5f);

            reel.padding = new RectOffset(px, px, py, py);

            Vector2 spacing = sizeSymbol + spacingSymbol;
            float   width   = spacing.x * config.reelLength;
            float   height  = spacing.y * config.rows;

            row.cellSize = new Vector2(width, sizeSymbol.y + spacingSymbol.y);
            row.spacing  = Vector2.zero;

            slot.mainScreen.sizeDelta = new Vector2(width + paddingMainScreen.horizontal, height + paddingMainScreen.vertical);

            (reel.transform as RectTransform).anchoredPosition = (row.transform as RectTransform).anchoredPosition = new Vector2(paddingMainScreen.left, config.hiddenTopRows * spacing.y - paddingMainScreen.top);

            if (linkLineManagerTransformToMainScreen)
            {
                (lineManager.transform as RectTransform).sizeDelta = (slot.mainScreen.transform as RectTransform).sizeDelta;
                lineManager.transform.position = slot.mainScreen.transform.position;
            }

            if (rebuild)
            {
                SymbolMap map = symbolManager.GetSymbolMap();
                Util.DestroyChildren <Row>(row);
                for (int i = 0; i < config.totalRows; i++)
                {
                    GameObject.Instantiate(slot.skin.row).OnRefreshLayout(slot, i);
                }
                Util.DestroyChildren <Reel>(reel);
                for (int i = 0; i < config.reelLength; i++)
                {
                    GameObject.Instantiate(slot.skin.reel).OnRefreshLayout(slot, i);
                }
                slot.reels = reel.transform.GetComponentsInChildren <Reel>();
                slot.rows  = row.transform.GetComponentsInChildren <Row>();
                symbolManager.ApplySymbolMap(map);
                lineManager.OnRefreshLayout();
                slot.Validate();
            }
            else
            {
                //	DOTween.CompleteAll(true);
                foreach (Reel r in slot.reels)
                {
                    foreach (SymbolHolder h in r.holders)
                    {
                        h._rect.sizeDelta = sizeSymbol;
                    }
                    r.y = r.nextY = 0;
                    r.RefreshHolderPositions();
                }
            }

            if (Application.isPlaying)
            {
                SetActiveLayout(false);
            }
        }