public NodeTitle(GameUI myGameUI, int myDepth) : base(myGameUI, myDepth, myGameUI.Puzzle.Details.Name, new Font("Lucida Console", 17f), new SolidBrush(Color.Yellow), new SolidBrush(Color.DarkOrange), new VectorInt(myGameUI.GameCoords.WindowRegion.TopMiddle.Add(-50, 3))) { secondLine = new NodeEffectText(myGameUI, myDepth - 1, "Sokoban rocks!", CurrentAbsolute.Add(0, 30)); secondLine.Brush = new SolidBrush(secondLineColour); secondLine.Font = new Font("Arial", 11f); secondLine.IsVisible = false; currentLine = 0; lines = GetTextLines().ToArray(); myGameUI.Add(secondLine); chain = new ActionChain(); chain.Add(new ActionMethod(SelectNextMessage)); chain.Add(new ActionCounter(20, 250, 4, new ActionDelegate(SetAlpha))); // FadeIn chain.Add(new ActionCounter(0, 50)); // wait chain.Add(new ActionCounter(250, 0, -7, new ActionDelegate(SetAlpha))); // FadeOut chain.Add(new ActionRetartChain(chain)); chain.Init(); }
public NodePuzzleWin(GameUI myGameUI, int myDepth, VectorInt pos) : base(myGameUI, myDepth) { CurrentAbsolute = pos; chain = new ActionChain(); chain.Add(new ActionCounter(0, 100, 2, ReSizeText)); chain.Init(); winner = new NodeEffectText(myGameUI, myDepth+1, "Congratz!!!", new Font("Arial", 10f), font, fontBK, pos); myGameUI.Add(winner); }
public NodeControllerStatus(GameUI myGameUI, int myDepth) : base(myGameUI, myDepth) { VectorInt locStatus = myGameUI.GameCoords.PositionStatus; labelMoves = new NodeEffectText(myGameUI, myDepth + 1, "Moves", locStatus); valueMoves = new NodeEffectText(myGameUI, myDepth + 1, "", locStatus.Add(0, 20)); valueMoves.Brush = new SolidBrush(Color.LightBlue); myGameUI.Add(labelMoves); myGameUI.Add(valueMoves); labelPushes = new NodeEffectText(myGameUI, myDepth + 1, "Pushes", locStatus.Add(0, 40)); valuePushes = new NodeEffectText(myGameUI, myDepth + 1, "", locStatus.Add(0, 60)); valuePushes.Brush = new SolidBrush(Color.LightBlue); myGameUI.Add(labelPushes); myGameUI.Add(valuePushes); labelComplete = new NodeEffectText(myGameUI, myDepth + 1, "Complete", locStatus.Add(0, 80)); valueComplete = new NodeEffectText(myGameUI, myDepth + 1, "", locStatus.Add(0, 100)); valueComplete.Brush = new SolidBrush(Color.LightBlue); myGameUI.Add(labelComplete); myGameUI.Add(valueComplete); labelUndo = new NodeEffectText(myGameUI, myDepth + 1, "Undo", locStatus.Add(0, 120)); valueUndo = new NodeEffectText(myGameUI, myDepth + 1, "", locStatus.Add(0, 140)); valueUndo.Brush = new SolidBrush(Color.LightBlue); myGameUI.Add(labelUndo); myGameUI.Add(valueUndo); labelRestart = new NodeEffectText(myGameUI, myDepth + 1, "Restart", locStatus.Add(0, 160)); valueRestart = new NodeEffectText(myGameUI, myDepth + 1, "", locStatus.Add(0, 180)); valueRestart.Brush = new SolidBrush(Color.LightBlue); myGameUI.Add(labelRestart); myGameUI.Add(valueRestart); labelTime = new NodeEffectText(myGameUI, myDepth + 1, "Time", locStatus.Add(0, 200)); valueTime = new NodeEffectText(myGameUI, myDepth + 1, "", locStatus.Add(0, 220)); valueTime.Brush = new SolidBrush(Color.LightBlue); myGameUI.Add(labelTime); myGameUI.Add(valueTime); }
/// <summary> /// Inititialise the special effects /// </summary> private void InitFX() { #if DEBUG NodeDebug debug = new NodeDebug(this, int.MaxValue); Add(debug); #endif if (initType == InitTypes.SolutionReplay) { // Exit return; } cursor = new NodeCursor(this, int.MaxValue); Add(cursor); if (initType == InitTypes.NewGame) { NodeEffectText start = new NodeEffectText(this, 10, "Welcome to SokoSolve, START!", Player.CurrentAbsolute); start.Brush = new SolidBrush(Color.FromArgb(80, Color.White)); start.BrushShaddow = new SolidBrush(Color.FromArgb(80, Color.Black)); start.Path = new Paths.Spiral(Player.CurrentCentre); Add(start); sound.PlaySound(sfxWelcome); sound.PlayMusic(sound.GetHandle("Camokaze-Low.mp3")); } else if (initType == InitTypes.Restart) { NodeEffectText start = new NodeEffectText(this, 10, "Starting again, eh?", Player.CurrentAbsolute); start.Brush = new SolidBrush(Color.FromArgb(180, Color.Gold)); start.BrushShaddow = new SolidBrush(Color.FromArgb(180, Color.Black)); start.Path = new Paths.Spiral(Player.CurrentCentre); Add(start); sound.PlaySound(sfxRestart); } else if (initType == InitTypes.Undo) { NodeEffectText start = new NodeEffectText(this, 10, new string[] { "Hmmm", "Grrr", "Pity", "???"}, GameCoords.WindowRegion.Center); start.Brush = new SolidBrush(Color.Cyan); Add(start); sound.PlaySound(sfxUndo); } NodeControllerStatus status = new NodeControllerStatus(this, 500); Add(status); NodeControllerCommands commands = new NodeControllerCommands(this, 501); Add(commands); NodeTitle title = new NodeTitle(this, 1000); Add(title); NodeControllerBookmarks waypoint = new NodeControllerBookmarks(this, 502); Add(waypoint); }
void Button_OnClick(object sender, NotificationEvent e) { GameUI.FireNotificationEvent(e); switch(e.Command) { case("Undo") : GameUI.Undo(); return; case ("Restart"): GameUI.Reset(); return; case ("Exit"): GameUI.Exit(); return; case ("Up"): GameUI.Player.doMove(Direction.Up); return; case ("Down"): GameUI.Player.doMove(Direction.Down); return; case ("Left"): GameUI.Player.doMove(Direction.Left); return; case ("Right"): GameUI.Player.doMove(Direction.Right); return; case ("Help"): NodeUIDialogHelp help = new NodeUIDialogHelp(GameUI, 20000); help.GameUI.Add(help); return; default: NodeEffectText msg = new NodeEffectText(GameUI, 100, "Command not implemented:"+e.Command, new VectorInt(100, 100)); msg.Path = new StaticPath(new VectorInt(100, 100), 30); GameUI.Add(msg); return; } }
/// <summary> /// Show a basic message in the center of the puzzle (with a background) /// </summary> /// <param name="message"></param> private void ShowText(string message) { NodeEffectText node = new NodeEffectText(gameUI, 100000, message, gameUI.GameCoords.PuzzleRegion.Center); node.BrushBackGround = new SolidBrush(Color.DarkSlateBlue); node.Path = new StaticPath(node.CurrentAbsolute, 20); gameUI.Add(node); }
public override void Render() { if (imageBack != null) { VectorInt pos = CurrentRect.Center.Subtract(imageBack.Width / 2 + 2, imageBack.Height / 2 + 2); GameUI.Graphics.DrawImage(imageBack, pos.X, pos.Y); } if (imageNormal != null) { DrawBitmapCentered(GameUI.Graphics, CurrentRect, imageNormal); } if (isMouseOver) { if (mouseOverBrush != null) { RectangleInt over = new RectangleInt(CurrentAbsolute.Subtract(1, 1), CurrentRect.BottomRight.Add(1, 1)); GameUI.Graphics.FillEllipse(mouseOverBrush, over.ToDrawingRect()); } if (toolTip != null) { Font ttFont = new Font("Arial", 10f); SizeF ffSizeF = GameUI.Graphics.MeasureString(toolTip, ttFont); SizeInt ffSize = new SizeInt((int) ffSizeF.Width, (int) ffSizeF.Height); RectangleInt posTT = new RectangleInt(CurrentRect.BottomLeft.Subtract(ffSize.Width/2, -5 ), ffSize); if (posTT.TopLeft.X < GameUI.GameCoords.WindowRegion.TopLeft.X) posTT.TopLeft.X = GameUI.GameCoords.WindowRegion.TopLeft.X; if (posTT.TopLeft.Y < GameUI.GameCoords.WindowRegion.TopLeft.Y) posTT.TopLeft.Y = GameUI.GameCoords.WindowRegion.TopLeft.Y; if (posTT.BottomRight.X > GameUI.GameCoords.WindowRegion.BottomRight.X) posTT.BottomRight.X = GameUI.GameCoords.WindowRegion.BottomRight.X; if (posTT.BottomRight.Y < GameUI.GameCoords.WindowRegion.BottomRight.Y) posTT.BottomRight.Y = GameUI.GameCoords.WindowRegion.BottomRight.Y; Brush ttBrush = new SolidBrush(Color.Cyan); Brush ttBrushShadow = new SolidBrush(Color.DarkCyan); NodeEffectText nodeTT = new NodeEffectText(GameUI, 10000, toolTip, ttFont, ttBrush, ttBrushShadow, posTT.TopLeft); nodeTT.BrushBackGround = new SolidBrush(Color.DarkSlateGray); nodeTT.Path = new Paths.StaticPath(posTT.TopLeft, 1); GameUI.Add(nodeTT); } } if (maskEffect != null) { RectangleInt over = new RectangleInt(CurrentAbsolute.Subtract(5, 5), CurrentRect.BottomRight.Add(10, 10)); GameUI.Graphics.FillEllipse(maskEffect, over.ToDrawingRect()); } }
/// <summary> /// Inititialise the special effects /// </summary> private void InitFX() { #if DEBUG NodeDebug debug = new NodeDebug(this, int.MaxValue); Add(debug); #endif if (initType == InitTypes.SolutionReplay) { // Exit return; } cursor = new NodeCursor(this, int.MaxValue); Add(cursor); if (initType == InitTypes.NewGame) { NodeEffectText start = new NodeEffectText(this, 10, "Welcome to SokoSolve, START!", Player.CurrentAbsolute); start.Brush = new SolidBrush(Color.FromArgb(80, Color.White)); start.BrushShaddow = new SolidBrush(Color.FromArgb(80, Color.Black)); start.Path = new Paths.Spiral(Player.CurrentCentre); Add(start); // Stop all music and sounds sound.Stop(); sound.PlaySound(ResourceFactory[ResourceID.GameSoundWelcome].DataAsSound); string[] music = Directory.GetFiles(FileManager.GetContent("$Music/"), "*.mp3"); sound.PlayMusic(sound.GetHandle(Path.GetFileName(RandomHelper.Select<string>(music)))); } else if (initType == InitTypes.Restart) { NodeEffectText start = new NodeEffectText(this, 10, "Starting again, eh?", Player.CurrentAbsolute); start.Brush = new SolidBrush(Color.FromArgb(180, Color.Gold)); start.BrushShaddow = new SolidBrush(Color.FromArgb(180, Color.Black)); start.Path = new Paths.Spiral(Player.CurrentCentre); Add(start); sound.PlaySound(ResourceFactory[ResourceID.GameSoundRestart].DataAsSound); } else if (initType == InitTypes.Undo) { NodeEffectText start = new NodeEffectText(this, 10, new string[] { "Hmmm", "Grrr", "Pity", "???"}, GameCoords.WindowRegion.Center); start.Brush = new SolidBrush(Color.Cyan); Add(start); sound.PlaySound(ResourceFactory[ResourceID.GameSoundUndo].DataAsSound); } NodeControllerStatus status = new NodeControllerStatus(this, 500); Add(status); NodeControllerCommands commands = new NodeControllerCommands(this, 501); Add(commands); NodeTitle title = new NodeTitle(this, 1000); Add(title); NodeControllerBookmarks waypoint = new NodeControllerBookmarks(this, 502); Add(waypoint); }
/// <summary> /// Perform a unit of puzzle time /// </summary> public override void doStep() { base.doStep(); //if (target == CurrentAbsolute) { if (futureMoves.Count > 0) { if (moveCurrentWait > 0) { moveCurrentWait--; } else { // Introduce a delay moveCurrentWait = moveWaitPeriod; Game.Game.MoveResult res = GameUI.Move(futureMoves.Dequeue()); if (res == Game.Game.MoveResult.Invalid) { string[] rndMsg = new string[] { "!!!", "$&!%", "&*!?", "Sorry" }; NodeEffectText msg = new NodeEffectText(GameUI, 20, rndMsg, CurrentCentre); msg.Brush = new SolidBrush(Color.Red); GameUI.Add(msg); } else if (res == Game.Game.MoveResult.ValidPushGoal) { string[] rndMsg = new string[] { "Great!", "Yeah!", "Cool", "Brilliant" }; NodeEffectText msg = new NodeEffectText(GameUI, 20, rndMsg, CurrentCentre); GameUI.Add(msg); } else if (res == Game.Game.MoveResult.ValidPushWin) { if (GameUI.InitType == UI.GameUI.InitTypes.SolutionReplay) { NodeEffectText msg = new NodeEffectText(GameUI, 20, "Complete. ESC to exit.", CurrentCentre); msg.Path = new Paths.StaticPath(CurrentCentre); GameUI.Add(msg); } else { NodePuzzleWin win = new NodePuzzleWin(GameUI, 5000, GameUI.GameCoords.PuzzleRegion.Center); GameUI.Add(win); } } } } } }