private void Start() { texts = GetComponentsInChildren <Text>(true); currentPage = 0; player = FrontSceneManager.player; textCanvas = FrontSceneManager.textCanvas; }
public override void ProcessCanvas(TextCanvas canvas) { canvas.ClearColor(Black); canvas.WriteTextCenter(2, " ", White, DarkRed); canvas.WriteTextCenter(3, " <<< GAME OVER >>> ", White, DarkRed); canvas.WriteTextCenter(4, " ", White, DarkRed); canvas.WriteTextCenter(7, $"{gameOverInfo.Reason}", Yellow, Black); canvas.WriteTextCenter(10, $"Player: {gameOverInfo.PlayerName}", Lime, Black); canvas.WriteTextCenter(12, $"SCORE: {gameOverInfo.Score}", LightTeal, Black); if (placement.HasValue) { canvas.WriteTextCenter(15, $"Congratulations!", White, Black); canvas.WriteTextCenter(16, $"You have earned enough points to be ranked!", Silver, Black); int x = placementImage.Size.AsRectangle.CenterAt(canvas.Size.AsRectangle.Center).TopLeft.X; int y = canvas.Size.Height - placementImage.Size.Height - 5; canvas.DrawImage(placementImage, new Point(x, y)); } canvas.WriteTextCenter(canvas.Size.Height - 2, "-- Presc ESC to back to main menu --", Silver, Black); }
/// <summary> /// Annotation Viewer on a container /// </summary> public AnnotationBox() { _scrollViewer = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden, Margin = new Thickness(3) }; _textViewer = new TextCanvas(_scrollViewer); _scrollViewer.Content = _textViewer; WidthRatio = 0.5; HeightRatio = 0.5; CornerRadius = 8; BubblePeakWidth = 16; BubblePeakHeight = 10; BubblePeakPosition = new Point(CornerRadius + BubblePeakWidth + 1, -BubblePeakHeight); Padding = new Thickness(5); BorderThickness = new Thickness(1); BorderBrush = Brushes.Teal; Foreground = Brushes.Teal; Background = new SolidColorBrush(Colors.Bisque) { Opacity = 0.97 }; FontSize = 16; FontFamily = new FontFamily("Arial"); TextAlign = TextAlignment.Justify; Child = _scrollViewer; }
/// <summary> /// Overwrites whole line at index of row /// </summary> /// <param name="canvas"></param> /// <param name="text"></param> /// <param name="row"></param> /// <param name="rightAligned"></param> public static void WriteLine(this TextCanvas canvas, string text, int?row = null, bool rightAligned = false) { row = row ?? canvas.CurrentRow; if (row.Value < 0 || row.Value > canvas.ContentHeight) { throw new ArgumentOutOfRangeException(nameof(row), row.Value, "Given row is out of range"); } #region Line-wrapping Logic if (text.Length > canvas.ContentWidth) { List <string> rows = FoldText(text, canvas.ContentWidth); rows.Last().Fill(canvas.ContentWidth, FillOptions.Default | FillOptions.OverwriteBaseString); if (rightAligned) { foreach (var rowString in rows) { for (int i = rowString.Length - 1, j = 0; i >= 0; i--, j++) { canvas.SetCursorPosition(canvas.ContentWidth - j, row.Value + rows.IndexOf(rowString)); Console.Write(rowString[i]); } } return; } foreach (var rowString in rows) { canvas.SetCursorPosition(0, row.Value + rows.IndexOf(rowString)); Console.Write(rowString); } return; } #endregion if (rightAligned) { for (int i = text.Length - 1, j = 0; i >= 0 && j < canvas.ContentWidth; i--, j++) { canvas.SetCursorPosition(canvas.ContentWidth - j, row.Value); Console.Write(text[i]); } return; } canvas.SetCursorPosition(0, row.Value); Console.Write(text); canvas.CurrentRow++; }
public override void ProcessCanvas(TextCanvas canvas) { canvas.ClearColor(Color16.Black); canvas.WriteTextCenter(3, "S N A K E", Color16.White, Color16.Black); canvas.WriteTextCenter(5, "Thanks for playing!", Color16.Lime, Color16.Black); }
private void Start() { fadeCanvas = GameManager.fadeCanvas.gameObject; textCanvas = FrontSceneManager.textCanvas; eventCanvas = FrontSceneManager.eventCanvas.canvas; playerRigidbody = GetComponent <Rigidbody>(); isStop = false; // diaryFlag = false; // tvFlag = false; moving = false; // get the transform of the main camera if (Camera.main != null) { m_Cam = Camera.main.transform; } else { Debug.LogWarning( "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject); // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them! } // get the third person character ( this should never be null due to require component ) m_Character = GetComponent <ThirdCharacter>(); screenSize = new Vector2Int(Screen.width, Screen.height); maxTouchDistance *= screenSize.x; }
//====== override: Window protected override void PaintContent(TextCanvas canvas) { for (int i = 0; i < items.Length; i++) { var foreColor = items[i].IsValueCritical ? Color16.Red : Color16.Lime; WriteStatsLine(canvas, new Point(2, 1 + (i * 2)), items[i].Name, items[i].Value, foreColor); } }
// Start is called before the first frame update void Start() { itemImage = transform.Find("ItemImage").GetComponent <Image>(); textCanvas = GetComponentInChildren <TextCanvas>(true); button = GetComponentInChildren <Button>(true); buttonText = button.GetComponentInChildren <Text>(true); button.gameObject.SetActive(false); textCanvas.gameObject.SetActive(false); cursor = transform.Find("Cursor"); }
//====== override: Window protected override void PaintContent(TextCanvas canvas) { var list = hiScoresList.GetList(); for (int i = 0; i < hiScoresList.Capacity; i++) { HiScoresEntry entry = (i < list.Count) ? list[i] : null; PrintHiScoreItem(canvas, new Point(2, 1 + i), i, entry); } }
//====== private methods private void PaintTitle(TextCanvas windowView) { if (windowView.Size.Width < 7) { return; } var titleView = windowView.Slice(new Rectangle(new Point(2, 0), new Size(windowView.Size.Width - 6, 1))); titleView.WriteText(Point.Zero, " " + Title + " ", Appearance.TitleTextColor, Appearance.BackColor); }
//====== private methods private void PaintStatsWindow(TextCanvas canvas) { var statsView = canvas.Slice(canvas.Size.AsRectangle.ChangeWidth(30)); statsView.ClearColor(Color16.DarkBlue); var app = new WindowAppearance(Color16.Black, Color16.Teal, Color16.Lime, true); var statsWindow = new StatsWindow(playerName, gameLogic.GetStatus(), statsView.Size, app); statsWindow.Paint(statsView, Point.Zero); }
// Start is called before the first frame update void Start() { textCanvas = FrontSceneManager.textCanvas; naviCanvas = FrontSceneManager.naviCanvas; player = FrontSceneManager.player; itemImage = FrontSceneManager.naviCanvas.itemImage; if (unityEvent == null) { new UnityEvent(); } countKey = 0; }
private void PrintHiScoreItem(TextCanvas canvas, Point position, int itemIndex, HiScoresEntry entry) { var color = (entry is null) ? Color16.Gray : Color16.White; string name = entry?.Name ?? "..."; string score = entry?.Score.ToString() ?? "..."; name = name.PadLeft(20, ' '); score = score.PadLeft(5, ' '); canvas.WriteText(position, $"{itemIndex + 1}. {score} {name}", color, Appearance.BackColor); }
// Start is called before the first frame update private void Awake() { eventButton = GameObject.Find("EventButton").GetComponent <Button>(); textCanvas = GetComponentInChildren <TextCanvas>(true); buttonText = eventButton.GetComponentInChildren <Text>(true); naviCanvas = GetComponentInChildren <NaviCanvas>(true); gameOverCanvas = GetComponentInChildren <GameOverCanvas>(true); gameClearCanvas = GetComponentInChildren <GameClearCanvas>(true); enemy = GameObject.FindGameObjectWithTag("Enemy").GetComponent <Enemy>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>(); eventCanvas = GetComponentInChildren <EventCanvas>(true); }
//====== ctors protected ScreenTransition(ITextArrayReader prevGameModuleScreenSnapshot, TextCanvas canvas, GameTime gameTime) : base(gameTime) { Verify.NotNull(prevGameModuleScreenSnapshot, nameof(prevGameModuleScreenSnapshot)); this.canvas = Verify.NotNull(canvas, nameof(canvas)); if (prevGameModuleScreenSnapshot.Size.Equals(canvas.Size) == false) { throw new ArgumentException($"Sizes are not equal."); } this.prevGameModuleScreenSnapshot = TextImage.CreateCopyFrom(prevGameModuleScreenSnapshot); }
// Start is called before the first frame update void Start() { eventCanvas = FrontSceneManager.eventCanvas; naviCanvas = FrontSceneManager.naviCanvas; button = FrontSceneManager.eventButton; buttonText = FrontSceneManager.buttonText; textCanvas = FrontSceneManager.textCanvas; firstTime = true; if (unityEvent == null) { unityEvent = new UnityEvent(); } }
public static void Focus( this TextCanvas canvas, ConsoleKeyInfo exitKey, Dictionary <ConsoleKeyInfo, Action> keyHandlers) { /** * TODO: Show Cursor * TODO: Save Input to Buffer * ... */ throw new NotImplementedException(); }
public void SetUp() { _mouse = new TestMouse(); _keyboard = new TestKeyboard(); _control = new TextCanvas(new ScrollBar(), new ScrollBar(), TextSettings.Default) { Width = 800, Height = 600 }; _control.Arrange(new Rect(0, 0, 800, 600)); DispatcherExtensions.ExecuteAllEvents(); }
public override void ProcessCanvas(TextCanvas canvas) { canvas.ClearColor(Color16.Black); canvas.WriteTextCenter(1, Resources.TextHiScores, hiScoresAnimation.CurrentFrame, Color16.Black); var appearance = new WindowAppearance(Color16.Black, Color16.Lime, Color16.Yellow); var hiScoresWindow = new HiScoresWindow(hiScores, appearance); var winPosition = hiScoresWindow.Size.AsRectangle.CenterAt(canvas.Size.AsRectangle.Center).TopLeft; hiScoresWindow.Paint(canvas, winPosition); canvas.WriteTextCenter(canvas.Size.Height - 2, "-- Presc ESC to back --", Color16.Silver, Color16.Black); }
//====== public methods public void DrawCenter(TextCanvas canvas, int y) { int currentScore = scoreStatus.Value; if (lastScore != currentScore || lastImage is null) { lastImage = new BigDigitsValueRenderer(currentScore, ForeColor).RenderImage(); lastScore = currentScore; } int xOffset = (canvas.Size.Width / 2) - (lastImage.Size.Width / 2); canvas.DrawImage(lastImage, new Point(xOffset, y)); }
public void SetUp() { _mouse = new TestMouse(); _keyboard = new TestKeyboard(); _columns = Columns.Minimum.Concat(new[] { PageBufferedLogSource.RetrievalState }).ToList(); _control = new TextCanvas(new ScrollBar(), new ScrollBar(), TextSettings.Default) { Width = 800, Height = 600 }; _control.Arrange(new Rect(0, 0, 800, 600)); _control.ChangeTextSettings(new TextSettings(), new TextBrushes(null)); DispatcherExtensions.ExecuteAllEvents(); }
[SerializeField] GameObject picture; // 写真のオブジェクト void Start() { // 人物と語尾の定義 people = new Person[] { new Person("マユリ", "だよ〜"), new Person("クリス", "よ!"), new Person("ルカ", "ですっ"), new Person("モエカ", "・・・"), new Person("スズハ", "だよ!") }; question = GetComponent <Text>(); eventCanvas = FrontSceneManager.eventCanvas; textCanvas = FrontSceneManager.textCanvas; MakeQuestion(); }
public override void ProcessCanvas(TextCanvas canvas) { canvas.ClearColor(Black); canvas.WriteTextCenter(2, Resources.TextCredits, colorAnimation.CurrentFrame, Black); canvas.WriteTextCenter(10, "Special thanks to:", LightTeal, Black); canvas.WriteTextCenter(12, "No one...", Yellow, Black); canvas.WriteTextCenter(16, "2017-2021", Silver, Black); canvas.WriteTextCenter(18, "Created by: Eryk Kisieliński", Gray, Black); canvas.WriteTextCenter(canvas.Size.Height - 2, "-- Presc ESC to back --", Silver, Black); }
public override void ProcessCanvas(TextCanvas canvas) { canvas.ClearColor(Color16.Black); terrainRenderer.Paint(gameLogic.TerrainReader, canvas, new Point(31, 0)); PaintStatsWindow(canvas); var scoreView = canvas.Slice(new Rectangle(new Point(1, 21), new Size(28, 76))); scoreView.WriteTextCenter(0, new string( '─', scoreView.Size.Width ), Color16.Teal, Color16.Black); scoreView.WriteTextCenter(0, " SCORE ", Color16.Yellow, Color16.Black); bigDigitsScoreUI.DrawCenter(scoreView, 2); }
// Start is called before the first frame update virtual protected void Start() { button = FrontSceneManager.eventButton; buttonText = FrontSceneManager.buttonText; fadeCanvas = GameManager.fadeCanvas; textCanvas = FrontSceneManager.textCanvas; // audioController = GameManager.audioController; naviCanvas = FrontSceneManager.naviCanvas; gameClearCanvas = FrontSceneManager.gameClearCanvas; enemy = FrontSceneManager.enemy.gameObject; player = FrontSceneManager.player.transform; if (unityEvent == null) { unityEvent = new UnityEvent(); } }
//====== private static methods private static void DrawRectangle(TextCanvas canvas, Rectangle rect, bool isFrame) { if (rect.Size.HasNoArea) { return; } var backColor = isFrame ? Color16.White : Color16.Black; var cell = new TextCell(' ', Color16.Black, backColor); canvas.HLine(rect.TopLeft, rect.Size.Width, cell); canvas.HLine(rect.BottomLeft, rect.Size.Width, cell); canvas.VLine(rect.TopLeft, rect.Size.Height, cell); canvas.VLine(rect.TopRight, rect.Size.Height, cell); }
/// <summary> /// Writes text on 1 line, does not handle Line-wrapping /// </summary> /// <exception cref="ArgumentOutOfRangeException">Is thrown if text would overflow from canvas</exception> /// <param name="canvas"></param> /// <param name="text"></param> /// <param name="row">Row of "Visible Content"</param> public static void Write(this TextCanvas canvas, string text, int?row = null) { row = row ?? canvas.CurrentRow; int widthIndex = canvas.ScreenBuffer[row.Value].Length; // Line-wrapping if (widthIndex + text.Length > canvas.ContentWidth) { throw new ArgumentOutOfRangeException(nameof(text), "Text Overflow"); } canvas.SetCursorPosition( widthIndex, row.Value); Console.Write(text); }
//====== override: Window protected override void PaintContent(TextCanvas canvas) { var list = optionSelector.OptionsList; for (int i = 0; i < list.Options.Count; i++) { bool isSelected = optionSelector.CurrentOptionIndex == i; var color = isSelected ? Color16.White : Color16.Silver; canvas.WriteText(new Point(3, 1 + i), list.Options[i].Name, color, Appearance.BackColor); if (isSelected) { canvas.WriteText(new Point(1, 1 + i), ">", color, Appearance.BackColor); } } }
public override void ProcessCanvas(TextCanvas canvas) { canvas.ClearColor(Color16.Black); canvas.WriteTextCenter(2, Resources.TextLogo, Color16.Red, Color16.Black); var menuWindow = new OptionsListWindow <MainMenuEntry>(optionSelector); var rectCenter = menuWindow.Size.AsRectangle.CenterAt(canvas.Size.AsRectangle.Center); menuWindow.Paint(canvas, rectCenter.TopLeft.AddToY(2)); // print version var version = 'v' + Resources.SnakeGameVersion; var position = new Point(canvas.Size.Width - version.Length - 1, canvas.Size.Height - 1); canvas.WriteText(position, version, Color16.Gray, Color16.Black); }
public static void Clear(this TextCanvas canvas, int?rowIndex = null) { canvas.CurrentRow = 0; if (rowIndex == null) { for (int y = 0; y < canvas.ContentHeight; y++) { canvas.SetCursorPosition(0, y); Console.Write(CharacterMap.Space.Repeat(canvas.ContentWidth)); } return; } // validation if (rowIndex.Value > canvas.ContentHeight || rowIndex.Value < 0) { throw new ArgumentOutOfRangeException(nameof(rowIndex), "Row index cannot overflow canvas's height"); } canvas.SetCursorPosition(0, rowIndex.Value); Console.Write(CharacterMap.Space.Repeat(canvas.ContentWidth)); }