コード例 #1
0
        private void PlayGame()
        {
            selfUser.CurrentState = UserState.Playing;
            client.Write(MessagePackSerializer.Serialize(new ChangeUserStateNetworkData {
                State = selfUser.CurrentState
            }));
            lastPlayState = LastPlayState.TryToPlayGame;
            var gameutility = new PPDGameUtility
            {
                SongInformation = currentSelectSong.SongInformation,
                Difficulty      = currentSelectSong.Difficulty,
                DifficultString = currentSelectSong.SongInformation.GetDifficultyString(currentSelectSong.Difficulty),
                Profile         = ProfileManager.Instance.Profiles[1],
                AutoMode        = AutoMode.None,
                SpeedScale      = 1,
                MuteSE          = leftMenu.MuteSE,
                Connect         = leftMenu.Connect
            };
            var dic = new Dictionary <string, object>
            {
                { "PPDGameUtility", gameutility },
                { "GameInterface", new GameInterface(device) },
                { "GameResult", null },
                { "PauseMenu", new PPDShareComponent.PauseMenu(device, Utility.Path) },
                { "MarkImagePath", new MarkImagePaths() }
            };

            SceneManager.PrepareNextScene(this, new PPDCore.MainGame(device), dic, dic, true);

            movieManager.Stop();
        }
コード例 #2
0
ファイル: EventManager.cs プロジェクト: KHCmaster/PPD
        private void InnerStruct(PPDGameUtility ppdgameutility, MainGameConfigBase config, FlowScriptManager scriptManager)
        {
            this.config        = config;
            this.defaultbpm    = ppdgameutility.SongInformation.BPM;
            this.scriptManager = scriptManager;

            BPMManager.CurrentBPM = defaultbpm;
            BPMManager.TargetBPM  = defaultbpm;

            displayStateCache      = new SortedList <float, DisplayState>();
            noteTypeCache          = new SortedList <float, NoteType>();
            initializeOrderCache   = new SortedList <float, ButtonType[]>();
            slideScaleCache        = new SortedList <float, float>();
            defaultInitializeOrder = new ButtonType[10];
            for (int i = 0; i < 10; i++)
            {
                defaultInitializeOrder[i] = (ButtonType)i;
            }
            for (int i = 0; i < volumePercents.Length; i++)
            {
                volumePercents[i] = 90;
                keepPlayings[i]   = false;
            }
            if (initialized)
            {
                InitializeState();
            }
        }
コード例 #3
0
ファイル: MarkManager.cs プロジェクト: KHCmaster/PPD
 public MarkManager(Device device, EventManager em, PPDGameUtility gameutility, int[] keychange, PPDEffectManager ppdem, CMarkImagePaths imagepathes, Stream stream, PPDFramework.Resource.ResourceManager resourceManager)
 {
     InnerStruct(device, em, gameutility, keychange, ppdem, imagepathes, resourceManager);
     readppddata(stream);
     CheckGroups();
     readppddata(gameutility.SongInformation.StartTime);
 }
コード例 #4
0
 private void UpdateScore(PPDGameUtility util, bool replaying)
 {
     HighScore = false;
     if (util.IsRegular && !replaying)
     {
         HighScore = ScoreReaderWriter.WriteScore(util.SongInformation.ID, PPDGameUtility.Difficulty, MarkEvals, MaxCombo, Score, Result, FinishTime, PPDGameUtility.SongInformation);
     }
 }
コード例 #5
0
        public override void Load()
        {
            //init
            int    selectnum        = 0;
            string initialdirectory = "songs";
            object temp;

            if (PreviousParam.TryGetValue("PPDGameUtility", out temp))
            {
                PPDGameUtility gameutility = temp as PPDGameUtility;
                initialdirectory = gameutility.SongInformation.ParentDirectory;// Directory.GetParent(gameutility.SongInformation.DirectoryPath).Name;
            }
            ssm                   = new SelectSongManager();
            ssm.SongChanged      += new EventHandler(ssm_SongChanged);
            ssm.DirectoryChanged += new EventHandler(ssm_DirectoryChanged);
            resource              = new Dictionary <string, ImageResource>();
            ImageResource ir = new ImageResource("img\\default\\num.png", Device);

            resource.Add("img\\default\\num.png", ir);
            pictureobjects = new ArrayList();
            mb             = new MovieBox(Device);
            mss            = new MenuSelectSong(Device, Sprite, this, ssm.Directory);
            sic            = new SongInfoControl(Device, Sprite);
            cc             = new ConfirmControl(Device, Sprite);
            if (PPDSetting.Setting.LightMode)
            {
                mt = new Moviethumb(Device, Sprite);
            }
            mss.DisapperFinish += new EventHandler(cc.Focus);
            //factory

            factory(selectnum);
            if (temp != null)
            {
                PPDGameUtility gameutility = temp as PPDGameUtility;
                Auto       = gameutility.Auto;
                Speedscale = gameutility.SpeedScale;
                Random     = gameutility.Random;
                changeprofiledisplay();
            }
            ssm.Directory = initialdirectory;
            if (temp != null)
            {
                PPDGameUtility  gameutility = temp as PPDGameUtility;
                SongInformation si          = gameutility.SongInformation;
                selectnum = Array.FindIndex(ssm.SongInformations, (songinfo) => si.DirectoryName == songinfo.DirectoryName);
                if (selectnum < 0)
                {
                    selectnum = 0;
                }
            }
            ssm.SelectedIndex = selectnum;
        }
