コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
                }
            }
        }
コード例 #6
0
        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));
                    }
                }
            }
        }
コード例 #7
0
 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];
 }
コード例 #8
0
        public GDWorldMapScreen(MonoSAMGame game, GraphicsDeviceManager gdm, GraphBlueprint g, Guid?initialFocus) : base(game, gdm)
        {
            Graph          = new LevelGraph(this);
            GraphBlueprint = g;

            Initialize(g, initialFocus);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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());
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        public void SetWorldMapScreenZoomedOut(GraphBlueprint g, LevelBlueprint initFocus = null)
        {
            var screen = new GDWorldMapScreen(this, Graphics, g, initFocus?.UniqueID);

            SetCurrentScreen(screen);
//			screen.ZoomInstantOut();
            screen.ZoomOut();
        }
コード例 #13
0
        public void SetWorldMapScreenWithTransition(GraphBlueprint g)
        {
            var screen = new GDWorldMapScreen(this, Graphics, g, null);

            SetCurrentScreen(screen);
            screen.AddAgent(new InitialTransitionAgent(screen));
            screen.ColorOverdraw = 1f;
        }
コード例 #14
0
ファイル: LevelGraph.cs プロジェクト: ssttv/GridDominance
        public void Init(GraphBlueprint g)
        {
            InitEntities(g);

            InitPipes(g);

            InitEnabled();

            InitViewport();
        }
コード例 #15
0
        public HighscorePanel(GraphBlueprint focus, bool mp)
        {
            _focus           = focus;
            _showMultiplayer = mp;

            RelativePosition = FPoint.Zero;
            Size             = new FSize(WIDTH, HEIGHT);
            Alignment        = HUDAlignment.CENTER;
            Background       = FlatColors.BackgroundHUD;
        }
コード例 #16
0
        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();
        }
コード例 #17
0
        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;
        }
コード例 #18
0
ファイル: HighscorePanel.cs プロジェクト: sorke/GridDominance
        public HighscorePanel(GraphBlueprint focus, HighscoreCategory mod)
        {
            _focus = focus;
            _mode  = mod;

            RelativePosition = FPoint.Zero;
            Size             = new FSize(WIDTH, HEIGHT);
            Alignment        = HUDAlignment.CENTER;
            Background       = FlatColors.BackgroundHUD;
        }
コード例 #19
0
        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();
        }
コード例 #20
0
        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);
        }
コード例 #21
0
ファイル: MainGame.cs プロジェクト: ssttv/GridDominance
        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);
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        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));
        }
コード例 #24
0
        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);
            }
        }
コード例 #25
0
        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);
                }
            }
        }
コード例 #26
0
        public GraphBlueprint Parse(string fileName = "__root__")
        {
            _result = new GraphBlueprint();

            _scaleFactor = 1f;
            _currentNode = null;

            StartParse(fileName, content);

            _result.ValidOrThrow();

            return(_result);
        }
コード例 #27
0
ファイル: GDServerAPI.cs プロジェクト: ssttv/GridDominance
        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);
            }
        }
コード例 #28
0
        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();
        }
コード例 #29
0
        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);
        }
コード例 #30
0
        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);
            }
        }