コード例 #1
0
        public Map(TmxMap tmxMap)
        {
            this.tmxMap = tmxMap;

            this.Entity = new Entity().AddComponent(new MapDrawer(tmxMap));

            #region Spawner laden

            difficultyToSpawnerList = new Dictionary<int, List<Spawner>>();

            difficultyToSpawnerList.Add(0, new List<Spawner>());
            difficultyToSpawnerList.Add(1, new List<Spawner>());
            difficultyToSpawnerList.Add(2, new List<Spawner>());

            foreach (TmxObjectGroup objectGroup in tmxMap.ObjectGroups)
            {
                if (objectGroup.Name == "Spawner")
                {
                    List<Spawner> easySpawners      = difficultyToSpawnerList.forceGetValue((int)Difficulty.Leicht);
                    List<Spawner> mediumSpawners    = difficultyToSpawnerList.forceGetValue((int)Difficulty.Mittel);
                    List<Spawner> hardSpawners      = difficultyToSpawnerList.forceGetValue((int)Difficulty.Schwer);

                    foreach (TmxObject tmxObject in objectGroup.Objects)
                    {
                        Spawner spawner = new Spawner();


                        bool inEasy;
                        bool inMedium;
                        bool inHard;

                        string inEasyString     = "false";
                        string inMediumString   = "false";
                        string inHardString     = "false";
                        string enemyType        = "";
                        string enemyCount       = "";
                        string enemyLevel       = "";

                        tmxObject.Properties.TryGetValue("inEasy", out inEasyString);
                        tmxObject.Properties.TryGetValue("inMedium", out inMediumString);
                        tmxObject.Properties.TryGetValue("inHard", out inHardString);
                        tmxObject.Properties.TryGetValue("enemyType", out enemyType);
                        tmxObject.Properties.TryGetValue("enemyCount", out enemyCount);
                        tmxObject.Properties.TryGetValue("enemyLevel", out enemyLevel);

                        inEasy      = Convert.ToBoolean(inEasyString);
                        inMedium    = Convert.ToBoolean(inMediumString);
                        inHard      = Convert.ToBoolean(inHardString);

                        spawner.setType(EnemyBuilder.getEnemyClassByName(enemyType));
                        spawner.setLevel(Convert.ToInt32(enemyLevel));
                        spawner.setCount(Convert.ToInt32(enemyCount));

                        if (inEasy)
                            easySpawners.Add(spawner);
                        if (inMedium)
                            mediumSpawners.Add(spawner);
                        if (inHard)
                            hardSpawners.Add(spawner);
                    }
                }
            }

            #endregion

        }