public void ApplySymbolMap(SymbolMap map = null, List <SymbolSwapper> swaps = null) { for (int x = 0; x < slot.reels.Length; x++) { Reel reel = slot.reels[x]; for (int y = 0; y < reel.symbols.Length; y++) { Symbol symbol = map == null ? reel.symbols[y] : (x < map.symbols.Count && y < map.symbols[x].Count) ? map.symbols[x][y] : null; if (swaps != null) { for (int i = 0; i < swaps.Count; i++) { if (symbol == swaps[i].from) { symbol = swaps[i].to; } } } reel.symbols[y] = symbol ?? slot.skin.defaultSymbol; } reel.RefreshHolders(); } if (swaps != null) { for (int i = 0; i < swaps.Count; i++) { if (swaps[i].to) { swaps[i].to.ignoreThisRound = true; } } } }
// SymbolMap is a 2-dimensional list of symbols which can be applied to reels to change their symbols. // Called by SlotLayouter before it destorys and create new reels so that symbols on the old reel can be // carried over to the newly created reel. public SymbolMap GetSymbolMap() { SymbolMap map = new SymbolMap(); for (int i = 0; i < slot.reels.Length; i++) { map.symbols.Add(new List <Symbol>()); foreach (Symbol symbol in slot.reels[i].symbols) { map.symbols[i].Add(symbol); } } return(map); }
public void Initialize() { cleanMap = slot.symbolManager.GetSymbolMap(); current = defaultMode; }
public void ApplySymbolMap(SymbolMap map, SymbolSwapper swap) { ApplySymbolMap(map, new List <SymbolSwapper> { swap }); }
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); } }