public Game(int scence_h_size = 55, int scence_v_size = 35) { SenceWidth = scence_h_size; SenceHeigth = scence_v_size; StageManager.LoadAllStage(); this.stage = StageManager.GetStageByIdx(0); this.gsm = GameStatusManger.GetInstance(); // gsm.Inital(); this.gsm.stage = this.stage; // TODO: adopt the new draw system // new draw buffer stagecanvas = new ConsoleCanvas(SenceWidth, SenceHeigth, anchor_h: 2, anchor_v: 2); gameMsgUI = new GameMsgUI(SenceWidth, 10, anchor_v: SenceHeigth + 2, anchor_h: 2); playerStatusUI = new PlayerStatusMsgUI(30, SenceHeigth, anchor_v: 2, anchor_h: 2 * (SenceWidth + 1) + 2); // gameMsgCanvas = new ConsoleCanvas(SenceWidth, 10, anchor_v: SenceHeigth + 2, anchor_h: 2); // playerStatusUICanvas = new ConsoleCanvas(25, SenceHeigth, anchor_v: 2, anchor_h: 2*(SenceWidth+1) + 2); draw_buffer = stagecanvas.GetBuffer(); color_buffer = stagecanvas.GetColorBuffer(); stagecanvas.drawEdge(); gameMsgUI.canvas.drawEdge(); playerStatusUI.canvas.drawEdge(); BulletManager.gsm = this.gsm; }
public SampleUI(int w, int h, char _empty = ' ', int anchor_v = 0, int anchor_h = 0) { this.canvas = new ConsoleCanvas(w, h, _empty, anchor_v, anchor_h); draw_buff = canvas.GetBuffer(); color_buff = canvas.GetColorBuffer(); this.MsgList = new List <string>(); }
static void Main(string[] args) { canvas = new ConsoleCanvas(width, height); buffer = canvas.GetBuffer(); color_buffer = canvas.GetColorBuffer(); Rule.Init(); int level = 1; if (args.Length > 1) { level = int.Parse(args[1]); } bool game_ok = true; while (game_ok) { // 关卡 StageLogic(); canvas.ClearBuffer_DoubleBuffer(); DrawAll(); canvas.Refresh_DoubleBuffer(); Console.ReadLine(); } }
private void DrawWelcome(TitleService.Banner banner) { Log log = new Log(); Animate(_titleService.TopLine(), banner); // Animate("Jeremy, Welcome to the Jungle...", banner); DrawHeader(banner); log.NewLine(); DrawCheatLines(); DrawHeader(banner); log.NewLine(); ConsoleCanvas canvas = new ConsoleCanvas(); UserInfoBlock userBlock = new UserInfoBlock(); canvas.AddBlock(userBlock.Block); canvas.GetInput(); Name = userBlock.Name; UserColor = userBlock.Color; DrawHeader(banner, Name); log.NewLine(); }
static void Main(string[] args) { Console.SetWindowSize(25, 10); Console.Title = "2048 Game"; canvas = new ConsoleCanvas(21, 9); buffer = canvas.GetBuffer(); colorBuffer = canvas.GetColorBuffer(); nums = new int[4, 4]; RandNewNum(); // 先刷新一次界面 canvas.ClearBuffer_DoubleBuffer(); DrawAll(); canvas.Refresh_DoubleBuffer(); while (true) { GameLogic(); canvas.ClearBuffer_DoubleBuffer(); DrawAll(); canvas.Refresh_DoubleBuffer(); } }
static void Main() { Console.OutputEncoding = Encoding.Unicode; Console.SetWindowSize(160, 40); AbstractCanvas canvas = new ConsoleCanvas(156, 30); Start(canvas); }
static void Main(string[] args) { int flag = minesweeper; canvas = new ConsoleCanvas(width, height + 3); buffer = canvas.GetBuffer(); color_buffer = canvas.GetColorBuffer(); player.SetPos(0, 0); // 默认位置 System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); // 计算用时 int[,] mine = initMine(); int[,] saveMine = SaveMap(mine); int[,] userMine = InitUser(mine.GetLength(0), mine.GetLength(1)); bool b = true; string res = "不好意思,您输了。下次走运!"; sw.Start(); // 计时开始 while (b) { below_text = "按U标记,按A打开,按IJKL移动"; level_target = $"当前雷数{minesweeper},剩余标记{flag}"; DrawAll(userMine); // 显示棋盘 int count = InputNum(); if (count == 1) { b = StartGame(mine, userMine); // if (GameOver(userMine, saveMine)) { res = "恭喜!您赢了!"; break; } } else if (count == 0) { if (userMine[player.i, player.j] != -10 && userMine[player.i, player.j] < 0) { userMine[player.i, player.j] = -10; flag--; } else if (userMine[player.i, player.j] == -10) { userMine[player.i, player.j] = -2; flag++; } } } sw.Stop(); // 计时结束 canvas.ClearBuffer_DoubleBuffer(); DrawOther(saveMine); canvas.Refresh_DoubleBuffer(); Console.WriteLine(); Console.Write(res); Console.WriteLine("时间:{0} 秒", sw.ElapsedMilliseconds / 1000); Console.ReadLine(); }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); panel = GetComponentInChildren <ConsolePanel>(); panel.gameObject.SetActive(false); Shown = false; } else if (instance != this) { Destroy(gameObject); } }
public void Test_canvas_draw() { // Arrange ICanvas <string> canvas = new ConsoleCanvas(); Rect rect = new Rect(30, 40, new Point(10, 10)); Square square = new Square(35, new Point(15, 30)); Ellipse ellipse = new Ellipse(300, 200, new Point(100, 150)); Circle circle = new Circle(300, new Point(1, 1)); TextBox textBox = new TextBox(200, 100, new Point(5, 5), "sample text"); string[] expected_output = { "----------------------------------------------------------------", "Current Drawing", "----------------------------------------------------------------", "Rectangle (10,10) width=30 height=40", "Square (15,30) size=35", "Ellipse (100,150) diameterH = 300 diameterV = 200", "Circle (1,1) size=300", "Textbox (5,5) width=200 height=100 Text=\"sample text\"", "----------------------------------------------------------------", }; // Act canvas .Add(rect) .Add(square) .Add(ellipse) .Add(circle) .Add(textBox); string[] output = canvas.Print().ToArray(); // Assert Assert.AreEqual(expected_output.Length, output.Length); for (int i = 0; i < expected_output.Length; i++) { Assert.AreEqual(expected_output[i], output[i]); } }
//static ConsoleColor[,] forecolor_buffer = null; //static ConsoleColor[,] backcolor_buffer = null; static void Main(string[] args) { string url_root = "http://127.0.0.1:8080/?timestamp=" + ""; string url = url_root; canvas = new ConsoleCanvas(canvas_width, canvas_height); buffer = canvas.GetBuffer(); //forecolor_buffer = canvas.GetForecolorBuffer(); //backcolor_buffer = canvas.GetBackcolorBuffer(); while (true) { DeliveryData data = Handler(url); if (!data.isPlayerReady)//人不齐时等待 { Console.WriteLine("等待玩家中......"); Thread.Sleep(100); Console.Clear(); url = url_root + data.cur_timestamp; continue; } canvas.ClearBuffer_DoubleBuffer(); InitMap(); ParseToChar(data); if (data.isGameOver) { if (data.player_idx < 2) { ParseInfo("游戏结束!" + (data.winner_idx == data.player_idx ? "你赢了!" : "你输了..."), 15); } else { ParseInfo("观战结束!" + data.winner_idx + "号玩家获胜!", 15); } //ParseInfo("房间将在5秒后重启......", 19); canvas.Refresh_DoubleBuffer(); break; } if (data.player_idx < 2 && data.isReady)//当玩家回合 { ParseInfo("请选择打击位置", 15); canvas.Refresh_DoubleBuffer(); int left = 5 * 2; int top = 5; int idx = 44; ConsoleKeyInfo cki; while (true) { cki = BlinkAt(ref left, ref top, mapForPaint[0, idx]); if (cki.Key == ConsoleKey.A) { if (left > 1 * 2) { left -= 2; idx--; } else { left = 2; } } else if (cki.Key == ConsoleKey.S) { if (top < 10) { top++; idx += 10; } else { top = 10; } } else if (cki.Key == ConsoleKey.D) { if (left < 10 * 2) { left += 2; idx++; } else { left = 20; } } else if (cki.Key == ConsoleKey.W) { if (top > 1) { top--; idx -= 10; } else { top = 1; } } else { if (mapForPaint[0, idx] == '_') { url = url_root + data.cur_timestamp + "&mapidx=" + idx.ToString(); break; } } } } else if (data.player_idx < 2)//当非玩家回合 { //canvas.ClearBuffer_DoubleBuffer(); //InitMap(); //ParseToChar(data); ParseInfo("对方正在考虑中......", 15); canvas.Refresh_DoubleBuffer(); url = url_root + data.cur_timestamp; Thread.Sleep(100); } else//观众 { //canvas.ClearBuffer_DoubleBuffer(); //InitMap(); //ParseToChar(data); ParseInfo("观战中......", 15); canvas.Refresh_DoubleBuffer(); url = url_root + data.cur_timestamp; Thread.Sleep(100); } } Console.ReadKey(); }