コード例 #6
0
        private void UpdateData(PPDGameUtility gameUtility)
        {
            var str = gameUtility.SongInformation.GetScore(gameUtility.Difficulty);

            if (!int.TryParse(str, out int val))
            {
                val = 0;
            }
            bestScore       = val;
            clearCount      = allClearCount = playCount = allPlayCount = 0;
            bestPerformance = 0;

            ResultInfo bestPerformanceResult = null;

            results = ResultInfo.GetInfoFromSongInformation(gameUtility.SongInformation);
            foreach (ResultInfo resultInfo in results)
            {
                allPlayCount++;
                if (resultInfo.ResultEvaluate != ResultEvaluateType.Mistake)
                {
                    allClearCount++;
                }
                if (resultInfo.Difficulty != gameUtility.Difficulty)
                {
                    continue;
                }
                playCount++;
                if (resultInfo.ResultEvaluate == ResultEvaluateType.Mistake)
                {
                    continue;
                }
                clearCount++;

                if (IsBestPerformance(bestPerformanceResult, resultInfo))
                {
                    bestPerformanceResult = resultInfo;
                }
            }
            if (bestPerformanceResult != null)
            {
                bestPerformance           = GetRatio(bestPerformanceResult);
                bestPerformanceCoolCount  = bestPerformanceResult.CoolCount;
                bestPerformanceGoodCount  = bestPerformanceResult.GoodCount;
                bestPerformanceSafeCount  = bestPerformanceResult.SafeCount;
                bestPerformanceSadCount   = bestPerformanceResult.SadCount;
                bestPerformanceWorstCount = bestPerformanceResult.WorstCount;
                bestPerformanceScore      = bestPerformanceResult.Score;
            }
            isAllFirstPlay = allPlayCount == 0;
            isFirstPlay    = playCount == 0;
        }
コード例 #7
0
ファイル: MarkManager.cs プロジェクト: KHCmaster/PPD
 private void InnerStruct(Device device, EventManager em, PPDGameUtility gameutility, int[] keychange, PPDEffectManager ppdem, CMarkImagePaths imagepathes, PPDFramework.Resource.ResourceManager resourceManager)
 {
     this.device          = device;
     this.gameutility     = gameutility;
     this.em              = em;
     this.keychange       = keychange;
     this.ppdem           = ppdem;
     this.imagepathes     = imagepathes;
     this.resourceManager = resourceManager;
     cd            = new ConnectionDrawer(device, 4);
     evals         = new float[] { PPDSetting.Setting.CoolArea, PPDSetting.Setting.GoodArea, PPDSetting.Setting.SafeArea, PPDSetting.Setting.SadArea };
     adjustgaptime = PPDSetting.Setting.AdjustGapTime;
     CreateResource();
 }
コード例 #8
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            if (this.Manager.Items.ContainsKey("PPDGameUtility"))
            {
                gameUtility = this.Manager.Items["PPDGameUtility"] as PPDGameUtility;
            }

            if (this.Manager.Items.ContainsKey("MarkManager"))
            {
                markManager = this.Manager.Items["MarkManager"] as IMarkManager;
            }
        }
コード例 #9
0
        private static float GetLatency(PPDGameUtility ppdGameUtility)
        {
            var path = Path.Combine(ppdGameUtility.SongInformation.DirectoryPath, "Latency");

            if (!File.Exists(path))
            {
                return(0);
            }

            if (!float.TryParse(File.ReadAllText(path), NumberStyles.Float, CultureInfo.InvariantCulture, out float val))
            {
                return(0);
            }
            return(val);
        }
