public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            SymbolManager t = target as SymbolManager;

            if (GUILayout.Button("Sort"))
            {
                t.Sort();
            }
            if (GUILayout.Button("Add a new Symbol"))
            {
                Util.InstantiateAt <Symbol>(t.slot.skin.defaultSymbol, t.transform);
                EditorUtility.SetDirty(t);
            }
            EditorGUILayout.LabelField("Or simply press CTRL+d on an existing symbol to duplicate");
        }
Exemplo n.º 2
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);
            }
        }