Ejemplo n.º 1
0
        public GameViewModel(string p, ObservableCollection <string> _floors)
        {
            type = MapType.NONE;

            path = p;

            GetName();

            IncreaseCommand = new CustomCommand(() => Increase(), () => CanUpdateTimeline());

            DecreaseCommand = new CustomCommand(() => Decrease(), () => CanUpdateTimeline());

            #region Conversion dictionnary
            nameConversion = new Dictionary <string, string>();

            nameConversion.Add("FirstFloor", "Basement");
            nameConversion.Add("SecondFloor", "Ground floor");
            nameConversion.Add("ThirdFloor", "First floor");
            nameConversion.Add("FourthFloor", "Roofs");

            #endregion

            #region List initiazation

            rounds = new ObservableCollection <string>();

            floors = new ObservableCollection <string>();

            characters = new ObservableCollection <string>();

            maps = new List <Map>();

            characters.Add("soldier");
            characters.Add("Scout");
            characters.Add("Trapper");
            characters.Add("Charger");

            foreach (string floor in _floors)
            {
                floors.Add(nameConversion[floor]);
            }

            //rounds.Add("Global");

            foreach (string s in Directory.GetDirectories(p))
            {
                rounds.Add(Path.GetFileName(s));
            }

            #endregion

            #region collections views

            roundsCollection = CollectionViewSource.GetDefaultView(rounds);

            floorsCollection = CollectionViewSource.GetDefaultView(floors);

            charactersCollection = CollectionViewSource.GetDefaultView(characters);

            if (roundsCollection == null)
            {
                throw new NullReferenceException("rounds view");
            }

            roundsCollection.CurrentChanged += RoundChanged;

            if (floorsCollection == null)
            {
                throw new NullReferenceException("floor collection");
            }

            floorsCollection.CurrentChanged += FloorsChanged;

            if (charactersCollection == null)
            {
                throw new NullReferenceException("character collection");
            }

            charactersCollection.CurrentChanged += CharactersChanged;
            #endregion
        }