public bool CatchPlayerInput(int horizontal, int vertical) { StaticCell emptyCell = GetEmptyStaticCell(); if (emptyCell == null) { return(false); // ERROR } if (horizontal == 1 && emptyCell.LeftCell) { MoveCell(emptyCell.LeftCell, emptyCell); return(true); } if (horizontal == -1 && emptyCell.RightCell) { MoveCell(emptyCell.RightCell, emptyCell); return(true); } if (vertical == 1 && emptyCell.DownCell) { MoveCell(emptyCell.DownCell, emptyCell); return(true); } if (vertical == -1 && emptyCell.UpCell) { MoveCell(emptyCell.UpCell, emptyCell); return(true); } return(false); }
public void Show(string name, ICell <bool> selected = null, Action <IDisposable> connectionSink = null) { text.text = name; if (selected == null) { selected = StaticCell <bool> .Default(); } if (connectionSink == null) { connectionSink = _ => { } } ; connectionSink(selected.Bind(sel => text.color = sel ? selectedTextColor : normalTextColor)); connectionSink(selected.Bind(sel => bg.color = sel ? selectedColor : normalColor)); } }
static ICell <int> FinalStat(Unit unit, Equipment eq, UnitBuffType buffType) { // selected unit can be null. if (unit == null) { return(StaticCell <int> .Default()); } var stat = StatForBuffType(unit, buffType); // If equipment does not buff this stat return just stat. if (eq == null || eq.type != buffType) { return(stat); } // If equipment stat match this kind of stat merge those. return(stat.Merge(eq.buff, (s, buff) => s + buff)); }
private void MoveCell(StaticCell startCell, StaticCell endCell) { startCell.MovingCell.MoveCell(endCell.transform); startCell.isUsed = false; endCell.isUsed = true; endCell.MovingCell = startCell.MovingCell; startCell.MovingCell = null; if (endCell.MovingCell.ID == endCell.ID) { if (CheckLevelCompleted()) { // Player WON sceneUIController.ShowLevelCompletePanel(); } } }
public CellSpacePartition(int cellX, int cellY, int partitionSize) { cellX /= partitionSize; cellY /= partitionSize; this.partitionSize = partitionSize; int cellIndex = cellX * cellY; cellLength = cellIndex; dynamicCells = new DynamicCell[cellIndex]; staticCells = new StaticCell[cellIndex]; for (int i = 0; i < cellIndex; i++) { dynamicCells[i] = new DynamicCell(); staticCells[i] = new StaticCell(); } numCellsX = cellX; numCellsY = cellY; }