public object Create(string name, string difficulte)
        {
            EDifficulty dif = EDifficulty.Facile;

            // mapping difficulte
            switch (difficulte)
            {
            case "facile": dif = EDifficulty.Facile; break;

            case "moyen": dif = EDifficulty.Moyen; break;

            case "difficile": dif = EDifficulty.Difficile; break;

            case "hardcore": dif = EDifficulty.Hardcore; break;
            }

            var partie = game.Initialise(name, dif);


            this._context.Parties.Add(partie);
            this._context.SaveChanges();

            return(new
            {
                id = partie.Id,
                name = partie.Name,
                nbMissiles = partie.NbMissiles,
                date = partie.Date,
                grid = partie.Grid.Select(c => (int)c).ToArray()
            });
        }
Beispiel #2
0
        private static string ShuffleMeAnOperationSon(Modifier modifier, EDifficulty difficulty)
        {
            var list           = modifier.Operators;
            var mychosenNumber = list[rndOperation.Next(0, list.Count)];

            Tuple <int, int> myNumbers = ShuffleMeANumberSon(difficulty);

            switch (mychosenNumber)
            {
            case 1:
                return($"{myNumbers.Item1}+{myNumbers.Item2}");

            case 2:
                return($"{myNumbers.Item1}-{myNumbers.Item2}");

            case 3:
                return($"{myNumbers.Item1}*{myNumbers.Item2}");

            case 4:
                return($"{myNumbers.Item1}/{myNumbers.Item2}");

            default:
                return($"{myNumbers.Item1}+{myNumbers.Item2}");
            }
        }
Beispiel #3
0
        public OptionsMenuScreen()
            : base("Options")
        {
            _sound = SettingsManager.Instance.Sound;
            _difficulty = SettingsManager.Instance.Difficulty;
            _debug = SettingsManager.Instance.Debug;

            _soundMenuEntry = new MenuEntry(string.Empty);
            _debugMenuEntry = new MenuEntry(string.Empty);
            _difficultyMenuEntry = new MenuEntry(string.Empty);
            _controlsMenuEntry = new MenuEntry("Control Settings");

            SetMenuEntryText();

            var backMenuEntry = new MenuEntry("Back");

            _soundMenuEntry.Entered += SoundMenuEntryEntered;
            _debugMenuEntry.Entered += DebugEntryEntered;
            _difficultyMenuEntry.Entered += DifficultyMenuEntryEntered;
            _controlsMenuEntry.Entered += ControlsMenuEntryEntryEntered;

            backMenuEntry.Entered += OnCancel;

            MenuEntries.Add(_soundMenuEntry);
            MenuEntries.Add(_debugMenuEntry);
            MenuEntries.Add(_difficultyMenuEntry);
            MenuEntries.Add(_controlsMenuEntry);
            MenuEntries.Add(backMenuEntry);
        }
        protected override System.Collections.IEnumerator OnInitializeRegisterSelf()
        {
            Mgr.Instance.RegisterModule(this);
            Debug.Log("Create PropertyManager");
            yield return(BrickMgrM.WaitModule <ILoaderTag>());

            //初始化数据
            plusCount.Init(100, PlayerPrefs.GetInt(PlayerPrefKey.PlusCount, 999));
            multiplyCount.Init(100, PlayerPrefs.GetInt(PlayerPrefKey.MultiplyCount, 999));
            // HealthCount.Init(3);
            //
            Difficulty = (EDifficulty)PlayerPrefs.GetInt(PlayerPrefKey.Difiicuilty, 1);
            Level      = PlayerPrefs.GetInt(PlayerPrefKey.Level, 1);

            //改变生命
            MessageBroker.Default.Receive <PropTag_ModifyHealth>().Where(x => x.isInit == false).Subscribe(x => OnModifyHealth(x.value)).AddTo(this);
            //改变plus
            MessageBroker.Default.Receive <PropTag_ModifyPlusCount>().Subscribe(x => OnModifyPlus(x.value)).AddTo(this);
            //改变multiply
            MessageBroker.Default.Receive <PropTag_ModifyMultiplyCount>().Subscribe(x => OnModufyMultiply(x.value)).AddTo(this);
            //改变slider size
            MessageBroker.Default.Receive <PropTag_ModifySliderSize>().Where(x => x.isInit == false).Subscribe(x => OnModifySliderSize(x.value)).AddTo(this);
            //游戏开始
            MessageBroker.Default.Receive <GameTag_GameStart>().Subscribe(__ => OnGameStart()).AddTo(this);
            //退出游戏
            MessageBroker.Default.Receive <GameTag_QuitGame>().Subscribe(__ => OnGameEnd()).AddTo(this);
            //游戏结束
            MessageBroker.Default.Receive <GameTag_GameEnd>().Subscribe(__ => OnGameEnd()).AddTo(this);
            //回到菜单
            MessageBroker.Default.Receive <GameTag_BackToMenu>().Subscribe(__ => OnGameEnd()).AddTo(this);
        }
    private void ShowHighscores(SongMeta songMeta, EDifficulty difficulty)
    {
        currentDifficulty       = difficulty;
        difficultyText.text     = TranslationManager.GetTranslation(R.Messages.difficulty) + ": " + difficulty.GetTranslatedName();
        titleAndArtistText.text = $"{songMeta.Title} - {songMeta.Artist}";

        LocalStatistic       localStatistic = statistics.GetLocalStats(songMeta);
        List <SongStatistic> songStatistics = localStatistic?.StatsEntries?.SongStatistics?
                                              .Where(it => it.Difficulty == difficulty).ToList();

        if (songStatistics.IsNullOrEmpty())
        {
            songStatistics = new List <SongStatistic>();
        }
        songStatistics.Sort(new CompareBySongScoreDescending());
        List <SongStatistic> topSongStatistics = songStatistics.Take(highscoreEntries.Count).ToList();

        for (int i = 0; i < highscoreEntries.Count; i++)
        {
            if (i < topSongStatistics.Count)
            {
                highscoreEntries[i].ShowByDisplay();
                FillHighscoreEntry(highscoreEntries[i], topSongStatistics[i], i);
            }
            else
            {
                highscoreEntries[i].HideByDisplay();
            }
        }

        // update "next difficulty button" text
        UpdateTranslation();
    }
