private void ChangeID2(int delta) { if (_server.Mode != SAMNetworkConnection.ServerMode.CreatingNewGame) { return; } var data = _currentWorld.LevelNodes.Select(n => Levels.LEVELS[n.LevelID]).OrderBy(n => n.Name.Split('-').Last().PadLeft(3, '0')).ToList(); var idx = data.IndexOf(_currentLevel); idx = (idx + data.Count + delta) % data.Count; if (_server.ConnType == MultiplayerConnectionType.P2P) { for (int i = 0; i < 128; i++) { if (BlueprintAnalyzer.PlayerCount(data[idx]) != 2) { idx++; continue; } break; } } _currentLevel = data[idx]; UpdateLabels(); }
public static int PointsForUnlock(Guid id) { if (id == Levels.WORLD_001.ID) { return(0); } if (id == Levels.WORLD_002.ID) { return(BlueprintAnalyzer.MaxPointCount(Levels.WORLD_001) - 1 * GDConstants.FREE_SCORE_PER_WORLD - GDConstants.SCORE_DIFF_0); } if (id == Levels.WORLD_003.ID) { return(BlueprintAnalyzer.MaxPointCount(Levels.WORLD_001) + BlueprintAnalyzer.MaxPointCount(Levels.WORLD_002) - 2 * GDConstants.FREE_SCORE_PER_WORLD - GDConstants.SCORE_DIFF_0); } if (id == Levels.WORLD_004.ID) { return(BlueprintAnalyzer.MaxPointCount(Levels.WORLD_001) + BlueprintAnalyzer.MaxPointCount(Levels.WORLD_002) + BlueprintAnalyzer.MaxPointCount(Levels.WORLD_003) - 3 * GDConstants.FREE_SCORE_PER_WORLD - GDConstants.SCORE_DIFF_0); } SAMLog.Error("UNLCK::PFU", $"UnlockManager: WorldID not found {id}"); return(99999); }
public static int PointsForUnlock(Guid id) { if (id == Levels.WORLD_001.ID) { return(0); } var sc = (GDConstants.SCORE_DIFF_0 + GDConstants.SCORE_DIFF_1 + GDConstants.SCORE_DIFF_2 * 0.75f); // (all on D1), (all on D2) and (3/4 on D3) int levelcount = 0; if (id == Levels.WORLD_002.ID || id == Levels.WORLD_003.ID || id == Levels.WORLD_004.ID) { levelcount += BlueprintAnalyzer.LevelCount(Levels.WORLD_001); } if (id == Levels.WORLD_003.ID || id == Levels.WORLD_004.ID) { levelcount += BlueprintAnalyzer.LevelCount(Levels.WORLD_002); } if (id == Levels.WORLD_004.ID) { levelcount += BlueprintAnalyzer.LevelCount(Levels.WORLD_003); } if (levelcount == 0) { SAMLog.Error("UNLCK::PFU", $"UnlockManager: WorldID not found {id}"); return(99999); } return((int)(levelcount * sc)); }
private void OnClickCreateLobby(HUDIconTextButton sender, HUDButtonEventArgs e) { _server.LevelID = _currentLevel.UniqueID; if (_music1.Selected) { _server.MusicIndex = _music1.MusicIndex; } if (_music2.Selected) { _server.MusicIndex = _music2.MusicIndex; } if (_music3.Selected) { _server.MusicIndex = _music3.MusicIndex; } if (_music4.Selected) { _server.MusicIndex = _music4.MusicIndex; } if (_music5.Selected) { _server.MusicIndex = _music5.MusicIndex; } if (_music6.Selected) { _server.MusicIndex = _music6.MusicIndex; } if (_speed1.Selected) { _server.Speed = _speed1.Speed; } if (_speed2.Selected) { _server.Speed = _speed2.Speed; } if (_speed3.Selected) { _server.Speed = _speed3.Speed; } if (_speed4.Selected) { _server.Speed = _speed4.Speed; } if (_speed5.Selected) { _server.Speed = _speed5.Speed; } _server.CreateSession(BlueprintAnalyzer.PlayerCount(_currentLevel)); MainGame.Inst.Profile.LastMultiplayerHostedLevel = _server.LevelID; MainGame.Inst.Profile.LastMultiplayerHostedSpeed = _server.Speed; MainGame.Inst.SaveProfile(); _btnCreate.Icon = Textures.CannonCogBig; }
private void UpdateLabels() { _lblLevelID1.Text = _currentLevel.Name.Split('-').First(); _lblLevelID2.Text = _currentLevel.Name.Split('-').Last(); _levelUserCount = BlueprintAnalyzer.PlayerCount(_currentLevel); var screen = new GDGameScreen_Display(MainGame.Inst, MainGame.Inst.Graphics, _currentLevel); _displayScreen.ChangeScreen(screen); }
private Tuple <LevelBlueprint, FractionDifficulty> GetNextNode() { var x = BlueprintAnalyzer.FindNextNode(GDScreen.WorldBlueprint, GDScreen.Blueprint.UniqueID, GDScreen.Difficulty); if (x == null) { return(null); } return(Tuple.Create(Levels.LEVELS[x.Value.LevelID], GDScreen.Difficulty)); }
private void DrawNodes(GraphBlueprint wgraph, Graphics g, Dictionary <Guid, LevelBlueprint> idmap) { var sbNode = new SolidBrush(Color.FromArgb(127, 140, 141)); var penExtender = new Pen(Color.FromArgb(231, 76, 60)); var sbExtender = new SolidBrush(Color.FromArgb(64, 231, 76, 60)); var diam = 2.75f * 64; var exw = 1.7f * 64; foreach (var n in wgraph.LevelNodes) { g.FillRectangle(sbExtender, n.X - diam / 2f - exw, n.Y - diam / 2f, diam + 2 * exw, diam); g.FillRectangle(sbExtender, n.X - diam / 2f, n.Y - diam / 2f - exw, diam, diam + 2 * exw); g.FillEllipse(sbNode, n.X - diam / 2f, n.Y - diam / 2f, diam, diam); g.DrawRectangle(penExtender, n.X - diam / 2f - exw, n.Y - diam / 2f, diam + 2 * exw, diam); g.DrawRectangle(penExtender, n.X - diam / 2f, n.Y - diam / 2f - exw, diam, diam + 2 * exw); var pl = BlueprintAnalyzer.ListPlayer(idmap[n.LevelID]).ToList(); var al = (2 * Math.PI) / pl.Count; var ap = Math.PI - al / 2; var R2D = (float)(180 / Math.PI); foreach (var p in pl) { g.DrawArc(new Pen(LevelPreviewPainter.CANNON_COLORS[p], 12), n.X - diam / 2f, n.Y - diam / 2f, diam, diam, R2D * (float)ap, R2D * (float)al); ap += al; } if (idmap.ContainsKey(n.LevelID)) { DrawFit(g, idmap[n.LevelID].Name, Color.Black, new Font("Courier New", 24, FontStyle.Bold), new RectangleF(n.X - diam / 2f, n.Y - diam / 2f, diam, diam)); } else { DrawFit(g, n.LevelID.ToString("D").Replace("-", "\r\n"), Color.Black, new Font("Courier New", 24, FontStyle.Bold), new RectangleF(n.X - diam / 2f, n.Y - diam / 2f, diam, diam)); } } }
public static WorldUnlockState IsUnlocked(Guid id, bool showToast) { if (id == Levels.WORLD_ID_TUTORIAL) { return(WorldUnlockState.OpenAndUnlocked); } if (id == Levels.WORLD_001.ID) { if (MainGame.Inst.Profile.SkipTutorial) { return(WorldUnlockState.OpenAndUnlocked); } if (MainGame.Inst.Profile.GetLevelData(Levels.LEVEL_TUTORIAL).HasAnyCompleted()) { return(WorldUnlockState.OpenAndUnlocked); } return(WorldUnlockState.UnreachableButCanBePreviewed); } if (id == Levels.WORLD_002.ID) { switch (GDConstants.FLAVOR) { case GDFlavor.FREE: { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_001, Levels.WORLD_002.ID); int neededPoints = PointsForUnlock(id); if (reachable && MainGame.Inst.Profile.TotalPoints >= neededPoints) { return(WorldUnlockState.OpenAndUnlocked); } return(WorldUnlockState.UnreachableButCanBePreviewed); } case GDFlavor.IAB: { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_001, Levels.WORLD_002.ID); int neededPoints = PointsForUnlock(id); if (reachable && MainGame.Inst.Profile.TotalPoints >= neededPoints) { return(WorldUnlockState.OpenAndUnlocked); } if (GetIABState(GDConstants.IAB_WORLD2, Levels.WORLD_002.ID, showToast)) { return(WorldUnlockState.OpenAndUnlocked); } return(reachable ? WorldUnlockState.ReachableButMustBePreviewed : WorldUnlockState.UnreachableButCanBePreviewed); } case GDFlavor.FULL: case GDFlavor.FULL_NOMP: { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_001, Levels.WORLD_002.ID); return(reachable ? WorldUnlockState.OpenAndUnlocked : WorldUnlockState.UnreachableAndFullyLocked); } default: { SAMLog.Error("UNLCK::EnumSwitch_IU_1", "GDConstants.FLAVOR = " + GDConstants.FLAVOR); } } } if (id == Levels.WORLD_003.ID) { switch (GDConstants.FLAVOR) { case GDFlavor.FREE: { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_002, Levels.WORLD_003.ID); int neededPoints = PointsForUnlock(id); if (reachable && MainGame.Inst.Profile.TotalPoints >= neededPoints) { return(WorldUnlockState.OpenAndUnlocked); } return(WorldUnlockState.UnreachableButCanBePreviewed); } case GDFlavor.IAB: { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_002, Levels.WORLD_003.ID); int neededPoints = PointsForUnlock(id); if (reachable && MainGame.Inst.Profile.TotalPoints >= neededPoints) { return(WorldUnlockState.OpenAndUnlocked); } if (GetIABState(GDConstants.IAB_WORLD3, Levels.WORLD_003.ID, showToast)) { return(WorldUnlockState.OpenAndUnlocked); } return(reachable ? WorldUnlockState.ReachableButMustBePreviewed : WorldUnlockState.UnreachableButCanBePreviewed); } case GDFlavor.FULL: case GDFlavor.FULL_NOMP: { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_002, Levels.WORLD_003.ID); return(reachable ? WorldUnlockState.OpenAndUnlocked : WorldUnlockState.UnreachableAndFullyLocked); } default: { SAMLog.Error("UNLCK::EnumSwitch_IU_2", "GDConstants.FLAVOR = " + GDConstants.FLAVOR); } } } if (id == Levels.WORLD_004.ID) { switch (GDConstants.FLAVOR) { case GDFlavor.FREE: { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_003, Levels.WORLD_004.ID); int neededPoints = PointsForUnlock(id); if (reachable && MainGame.Inst.Profile.TotalPoints >= neededPoints) { return(WorldUnlockState.OpenAndUnlocked); } return(WorldUnlockState.UnreachableButCanBePreviewed); } case GDFlavor.IAB: { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_003, Levels.WORLD_004.ID); int neededPoints = PointsForUnlock(id); if (reachable && MainGame.Inst.Profile.TotalPoints >= neededPoints) { return(WorldUnlockState.OpenAndUnlocked); } if (GetIABState(GDConstants.IAB_WORLD4, Levels.WORLD_004.ID, showToast)) { return(WorldUnlockState.OpenAndUnlocked); } return(reachable ? WorldUnlockState.ReachableButMustBePreviewed : WorldUnlockState.UnreachableButCanBePreviewed); } case GDFlavor.FULL: case GDFlavor.FULL_NOMP: { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_003, Levels.WORLD_004.ID); return(reachable ? WorldUnlockState.OpenAndUnlocked : WorldUnlockState.UnreachableAndFullyLocked); } default: { SAMLog.Error("UNLCK::EnumSwitch_IU_3", "GDConstants.FLAVOR = " + GDConstants.FLAVOR); } } } if (id == Levels.WORLD_ID_GAMEEND) { if (!BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_004, Levels.WORLD_ID_GAMEEND)) { return(WorldUnlockState.OpenAndUnlocked); } return(WorldUnlockState.UnreachableAndFullyLocked); } if (id == Levels.WORLD_ID_MULTIPLAYER) { switch (GDConstants.FLAVOR) { case GDFlavor.FREE: { return(WorldUnlockState.UnreachableAndFullyLocked); } case GDFlavor.IAB: { return(GetIABState(GDConstants.IAB_MULTIPLAYER, Levels.WORLD_ID_MULTIPLAYER, showToast) ? WorldUnlockState.OpenAndUnlocked : WorldUnlockState.ReachableButMustBePreviewed); } case GDFlavor.FULL: { return(WorldUnlockState.OpenAndUnlocked); } case GDFlavor.FULL_NOMP: { return(WorldUnlockState.UnreachableAndFullyLocked); } default: { SAMLog.Error("UNLCK::EnumSwitch_IU_4", "GDConstants.FLAVOR = " + GDConstants.FLAVOR); } } } SAMLog.Error("UNLCK::NID", $"UnlockManager: ID not found {id} ({showToast})"); return(WorldUnlockState.UnreachableAndFullyLocked); }
private void SetLevelDataRandom() { List <LevelBlueprint> pool = new List <LevelBlueprint>(); foreach (var world in Levels.WORLDS_MULTIPLAYER) { foreach (var item in world.LevelNodes.Select(p => Levels.LEVELS[p.LevelID]).Where(l => BlueprintAnalyzer.PlayerCount(l) == _server.SessionCapacity)) { if (item.UniqueID == _serverHost.LevelID) { continue; } pool.Add(item); } } if (!pool.Any()) { return; } _serverHost.LevelID = pool[FloatMath.GetRangedIntRandom(pool.Count)].UniqueID; }
public static WorldUnlockState IsUnlocked(Guid id, bool showToast) { if (id == Levels.WORLD_ID_TUTORIAL) { return(WorldUnlockState.Unlocked); } if (id == Levels.WORLD_001.ID) { if (MainGame.Inst.Profile.SkipTutorial) { return(WorldUnlockState.Unlocked); } if (MainGame.Inst.Profile.GetLevelData(Levels.LEVEL_TUTORIAL).HasAnyCompleted()) { return(WorldUnlockState.Unlocked); } return(WorldUnlockState.FullyLocked); } if (id == Levels.WORLD_002.ID) { if (!GDConstants.USE_IAB) { if (MainGame.Inst.Profile.SkipTutorial) { return(WorldUnlockState.Unlocked); } if (MainGame.Inst.Profile.GetLevelData(Levels.LEVEL_TUTORIAL).HasAnyCompleted()) { return(WorldUnlockState.Unlocked); } return(WorldUnlockState.FullyLocked); } else { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_001, Levels.WORLD_002.ID); int neededPoints = PointsForUnlock(id); if (reachable && MainGame.Inst.Profile.TotalPoints >= neededPoints) { return(WorldUnlockState.Unlocked); } if (GetIABState(GDConstants.IAB_WORLD2, Levels.WORLD_002.ID, showToast)) { return(WorldUnlockState.Unlocked); } else { return(reachable ? WorldUnlockState.NeedsAction : WorldUnlockState.FullyLocked); } } } if (id == Levels.WORLD_003.ID) { if (!GDConstants.USE_IAB) { if (MainGame.Inst.Profile.SkipTutorial) { return(WorldUnlockState.Unlocked); } if (MainGame.Inst.Profile.GetLevelData(Levels.LEVEL_TUTORIAL).HasAnyCompleted()) { return(WorldUnlockState.Unlocked); } return(WorldUnlockState.FullyLocked); } else { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_002, Levels.WORLD_003.ID); int neededPoints = PointsForUnlock(id); if (reachable && MainGame.Inst.Profile.TotalPoints >= neededPoints) { return(WorldUnlockState.Unlocked); } if (GetIABState(GDConstants.IAB_WORLD3, Levels.WORLD_003.ID, showToast)) { return(WorldUnlockState.Unlocked); } else { return(reachable ? WorldUnlockState.NeedsAction : WorldUnlockState.FullyLocked); } } } if (id == Levels.WORLD_004.ID) { if (!GDConstants.USE_IAB) { if (MainGame.Inst.Profile.SkipTutorial) { return(WorldUnlockState.Unlocked); } if (MainGame.Inst.Profile.GetLevelData(Levels.LEVEL_TUTORIAL).HasAnyCompleted()) { return(WorldUnlockState.Unlocked); } return(WorldUnlockState.FullyLocked); } else { bool reachable = BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_003, Levels.WORLD_004.ID); int neededPoints = PointsForUnlock(id); if (reachable && MainGame.Inst.Profile.TotalPoints >= neededPoints) { return(WorldUnlockState.Unlocked); } if (GetIABState(GDConstants.IAB_WORLD4, Levels.WORLD_004.ID, showToast)) { return(WorldUnlockState.Unlocked); } else { return(reachable ? WorldUnlockState.NeedsAction : WorldUnlockState.FullyLocked); } } } if (id == Levels.WORLD_ID_GAMEEND) { if (!BlueprintAnalyzer.IsWorldReachable(Levels.WORLD_004, Levels.WORLD_ID_GAMEEND)) { return(WorldUnlockState.FullyLocked); } return(WorldUnlockState.FullyLocked); } if (id == Levels.WORLD_ID_MULTIPLAYER) { if (!GDConstants.USE_IAB) { return(WorldUnlockState.Unlocked); } return(GetIABState(GDConstants.IAB_MULTIPLAYER, Levels.WORLD_ID_MULTIPLAYER, showToast) ? WorldUnlockState.Unlocked : WorldUnlockState.NeedsAction); } SAMLog.Error("UNLCK::NID", $"UnlockManager: ID not found {id} ({showToast})"); return(WorldUnlockState.FullyLocked); }