コード例 #10
0
        public void End(object sender, EventArgs e)
        {
            PPDGameUtility gameutility = new PPDGameUtility();

            gameutility.SongInformation = ssm.SelectedSongInformation;
            gameutility.Difficulty      = Difficulty;
            gameutility.DifficultString = DifficultString;
            gameutility.Profile         = ProfileManager.Instance.Current;
            gameutility.Auto            = Auto;
            gameutility.SpeedScale      = Speedscale;
            gameutility.Random          = random;
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("PPDGameUtility", gameutility);
            SceneManager.PrepareNextScene(this, GameHost.GetMainGame(), dic, dic);
        }
コード例 #11
0
ファイル: KasiManager.cs プロジェクト: KHCmaster/PPD
        public KasiManager(PPDGameUtility ppdgameutility)
        {
            var path = Path.Combine(ppdgameutility.SongInformation.DirectoryPath, "kasi.txt");

            if (File.Exists(path))
            {
                using (StreamReader sr = new StreamReader(path))
                {
                    var data = sr.ReadToEnd();
                    sr.Close();
                    data = data.Replace("\r\n", "\r").Replace("\r", "\n");
                    if (string.IsNullOrEmpty(data))
                    {
                        return;
                    }
                    var datas = data.Split('\n');
                    foreach (string eachdata in datas)
                    {
                        var temp = eachdata.Split(':');
                        try
                        {
                            if (temp.Length >= 2)
                            {
                                pool.Add(float.Parse(temp[0], CultureInfo.InvariantCulture), temp[1]);
                            }
                            else
                            {
                                pool.Add(float.Parse(temp[0], CultureInfo.InvariantCulture), "");
                            }
                        }
                        catch
                        {
                        }
                    }
                    if (pool.Count > 0)
                    {
                        nexttime  = pool.Keys[0];
                        starttime = nexttime;
                    }
                    initialized = true;
                }
            }
        }
コード例 #12
0
        private void InnerStruct(PPDGameUtility gameutility, PPDFramework.Resource.ResourceManager resourceManager, RandomChangeManager randomChangeManager, PPDEffectManager ppdem, MarkImagePathsBase imagepathes, MainGameConfigBase config, FlowScriptManager scriptManager)
        {
            this.gameutility         = gameutility;
            this.randomChangeManager = randomChangeManager;
            this.ppdem           = ppdem;
            this.imagepathes     = imagepathes;
            this.resourceManager = resourceManager;
            this.config          = config;
            this.scriptManager   = scriptManager;
            externalMarks        = new List <MarkData>();

            evals = new float[] { PPDSetting.Setting.CoolArea, PPDSetting.Setting.GoodArea, PPDSetting.Setting.SafeArea, PPDSetting.Setting.SadArea };
            Logger.Instance.AddLog("CoolArea:{0}", PPDSetting.Setting.CoolArea);
            Logger.Instance.AddLog("GoodArea:{0}", PPDSetting.Setting.GoodArea);
            Logger.Instance.AddLog("SafeArea:{0}", PPDSetting.Setting.SafeArea);
            Logger.Instance.AddLog("SadArea:{0}", PPDSetting.Setting.SadArea);
            adjustgaptime = PPDSetting.Setting.AdjustGapTime;
            CreateResource();

            MarkLayer            = new SpriteObject(device);
            ConnectLayer         = new SpriteObject(device);
            postDrawManager      = new PostDrawManager(device);
            markConnectionCommon = new MarkConnectionCommon(device, resourceManager);
            this.AddChild(markConnectionCommon);
            if (PPDSetting.Setting.DrawConnectUnderAllMark)
            {
                this.AddChild(postDrawManager);
                this.AddChild(MarkLayer);
                this.AddChild(ConnectLayer);
            }
            else
            {
                this.AddChild(postDrawManager);
                this.AddChild(ConnectLayer);
                this.AddChild(MarkLayer);
            }
            ConnectLayer.CanDraw += (obj, context, depth, childIndex) =>
            {
                return(gameutility.Connect || gameutility.Profile.Connect);
            };
        }
コード例 #13
0
        private void SendScore(PPDGameUtility util, byte[] inputs, bool replaying, string perfectTrialToken)
        {
            if (util.IsRegular && Result != ResultEvaluateType.Mistake && WebManager.Instance.IsLogined && !replaying)
            {
                var hash = util.SongInformation.GetScoreHash(util.Difficulty);
                if (hash != null)
                {
                    ScoreSending?.Invoke();
                    ThreadManager.Instance.GetThread(() =>
                    {
                        var reason = WebManager.Instance.PlayResult(hash, Score, MarkEvals[0], MarkEvals[1], MarkEvals[2], MarkEvals[3], MarkEvals[4], MaxCombo,
                                                                    PPDGameUtility.SongInformation.StartTime, FinishTime, inputs, 3, perfectTrialToken, out Dictionary <string, string> data);

                        if (data.TryGetValue("PerfectTrialResult", out string result))
                        {
                            PerfectTrialSucceess |= result == "1";
                        }
                        ScoreSent?.Invoke(reason, data);
                    }).Start();
                }
            }
        }