Beispiel #6
0
 public void Init(bool isOn, int level, EDifficulty difficulty)
 {
     if (image == null)
     {
         image = this.GetComponent <Image>();
     }
     if (button == null)
     {
         button = this.GetComponent <Button>();
     }
     this.isOn       = isOn;
     this.difficulty = difficulty;
     this.level      = level;
     if (isOn)
     {
         button.interactable = true;
         this.image.color    = new Color32(80, 140, 90, 255);
         // image.DOColor(new Color32(0, 0, 0, 255), 1).From();
     }
     else
     {
         button.interactable = false;
         this.image.color    = new Color32(90, 90, 90, 255);
         // image.DOColor(new Color32(255, 255, 255, 255), 1).From();
     }
 }
Beispiel #7
0
    private void ShowHighscores(SongMeta songMeta, EDifficulty difficulty)
    {
        currentDifficulty       = difficulty;
        difficultyText.text     = i18nManager.GetTranslation(I18NKeys.difficulty) + ": " + difficulty.GetTranslatedName();
        titleAndArtistText.text = $"{songMeta.Title} - {songMeta.Artist}";

        LocalStatistic       localStatistic = statistics.GetLocalStats(songMeta);
        List <SongStatistic> songStatistics = localStatistic?.StatsEntries?.SongStatistics?
                                              .Where(it => it.Difficulty == difficulty).ToList();

        if (songStatistics.IsNullOrEmpty())
        {
            songStatistics = new List <SongStatistic>();
        }
        songStatistics.Sort(new CompareBySongScoreDescending());
        List <SongStatistic> topSongStatistics = songStatistics.Take(topEntries.Length).ToList();

        for (int i = 0; i < topEntries.Length; i++)
        {
            if (i < topSongStatistics.Count)
            {
                ShowHighscore(topEntries[i], topSongStatistics[i], i);
                topEntries[i].gameObject.SetActive(true);
            }
            else
            {
                topEntries[i].gameObject.SetActive(false);
            }
        }
    }
Beispiel #8
0
 public SongStatistic(string playerName, EDifficulty difficulty, int score)
 {
     this.PlayerName = playerName;
     this.Difficulty = difficulty;
     this.Score      = score;
     this.DateTime   = DateTime.Now;
 }
