public void SetFrameYAt(int x, int y, short val) { ChangedTile tile; if (!changedTiles.TryGetValue((x << 16) | y, out tile)) { tile = new ChangedTile(x, y); changedTiles[(x << 16) | y] = tile; } Logging.ProgramLog.Debug.Log("{0}, {1} FrameY = {2}", x, y, val); tile.data.FrameY = val; }
public void SetLiquidAt(int x, int y, byte val) { ChangedTile tile; if (!changedTiles.TryGetValue((x << 16) | y, out tile)) { tile = new ChangedTile(x, y); changedTiles[(x << 16) | y] = tile; } Logging.ProgramLog.Debug.Log("{0}, {1} Liquid = {2}", x, y, val); tile.data.Liquid = val; }
public void SetWire(int x, int y, bool val) { ChangedTile tile; if (!changedTiles.TryGetValue((x << 16) | y, out tile)) { tile = new ChangedTile(x, y); changedTiles[(x << 16) | y] = tile; } Logging.ProgramLog.Debug.Log("{0}, {1} SetWire = {2}", x, y, val); tile.data.Wire = val; }
ChangedTile Change(int x, int y) { ChangedTile tile; if (!changedTiles.TryGetValue((x << 16) | y, out tile)) { tile = new ChangedTile(x, y); changedTiles[(x << 16) | y] = tile; } if (x < left) { left = x; } if (x > right) { right = x; } if (y < top) { top = y; } if (y > bottom) { bottom = y; } MinMax row; if (!changedRows.TryGetValue(y, out row)) { changedRows[y] = new MinMax { Min = x, Max = x }; } else { changedRows[y] = new MinMax { Min = Math.Min(x, row.Min), Max = Math.Max(x, row.Max) }; } if (lastX != x || lastY != y) { Logging.ProgramLog.Debug.Log("changed"); lastX = x; lastY = y; } return(tile); }
public void SetFrameYAt(int x, int y, short val) { ChangedTile tile; if (! changedTiles.TryGetValue ((x << 16) | y, out tile)) { tile = new ChangedTile (x, y); changedTiles[(x << 16) | y] = tile; } Logging.ProgramLog.Debug.Log ("{0}, {1} FrameY = {2}", x, y, val); tile.data.FrameY = val; }
ChangedTile Change(int x, int y) { ChangedTile tile; if (! changedTiles.TryGetValue ((x << 16) | y, out tile)) { tile = new ChangedTile (x, y); changedTiles[(x << 16) | y] = tile; } if (x < left) left = x; if (x > right) right = x; if (y < top) top = y; if (y > bottom) bottom = y; MinMax row; if (! changedRows.TryGetValue (y, out row)) { changedRows[y] = new MinMax { Min = x, Max = x }; } else { changedRows[y] = new MinMax { Min = Math.Min(x, row.Min), Max = Math.Max (x, row.Max) }; } if (lastX != x || lastY != y) { Logging.ProgramLog.Debug.Log ("changed"); lastX = x; lastY = y; } return tile; }
public void SetLiquidAt(int x, int y, byte val) { ChangedTile tile; if (! changedTiles.TryGetValue ((x << 16) | y, out tile)) { tile = new ChangedTile (x, y); changedTiles[(x << 16) | y] = tile; } Logging.ProgramLog.Debug.Log ("{0}, {1} Liquid = {2}", x, y, val); tile.data.Liquid = val; }
public IEnumerator ShowReplay() { CameraBehaviour.current.replayMode = true; //yield return new WaitUntil(() => Input.touchCount == 0); //yield return new WaitUntil(() => Input.touchCount > 0); // Undo All Changes for (int i = changes.Count - 1; i >= 0; i--) { ChangedTile change = changes[i]; change.Undo(); //yield return new WaitUntil(() => Input.touchCount == 0); //yield return new WaitUntil(() => Input.touchCount > 0); } HexTile focusTile = null; for (int i = 0; i < changes.Count; i++) { ChangedTile change = changes[i]; CameraBehaviour.current.focusTransform = change.tileB.transform; float waitTime = 0.25f; if (focusTile != change.tileB) { waitTime = .5f; } focusTile = change.tileB; yield return(new WaitForSeconds(waitTime)); change.Apply(); //yield return new WaitUntil(() => Input.touchCount == 0); //yield return new WaitUntil(() => Input.touchCount > 0); //yield return new WaitForSeconds(.25f); if (i + 1 < changes.Count && changes[i + 1].tileB != focusTile) { focusTile = changes[i + 1].tileB; yield return(new WaitForSeconds(.5f)); } if (i + 1 == changes.Count) { yield return(new WaitForSeconds(.5f)); } } changes = new List <ChangedTile>(); //changes = new List<ChangedTile>(); CameraBehaviour.current.focusTransform = null; CameraBehaviour.current.replayMode = false; StartCoroutine(CameraBehaviour.current.MoveCameraToLast(GameManager.current.activePlayer.lastCameraPos)); }
// Adds the tile to the changed tiles public void AddMovementToReplay(ChangedTile change) { changes.Add(change); }
// Moves ALL Units from this tile to the other Tile public bool MoveUnitsToTile(HexTile otherTile, int Amount, bool replay) { otherTile.SetMoveLocked(otherTile.team == GameManager.current.activeTeam || otherTile.team == GameManager.Teams.Null); otherTile.CheckFree(); // Not possible if Amount is bigger than available units if (Amount > units) { return(false); } // Same Team if (team == otherTile.team) { ChangedTile change = new ChangedTile(this, otherTile, -1, 1); change.AddTeamBefore(team, otherTile.team); otherTile.units += Amount; units -= Amount; Player player = GameManager.current.GetPlayerByTeam(otherTile.team); GameManager.Teams after = units == 0 ? GameManager.Teams.Null : team; change.AddTeamAfter(after, otherTile.team, units, otherTile.units); if (replay) { player.replays.AddMovementToReplay(change); } if (change.teamBBefore != change.teamBAfter && change.teamBAfter != GameManager.Teams.Null) { Debug.Log("Marked Change " + change.tileA + "->" + change.tileB + ": SAME TEAM"); change.Mark(); } CheckFree(); otherTile.CheckFree(); return(true); } // Other Team if (otherTile.team != GameManager.Teams.Null) { ChangedTile change = new ChangedTile(this, otherTile, -1, -1); change.AddTeamBefore(team, otherTile.team); otherTile.units -= Amount; units -= Amount; GameManager.Teams otherBefore = otherTile.team; // Conquered other Tile if (otherTile.units < 0) { Debug.Log("Conquered Tile! Shouldn't happen! Amount: " + Amount); GameManager.current.AddTileToPlayer(otherTile, GameManager.current.activePlayer); otherTile.units *= -1; } Player player = GameManager.current.GetPlayerByTeam(otherTile.team); GameManager.Teams afterOwn = units <= 0 ? GameManager.Teams.Null : team; GameManager.Teams afterOther; if (otherTile.units <= 0) { afterOther = GameManager.Teams.Null; } else { afterOther = otherTile.team; } change.AddTeamAfter(afterOwn, afterOther, units, otherTile.units); player.replays.AddMovementToReplay(change); if (change.teamBBefore != change.teamBAfter && change.teamBAfter != GameManager.Teams.Null) { Debug.Log("Marked Change " + change.tileA + "->" + change.tileB + ": OTHER TEAM"); change.Mark(); } if (replay) { GameManager.current.GetPlayerByTeam(team).replays.AddMovementToReplay(change); } CheckFree(); otherTile.CheckFree(); return(true); } // Empty HexTile if (otherTile.team == GameManager.Teams.Null) { ChangedTile change = new ChangedTile(this, otherTile, -1, 1); change.AddTeamBefore(team, otherTile.team); GameManager.current.AddTileToPlayer(otherTile, GameManager.current.activePlayer); otherTile.units = Amount; units -= Amount; Player player = GameManager.current.GetPlayerByTeam(team); GameManager.Teams after = units == 0 ? GameManager.Teams.Null : team; change.AddTeamAfter(after, otherTile.team, units, otherTile.units); if (change.teamBBefore != change.teamBAfter && change.teamBAfter != GameManager.Teams.Null && change.teamBBefore != GameManager.Teams.Null) { Debug.Log("Marked Change " + change.tileA + "->" + change.tileB + ": EMPTY"); change.Mark(); } if (replay) { player.replays.AddMovementToReplay(change); } CheckFree(); otherTile.CheckFree(); return(true); } return(false); }