49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace 贪吃蛇
|
|
{
|
|
abstract class BaseScene : ISceneUpdate
|
|
{
|
|
protected int nowSceneIndex = 0;
|
|
protected string title;
|
|
protected string str1;
|
|
|
|
public abstract void PressEnter();
|
|
public void Update()
|
|
{
|
|
//要完成的内容:绘制开始和结束场景,并完成切换选择功能
|
|
Console.ForegroundColor = ConsoleColor.White;
|
|
|
|
//绘制标题
|
|
Console.SetCursorPosition(Game.w / 2 - title.Length, 5);
|
|
Console.Write(title);
|
|
|
|
//绘制选项
|
|
Console.SetCursorPosition(Game.w / 2 - str1.Length, 8);
|
|
Console.ForegroundColor = nowSceneIndex == 0 ? ConsoleColor.Red : ConsoleColor.White;
|
|
Console.Write(str1);
|
|
|
|
Console.SetCursorPosition(Game.w / 2 - 4, 10);
|
|
Console.ForegroundColor = nowSceneIndex == 1 ? ConsoleColor.Red : ConsoleColor.White;
|
|
Console.Write("结束游戏");
|
|
//根据nowSceneIndex绘制wsj选中的索引
|
|
switch (Console.ReadKey(true).Key)
|
|
{
|
|
case ConsoleKey.W:
|
|
nowSceneIndex = 0;
|
|
break;
|
|
case ConsoleKey.S:
|
|
nowSceneIndex = 1;
|
|
break;
|
|
case ConsoleKey.Enter:
|
|
PressEnter();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|