Beispiel #9
0
    public void SetGameDifficulty(EDifficulty difficulty)
    {
        VeryEasy_Text.fontStyle = FontStyle.Normal;
        Easy_Text.fontStyle     = FontStyle.Normal;
        Hard_Text.fontStyle     = FontStyle.Normal;
        VeryHard_Text.fontStyle = FontStyle.Normal;

        CurrentGameDifficulty = difficulty;

        switch (CurrentGameDifficulty)
        {
        case EDifficulty.VeryEasy:
            VeryEasy_Text.fontStyle = FontStyle.Bold;
            break;

        case EDifficulty.Easy:
            Easy_Text.fontStyle = FontStyle.Bold;
            break;

        case EDifficulty.Hard:
            Hard_Text.fontStyle = FontStyle.Bold;
            break;

        case EDifficulty.VeryHard:
            VeryHard_Text.fontStyle = FontStyle.Bold;
            break;

        default:
            Debug.Log("Invalid Difficulty.");
            break;
        }
    }
Beispiel #10
0
        //游戏开始,1和2都对应游戏scene,通过切换销毁物体
        public void GameStart(int level, EDifficulty difficulty)
        {
            currentLevelIndex = level;

            if (sceneIndex != 1)
            {
                LoadSceneByNum(1).Last().Subscribe(__ =>
                {
                    MessageBroker.Default.Publish(new GameTag_GameStart(level, difficulty));
                    sceneIndex             = 1;
                    this.currentDifficulty = difficulty;
                    // levelIndex++;
                });
            }
            else
            {
                LoadSceneByNum(2).Last().Subscribe(__ =>
                {
                    MessageBroker.Default.Publish(new GameTag_GameStart(level, difficulty));
                    sceneIndex             = 2;
                    this.currentDifficulty = difficulty;
                    // levelIndex++;
                });
            }
        }
 private void GetSceneParameter()
 {
     Difficulty = SceneParameter.Difficulty;
     ReadCircles(SceneParameter.BeatmapFilePath);
     ChangePlayerModel(SceneParameter.PlayerModel);
     LoadSong(SceneParameter.MP3FilePath);
 }
Beispiel #12
0
 /// <summary>
 /// 加载level slot
 /// </summary>
 /// <param name="count">图标,解锁或未解锁</param>
 /// <param name="level"></param>
 /// <param name="difficulty"></param>
 private void PreloadLevelSlot(int count, int level, EDifficulty difficulty)
 {
     // ClearLevelSlot();
     if (showLevelStream != null)
     {
         showLevelStream.Dispose();
     }
     showLevelStream = Observable.Interval(System.TimeSpan.FromMilliseconds(10))
                       .Take(count)
                       .Delay(System.TimeSpan.FromMilliseconds(250))
                       .Subscribe(levelCount =>
     {
         if (levelCount < level)
         {
             pool.RentAsync().Subscribe(x =>
             {
                 x.Init(true, (int)levelCount, difficulty);
                 slotsList.Add(x);
             });
         }
         else
         {
             pool.RentAsync().Subscribe(x =>
             {
                 x.Init(false, (int)levelCount, difficulty);
                 slotsList.Add(x);
             });
         }
     }).AddTo(this);
 }
Beispiel #13
0
        private void OnGeneratePuzzle(EDifficulty difficulty)
        {
            // memorize difficulty
            Difficulty = difficulty;

            // Close dialog
            CommitCommand.Execute();
        }
    private EDifficulty GetNextDifficulty(EDifficulty difficulty, int direction)
    {
        int         currentDifficultyIndex = difficulty.GetIndex();
        int         nextDifficultyIndex    = NumberUtils.Mod(currentDifficultyIndex + direction, EnumUtils.GetValuesAsList <EDifficulty>().Count);
        EDifficulty nextDifficulty         = EnumUtils.GetValuesAsList <EDifficulty>()
                                             .FirstOrDefault(it => it.GetIndex() == nextDifficultyIndex);

        return(nextDifficulty);
    }
    public void UpdateTranslation()
    {
        sceneTitle.text     = TranslationManager.GetTranslation(R.Messages.highscoreScene_title);
        continueButton.text = TranslationManager.GetTranslation(R.Messages.continue_);

        EDifficulty nextDifficulty = GetNextDifficulty(currentDifficulty, 1);

        nextItemButton.Q <Label>().text = nextDifficulty.GetTranslatedName();
    }
