Exemplo n.º 1
0
        public override void RestartLevel(bool updateSpeed)
        {
            if (updateSpeed)
            {
                MainGame.Inst.Profile.SingleplayerGameSpeed = GameSpeedMode;
                MainGame.Inst.SaveProfile();
            }

            GDOwner.SetLevelScreen(Blueprint, Difficulty, WorldBlueprint);
        }
Exemplo n.º 2
0
        private void ChangeObstacleType()
        {
            ObstacleType = (ObstacleStubType)(((int)ObstacleType + 1) % 6);
            if (GDOwner.CanInsertObstacleStub(Position, ObstacleType, Width, Height, Rotation, this) == null)
            {
                Width    = GDConstants.TILE_WIDTH / 2f;
                Height   = GDConstants.TILE_WIDTH / 2f;
                Rotation = 0;
            }

            GDOwner.GDHUD.AttrPanel.Recreate(this);
        }
Exemplo n.º 3
0
        private void ChangeRot()
        {
            var idxCurr = ROTS.IndexOf(Normal);

            for (int i = 1; i < ROTS.Length; i++)
            {
                var idxTest = (idxCurr + i) % ROTS.Length;
                if (GDOwner.CanInsertPortalStub(Position, Length, ROTS[idxTest], this) != null)
                {
                    Normal = ROTS[idxTest];
                    return;
                }
            }
        }
Exemplo n.º 4
0
        private void ChangeScale()
        {
            var idxCurr = SCALES.IndexOf(Scale);

            for (int i = 1; i < SCALES.Length; i++)
            {
                var idxTest = (idxCurr + i) % SCALES.Length;
                if (GDOwner.CanInsertCannonStub(Position, SCALES[idxTest], this) != null)
                {
                    Scale = SCALES[idxTest];
                    return;
                }
            }
        }
Exemplo n.º 5
0
        private void ChangeRot()
        {
            var idxCurr = ROTS.IndexOf(Rotation);

            for (int i = 1; i < ROTS.Length; i++)
            {
                var idxTest = (idxCurr + i) % ROTS.Length;
                if (GDOwner.CanInsertObstacleStub(Position, ObstacleType, Width, Height, ROTS[idxTest], this) != null)
                {
                    Rotation = ROTS[idxTest];
                    return;
                }
            }
        }
Exemplo n.º 6
0
        private void ChangeDiameter()
        {
            var newsize = ((FloatMath.Round(Width / (GDConstants.TILE_WIDTH / 2f))) % 16 + 1) * (GDConstants.TILE_WIDTH / 2f);

            if (GDOwner.CanInsertObstacleStub(Position, ObstacleType, newsize, newsize, Rotation, this) != null)
            {
                Width = Height = newsize;
                return;
            }
            else
            {
                Width = Height = (GDConstants.TILE_WIDTH / 2f);
                return;
            }
        }
Exemplo n.º 7
0
        private void ChangeHeight()
        {
            var newheight = FloatMath.Round(Height / (GDConstants.TILE_WIDTH / 2f)) * (GDConstants.TILE_WIDTH / 2f);

            newheight += (GDConstants.TILE_WIDTH / 2f);

            if (newheight > GDOwner.LevelData.Height * GDConstants.TILE_WIDTH + 4 * GDConstants.TILE_WIDTH)
            {
                newheight = (GDConstants.TILE_WIDTH / 2f);
            }

            if (GDOwner.CanInsertObstacleStub(Position, ObstacleType, Width, newheight, Rotation, this) == null)
            {
                newheight = (GDConstants.TILE_WIDTH / 2f);
            }

            Height = newheight;
        }