コード例 #14
0
 private void InnerStruct(PPDGameUtility ppdgameutility)
 {
     this.defaultbpm        = ppdgameutility.SongInformation.BPM;
     currentbpm             = defaultbpm;
     targetbpm              = defaultbpm;
     DstateCache            = new SortedList <float, DisplayState>();
     ACCache                = new SortedList <float, bool>();
     InitializeOrderCache   = new SortedList <float, ButtonType[]>();
     defaultInitializeOrder = new ButtonType[10];
     for (int i = 0; i < 10; i++)
     {
         defaultInitializeOrder[i] = (ButtonType)i;
     }
     for (int i = 0; i < volumePercents.Length; i++)
     {
         volumePercents[i] = 90;
         keepPlaying[i]    = false;
     }
     if (initialized)
     {
         initializestate();
     }
 }
コード例 #15
0
ファイル: Maingame.cs プロジェクト: KHCmaster/PPD
        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);
        }
コード例 #16
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="gameResultManager">ゲームリザルト</param>
 /// <param name="evatype">結果評価</param>
 /// <param name="finishtime">終了時間</param>
 /// <param name="util">PPDGameUtility</param>
 /// <param name="replaying">リプレイかどうか</param>
 /// <param name="inputs">入力データ</param>
 /// <param name="perfectTrialToken">パーフェクトトライアルのトークン</param>
 public void SetResult(GameResultManager gameResultManager, ResultEvaluateType evatype, float finishtime, PPDGameUtility util, byte[] inputs, bool replaying,
                       string perfectTrialToken)
 {
     Score      = gameResultManager.CurrentScore;
     MaxCombo   = gameResultManager.MaxCombo;
     MarkEvals  = gameResultManager.Evalutes;
     FinishTime = finishtime;
     if (evatype != ResultEvaluateType.Mistake)
     {
         Result = gameResultManager.ResultEvaluateType;
     }
     else
     {
         Result = ResultEvaluateType.Mistake;
     }
     UpdateScore(util, replaying);
     SendScore(util, inputs, replaying, perfectTrialToken);
     if (ResultSet != null)
     {
         ResultSet.Invoke(this, EventArgs.Empty);
     }
 }
コード例 #17
0
 public FileLatencyUpdater(PPDGameUtility ppdGameUtility) :
     base(GetLatency(ppdGameUtility))
 {
     this.ppdGameUtility = ppdGameUtility;
 }
コード例 #18
0
ファイル: EventManager.cs プロジェクト: KHCmaster/PPD
 public EventManager(PPDGameUtility ppdgameutility, Stream stream, MainGameConfigBase config, FlowScriptManager scriptManager)
 {
     LoadData(stream);
     InnerStruct(ppdgameutility, config, scriptManager);
 }
コード例 #19
0
ファイル: EventManager.cs プロジェクト: KHCmaster/PPD
 public EventManager(PPDGameUtility ppdgameutility, MainGameConfigBase config, FlowScriptManager scriptManager)
 {
     LoadData(ppdgameutility.SongInformation.DirectoryPath, ppdgameutility.Difficulty);
     InnerStruct(ppdgameutility, config, scriptManager);
 }
コード例 #20
0
 public DbLatencyUpdater(PPDGameUtility ppdGameUtility)
     : base(ppdGameUtility.SongInformation.Latency)
 {
     this.ppdGameUtility = ppdGameUtility;
 }
コード例 #21
0
 public EventManager(PPDGameUtility ppdgameutility)
 {
     loaddata(ppdgameutility.SongInformation.DirectoryPath, ppdgameutility.Difficulty);
     InnerStruct(ppdgameutility);
 }
コード例 #22
0
ファイル: GameInterfaceTop.cs プロジェクト: KHCmaster/PPD
        public GameInterfaceTop(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, PPDGameUtility ppdgameutility) : base(device)
        {
            top       = new PictureObject(device, resourceManager, Utility.Path.Combine("top.png"));
            topdanger = new PictureObject(device, resourceManager, Utility.Path.Combine("topred.png"))
            {
                Hidden = true
            };
            onpu       = new PictureObject(device, resourceManager, Utility.Path.Combine("toponpu.png"));
            songname   = new TextureString(device, ppdgameutility.SongInformation.DirectoryName, 20, 270, PPDColors.White);
            sco        = new Score(device, resourceManager);
            difficulty = new TextureString(device, String.Format("-{0}-", ppdgameutility.Difficulty.ToString().ToUpper()), 20, true, PPDColors.White);

            this.AddChild(difficulty);
            this.AddChild(songname);
            this.AddChild(onpu);
            this.AddChild(sco);
            this.AddChild(top);
            this.AddChild(topdanger);
            InitializeComponentPosition();
        }