Beispiel #16
0
 public void CheckDifficultyTime()
 {
     if (((int)currentDifficulty < sizeof(EDifficulty)) && totTime > difficultyTimeChanges)
     {
         currentDifficulty = (EDifficulty)((int)currentDifficulty + 1);
         UpdateGameDifficulty();
         currentLevel.text = "" + ((int)currentDifficulty);
     }
 }
Beispiel #17
0
    public void ShowNextDifficulty(int direction)
    {
        int         currentDifficutlyIndex = currentDifficulty.GetIndex();
        int         nextDifficultyIndex    = NumberUtils.Mod(currentDifficutlyIndex + direction, EnumUtils.GetValuesAsList <EDifficulty>().Count);
        EDifficulty nextDifficulty         = EnumUtils.GetValuesAsList <EDifficulty>()
                                             .Where(it => it.GetIndex() == nextDifficultyIndex).FirstOrDefault();

        ShowHighscores(sceneData.SongMeta, nextDifficulty);
    }
Beispiel #18
0
 public void SelectStageInList(int pos)
 {
     if (m_stageList.Length > pos)
     {
         g_stageNumber = m_stageList[pos].StageNumber;
         g_difficulty  = m_stageList[pos].Difficulty;
         g_rotatable   = m_stageList[pos].Rotatable;
         g_reversible  = m_stageList[pos].Reversible;
     }
 }
Beispiel #19
0
 public void ResetTimer()
 {
     currentTime       = maxTime;
     currentDifficulty = EDifficulty.Beginner;
     totTime           = 0f;
     currentXScale     = initXScale;
     UpdateBar();
     UpdateGameDifficulty();
     currentLevel.text = "" + ((int)currentDifficulty);
 }
Beispiel #20
0
        //
        // Generate a puzzle of a specific difficulty
        //
        public void OnGeneratePuzzle(EDifficulty difficulty)
        {
            puzzle = creator.GeneratePuzzle(difficulty);

            Check.SetCanExecute(true);
            Hint.SetCanExecute(true);
            Query.SetCanExecute(true);

            OnReset();
        }
Beispiel #21
0
 public void ShowLevelSlots(EDifficulty difficulty)
 {
     if (difficulty == EDifficulty.Eazy)
     {
         ShowLevelSlotsCore(100, 11, difficulty);
     }
     else
     {
         ShowLevelSlotsCore(100, 5, difficulty);
     }
 }
Beispiel #22
0
    void Start()
    {
        if (EDifficulty.max != StaticDatas.eCurrentDifficulty)
        {
            Difficulty = StaticDatas.eCurrentDifficulty;
        }

        gameGrid = gameObject.GetComponent <GameGrid>();

        GenerateNewGrid();
    }
Beispiel #23
0
 public SaveGameMeta(DateTime p_time, TimeSpan p_playTime, Int32 p_saveNumber, ESaveGameType p_type, EDifficulty p_difficulty)
 {
     Name         = String.Empty;
     SlotId       = 0;
     m_time       = p_time;
     m_playTime   = p_playTime;
     m_loaded     = false;
     m_saveNumber = p_saveNumber;
     m_type       = p_type;
     m_difficulty = p_difficulty;
 }
Beispiel #24
0
    public void RecordSongFinished(SongMeta songMeta, string playerName, EDifficulty difficulty, int score)
    {
        Debug.Log("Recording song stats for " + playerName);
        SongStatistic statsObject = new SongStatistic(playerName, difficulty, score);

        LocalStatistics.GetOrInitialize(songMeta.SongHash).UpdateSongFinished(statsObject);

        UpdateTopScores(songMeta, statsObject);

        IsDirty = true;
    }
Beispiel #25
0
    public void RecordSongFinished(SongMeta songMeta, string playerName, EDifficulty difficulty, int score)
    {
        Debug.Log("Recording song stats for " + playerName);
        SongStatistic statsObject = new SongStatistic(playerName, difficulty, score);

        GetOrInitialize <LocalStatistic>(LocalStatistics, songMeta.SongHash).UpdateSongFinished(statsObject);

        UpdateTopScores(songMeta, statsObject);

        TriggerDatabaseWrite();
    }
