예제 #1
0
파일: Level.cs 프로젝트: NickABoen/RKO
        public void LoadContent(int levelValue)
        {
            _levelValue  = levelValue;
            _currentWave = -1;
            _waveTimer   = 5000;
            // Load the enemies into the unit list
            List <Tuple <string, int> > list = LoadFromFile();

            foreach (Tuple <string, int> val in list)
            {
                string type = val.Item1;
                int    num  = val.Item2;

                switch (type)
                {
                case "---":
                    _waves.Add(new Wave(++_currentWave, _numLanes, FIELD_SIZE, FIELD_ORIGIN));
                    break;

                case "WeakMelee":
                    for (int i = 0; i < num; i++)
                    {
                        _waves[_currentWave].AddUnit(UnitFactory.CreateWeakMelee());
                    }
                    break;

                case "MediumMelee":
                    for (int i = 0; i < num; i++)
                    {
                        _waves[_currentWave].AddUnit(UnitFactory.CreateMediumMelee());
                    }
                    break;

                case "StrongMelee":
                    for (int i = 0; i < num; i++)
                    {
                        _waves[_currentWave].AddUnit(UnitFactory.CreateStrongMelee());
                    }
                    break;

                case "WeakRanged":
                    for (int i = 0; i < num; i++)
                    {
                        _waves[_currentWave].AddUnit(UnitFactory.CreateWeakRanged());
                    }
                    break;

                case "MediumRanged":
                    for (int i = 0; i < num; i++)
                    {
                        _waves[_currentWave].AddUnit(UnitFactory.CreateMediumRanged());
                    }
                    break;

                case "StrongRanged":
                    for (int i = 0; i < num; i++)
                    {
                        _waves[_currentWave].AddUnit(UnitFactory.CreateStrongRanged());
                    }
                    break;

                default:
                    throw new ArgumentException("you cant spell for shit");
                }
            }
            _currentWave = -1;

            foreach (Wave w in _waves)
            {
                w.LoadContent();
            }
        }