コード例 #23
0
        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();
                    }
                }
            }
        }
コード例 #24
0
ファイル: MainGame.cs プロジェクト: KHCmaster/PPD
        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);
        }
コード例 #25
0
        public GameResultScore(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager,
                               PPDGameUtility ppdGameUtility, ISound sound, ITweetManager tweetManager, IReviewManager reviewManager, IGameHost gameHost) : base(device)
        {
            this.ppdGameUtility = ppdGameUtility;
            this.TweetManager   = tweetManager;
            this.ReviewManager  = reviewManager;
            this.Sound          = sound;
            this.gameHost       = gameHost;
            menuRanking         = new MenuRanking(device, resourceManager)
            {
                Position = new Vector2(455, 100)
            };
            td = new TweetDialog(device, resourceManager, sound, tweetManager);
            rd = new ReviewDialog(device, resourceManager, sound, reviewManager);
            this.AddChild(td);
            this.AddChild(rd);
            result = new EffectObject[6];
            for (int i = 0; i < result.Length; i++)
            {
                int x    = 220;
                int y    = 74;
                var anim = new EffectObject(device, resourceManager, Utility.Path.Combine("result", String.Format("{0}.etd", ((ResultEvaluateType)i).ToString().ToLower())))
                {
                    Position = new Vector2(x, y)
                };
                anim.PlayType = Effect2D.EffectManager.PlayType.ReverseLoop;
                anim.Play();
                result[i] = anim;
            }
            string filename = "";

            switch (ppdGameUtility.Difficulty)
            {
            case Difficulty.Easy:
                filename = "easy.png";
                break;

            case Difficulty.Normal:
                filename = "normal.png";
                break;

            case Difficulty.Hard:
                filename = "hard.png";
                break;

            case Difficulty.Extreme:
                filename = "extreme.png";
                break;

            default:
                filename = "normal.png";
                break;
            }
            difficulty = new PictureObject(device, resourceManager, Utility.Path.Combine("result", filename))
            {
                Position = new Vector2(45, 105)
            };
            high = new EffectObject(device, resourceManager, Utility.Path.Combine("result", "high.etd"))
            {
                Position = new Vector2(-25, 300)
            };
            high.PlayType = Effect2D.EffectManager.PlayType.Loop;
            high.Play();
            high.Alignment = EffectObject.EffectAlignment.TopLeft;
            scoresmalls    = new NumberPictureObject[6];
            for (int i = 0; i < scoresmalls.Length; i++)
            {
                scoresmalls[i] = new NumberPictureObject(device, resourceManager, Utility.Path.Combine("result", "scoresmall.png"))
                {
                    Position  = new Vector2(scorex, scorey[i]),
                    Alignment = Alignment.Right,
                    MaxDigit  = -1
                };
            }
            scorebig = new NumberPictureObject(device, resourceManager, Utility.Path.Combine("result", "scorebig.png"))
            {
                Position  = new Vector2(scorex, scorey[6]),
                Alignment = Alignment.Right,
                MaxDigit  = -1
            };
            scoreboard = new PictureObject(device, resourceManager, Utility.Path.Combine("result", "score.png"))
            {
                Position = new Vector2(18, 52)
            };
            scoreboard.AddChild(new PictureObject(device, resourceManager, Utility.Path.Combine("eva", "cool.png"), true)
            {
                Position = new Vector2(105, 108),
                Scale    = new Vector2(0.75f, 0.75f)
            });
            scoreboard.AddChild(new PictureObject(device, resourceManager, Utility.Path.Combine("eva", "good.png"), true)
            {
                Position = new Vector2(105, 138),
                Scale    = new Vector2(0.75f, 0.75f)
            });
            scoreboard.AddChild(new PictureObject(device, resourceManager, Utility.Path.Combine("eva", "safe.png"), true)
            {
                Position = new Vector2(105, 168),
                Scale    = new Vector2(0.75f, 0.75f)
            });
            scoreboard.AddChild(new PictureObject(device, resourceManager, Utility.Path.Combine("eva", "sad.png"), true)
            {
                Position = new Vector2(105, 198),
                Scale    = new Vector2(0.75f, 0.75f)
            });
            scoreboard.AddChild(new PictureObject(device, resourceManager, Utility.Path.Combine("eva", "worst.png"), true)
            {
                Position = new Vector2(105, 228),
                Scale    = new Vector2(0.75f, 0.75f)
            });
            scoreboard.AddChild(new PictureObject(device, resourceManager, Utility.Path.Combine("eva", "combo.png"), true)
            {
                Position = new Vector2(105, 258),
                Scale    = new Vector2(0.75f, 0.75f)
            });

            top = new PictureObject(device, resourceManager, Utility.Path.Combine("result", "top.png"));
            top.AddChild(new TextureString(device, Utility.Language["Result"], 20, PPDColors.White)
            {
                Position = new Vector2(70, 2)
            });
            bottom = new PictureObject(device, resourceManager, Utility.Path.Combine("result", "bottom.png"));
            bottom.AddChild(new TextureString(device, Utility.Language["Move"], 16, PPDColors.White)
            {
                Position = new Vector2(587, 21)
            });
            bottom.AddChild(new TextureString(device, Utility.Language["Decide"], 16, PPDColors.White)
            {
                Position = new Vector2(708, 21)
            });
            bottom.Position = new Vector2(0, 450 - bottom.Height + 1);
            black           = new RectangleComponent(device, resourceManager, PPDColors.Black)
            {
                RectangleHeight = 450,
                RectangleWidth  = 800
            };
            black.Alpha = 0;
            buttons     = new Button[5];
            for (int i = 0; i < buttons.Length; i++)
            {
                string text = "";
                switch (i)
                {
                case 0:
                    text = "TWEET";
                    break;

                case 1:
                    text = "REVIEW";
                    break;

                case 2:
                    text = "RETRY";
                    break;

                case 3:
                    text = "REPLAY";
                    break;

                case 4:
                    text = "RETURN";
                    break;
                }
                Vector2 pos;
                if (i >= 2)
                {
                    pos = new Vector2(500 + ((i - 2) % 3) * 100, 380);
                }
                else
                {
                    pos = new Vector2(500 + (i % 2) * 100, 340);
                }
                buttons[i] = new Button(device, resourceManager, Utility.Path, text)
                {
                    Position = pos
                };
                gridSelection.Add(pos);
                buttons[i].Selected = false;
                this.AddChild(buttons[i]);
            }
            gridSelection.Initialize();
            songname = new TextureString(device, ppdGameUtility.SongInformation.DirectoryName, 20, 500, PPDColors.White)
            {
                Position = new Vector2(35, 4)
            };
            songname.Position = new Vector2(790 - songname.JustWidth, songname.Position.Y);
            difficultstring   = new TextureString(device, ppdGameUtility.DifficultString, 24, 200, PPDColors.White)
            {
                Position    = new Vector2(35, 103),
                AllowScroll = true
            };
            difficultstring.Position = new Vector2(400 - Math.Min(200, difficultstring.Width), difficultstring.Position.Y);

            bgd = new BackGroundDisplay(device, resourceManager, "skins\\PPDSingle_BackGround.xml", "Result");

            Inputed    += GameResultScore_Inputed;
            GotFocused += GameResultScore_GotFocused;

            this.AddChild(menuRanking);
            this.AddChild(high);
            this.AddChild(difficulty);
            for (int i = 0; i < result.Length; i++)
            {
                this.AddChild(result[i]);
            }
            for (int i = 0; i < scoresmalls.Length; i++)
            {
                this.AddChild(scoresmalls[i]);
            }
            this.AddChild(scorebig);
            this.AddChild(difficultstring);
            this.AddChild(scoreboard);
            this.AddChild(songname);
            this.AddChild(top);
            this.AddChild(bottom);
            this.AddChild(bgd);

            this.InsertChild(black, 0);
        }
