public static void ResumeGame(this Game game) { game.CleanupComponents(); var mainGame = new MainGameComponent(game, false, GameDifficulty.Easy); mainGame.Back += game.ShowMainMenu; game.Components.Add(mainGame); }
public static void ResumeGame(this MainGame game) { game.CleanupComponents(); var mainGame = new MainGameComponent(game, false, 0); mainGame.Back += game.ShowMainMenu; mainGame.Win += () => game.ShowEndMenu(true); game.Components.Add(mainGame); }
public static void StartGame(this MainGame game, bool forceNewgame, int selcetedLevel) { game.CleanupComponents(); var mainGame = new MainGameComponent(game, forceNewgame, selcetedLevel); mainGame.Back += game.ShowMainMenu; mainGame.Win += () => game.ShowEndMenu(true); game.Components.Add(mainGame); }
protected override void OnBeforeInitialize() { base.OnBeforeInitialize(); if (gameUtility.RivalGhost) { var newGameUtility = new PPDGameUtility { SongInformation = gameUtility.SongInformation, Difficulty = gameUtility.Difficulty, DifficultString = gameUtility.DifficultString, Profile = ProfileManager.Instance.Default, SpeedScale = 1, GodMode = true, MuteSE = true }; using (var disposable = Sound.Disable()) { var reason = WebManager.Instance.GetGhost(CryptographyUtility.Getx2Encoding(gameUtility.SongInformation.GetScoreHash(gameUtility.Difficulty)), gameUtility.RivalGhostCount, out GhostInfo[] ghosts); if (reason == ErrorReason.OK) { var games = new MainGameComponent[ghosts.Length]; for (var i = 0; i < games.Length; i++) { games[i] = new MainGameComponent(device, GameHost, ResourceManager, Sound, this, newGameUtility, null, (MarkImagePathsBase)Param["MarkImagePath"], null, null, MainGameConfigBase.Default, startTime, mmStartTime); games[i].Initialize(false, true); } userScoreListComponent = new UserScoreListComponent(device, ResourceManager) { Position = new SharpDX.Vector2(680, 45) }; var ghostInfo = new Dictionary <GhostInfo, GhostFrame[]>(); var actions = new Action[] { () => { var progresses = new int[ghosts.Length]; var prevAllProgress = 0; Action <int, int> allProgressCallback = (i, p) => { progresses[i] = p; var allProgress = progresses.Sum() / ghosts.Length; if (prevAllProgress != allProgress) { GameHost.SendToLoading(new Dictionary <string, object> { { "Progress", allProgress } }); prevAllProgress = allProgress; } }; Parallel.For(0, ghosts.Length, new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, i => { var ghost = ghosts[i]; var tempMainGameComponent = games[i]; var prevProgress = 0; Action <int> progressCallback = p => { if (prevProgress != p) { allProgressCallback(i, p); prevProgress = p; } }; var ghostFrame = tempMainGameComponent.GetGhostFrames(ghost.ReplayData, progressCallback); lock (ghostInfo) { ghostInfo.Add(ghost, ghostFrame); } }); }, () => { InitializeUserList(ghosts); } }; Parallel.ForEach(actions, new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, a => a()); ghostPlayInfos = ghostInfo.Select(p => new GhostPlayInfo( userScoreListComponent.Players.FirstOrDefault(pi => !pi.UserPlayState.User.IsSelf && pi.UserPlayState.User.AccountId == p.Key.AccountId).UserPlayState, p.Value)).ToArray(); } } } }
public override bool Load() { clientHandledData = new Queue <NetworkData>(); client = Param["Client"] as Client; byteReader = Param["ByteReader"] as TcpByteReader; client.Closed += client_Closed; byteReader.ByteReaded += TcpByteReader_ByteReaded; gameRule = Param["GameRule"] as GameRule; userList = new ChangableList <User>(Param["Users"] as User[]); var songInformation = Param["SongInformation"] as SongInformation; var difficulty = (Difficulty)Param["Difficulty"]; var allowedModList = (AllowedModList)Param["AllowedModList"]; selfUser = Param["Self"] as User; userPlayStateList = new ChangableList <UserPlayState>(); userPlayStateList.ItemChanged += userPlayStateList_ItemChanged; userScoreListComponent = new UserScoreListComponent(device, ResourceManager) { Position = new SharpDX.Vector2(680, 45) }; itemManagerComponent = new ItemManagerComponent(device, ResourceManager, gameRule) { Position = new SharpDX.Vector2(682, 420) }; itemOverrayComponent = new ItemOverrayComponent(device, ResourceManager, itemManagerComponent); itemOverrayComponent.ItemSet += itemOverrayComponent_ItemSet; selfPlayState = new UserPlayState { User = selfUser }; foreach (User user in userList) { var userPlayState = new UserPlayState { User = user }; if (user == selfUser) { userScoreListComponent.AddSelfUser(selfPlayState, itemManagerComponent); } else { userPlayStateList.Add(userPlayState); userScoreListComponent.AddUser(userPlayState); } } userScoreListComponent.AddFinish(); black = new RectangleComponent(device, ResourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0, Hidden = true }; // メインゲーム用のパラメータの準備 gameutility = new PPDGameUtility { SongInformation = songInformation, Difficulty = difficulty, DifficultString = songInformation.GetDifficultyString(difficulty), Profile = ProfileManager.Instance.Default, AutoMode = AutoMode.None, SpeedScale = 1, Random = false, MuteSE = (bool)Param["MuteSE"], Connect = (bool)Param["Connect"], IsDebug = true, GodMode = true, CanApplyModCallback = m => allowedModList.IsAllowed(m.FileHashString) || !m.ContainsModifyData }; GameInterfaceBase cgi = new GameInterface(device) { Sound = Sound, PPDGameUtility = gameutility, ResourceManager = ResourceManager }; cgi.Load(); pauseMenu = null; if (selfUser.IsLeader) { pauseMenu = new PauseMenu(device) { Sound = Sound, ResourceManager = ResourceManager }; pauseMenu.Load(); pauseMenu.Resumed += pauseMenu_Resumed; pauseMenu.Returned += pauseMenu_Returned; } config = new MainGameConfig(itemManagerComponent); mainGameComponent = new MainGameComponent(device, GameHost, ResourceManager, Sound, this, gameutility, cgi, new MarkImagePaths(), null, pauseMenu, config, songInformation.StartTime, songInformation.StartTime) { PauseMovieWhenPause = false }; filterSprite = new SpriteObject(device); mainGameComponent.Finished += mainGameComponent_Finished; mainGameComponent.Drawed += mainGameComponent_Drawed; mainGameComponent.ScoreChanged += mainGameComponent_ScoreChanged; mainGameComponent.LifeChanged += mainGameComponent_LifeChanged; mainGameComponent.EvaluateChanged += mainGameComponent_EvaluateChanged; mainGameComponent.ComboChanged += mainGameComponent_ComboChanged; mainGameComponent.Initialize(fadeOut, fadeOut, new Dictionary <string, object> { { "MultiItemComponent", itemManagerComponent } }); this.AddChild(black); shouldDisposeItem.AddRange(new GameComponent[] { userScoreListComponent, itemManagerComponent, itemOverrayComponent, mainGameComponent, filterSprite, pauseMenu }); ConnectExpansion(); client.Write(MessagePackSerializer.Serialize(new MainGameLoadedNetworkData())); return(true); }
public static void StartGame(this Game game, GameDifficulty difficulty) { game.CleanupComponents(); var mainGame = new MainGameComponent(game, true, difficulty); mainGame.Back += game.ShowMainMenu; mainGame.Win += () => game.ShowEndMenu(true); mainGame.Lose += () => game.ShowEndMenu(false); game.Components.Add(mainGame); }
public override bool Load() { if (!Param.ContainsKey("PPDGameUtility")) { throw new PPDException(PPDExceptionType.SkinIsNotCorrectlyImplemented, "Parameter PPDGameUtility is not contained", null); } gameUtility = Param["PPDGameUtility"] as PPDGameUtility; exitOnReturn |= Param.ContainsKey("ExitOnReturn"); if (Param.ContainsKey("StartTime")) { gameUtility.IsDebug = true; startTime = (float)Param["StartTime"] - 3; mmStartTime = (float)Param["StartTime"]; } else if (Param.ContainsKey("StartTimeEx")) { gameUtility.IsDebug = true; gameUtility.LatencyType = LatencyType.File; startTime = (float)Param["StartTimeEx"]; mmStartTime = (float)Param["StartTimeEx"]; } else { startTime = gameUtility.SongInformation.StartTime; mmStartTime = startTime; } black = new RectangleComponent(device, ResourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0, Hidden = true }; cgi = (GameInterfaceBase)Param["GameInterface"]; cgi.Sound = Sound; cgi.PPDGameUtility = gameUtility; cgi.ResourceManager = ResourceManager; cgi.Load(); gr = Param["GameResult"] as GameResultBase; if (gr != null) { gr.GameHost = GameHost; gr.Sound = Sound; gr.PPDGameUtility = gameUtility; gr.ResourceManager = ResourceManager; gr.TweetManager = this; gr.ReviewManager = this; gr.Load(); } pd = (PauseMenuBase)Param["PauseMenu"]; pd.Sound = Sound; pd.PPDGameUtility = gameUtility; pd.ResourceManager = ResourceManager; pd.Load(); mainGameComponent = new MainGameComponent(device, GameHost, ResourceManager, Sound, this, gameUtility, cgi, (MarkImagePathsBase)Param["MarkImagePath"], gr, pd, MainGameConfigBase.Default, startTime, mmStartTime); mainGameComponent.Finished += mainGameComponent_Finished; mainGameComponent.Paused += mainGameComponent_Paused; mainGameComponent.Drawed += mainGameComponent_Drawed; pd.Resumed += pd_Resumed; pd.Retryed += pd_Retryed; pd.Replayed += pd_Replayed; pd.Returned += pd_Returned; if (gr != null) { gr.Returned += gr_Returned; gr.Retryed += gr_Retryed; } ConnectExpansion(); OnBeforeInitialize(); mainGameComponent.CannotStartPerfectTrial += mainGameComponent_CannotStartPerfectTrial; mainGameComponent.PerfectTrialError += mainGameComponent_PerfectTrialError; mainGameComponent.PerfectTrialStart += mainGameComponent_PerfectTrialStart; try { mainGameComponent.Initialize(true); } catch (Exception e) { if (!OnInitializeError(e)) { throw; } return(false); } this.AddChild(black); this.AddChild(mainGameComponent); return(true); }
public static void StartGame(this Game game, GameDifficulty difficulty) { game.CleanupComponents(); var mainGame = new MainGameComponent(game, true, difficulty); mainGame.Back += game.ShowMainMenu; game.Components.Add(mainGame); }