Esempio n. 1
0
        public TDLevel(int lvl)
        {
            this.Level  = lvl;
            HPRemaining = StartingHP;

            this.Map = new TDMap(TDResources.Maps[lvl - 1]);

            if (this.Map.Paths != null && this.Map.Paths.Count > 0)
            {
                GenerateAttackersForLevel(lvl, this.Map.Paths);
            }
        }
Esempio n. 2
0
        public TDMap(TDMap sourceTemplate)
        {
            if (sourceTemplate != null)
            {
                this.BackColor = sourceTemplate.BackColor;
                this.BackImage = sourceTemplate.BackImage;

                this.BaseColor = sourceTemplate.BaseColor;
                this.BaseImage = sourceTemplate.BaseImage;

                this.Level = sourceTemplate.Level;

                this.PathColor = sourceTemplate.PathColor;
                this.PathImage = sourceTemplate.PathImage;

                this.Paths = sourceTemplate.Paths;
            }
        }
Esempio n. 3
0
        private static TDMap[] LoadMaps()
        {
            DataSet data;

            try
            {
                ClaimRemedi.ExcelReader.Reader r = new ClaimRemedi.ExcelReader.Reader("Maps.xls");
                //r.FirstLineIsHeader = true;
                data = r.ReadAllData();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Cannot read Maps.xls");
                return(null);
            }

            int maxLevel = 0;
            List <TDMapTabData> MapDataTabs = new List <TDMapTabData>();

            #region Determine the count of levels in the file and store the tabs
            string tableName;
            string Level;
            int    lvl;
            // based on the tab name, each tab represents different things.
            foreach (DataTable t in data.Tables)
            {
                tableName = t.TableName.Replace("'", ""); // remove the quotes
                tableName = tableName.Replace("$", "");   // remove the $ sign

                if (tableName.ToLower().Contains("template"))
                {
                    continue;
                }

                // get just the level
                Level = tableName.Substring(0, 2);
                if (!Int32.TryParse(Level, out lvl))
                {
                    // if we can't parse the level, then there's no point in keeping it
                    continue;
                }

                TowerDefense.TDMapTabData.TDMapTabTypes type = TDMapTabData.TDMapTabTypes.Path;
                // check for a level's data tab
                if (tableName.ToLower().Contains("data"))
                {
                    type = TDMapTabData.TDMapTabTypes.Data;
                }

                // store the data we have into a list.
                MapDataTabs.Add(new TDMapTabData(tableName, lvl, type, t));

                // set the max level for later use
                maxLevel = Math.Max(maxLevel, lvl);
            } // end first lap
            #endregion

            TDMap[] results = new TDMap[maxLevel];

            foreach (TDMapTabData tab in MapDataTabs)
            {
                // make sure we have this level in our output collection
                if (results[tab.Level - 1] == null)
                {
                    results[tab.Level - 1] = new TDMap(tab.Level, new List <TDPath>());
                }

                switch (tab.Type)
                {
                case TDMapTabData.TDMapTabTypes.Data:
                    results[tab.Level - 1].LoadMapData(tab);
                    break;

                case TDMapTabData.TDMapTabTypes.Path:
                    results[tab.Level - 1].Paths.Add(LoadPathFromDataTable(tab.Table));
                    break;
                }
            }
            return(results);
        }