public WinController(MissionConstruct mc, MatchBoard gB) { Result = GameResult.None; mGrid = gB.grid; mBoard = gB; movesCostrain = mc.MovesConstrain; MovesRest = movesCostrain; ScoreTarget = mc.ScoreTarget; botDynCells = mBoard.grid.GetBottomDynCells(); #region time timeCostrain = mc.TimeConstrain; IsTimeLevel = mc.IsTimeLevel; if (IsTimeLevel) { MovesRest = 0; Timer = new SessionTimer(timeCostrain); Timer.TickRestFullSecondsEvent += (s) => { TimerTickEvent?.Invoke(s); }; Timer.TickRestFullSecondsEvent += (sec) => { TimeRest = (int)sec; if (TimeRest == 30) { TimerLeft30Event?.Invoke(); } }; Timer.TimePassedEvent += () => { if (Result == GameResult.None) { CheckResult(); } }; } #endregion time }
public void UpdateMap(MatchGrid grid) // new proc { // check if grid size int gCount = grid.Cells.Count; int pfCount = pfCells.Count; if (gCount == pfCount && grid.Cells[0] == pfCells[0].gCell && grid.Cells[gCount - 1] == pfCells[pfCount - 1].gCell) { // UnityEngine.Debug.Log("Refresh map"); foreach (var item in pfCells) { item.mather = null; // item.openClose = 0; item.fCost = 0;item.gCost = 0; item.hCost = 0; item.available = (!item.gCell.IsDisabled && !item.gCell.Blocked); } } else { CreateMap(grid); } }
private void CreateMap(MatchGrid grid) { pfCells = new List <PFCell>(grid.Cells.Count); // UnityEngine.Debug.Log("Create new map"); // create all pfcells foreach (var item in grid.Cells) { PFCell pfc = new PFCell(item); pfc.available = (!item.IsDisabled && !item.Blocked && !item.StaticBlocker); item.pfCell = pfc; pfCells.Add(pfc); } // set pfcell neighborns foreach (var item in pfCells) { item.CreateNeighBorns(); } }
public MatchGrid(LevelConstructSet lcSet, GameObjectsSet goSet, Transform parent, int sortingOrder, GameMode gMode) { Instance = this; Debug.Log("new grid "); this.lcSet = lcSet; this.parent = parent; this.gMode = gMode; this.sortingOrder = sortingOrder; vertSize = lcSet.VertSize; horSize = lcSet.HorSize; this.goSet = goSet; prefab = goSet.gridCellEven; cellSize = prefab.GetComponent <BoxCollider2D>().size; float deltaX = lcSet.DistX; float deltaY = lcSet.DistY; float scale = lcSet.Scale; parent.localScale = new Vector3(scale, scale, scale); Cells = new List <GridCell>(vertSize * horSize); Rows = new List <Row <GridCell> >(vertSize); yOffset = 0; xStep = (cellSize.x + deltaX); yStep = (cellSize.y + deltaY); cOffset = (1 - horSize) * xStep / 2.0f; // offset from center by x-axe yStart = (vertSize - 1) * yStep / 2.0f; //instantiate cells for (int i = 0; i < vertSize; i++) { AddRow(); } SetObjectsData(lcSet, gMode); Debug.Log("create cells: " + Cells.Count); }
public Map(MatchGrid grid) { CreateMap(grid); }