public MainMap(int xIn, int yIn) { xLen = xIn; yLen = yIn; tiles = new MapTile[xLen, yLen]; for (int x = 0; x < xLen; x++) { for (int y = 0; y < yLen; y++) { tiles[x, y] = new MapTile(new Loc(x, y), this); } } // holding pens pents = new List <Loc>(); FlowMap.Init(ref flows, xLen, yLen); }
public static void FlowOutAndBack(int distance, FlowMap ourFlow) { // ref http://www.roguebasin.com/index.php?title=Dijkstra_Maps_Visualized ourFlow.SetToNines(); ourFlow.TileByLoc(Refs.p.loc).flow = 0; ourFlow.RunFlow(maskWalls: true); ReportHighAndLow(ourFlow, "after first flow"); ourFlow.Reverse(); ReportHighAndLow(ourFlow, "after reverse "); ourFlow.MultFactor(1.5); ReportHighAndLow(ourFlow, "after mult "); ourFlow.RunFlow(maskWalls: true); ReportHighAndLow(ourFlow, "after 2nd flow "); ourFlow.AdjustFactor(-25); }
public void PreviewKeyDownHandler(object sender, PreviewKeyDownEventArgs e) { this.ActiveControl = defaultFocus; var sw = new Stopwatch(); sw.Start(); Console.WriteLine("Key " + e.KeyCode + " Pressed"); Console.WriteLine("Starting new frame."); try { if (turnTimer.ElapsedMilliseconds < 300) { return; } turnTimer.Start(); int timePass = Refs.p.HandlePlayerInput(e); Refs.m.HealWalls(); Console.WriteLine("Finished HealWalls at " + sw.ElapsedMilliseconds + "ms in."); Console.WriteLine("Finished RunLos at " + sw.ElapsedMilliseconds + "ms in."); FlowMap.RemakeAllFlows(); Console.WriteLine("Finished RemakeAllFlows at " + sw.ElapsedMilliseconds + "ms in."); if (timePass == 0) { UpdateMap(); Console.WriteLine("Finished UpdateMap at " + sw.ElapsedMilliseconds + "ms in."); } else { while (timePass > 0) { // run ai for multiple turns if needed foreach (Cubi c in Refs.h.roster) { c.AiMove(); } Console.WriteLine("Finished AiMove at " + sw.ElapsedMilliseconds + "ms in."); Refs.m.SpreadNectar(); UpdateMap(); Thread.Sleep(75); Console.WriteLine("Finished UpdateMap at " + sw.ElapsedMilliseconds + "ms in."); timePass--; Refs.p.turnCounter++; } } } catch (Exception ex) { MessageBox.Show("Last chance catch of exception " + ex.GetType() + " with message " + ex.Message + " at " + ex.Source + " with trace " + ex.StackTrace); } Console.WriteLine("Total time this update = " + sw.ElapsedMilliseconds + "ms. or " + 1000 / sw.ElapsedMilliseconds + " fps if it mattered."); this.ActiveControl = defaultFocus; }