Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
0
        private void EndGame(bool playerWon, Fraction winner)
        {
            MainGame.Inst.Profile.SingleplayerGameSpeed = GameSpeedMode;
            MainGame.Inst.SaveProfile();

            HasFinished = true;
            PlayerWon   = playerWon;

            var ctime = (int)(LevelTime * 1000);

            if (playerWon)
            {
                int scoreGain = 0;
                HashSet <FractionDifficulty> gains = new HashSet <FractionDifficulty>();

                for (FractionDifficulty diff = FractionDifficulty.DIFF_0; diff <= Difficulty; diff++)
                {
                    if (!GDOwner.Profile.GetLevelData(Blueprint.UniqueID).HasCompletedOrBetter(diff))
                    {
                        scoreGain += FractionDifficultyHelper.GetScore(diff);
                        gains.Add(diff);
                    }
                }

                {
                    if (!GDOwner.Profile.GetLevelData(Blueprint.UniqueID).HasCompletedExact(Difficulty))
                    {
                        GDOwner.Profile.SetCompleted(Blueprint.UniqueID, Difficulty, ctime, true);
                    }
                    var localdata = GDOwner.Profile.LevelData[Blueprint.UniqueID].Data[Difficulty];

                    if (ctime < localdata.BestTime)
                    {
                        // update PB
                        GDOwner.Profile.SetCompleted(Blueprint.UniqueID, Difficulty, ctime, true);
                    }

                    // Fake the online data until next sync
                    localdata.GlobalCompletionCount++;
                    if (ctime < localdata.GlobalBestTime || localdata.GlobalBestTime == -1)
                    {
                        if (localdata.GlobalBestTime != -1)
                        {
                            // WURLD RECARD !!
                            // Dispatch is trick to put in infront of score panel ...
                            MainGame.Inst.DispatchBeginInvoke(() => { AchievementPopup.Show(L10N.T(L10NImpl.STR_ACH_WORLDRECORD)); });
                        }

                        localdata.GlobalBestTime   = ctime;
                        localdata.GlobalBestUserID = GDOwner.Profile.OnlineUserID;
                    }
                }

                GDOwner.SaveProfile();
                ShowScorePanel(Blueprint, GDOwner.Profile, gains, true, scoreGain, ctime);
                MainGame.Inst.GDSound.PlayEffectGameWon();

                EndGameConvert(winner);
            }
            else
            {
                ShowScorePanel(Blueprint, GDOwner.Profile, new HashSet <FractionDifficulty>(), false, 0, ctime);

                MainGame.Inst.GDSound.PlayEffectGameOver();

                EndGameConvert(winner);
            }

            foreach (var cannon in Entities.Enumerate().OfType <Cannon>())
            {
                cannon.ForceUpdateController();
            }
        }
Esempio n. 3
0
        private void EndGame(bool playerWon, Fraction winner)
        {
            HasFinished = true;
            PlayerWon   = playerWon;

            var ctime = (int)(LevelTime * 1000);

            if (playerWon)
            {
                int scoreGain = 0;
                HashSet <FractionDifficulty> gains = new HashSet <FractionDifficulty>();

                for (FractionDifficulty diff = FractionDifficulty.DIFF_0; diff <= Difficulty; diff++)
                {
                    if (!GDOwner.Profile.GetLevelData(Blueprint.UniqueID).HasCompletedOrBetter(diff))
                    {
                        scoreGain += FractionDifficultyHelper.GetScore(diff);
                        gains.Add(diff);
                    }
                }

                {
                    if (!GDOwner.Profile.GetLevelData(Blueprint.UniqueID).HasCompletedExact(Difficulty))
                    {
                        GDOwner.Profile.SetCompleted(Blueprint.UniqueID, Difficulty, ctime, true);
                    }
                    var localdata = GDOwner.Profile.LevelData[Blueprint.UniqueID].Data[Difficulty];

                    if (ctime < localdata.BestTime)
                    {
                        // update PB
                        GDOwner.Profile.SetCompleted(Blueprint.UniqueID, Difficulty, ctime, true);
                    }

                    // Fake the online data until next sync
                    localdata.GlobalCompletionCount++;
                    if (ctime < localdata.GlobalBestTime || localdata.GlobalBestTime == -1)
                    {
                        localdata.GlobalBestTime   = ctime;
                        localdata.GlobalBestUserID = GDOwner.Profile.OnlineUserID;
                    }
                }

                GDOwner.SaveProfile();
                ShowScorePanel(Blueprint, GDOwner.Profile, gains, true, scoreGain, ctime);
                MainGame.Inst.GDSound.PlayEffectGameWon();

                EndGameConvert(winner);
            }
            else
            {
                ShowScorePanel(Blueprint, GDOwner.Profile, new HashSet <FractionDifficulty>(), false, 0, ctime);

                MainGame.Inst.GDSound.PlayEffectGameOver();

                EndGameConvert(winner);
            }

            foreach (var cannon in Entities.Enumerate().OfType <Cannon>())
            {
                cannon.ForceUpdateController();
            }
        }