private static void Glowinator(Color glowCol, MapTileSet done, MapTile from, double amt) { MapTileSet surround = from.GetPossibleMoves(Dir.AllAround); while (amt > 0.1) { MapTileSet newSurround = new MapTileSet(); foreach (MapTile t in surround) { if (t.clear && !done.Contains(t)) { t.backCol = GlowColOffset(t.backCol, glowCol, amt); done.Add(t); MapTileSet more = t.GetPossibleMoves(Dir.AllAround); foreach (MapTile m in more) { newSurround.Add(m); } } } surround = newSurround; amt -= 0.1; } }
public MapTileSet GetClosed3Sides(MapTileSet input) { var r = new MapTileSet(); foreach (MapTile t in input) { int sum = 0; if (t.OneNorth() == null || t.OneNorth().clear == false) { sum++; } if (t.OneSouth() == null || t.OneSouth().clear == false) { sum++; } if (t.OneEast() == null || t.OneEast().clear == false) { sum++; } if (t.OneWest() == null || t.OneWest().clear == false) { sum++; } if (sum >= 3) { r.Add(t); } } return(r); }
private static void AddGlow(Loc l, Color glowCol) { // todo what about overlapping glows? MapTileSet done = new MapTileSet(); MapTile source = Refs.m.TileByLoc(l); source.backCol = GlowColOffset(source.backCol, glowCol, 0.5); done.Add(source); Glowinator(glowCol, done, source, 0.25); }
public MapTileSet TileList() { if (cachedTileList == null) { cachedTileList = new MapTileSet(); foreach (MapTile t in tiles) { cachedTileList.Add(t); } } return(cachedTileList); }
// for use with KnightMoves(), DodgeMoves(), LeapMoves() public MapTileSet GetPossibleMoves(HashSet <Loc> options) { var result = new MapTileSet(); foreach (Loc p in options) { Loc newloc = Loc.AddPts(loc, p); if (Refs.m.ValidLoc(newloc) && Refs.m.ClearLoc(newloc)) { result.Add(Refs.m.TileByLoc(newloc)); } } return(result); }
private static FlowTileSet PlayerNectarTiles(FlowMap f) { // tiles containing player nectar are targets too var allTiles = Refs.m.TileList(); var nectarTiles = new MapTileSet(); foreach (MapTile t in allTiles) { if (t.nectarLevel[0] > 0) // 0 for player { nectarTiles.Add(t); } } return(ConvertTiles.FlowSquaresFromTileSet(nectarTiles, f)); }
private static FlowTileSet SetUpInitialRing(int distance, FlowMap f) { // we'll try to flow to a set distance from the player by // making a ring of target squares and working from there var allTiles = Refs.m.TileList(); var ring = new MapTileSet(); foreach (MapTile t in allTiles) { double c = Loc.Distance(Refs.p.loc, t.loc); if (c > distance - 1 && c < distance + 1) { ring.Add(t); } } return(ConvertTiles.FlowSquaresFromTileSet(ring, f)); }
// returns number of round passed, 0 for free actions, 1 for normal moves. public int HandlePlayerInput(PreviewKeyDownEventArgs e) { // for convenience MapTile here = Refs.m.TileByLoc(loc); // debugging nectar report Console.Write("Nectar here is "); foreach (int i in here.nectarLevel) { Console.Write(i + ", "); } Console.Write("."); if (e.KeyCode == Keys.F && heldCubiId != 0) { return(BoinkHeld()); } if (e.KeyCode == Keys.C && heldCubiId != 0) { return(CaneHeld()); } Loc lastPos = loc; // visualise flows. hotkeys are just pretend this is where we really do it if (e.KeyCode == Keys.D0) { viewFlow = 0; return(0); } if (e.KeyCode == Keys.D1) { viewFlow = 1; return(0); } if (e.KeyCode == Keys.D2) { viewFlow = 2; return(0); } if (e.KeyCode == Keys.D3) { viewFlow = 3; return(0); } if (e.KeyCode == Keys.D4) { viewFlow = 4; return(0); } int timepass = 1; if (e.KeyCode == Keys.Space) { return(1); // allow waiting at any time } if (placemode || e.Shift) { timepass = 0; // place / pickup is a free action for now switch (e.KeyCode) { case Keys.Down: case Keys.S: ActionSouth(); FinishMode(); break; case Keys.Right: case Keys.D: ActionEast(); FinishMode(); break; case Keys.Up: case Keys.W: ActionNorth(); FinishMode(); break; case Keys.Left: case Keys.A: ActionWest(); FinishMode(); break; case Keys.Escape: CancelModes(); break; default: break; } } else if (throwmode || e.Control) { timepass = 0; // throw is a free action for now switch (e.KeyCode) { case Keys.Down: case Keys.S: ThrowSouth(); FinishMode(); break; case Keys.Right: case Keys.D: ThrowEast(); FinishMode(); break; case Keys.Up: case Keys.W: ThrowNorth(); FinishMode(); break; case Keys.Left: case Keys.A: ThrowWest(); FinishMode(); break; case Keys.Escape: CancelModes(); break; default: break; } } else { timepass = 1; switch (e.KeyCode) { // moves cost 1 turn case Keys.Down: case Keys.S: RunSouth(); break; case Keys.Right: case Keys.D: RunEast(); break; case Keys.Up: case Keys.W: RunNorth(); break; case Keys.Left: case Keys.A: RunWest(); break; // mode changes are free actions case Keys.T: SetThrowMode(); timepass = 0; break; case Keys.P: SetPlaceMode(); timepass = 0; break; case Keys.Escape: CancelModes(); timepass = 0; break; default: timepass = 0; break; } } // save our current location for next turn lastMove = Loc.SubPts(loc, lastPos); // starting at 1 skips player nectar processing for now for (int nLoop = 1; nLoop < here.nectarLevel.Length; nLoop++) { if (here.nectarLevel[nLoop] > 0) { horny += here.nectarLevel[nLoop]; here.nectarLevel[nLoop] = 0; } } if (horny > 15) // having fun { Refs.mf.Announce("Awwww yeah! *splurt*", myAlign, myColor); timepass += 5; MainMap.SplurtNectar(here, myIndex: 0); horny = 0; } if (!victory) { // we're duplicating this location scanning code a lot... // but this will be useful if we ever move jails so I'll leave it // get list of capture tiles MapTileSet jails = new MapTileSet(); foreach (Loc l in Refs.m.pents) { jails.Add(Refs.m.TileByLoc(l)); } // get list of cubi locations MapTileSet breaker = new MapTileSet(); foreach (Cubi c in Refs.h.roster) { breaker.Add(Refs.m.TileByLoc(c.loc)); } // IntersectWith to get occupied jails jails.IntersectWith(breaker); // if jails filled = total jails, we won! if (jails.Count == Refs.m.pents.Count) { victory = true; Refs.mf.Announce("Gotcha all! And in only " + turnCounter + " turns!", myAlign, myColor); } } return(timepass); }
public void AddToClearTileCache(MapTile t) => clearCache.Add(t);