Exemplo n.º 8
0
        private void ChangeWidth()
        {
            var newwidth = FloatMath.Round(Width / (GDConstants.TILE_WIDTH / 2f)) * (GDConstants.TILE_WIDTH / 2f);

            newwidth += (GDConstants.TILE_WIDTH / 2f);

            if (newwidth > GDOwner.LevelData.Width * GDConstants.TILE_WIDTH + 4 * GDConstants.TILE_WIDTH)
            {
                newwidth = (GDConstants.TILE_WIDTH / 2f);
            }

            if (GDOwner.CanInsertObstacleStub(Position, ObstacleType, newwidth, Height, Rotation, this) == null)
            {
                newwidth = (GDConstants.TILE_WIDTH / 2f);
            }

            Width = newwidth;
        }
Exemplo n.º 9
0
        private void ChangeLen()
        {
            float nextlen = (GDConstants.TILE_WIDTH / 2f) * (FloatMath.Round(Length / (GDConstants.TILE_WIDTH / 2f)) + 1);

            if (nextlen > GDConstants.TILE_WIDTH * 4)
            {
                nextlen = (GDConstants.TILE_WIDTH / 2f);
            }

            if (GDOwner.CanInsertPortalStub(Position, nextlen, Normal, this) != null)
            {
                Length = nextlen;
            }
            else
            {
                Length = (GDConstants.TILE_WIDTH / 2f);
            }
        }
Exemplo n.º 10
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)
            {
                if (!GDOwner.Profile.GetOrAddCustomLevelData(Blueprint.CustomMeta_LevelID).HasCompletedExact(Difficulty))
                {
                    GDOwner.Profile.SetCustomLevelCompleted(Blueprint.CustomMeta_LevelID, Difficulty, ctime);
                }

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

                EndGameConvert(winner);
            }
            else
            {
                ShowScorePanel(Blueprint, GDOwner.Profile, null, false, 0, ctime);

                MainGame.Inst.GDSound.PlayEffectGameOver();

                EndGameConvert(winner);
            }

            foreach (var cannon in Entities.Enumerate().OfType <Cannon>())
            {
                cannon.ForceUpdateController();
            }
        }
Exemplo n.º 11
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();
            }
        }
Exemplo n.º 12
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();
            }
        }
Exemplo n.º 13
0
 public override void RestartLevel(bool updateSpeed)
 {
     GDOwner.SetEditorUploadLevel(Blueprint, SCCMData, false, updateSpeed ? GameSpeedMode : _lastSpeed);
 }
Exemplo n.º 14
0
 public override void ReplayLevel(FractionDifficulty diff)
 {
     GDOwner.SetTutorialLevelScreen();
 }
Exemplo n.º 15
0
 public override void RestartLevel(bool updateSpeed)
 {
     GDOwner.SetTutorialLevelScreen();
 }
Exemplo n.º 16
0
 public override void ReplayLevel(FractionDifficulty diff)
 {
     GDOwner.SetEditorUploadLevel(Blueprint, SCCMData, false, GameSpeedMode);
 }
Exemplo n.º 17
0
 public override void RestartLevel()
 {
     GDOwner.SetTutorialLevelScreen();
 }
Exemplo n.º 18
0
 public override void RestartLevel(bool updateSpeed)
 {
     GDOwner.SetEditorTestLevel(Blueprint, Difficulty, SCCMData, updateSpeed ? GameSpeedMode : _lastSpeed);
 }
Exemplo n.º 19
0
 public override void ReplayLevel(FractionDifficulty diff)
 {
     GDOwner.SetLevelScreen(Blueprint, diff, WorldBlueprint);
 }
Exemplo n.º 20
0
 public override void ReplayLevel(FractionDifficulty diff)
 {
     GDOwner.SetCustomLevelScreen(Blueprint, diff);
 }
Exemplo n.º 21
0
 public override void ReplayLevel(FractionDifficulty diff)
 {
     GDOwner.SetEditorTestLevel(Blueprint, Difficulty, SCCMData, GameSpeedMode);
 }
Exemplo n.º 22
0
 public override void RestartLevel()
 {
     GDOwner.SetLevelScreen(Blueprint, Difficulty, WorldBlueprint, GameSpeedMode);
 }