コード例 #26
0
ファイル: Menu.cs プロジェクト: KHCmaster/PPD
        private void ChangeSceneToMainGame(SongInformation songInfo, Difficulty difficulty, float startTime, bool useStack, bool useItem, int replayResultId)
        {
            // メインゲーム用のパラメータの準備
            var gameutility = new PPDGameUtility
            {
                SongInformation = songInfo,
                Difficulty      = difficulty,
                DifficultString = songInfo.GetDifficultyString(difficulty),
                Profile         = ProfileManager.Instance.Current,
                AutoMode        = oc.AutoMode,
                SpeedScale      = oc.SpeedScale,
                Random          = oc.Random,
                MuteSE          = oc.MuteSE,
                Connect         = oc.Connect,
                PerfectTrial    = oc.PerfectTrial,
                RivalGhost      = oc.RivalGhost,
                RivalGhostCount = oc.RivalGhostCount,
                ReplayResultId  = replayResultId
            };

            if (useItem && lm.UseItem != null && !lm.UseItem.IsUsed)
            {
                gameutility.AddItem(lm.UseItem);
                gameutility.AutoMode = AutoMode.None;
            }
            if (ssm.SelectedSongInformation is ContestSelectedSongInfo)
            {
                var contest = ssm.SelectedSongInformation as ContestSelectedSongInfo;
                gameutility.RankingUpdateFunc = contest.GetRanking;
            }
            SkinSetting.Setting.Connect         = oc.Connect;
            SkinSetting.Setting.RivalGhost      = oc.RivalGhost;
            SkinSetting.Setting.RivalGhostCount = oc.RivalGhostCount;
            var dic = new Dictionary <string, object>
            {
                { "PPDGameUtility", gameutility },
                { "GameInterface", new GameInterface(device) },
                { "GameResult", new GameResult(device) },
                { "PauseMenu", new PauseMenu(device, Utility.Path) },
                { "MarkImagePath", new MarkImagePaths() }
            };

            if (!useStack)
            {
                dic.Add("NextScene", typeof(Menu));
            }
            if (gameutility.SongInformation.StartTime != startTime)
            {
                dic.Add("StartTime", startTime);
            }
            // 最後の曲選択を残しておく
            dic.Add("CurrentRoot", ssm.CurrentRoot);
            dic.Add("CurrentLogicRoot", ssm.CurrentLogicRoot);
            dic.Add("CurrentMode", ssm.CurrentMode);
            dic.Add("SelectedIndex", ssm.SelectedIndex);
            var mainGame = new MainGame(device);

            mainGame.CannotStartPerfectTrial += mainGame_CannotStartPerfectTrial;
            mainGame.PerfectTrialError       += mainGame_PerfectTrialError;
            mainGame.PerfectTrialStart       += mainGame_PerfectTrialStart;
            SceneManager.PrepareNextScene(this, mainGame, dic, dic, useStack);

            if (useStack)
            {
                menuMovie.Stop();
            }
        }