Beispiel #26
0
    public static int GetIndex(this EDifficulty difficulty)
    {
        switch (difficulty)
        {
        case EDifficulty.Easy: return(0);

        case EDifficulty.Medium: return(1);

        case EDifficulty.Hard: return(2);

        default:
            throw new UnityException("Unhandled difficulty: " + difficulty);
        }
    }
Beispiel #27
0
    private static string GetI18NCode(this EDifficulty difficulty)
    {
        switch (difficulty)
        {
        case EDifficulty.Easy: return(I18NKeys.difficulty_easy);

        case EDifficulty.Medium: return(I18NKeys.difficulty_medium);

        case EDifficulty.Hard: return(I18NKeys.difficulty_hard);

        default:
            throw new UnityException("Unhandled difficulty: " + difficulty);
        }
    }
Beispiel #28
0
 public SkillModel(
     string name,
     EStatAttribute attributeType,
     EDifficulty difficulty,
     string description,
     List <SkillModel> prerequisite = null)
 {
     this.Name         = name;
     this.Difficulty   = difficulty;
     this.Attribute    = attributeType;
     this.Prerequisite = prerequisite;
     this.Description  = description;
     this.BaseModifier = SetModifier(difficulty);
 }
Beispiel #29
0
 private void ShowLevelSlotsCore(int count, int level, EDifficulty difficulty)
 {
     for (int i = 1; i <= 100; i++)
     {
         if (i < level)
         {
             slotsList[i - 1].Init(true, (int)i, difficulty);
         }
         else
         {
             slotsList[i - 1].Init(false, (int)i, difficulty);
         }
     }
 }
Beispiel #30
0
        private IEnumerator LoadLevel(int level, EDifficulty difficulty)
        {
            //bgTile
            if (bgTile != null)
            {
                BrickMgrM.LoaderManager.ReleaseObject(bgTile.gameObject);
            }
            var bgStream = BrickMgrM.LoaderManager.InstantiatePrefabByPath <GameObject>(AssetPath.LevelBackGround, null).Last().Do(x =>
            {
                bgTile = x;
            });

            yield return(bgStream.ToYieldInstruction().AddTo(this));

            //levelTile
            if (LevelTile != null)
            {
                BrickMgrM.LoaderManager.ReleaseObject(LevelTile.gameObject);
            }
            var path = "";

            switch (difficulty)
            {
            case EDifficulty.Eazy:
                path = $"{AssetPath.EasyLevel}{level}";
                break;

            case EDifficulty.Hard:
                path = $"{AssetPath.HardLevel}{level}";
                break;
            }
            Debug.Log(path);
            var levelStram = BrickMgrM.LoaderManager.InstantiatePrefabByPath <GameObject>(path).Last().Do(x =>
            {
                x.transform.parent = bgTile.transform;
                LevelTile          = x.GetComponent <Tilemap>();
                // var ballPool = (BrickMgrM.PoolModule as PoolManager).GetComponentInChildren<BallEntityPool>();
                // if (ballPool != null)
                // {
                //     ballPool.levelTile = LevelTile;
                // }
            });

            yield return(levelStram.ToYieldInstruction().AddTo(this));

            BoundsInt bounds = LevelTile.cellBounds;

            TileBase[] allTiles = LevelTile.GetTilesBlock(bounds);
            brickTileList = allTiles.Where(x => x != null && x.name != _wall.name).ToList();
        }
Beispiel #31
0
 public void CpyParamData(StageParam rhs)
 {
     this.m_name      = rhs.m_name;
     this.StageNumber = rhs.StageNumber;
     //this.StageName = rhs.StageName; name exist
     this.m_price           = rhs.m_price;
     this.Difficulty        = rhs.Difficulty;
     this.Width             = rhs.Width;
     this.Height            = rhs.Height;
     this.AvgTime           = rhs.AvgTime;
     this.Rotatable         = rhs.Rotatable;
     this.Reversible        = rhs.Reversible;
     this.ShuffleComplexity = rhs.ShuffleComplexity;
     this.ShuffleTime       = rhs.ShuffleTime;
 }
