private static NodeBlueprint?FindNextUnfinishedNode(GraphBlueprint g, INodeBlueprint snode, FractionDifficulty d) { Stack <INodeBlueprint> mem = new Stack <INodeBlueprint>(); mem.Push(snode); while (mem.Any()) { var node = mem.Pop(); foreach (var pipe in node.Pipes.OrderBy(p => p.Priority)) { var lnode = Get(g, pipe.Target); if (!(lnode is NodeBlueprint)) { continue; } if (!MainGame.Inst.Profile.GetLevelData(lnode.ConnectionID).HasCompletedOrBetter(d)) { return((NodeBlueprint?)lnode); } mem.Push(lnode); } } return(null); }
private static void DrawRootNode(GraphBlueprint wgraph, Graphics g) { var sbNode = new SolidBrush(Color.FromArgb(127, 140, 141)); var diamRoot = 3f * 64; g.FillRectangle(sbNode, wgraph.RootNode.X - diamRoot / 2f, wgraph.RootNode.Y - diamRoot / 2f, diamRoot, diamRoot); }
public static INodeBlueprint FindInitialNode(GraphBlueprint g) { INodeBlueprint n; n = FindNextUnfinishedNode(g, g.RootNode, FractionDifficulty.DIFF_0); if (n != null) { return(n); } n = FindNextUnfinishedNode(g, g.RootNode, FractionDifficulty.DIFF_1); if (n != null) { return(n); } n = FindNextUnfinishedNode(g, g.RootNode, FractionDifficulty.DIFF_2); if (n != null) { return(n); } n = FindNextUnfinishedNode(g, g.RootNode, FractionDifficulty.DIFF_3); if (n != null) { return(n); } return(g.RootNode); // can happen when all completed }
public void ScrollTo(GraphBlueprint bp) { int focus = -1; for (int i = 0; i < _nodes.Length; i++) { if (_nodes[i].ContentID == bp.ID) { focus = i; } } if (focus == -1) { return; } var offset0 = GDConstants.VIEW_WIDTH / 2f - focus * DIST_X; for (int i = 0; i < _nodes.Length; i++) { _values[i] = new AdaptionFloat(offset0 + i * DIST_X, FORCE, DRAG, MIN_SPEED); _nodes[i].NodePos = new FPoint(_values[i].Value, POSITION_Y); } CleanUpPositions(true); }
public static void ListUnfinishedCount(GraphBlueprint g, out int missPoints, out int missLevel) { missPoints = 0; missLevel = 0; var p = MainGame.Inst.Profile; foreach (var levelnode in g.LevelNodes) { if (!p.GetLevelData(levelnode).HasCompletedOrBetter(FractionDifficulty.DIFF_0)) { missLevel++; missPoints += FractionDifficultyHelper.GetScore(FractionDifficulty.DIFF_0); } if (!p.GetLevelData(levelnode).HasCompletedOrBetter(FractionDifficulty.DIFF_1)) { missLevel++; missPoints += FractionDifficultyHelper.GetScore(FractionDifficulty.DIFF_1); } if (!p.GetLevelData(levelnode).HasCompletedOrBetter(FractionDifficulty.DIFF_2)) { missLevel++; missPoints += FractionDifficultyHelper.GetScore(FractionDifficulty.DIFF_2); } if (!p.GetLevelData(levelnode).HasCompletedOrBetter(FractionDifficulty.DIFF_3)) { missLevel++; missPoints += FractionDifficultyHelper.GetScore(FractionDifficulty.DIFF_3); } } }
private void DrawPriorityMarker(GraphBlueprint wgraph, Graphics g) { var sbMarker = new SolidBrush(Color.FromArgb(255, 255, 255)); var diam = 2.75f * 64; var diamRoot = 3f * 64; foreach (var n in wgraph.AllNodes) { if (n.Pipes.Count > 1 && n.Pipes.Select(p => p.Priority).Distinct().Count() > 1) { foreach (var p in n.Pipes) { var o = wgraph.AllNodes.Single(nd => nd.ConnectionID == p.Target); var start = new Vector2(n.X, n.Y); var end = new Vector2(o.X, o.Y); var delta = end - start; delta.Normalize(); var thisdia = n is RootNodeBlueprint ? (float)Math.Sqrt(2 * diamRoot * diamRoot) : diam; var marker = start + delta * (thisdia / 2f + 8); g.FillEllipse(sbMarker, marker.X - 16, marker.Y - 16, 32, 32); DrawFit(g, p.Priority.ToString(), Color.Black, new Font("Arial", 24), new RectangleF(marker.X - 16, marker.Y - 16, 32, 32)); } } } }
public WarpNode(GDWorldMapScreen scrn, WarpNodeBlueprint bp) : base(scrn, GDConstants.ORDER_MAP_NODE) { Position = new FPoint(bp.X, bp.Y); DrawingBoundingBox = new FSize(DIAMETER, DIAMETER); Blueprint = bp; Target = Levels.WORLDS[bp.TargetWorld]; }
public GDWorldMapScreen(MonoSAMGame game, GraphicsDeviceManager gdm, GraphBlueprint g, Guid?initialFocus) : base(game, gdm) { Graph = new LevelGraph(this); GraphBlueprint = g; Initialize(g, initialFocus); }
public static NodeBlueprint?FindNextNode(GraphBlueprint g, INodeBlueprint snode, FractionDifficulty d) { snode = Get(g, snode.ConnectionID); if (snode == null) { return(null); } // unfinished descendants var descendant = FindNextUnfinishedNode(g, snode, d); if (descendant != null) { return(descendant.Value); } // all unfinished var unfin = FindNextUnfinishedNode(g, g.RootNode, d); if (unfin != null) { return(unfin.Value); } // none return(null); }
private void Initialize(GraphBlueprint g, Guid?initialFocus) { #if DEBUG DebugUtils.CreateShortcuts(this); DebugDisp = DebugUtils.CreateDisplay(this); #endif Graph.Init(g); MapFullBounds = Graph.BoundingRect.AsInflated(2 * GDConstants.TILE_WIDTH, 2 * GDConstants.TILE_WIDTH); AddAgent(new WorldMapDragAgent(GetEntities <LevelNode>().Select(n => n.Position).ToList())); if (initialFocus == null) { MapViewportCenterX = Graph.BoundingRect.CenterX; MapViewportCenterY = Graph.BoundingRect.CenterY; } else { var nd = Graph.Nodes.FirstOrDefault(n => n.ConnectionID == initialFocus); if (nd != null) { MapViewportCenterX = nd.Position.X; MapViewportCenterY = nd.Position.Y; } } GDBackground.InitBackground(GetEntities <LevelNode>().ToList(), MapFullBounds.InReferenceRaster(GDConstants.TILE_WIDTH).AsInflated(16, 16).Truncate()); }
public GDGameScreen_SP(MainGame game, GraphicsDeviceManager gdm, LevelBlueprint bp, FractionDifficulty diff, GraphBlueprint ws) : base(game, gdm, bp, diff, false, false, diff == FractionDifficulty.DIFF_0 && bp.UniqueID == Levels.LEVELID_1_1) { WorldBlueprint = ws; GameSpeedMode = MainGame.Inst.Profile.SingleplayerGameSpeed; UpdateGameSpeed(); }
public void SetWorldMapScreenZoomedOut(GraphBlueprint g, LevelBlueprint initFocus = null) { var screen = new GDWorldMapScreen(this, Graphics, g, initFocus?.UniqueID); SetCurrentScreen(screen); // screen.ZoomInstantOut(); screen.ZoomOut(); }
public void SetWorldMapScreenWithTransition(GraphBlueprint g) { var screen = new GDWorldMapScreen(this, Graphics, g, null); SetCurrentScreen(screen); screen.AddAgent(new InitialTransitionAgent(screen)); screen.ColorOverdraw = 1f; }
public void Init(GraphBlueprint g) { InitEntities(g); InitPipes(g); InitEnabled(); InitViewport(); }
public HighscorePanel(GraphBlueprint focus, bool mp) { _focus = focus; _showMultiplayer = mp; RelativePosition = FPoint.Zero; Size = new FSize(WIDTH, HEIGHT); Alignment = HUDAlignment.CENTER; Background = FlatColors.BackgroundHUD; }
private void ChangeID1(int delta) { int i1 = Levels.WORLDS_MULTIPLAYER.ToList().IndexOf(_currentWorld); i1 = (i1 + delta + Levels.WORLDS_MULTIPLAYER.Length) % Levels.WORLDS_MULTIPLAYER.Length; _currentWorld = Levels.WORLDS_MULTIPLAYER[i1]; _currentLevel = Levels.LEVELS[_currentWorld.LevelNodes.First().LevelID]; UpdateLabels(); }
public ReappearTransitionAgent(GDOverworldScreen scrn, GraphBlueprint g) : base(scrn, DURATION) { _gdNode = scrn.GetEntities <OverworldNode>().First(n => n.ContentID == g.ID); vp = scrn.VAdapterGame; rectStart = FRectangle.CreateByCenter(_gdNode.Position, new FSize(1.8f * GDConstants.TILE_WIDTH, 1.8f * GDConstants.TILE_WIDTH)) .SetRatioUnderfitKeepCenter(GDConstants.VIEW_WIDTH * 1f / GDConstants.VIEW_HEIGHT); rectFinal = scrn.GuaranteedMapViewport; }
public HighscorePanel(GraphBlueprint focus, HighscoreCategory mod) { _focus = focus; _mode = mod; RelativePosition = FPoint.Zero; Size = new FSize(WIDTH, HEIGHT); Alignment = HUDAlignment.CENTER; Background = FlatColors.BackgroundHUD; }
public void SetOverworldScreenWithTransition(GraphBlueprint bp) { var screen = new GDOverworldScreen(this, Graphics); SetCurrentScreen(screen); screen.ScrollAgent.ScrollTo(bp); screen.AddAgent(new ReappearTransitionOperation(bp)); screen.GDHUD.ScoreDispMan.FinishCounter(); }
public LeaveTransitionWorldMapAgent(GDWorldMapScreen scrn, bool slower, WarpNode node, GraphBlueprint target) : base(scrn, slower ? DURATION_SLOW : DURATION) { _gdScreen = scrn; _node = node; _target = target; vp = scrn.VAdapterGame; rectStart = scrn.GuaranteedMapViewport; rectFinal = node.DrawingBoundingRect.AsResized(0.5f, 0.5f); }
public void SetLevelScreen(LevelBlueprint blueprint, FractionDifficulty d, GraphBlueprint source, GameSpeedModes?speed = null) { var scrn = new GDGameScreen_SP(this, Graphics, blueprint, d, source); if (speed != null) { scrn.GameSpeedMode = speed.Value; scrn.UpdateGameSpeed(); } SetCurrentScreen(scrn); }
public TransitionZoomInAgent(GDOverworldScreen scrn, OverworldNode node, GraphBlueprint g) : base(scrn, DURATION) { _gdNode = node; _graph = g; vp = scrn.VAdapterGame; rectStart = scrn.GuaranteedMapViewport; rectFinal = FRectangle.CreateByCenter(node.Position, new FSize(1.8f * GDConstants.TILE_WIDTH, 1.8f * GDConstants.TILE_WIDTH)) .SetRatioUnderfitKeepCenter(GDConstants.VIEW_WIDTH * 1f / GDConstants.VIEW_HEIGHT); }
public static NodeBlueprint?FindNextNode(GraphBlueprint g, Guid idnode, FractionDifficulty d) { var snode = Get(g, idnode); if (snode == null) { return(null); } return(FindNextNode(g, snode, d)); }
private static void DrawWarpNodes(GraphBlueprint wgraph, Graphics g) { var sbNode = new SolidBrush(Color.FromArgb(127, 140, 141)); var pen = new Pen(Color.Black, 4); var diamRoot = 3f * 64; foreach (var node in wgraph.WarpNodes) { g.FillRectangle(sbNode, node.X - diamRoot / 2f, node.Y - diamRoot / 2f, diamRoot, diamRoot); g.DrawEllipse(pen, node.X - diamRoot / 2f, node.Y - diamRoot / 2f, diamRoot, diamRoot); } }
private void DrawPipes(GraphBlueprint wgraph, Graphics g) { foreach (var n in wgraph.AllNodes) { foreach (var p in n.Pipes) { var o = wgraph.AllNodes.Single(nd => nd.ConnectionID == p.Target); ManhattanLine(g, n.X, n.Y, o.X, o.Y, p.PipeOrientation); } } }
public GraphBlueprint Parse(string fileName = "__root__") { _result = new GraphBlueprint(); _scaleFactor = 1f; _currentNode = null; StartParse(fileName, content); _result.ValidOrThrow(); return(_result); }
public async Task <QueryResultRanking> GetRanking(PlayerProfile profile, GraphBlueprint limit, bool multiplayer) { try { var ps = new RestParameterSet(); ps.AddParameterInt("userid", profile.OnlineUserID); if (multiplayer) { ps.AddParameterString("world_id", "@"); } else if (limit == null) { ps.AddParameterString("world_id", "*"); } else { ps.AddParameterString("world_id", limit.ID.ToString("B")); } var response = await QueryAsync <QueryResultRanking>("get-ranking", ps, RETRY_GETRANKING); if (response == null) { ShowErrorCommunication(); return(null); } else if (response.result == "success") { return(response); } else { ShowErrorCommunication(); return(null); } } catch (RestConnectionException e) { SAMLog.Warning("Backend::GR_RCE", e); // probably no internet ShowErrorConnection(); return(null); } catch (Exception e) { SAMLog.Error("Backend::GR_E", e); ShowErrorCommunication(); return(null); } }
private void ChangeID1(int delta) { if (_server.Mode != SAMNetworkConnection.ServerMode.CreatingNewGame) { return; } int i1 = Levels.WORLDS_MULTIPLAYER.ToList().IndexOf(_currentWorld); i1 = (i1 + delta + Levels.WORLDS_MULTIPLAYER.Length) % Levels.WORLDS_MULTIPLAYER.Length; _currentWorld = Levels.WORLDS_MULTIPLAYER[i1]; _currentLevel = Levels.LEVELS[_currentWorld.LevelNodes.First().LevelID]; UpdateLabels(); }
protected OverworldNode_Graph(GDOverworldScreen scrn, FPoint pos, GraphBlueprint world, string iab) : base(scrn, pos, Levels.WORLD_NAMES[world.ID], world.ID) { Blueprint = world; IABCode = iab; solvedPerc[FractionDifficulty.DIFF_0] = GetSolvePercentage(FractionDifficulty.DIFF_0); solvedPerc[FractionDifficulty.DIFF_1] = GetSolvePercentage(FractionDifficulty.DIFF_1); solvedPerc[FractionDifficulty.DIFF_2] = GetSolvePercentage(FractionDifficulty.DIFF_2); solvedPerc[FractionDifficulty.DIFF_3] = GetSolvePercentage(FractionDifficulty.DIFF_3); _swingPeriode *= FloatMath.GetRangedRandom(0.85f, 1.15f); _ustate = UnlockManager.IsUnlocked(world, false); }
private ImageSource ReparseGraphFile(string input) { try { var sw = Stopwatch.StartNew(); ClearLog(); AddLog("Start parsing"); var incf = DSLUtil.GetIncludesFunc(FilePath); var lp = DSLUtil.ParseGraphFromString(input, incf); _currentDisplayGraph = lp; var img = ImageHelper.CreateImageSource(graphPainter.Draw(lp, FilePath, AddLog, last)); AddLog("File parsed in " + sw.ElapsedMilliseconds + "ms"); if (lp != null) { last = img.Item2; } return(img.Item1); } catch (ParsingException pe) { AddLog(pe.ToOutput()); Console.Out.WriteLine(pe.ToString()); _currentDisplayGraph = null; return(ImageHelper.CreateImageSource(graphPainter.Draw(null, null, AddLog, last)).Item1); } catch (Exception pe) { AddLog(pe.Message); Console.Out.WriteLine(pe.ToString()); _currentDisplayGraph = null; return(ImageHelper.CreateImageSource(graphPainter.Draw(null, null, AddLog, last)).Item1); } }