コード例 #27
0
 public MarkManager(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, PPDGameUtility gameutility, RandomChangeManager randomChangeManager, PPDEffectManager ppdem, MarkImagePathsBase imagepathes, MainGameConfigBase config, FlowScriptManager scriptManager, Stream stream) : base(device)
 {
     InnerStruct(gameutility, resourceManager, randomChangeManager, ppdem, imagepathes, config, scriptManager);
     ReadPpdData(stream);
     CheckGroups();
     InitializeRandomChange();
 }
コード例 #28
0
 public EventManager(PPDGameUtility ppdgameutility, Stream stream)
 {
     loaddata(stream);
     InnerStruct(ppdgameutility);
 }
コード例 #29
0
ファイル: Maingame.cs プロジェクト: KHCmaster/PPD
        public override void Load()
        {
            if (!Param.ContainsKey("PPDGameUtility"))
            {
                throw new PPDException(PPDExceptionType.SkinIsNotCorrectlyImplemented);
            }
            ppdgameutility = Param["PPDGameUtility"] as PPDGameUtility;
            currentLatency = ppdgameutility.SongInformation.Latency;
            if (Param.ContainsKey("ExitOnReturn"))
            {
                exitonreturn = true;
            }
            if (Param.ContainsKey("StartTime"))
            {
                ppdgameutility.IsDebug = true;
                startTime   = (float)Param["StartTime"] - 3;
                mmStartTime = (float)Param["StartTime"];
            }
            else if (Param.ContainsKey("StartTimeEx"))
            {
                ppdgameutility.IsDebug = true;
                startTime   = (float)Param["StartTimeEx"];
                mmStartTime = (float)Param["StartTimeEx"];
            }
            else
            {
                startTime   = ppdgameutility.SongInformation.StartTime;
                mmStartTime = startTime;
            }

            black        = new PictureObject("img\\default\\black.png", 0, 0, false, ResourceManager, Device);
            black.Alpha  = 0;
            black.Hidden = true;

            string moviefile = ppdgameutility.SongInformation.MoviePath;

#if x64
            if (Path.GetExtension(moviefile) == ".mp4")
            {
                PlatformGap = 0.03f;
            }
#endif
            if (moviefile != "")
            {
                m = GameHost.GetMovie(moviefile);
                try
                {
                    if (m.Initialize() == -1)
                    {
                        throw new PPDException(PPDExceptionType.CannotOpenMovie);
                    }
                    readmoviesetting();
                    initialized = true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    initialized = false;
                    ReturnToMenu();
                    return;
                }
            }
            else
            {
                MessageBox.Show("No moviefile");
                black.Hidden = false;
                if (exitonreturn)
                {
                    Application.Exit();
                }
                else
                {
                    ReturnToMenu();
                    return;
                }
            }
            keychange = new int[(int)ButtonType.Start];
            for (int i = 0; i < keychange.Length; i++)
            {
                keychange[i] = i;
            }
            if (ppdgameutility.Random)
            {
                randomchange();
            }
            readprofile();
            hm                  = new HoldManager(Device, ResourceManager);
            hm.ScoreGained     += new HoldManager.GainScoreEventHandler(hm_ScoreGained);
            ppdem               = new PPDEffectManager(Device, ResourceManager);
            km                  = new KasiManager(ppdgameutility);
            km.KasiChanged     += new KasiManager.KasiChangeEventHandler(km_KasiChanged);
            cgi                 = GameHost.GetCGameInterface();
            cgi.PPDGameUtility  = ppdgameutility;
            cgi.ResourceManager = ResourceManager;
            cgi.Load();
            sm = new SoundManager(Sound as ExSound, ppdgameutility);
            if (ppdgameutility.SongInformation.IsOld)
            {
                em = new EventManager(ppdgameutility);
                mm = new MarkManager(Device, em, ppdgameutility, keychange, ppdem, GameHost.GetMarkImagePath(), ResourceManager);
            }
            else
            {
                string              path   = Path.Combine(ppdgameutility.SongInformation.DirectoryPath, DifficultyUtility.ConvertDifficulty(ppdgameutility.Difficulty) + ".ppd");
                PackReader          reader = new PackReader(path);
                PPDPackStreamReader ppdpsr = reader.Read("evd");
                em = new EventManager(ppdgameutility, ppdpsr);
                ppdpsr.Close();
                ppdpsr = reader.Read("ppd");
                mm     = new MarkManager(Device, em, ppdgameutility, keychange, ppdem, GameHost.GetMarkImagePath(), ppdpsr, ResourceManager);
                ppdpsr.Close();
                reader.Close();
            }
            grm = new GameResultManager();
            gr  = GameHost.GetGameResult();
            gr.PPDGameUtility  = ppdgameutility;
            gr.ResourceManager = ResourceManager;
            gr.TweetManager    = this;
            gr.Load();
            pd = GameHost.GetPauseMenu();
            pd.PPDGameUtility  = ppdgameutility;
            pd.ResourceManager = ResourceManager;
            pd.Load();
            pd.Resumed           += new EventHandler(pd_Resumed);
            pd.Retryed           += new EventHandler(pd_Retryed);
            pd.Returned          += new EventHandler(pd_Returned);
            pd.LatencyChanged    += new ChangeLatencyEventHandler(pd_LatencyChanged);
            gr.Retryed           += new EventHandler(this.Retry);
            gr.Returned          += new EventHandler(this.Return);
            mm.ChangeCombo       += new MarkManager.ChangeComboHandler(mm_ChangeCombo);
            mm.PlaySound         += new MarkManager.SpecialSoundHandler(this.SpecialPlaySound);
            mm.StopSound         += new MarkManager.SpecialSoundHandler(this.SpecialStopSound);
            mm.EvaluateCount     += new MarkManager.EvaluateCountHandler(this.EvaluateCount);
            mm.PressingButton    += new MarkManager.PressingButtonHandler(mm_PressingButton);
            em.ChangeMovieVolume += new EventManager.VolumeHandler(ChangeMovieVolume);
            //seek
            mm.Seek(mmStartTime);
            em.Seek(startTime > 0 ? startTime : 0);
            sm.Seek(startTime);
            km.Seek(startTime);
            if (m != null && m.Initialized)
            {
                m.Play();
                m.Pause();
                m.Seek(startTime);
            }
            if (startTime < 0)
            {
                waitingmoviestart = true;
                lasttime          = Win32API.timeGetTime();
            }
            else
            {
                if (m != null && m.Initialized)
                {
                    m.Play();
                }
            }

            this.AddChild(black);
        }
コード例 #30
0
 public SoundManager(ExSound sou, PPDGameUtility ppdgameutility)
 {
     this.sou = sou;
     LoadSoundSet(ppdgameutility.SongInformation.DirectoryPath);
     LoadSoundChangeData(ppdgameutility.SongInformation.DirectoryPath, ppdgameutility.Difficulty);
 }