Beispiel #32
0
 /// <summary>
 /// Creates a map only for test
 /// </summary>
 /// <param name="difficulty">Difficulty.</param>
 public Map(EDifficulty difficulty)
 {
     switch (difficulty)
     {
     case EDifficulty.Easy:
         GenerateEasyMap ();
         break;
     case EDifficulty.Medium:
         GenerateMediumMap ();
         break;
     case EDifficulty.Hard:
         GenerateHardMap ();
         break;
     }
     GenerateShops ();
 }
Beispiel #33
0
        /// <summary>
        /// Zapisuje wynik do pliku z najlepszymi wynikami.
        /// </summary>
        /// <param name="playerName">Imię gracza</param>
        /// <param name="points">Liczba zebranych punktów</param>
        /// <param name="difficulty">Poziom trudności</param>
        public static void AddHighScore(string playerName, int points, EDifficulty difficulty)
        {
            var highScoresData = LoadHighScores();
            highScoresData.HighScores.Add(new HighScore()
            {
                Player = playerName,
                Points = points,
                Difficulty = difficulty
            });

            var scoresList = new List<HighScore>(highScoresData.HighScores.OrderByDescending(x => x.Points).Take(MaxHighScores));// as SerializableDictionary<string, int>;

            highScoresData.HighScores.Clear();
            highScoresData.HighScores.AddRange(scoresList);

            highScoresData.Serialize(GetHighScoresFilePath());
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            selectedDifficulty = EDifficulty.Easy;

            #region select difficulty
            difficulties = new Dictionary<int, EDifficulty>();

            actionDifficulty = new UIActionSheet();

            actionDifficulty.Title = "Selecteer de moeilijkheidsgraad";

            int index = 0;

            foreach (var item in Enum.GetValues(typeof(EDifficulty)))
            {
                if ((EDifficulty)item != EDifficulty.Custom && (EDifficulty)item != EDifficulty.None)
                {
                    difficulties.Add(index, (EDifficulty)item);

                    actionDifficulty.Add(item.ToString());

                    index++;
                }
            }

            actionDifficulty.Add("Annuleer");

            actionDifficulty.Clicked += (sender1, e1) =>
            {
                if (e1.ButtonIndex != actionDifficulty.ButtonCount - 1)
                {
                    selectedDifficulty = difficulties[(int)e1.ButtonIndex];

                    UpdateTableView();
                }
            };
            #endregion

            btnDifficulty.TouchUpInside += (object sender, EventArgs e) =>
            {
                actionDifficulty.ShowInView(scrollView);
            };
        }
Beispiel #35
0
 void DifficultyMenuEntryEntered(object sender, EventArgs e)
 {
     _difficulty = EnumExtensions.GetNextValue(_difficulty);
     SetMenuEntryText();
 }
Beispiel #36
0
        /// <summary>
        /// Ustawia opcje odpowiadające danemu poziomowi trudności
        /// </summary>
        /// <param name="difficulty"></param>
        private void SetOptionsForDifficulty(EDifficulty difficulty)
        {
            var difficultyDefaultSettingsSection = ConfigurationManager.GetSection(DifficultyDefaultsDataSection.SectionName) as DifficultyDefaultsDataSection;
            if (difficultyDefaultSettingsSection != null)
            {

                foreach (DifficultyLevelDefaultsElement levelDefaults in difficultyDefaultSettingsSection.DifficultyLevelDefaults)
                {
                    if (difficulty.ToString() == levelDefaults.LevelName)
                    {
                        MaxOxygen = levelDefaults.MaxOxygen;
                        StartLives = levelDefaults.StartLives;
                        StartDynamite = levelDefaults.StartDynamite;

                        return;
                    }
                }
            }
            else
            {
                switch (difficulty)
                {
                    case EDifficulty.Easy:
                        MaxOxygen = 200;
                        StartLives = 5;
                        StartDynamite = 10;
                        break;
                    case EDifficulty.Medium:
                        MaxOxygen = 150;
                        StartLives = 3;
                        StartDynamite = 5;
                        break;
                    case EDifficulty.Hard:
                        MaxOxygen = 100;
                        StartLives = 1;
                        StartDynamite = 3;
                        break;
                }
            }
        }