Exemple #1
0
        public Level(bool isIngameLevel, int morning, int midday, int evening, int night, string name,
                     string description, Dictionary <PlayerIndex, int> startingGold, LevelsEnum type)
        {
            dayNightTurns = new Dictionary <DayStates, int>();
            dayNightTurns.Add(DayStates.Morning, morning);
            dayNightTurns.Add(DayStates.Midday, midday);
            dayNightTurns.Add(DayStates.Evening, evening);
            dayNightTurns.Add(DayStates.Night, night);
            this.isIngameLevel = isIngameLevel;
            levelName          = name;
            levelDescription   = description;
            this.type          = type;

            Tiles   = new Dictionary <int, Dictionary <int, Tile> >();
            Players = new SortedList <PlayerIndex, Player>
            {
                { PlayerIndex.Neutral, new Player("Neutral player", PlayerIndex.Neutral, Color.gray) },
                { PlayerIndex.Blue, new Player("Player Blue", PlayerIndex.Blue, Color.blue) },
                { PlayerIndex.Red, new Player("Player Red", PlayerIndex.Red, Color.red) }
            };
            CurrentPlayer = Players[PlayerIndex.Blue];

            foreach (KeyValuePair <PlayerIndex, int> gold in startingGold)
            {
                Player pl = Players[gold.Key];
                pl.SetGold(gold.Value);
            }
        }
    protected override void Execute(List <GameEntity> entities)
    {
        foreach (var entity in entities)
        {
            if (entity.isLoadNextLevelTrigger)
            {
                ClearInteractibleObjects();

                if ((int)_sceneToLoad + 1 < _maxLevels)
                {
                    _sceneToLoad   = _sceneToLoad + 1;
                    _sceneToUnload = _gameContext.globals.value.GetSceneForLevel(_sceneToLoad - 1);
                }
            }

            if (entity.hasLoadLevelTrigger)
            {
                if (_sceneToLoad != entity.loadLevelTrigger.Level)
                {
                    _sceneToLoad   = entity.loadLevelTrigger.Level;
                    _sceneToUnload = string.Empty;
                }
            }

            if (_sceneToUnload != string.Empty)
            {
                SceneManager.UnloadSceneAsync(_sceneToUnload);
            }

            _gameContext.globals.value.sceneIntroView.FadeIn();
            LoadNewScene();

            entity.Destroy();
        }
    }
 public void Activate(LevelsEnum level, string subtitle)
 {
     _titleText.text        = _textHelper.GetTranslation(level.ToString());
     _subtitleText.text     = _textHelper.GetTranslation(subtitle);
     _backgroundImage.color = Color.black;
     _crosshair.SetActive(false);
     StartCoroutine(ActivateCoroutine());
 }
Exemple #4
0
    public void ReplaceLoadLevelTrigger(LevelsEnum newLevel)
    {
        var index     = GameComponentsLookup.LoadLevelTrigger;
        var component = CreateComponent <LoadLevelTriggerComponent>(index);

        component.Level = newLevel;
        ReplaceComponent(index, component);
    }
    public static string GetString(LevelsEnum level)
    {
        switch (level)
        {
        case LevelsEnum.Galletown:
            return("Galletown");

        case LevelsEnum.TartaDeTortas:
            return("Tarta de tortas");

        case LevelsEnum.TartaDeCastanas:
            return("Tarta de castañas");

        default:
            throw new ArgumentOutOfRangeException(nameof(level), level, null);
        }
    }
    public static LevelsEnum GetPreviousEnum(LevelsEnum level)
    {
        switch (level)
        {
        case LevelsEnum.Galletown:
            return(LevelsEnum.TartaDeCastanas);

        case LevelsEnum.TartaDeTortas:
            return(LevelsEnum.Galletown);

        case LevelsEnum.TartaDeCastanas:
            return(LevelsEnum.TartaDeTortas);

        default:
            throw new ArgumentOutOfRangeException(nameof(level), level, null);
        }
    }
    public static string GetScene(LevelsEnum level)
    {
        switch (level)//
        {
        case LevelsEnum.Galletown:
            return("Screen_02_2_game_0_galletown");

        case LevelsEnum.TartaDeTortas:
            return("Screen_02_2_game_1_tartaDeTortas");

        case LevelsEnum.TartaDeCastanas:
            return("Screen_02_2_game_2_tartaDeCastanas");

        default:
            throw new ArgumentOutOfRangeException(nameof(level), level, null);
        }
    }
Exemple #8
0
 private static bool CheckIfLeoNeededBecauseOfLevelChange(LevelsEnum previousLevel, LevelsEnum newLevel)
 {
     if (previousLevel < LevelsEnum.Level5 && newLevel == LevelsEnum.Level5)
     {
         return(false);
     }
     if (previousLevel >= LevelsEnum.Level6 && newLevel <= LevelsEnum.Level10)
     {
         return(false);
     }
     if (previousLevel == LevelsEnum.XcelBronze && newLevel == LevelsEnum.XcelSilver || previousLevel == LevelsEnum.XcelSilver && newLevel == LevelsEnum.XcelBronze)
     {
         return(false);
     }
     if (previousLevel >= LevelsEnum.XcelGold && newLevel <= LevelsEnum.XcelDiamond)
     {
         return(false);
     }
     return(true);
 }
Exemple #9
0
        /// <summary>
        /// Load the level that is set in the LevelManager script.
        /// </summary>
        private void LoadLevel()
        {
            var        lm    = GameObjectReferences.GetGlobalScriptsGameObject().GetComponent <LevelManager>();
            LevelsEnum level = lm.levelToLoad;

            if (level == LevelsEnum.Menu)
            {
                lm.CurrentLevel = new Level(level);
                Application.LoadLevel(level.ToString());
            }
            else
            {
                string jsonString = ResourceCache.GetResource <TextAsset>(level.ToString()).text;

                JSONNode jsonLevel = JSON.Parse(jsonString);

                int       morning     = Mathf.Clamp(jsonLevel["turn-morning"].AsInt, 1, int.MaxValue);
                int       midday      = Mathf.Clamp(jsonLevel["turn-midday"].AsInt, 1, int.MaxValue);
                int       evening     = Mathf.Clamp(jsonLevel["turn-evening"].AsInt, 1, int.MaxValue);
                int       night       = Mathf.Clamp(jsonLevel["turn-night"].AsInt, 1, int.MaxValue);
                string    name        = jsonLevel["level-name"];
                string    description = jsonLevel["level-description"];
                JSONArray gold        = jsonLevel["starting-gold"].AsArray;

                var startGold = new Dictionary <PlayerIndex, int>();

                foreach (PlayerIndex pl in (PlayerIndex[])Enum.GetValues(typeof(PlayerIndex)))
                {
                    foreach (JSONNode item in gold)
                    {
                        if (!String.IsNullOrEmpty(item[pl.ToString()]) && item[pl.ToString()] != pl.ToString())
                        {
                            startGold.Add(pl, item[pl.ToString()].AsInt);
                        }
                    }
                }

                lm.CurrentLevel = new Level(true, morning, midday, evening, night, name, description, startGold, level);
                Application.LoadLevel(level.ToString());
            }
        }
Exemple #10
0
    public Dictionary <EventsEnum, Mission> GetEventsForDay(LevelsEnum day)
    {
        switch (day)
        {
        case LevelsEnum.DayOne:
            return(_dayOneEvents);

        case LevelsEnum.DayTwo:
            return(_dayTwoEvents);

        case LevelsEnum.DayThree:
            return(_dayThreeEvents);

        case LevelsEnum.DayFour:
            return(_dayFourEvents);

        case LevelsEnum.DayFive:
            return(_dayFiveEvents);
        }

        return(null);
    }
Exemple #11
0
    public string GetSceneForLevel(LevelsEnum level)
    {
        switch (level)
        {
        case LevelsEnum.DayOne:
            return("scene_day_1");

        case LevelsEnum.DayTwo:

            return("scene_day_2");

        case LevelsEnum.DayThree:
            return("scene_day_3");

        case LevelsEnum.DayFour:
            return("scene_day_4");

        case LevelsEnum.DayFive:
            return("scene_day_5");
        }

        return(string.Empty);
    }
Exemple #12
0
 public Level(LevelsEnum level)
 {
     type = level;
 }
Exemple #13
0
 /// <summary>
 /// Load the level. It will load the loadingscene and from there load the properties of the level.
 /// </summary>
 /// <param name="level"></param>
 public void LoadLevel(LevelsEnum level)
 {
     levelToLoad = level;
     Application.LoadLevel(loadLevelSceneName);
 }