public void ActivateTarget()
 {
     if (this.m_numTargets - this.m_currentTargetIndex < this.m_targetIcons.NumChildren)
     {
         this.m_targetIcons.GetChildAt(this.m_numTargets - this.m_currentTargetIndex).Visible = false;
         this.GiveGold();
     }
     if (this.m_currentTargetIndex >= this.m_numTargets)
     {
         this.m_currentTarget = null;
         return;
     }
     if (this.m_currentTarget != null)
     {
         this.m_targetSpeed += this.m_targetSpeedMod;
     }
     this.m_currentTarget = this.m_targetList[this.m_currentTargetIndex];
     this.m_currentTarget.Visible = true;
     if (!base.IsReversed)
     {
         Tween.By(this.m_currentTarget, 2f, new Easing(Quad.EaseOut), new string[]
         {
             "X",
             (-400 + CDGMath.RandomInt(-200, 200)).ToString()
         });
         return;
     }
     Tween.By(this.m_currentTarget, 2f, new Easing(Quad.EaseOut), new string[]
     {
         "X",
         (400 + CDGMath.RandomInt(-200, 200)).ToString()
     });
 }
Example #2
0
 public void ActivateTarget()
 {
     if (m_numTargets - m_currentTargetIndex < m_targetIcons.NumChildren)
     {
         m_targetIcons.GetChildAt(m_numTargets - m_currentTargetIndex).Visible = false;
         GiveGold();
     }
     if (m_currentTargetIndex >= m_numTargets)
     {
         m_currentTarget = null;
         return;
     }
     if (m_currentTarget != null)
     {
         m_targetSpeed += m_targetSpeedMod;
     }
     m_currentTarget         = m_targetList[m_currentTargetIndex];
     m_currentTarget.Visible = true;
     if (!IsReversed)
     {
         Tween.By(m_currentTarget, 2f, Quad.EaseOut, "X", (-400 + CDGMath.RandomInt(-200, 200)).ToString());
         return;
     }
     Tween.By(m_currentTarget, 2f, Quad.EaseOut, "X", (400 + CDGMath.RandomInt(-200, 200)).ToString());
 }
Example #3
0
 public override void Dispose()
 {
     if (!IsDisposed)
     {
         m_targetList.Clear();
         m_targetList    = null;
         m_line          = null;
         m_currentTarget = null;
         m_elf           = null;
         m_daggerIcons   = null;
         m_targetIcons   = null;
         m_balloonList.Clear();
         m_balloonList = null;
         m_rewardChest = null;
         base.Dispose();
     }
 }
Example #4
0
        public override void Initialize()
        {
            Color[] array =
            {
                Color.Red,
                Color.Blue,
                Color.Green,
                Color.Yellow,
                Color.Orange,
                Color.Purple,
                Color.Pink,
                Color.MediumTurquoise,
                Color.CornflowerBlue
            };
            foreach (var current in GameObjList)
            {
                if (current is WaypointObj)
                {
                    m_elf.X = current.X;
                }
                if (current.Name == "Line")
                {
                    m_line = current;
                }
                if (current.Name == "Balloon")
                {
                    m_balloonList.Add(current as ObjContainer);
                    (current as ObjContainer).GetChildAt(1).TextureColor = array[CDGMath.RandomInt(0, array.Length - 1)];
                }
            }
            var num = 0f;

            foreach (var current2 in TerrainObjList)
            {
                if (current2.Name == "Floor")
                {
                    m_elf.Y = current2.Y - (m_elf.Bounds.Bottom - m_elf.Y);
                    num     = current2.Y;
                    break;
                }
            }
            if (!IsReversed)
            {
                m_elf.Flip = SpriteEffects.FlipHorizontally;
            }
            GameObjList.Add(m_elf);
            m_elf.Y     -= 2f;
            m_targetList = new List <BreakableObj>();
            for (var i = 0; i < m_numTargets; i++)
            {
                var breakableObj = new BreakableObj("Target1_Character");
                breakableObj.Scale           = new Vector2(2f, 2f);
                breakableObj.Visible         = false;
                breakableObj.DropItem        = false;
                breakableObj.HitBySpellsOnly = true;
                breakableObj.Position        = m_line.Position;
                if (!IsReversed)
                {
                    breakableObj.Flip = SpriteEffects.FlipHorizontally;
                }
                else
                {
                    breakableObj.Flip = SpriteEffects.None;
                }
                m_targetList.Add(breakableObj);
                GameObjList.Add(breakableObj);
            }
            m_rewardChest           = new ChestObj(null);
            m_rewardChest.ChestType = 3;
            if (!IsReversed)
            {
                m_rewardChest.Flip     = SpriteEffects.FlipHorizontally;
                m_rewardChest.Position = new Vector2(m_elf.X + 100f, num - m_rewardChest.Height - 8f);
            }
            else
            {
                m_rewardChest.Position = new Vector2(m_elf.X - 150f, num - m_rewardChest.Height - 8f);
            }
            m_rewardChest.Visible = false;
            GameObjList.Add(m_rewardChest);
            base.Initialize();
        }
 public override void Initialize()
 {
     Color[] array = new Color[]
     {
         Color.Red,
         Color.Blue,
         Color.Green,
         Color.Yellow,
         Color.Orange,
         Color.Purple,
         Color.Pink,
         Color.MediumTurquoise,
         Color.CornflowerBlue
     };
     foreach (GameObj current in base.GameObjList)
     {
         if (current is WaypointObj)
         {
             this.m_elf.X = current.X;
         }
         if (current.Name == "Line")
         {
             this.m_line = current;
         }
         if (current.Name == "Balloon")
         {
             this.m_balloonList.Add(current as ObjContainer);
             (current as ObjContainer).GetChildAt(1).TextureColor = array[CDGMath.RandomInt(0, array.Length - 1)];
         }
     }
     float num = 0f;
     foreach (TerrainObj current2 in base.TerrainObjList)
     {
         if (current2.Name == "Floor")
         {
             this.m_elf.Y = current2.Y - ((float)this.m_elf.Bounds.Bottom - this.m_elf.Y);
             num = current2.Y;
             break;
         }
     }
     if (!base.IsReversed)
     {
         this.m_elf.Flip = SpriteEffects.FlipHorizontally;
     }
     base.GameObjList.Add(this.m_elf);
     this.m_elf.Y -= 2f;
     this.m_targetList = new List<BreakableObj>();
     for (int i = 0; i < this.m_numTargets; i++)
     {
         BreakableObj breakableObj = new BreakableObj("Target1_Character");
         breakableObj.Scale = new Vector2(2f, 2f);
         breakableObj.Visible = false;
         breakableObj.DropItem = false;
         breakableObj.HitBySpellsOnly = true;
         breakableObj.Position = this.m_line.Position;
         if (!base.IsReversed)
         {
             breakableObj.Flip = SpriteEffects.FlipHorizontally;
         }
         else
         {
             breakableObj.Flip = SpriteEffects.None;
         }
         this.m_targetList.Add(breakableObj);
         base.GameObjList.Add(breakableObj);
     }
     this.m_rewardChest = new ChestObj(null);
     this.m_rewardChest.ChestType = 3;
     if (!base.IsReversed)
     {
         this.m_rewardChest.Flip = SpriteEffects.FlipHorizontally;
         this.m_rewardChest.Position = new Vector2(this.m_elf.X + 100f, num - (float)this.m_rewardChest.Height - 8f);
     }
     else
     {
         this.m_rewardChest.Position = new Vector2(this.m_elf.X - 150f, num - (float)this.m_rewardChest.Height - 8f);
     }
     this.m_rewardChest.Visible = false;
     base.GameObjList.Add(this.m_rewardChest);
     base.Initialize();
 }
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         this.m_targetList.Clear();
         this.m_targetList = null;
         this.m_line = null;
         this.m_currentTarget = null;
         this.m_elf = null;
         this.m_daggerIcons = null;
         this.m_targetIcons = null;
         this.m_balloonList.Clear();
         this.m_balloonList = null;
         this.m_rewardChest = null;
         base.Dispose();
     }
 }
Example #7
0
 public static void ParseRooms(string filePath, ContentManager contentManager = null, bool isDLCMap = false)
 {
     CultureInfo cultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
     cultureInfo.NumberFormat.CurrencyDecimalSeparator = ".";
     XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
     xmlReaderSettings.IgnoreComments = true;
     xmlReaderSettings.IgnoreWhitespace = true;
     XmlReader xmlReader;
     if (contentManager == null)
     {
         xmlReader = XmlReader.Create(filePath, xmlReaderSettings);
     }
     else
     {
         xmlReader = XmlReader.Create(contentManager.RootDirectory + "\\Levels\\" + filePath + ".xml", xmlReaderSettings);
     }
     RoomObj roomObj = null;
     RoomObj roomObj2 = null;
     RoomObj roomObj3 = null;
     RoomObj roomObj4 = null;
     RoomObj roomObj5 = null;
     while (xmlReader.Read())
     {
         if (xmlReader.NodeType == XmlNodeType.Element)
         {
             if (xmlReader.Name == "RoomObject")
             {
                 roomObj = new RoomObj();
                 LevelParser.ParseGenericXML(xmlReader, roomObj);
                 if (isDLCMap)
                 {
                     roomObj.IsDLCMap = true;
                 }
                 roomObj2 = (roomObj.Clone() as RoomObj);
                 roomObj3 = (roomObj.Clone() as RoomObj);
                 roomObj4 = (roomObj.Clone() as RoomObj);
                 roomObj5 = (roomObj.Clone() as RoomObj);
             }
             if (xmlReader.Name == "GameObject")
             {
                 xmlReader.MoveToAttribute("Type");
                 string value = xmlReader.Value;
                 GameObj gameObj = null;
                 string key;
                 switch (key = value)
                 {
                 case "CollHullObj":
                     gameObj = new TerrainObj(0, 0);
                     break;
                 case "DoorObj":
                     gameObj = new DoorObj(roomObj, 0, 0, GameTypes.DoorType.OPEN);
                     break;
                 case "ChestObj":
                     if (xmlReader.MoveToAttribute("Fairy"))
                     {
                         if (bool.Parse(xmlReader.Value))
                         {
                             gameObj = new FairyChestObj(null);
                             (gameObj as ChestObj).ChestType = 4;
                         }
                         else
                         {
                             gameObj = new ChestObj(null);
                         }
                     }
                     else
                     {
                         gameObj = new ChestObj(null);
                     }
                     break;
                 case "HazardObj":
                     gameObj = new HazardObj(0, 0);
                     break;
                 case "BorderObj":
                     gameObj = new BorderObj();
                     break;
                 case "EnemyObj":
                     xmlReader.MoveToAttribute("Procedural");
                     if (!bool.Parse(xmlReader.Value))
                     {
                         xmlReader.MoveToAttribute("EnemyType");
                         byte enemyType = byte.Parse(xmlReader.Value, NumberStyles.Any, cultureInfo);
                         xmlReader.MoveToAttribute("Difficulty");
                         GameTypes.EnemyDifficulty difficulty = (GameTypes.EnemyDifficulty)Enum.Parse(typeof(GameTypes.EnemyDifficulty), xmlReader.Value, true);
                         gameObj = EnemyBuilder.BuildEnemy((int)enemyType, null, null, null, difficulty, false);
                         if (xmlReader.MoveToAttribute("Flip") && bool.Parse(xmlReader.Value))
                         {
                             gameObj.Flip = SpriteEffects.FlipHorizontally;
                         }
                         if (xmlReader.MoveToAttribute("InitialDelay"))
                         {
                             (gameObj as EnemyObj).InitialLogicDelay = float.Parse(xmlReader.Value, NumberStyles.Any, cultureInfo);
                         }
                     }
                     else
                     {
                         xmlReader.MoveToAttribute("EnemyType");
                         string value2 = xmlReader.Value;
                         gameObj = new EnemyTagObj();
                         (gameObj as EnemyTagObj).EnemyType = value2;
                     }
                     break;
                 case "EnemyOrbObj":
                 {
                     xmlReader.MoveToAttribute("OrbType");
                     int orbType = int.Parse(xmlReader.Value, NumberStyles.Any, cultureInfo);
                     bool flag = false;
                     if (xmlReader.MoveToAttribute("IsWaypoint"))
                     {
                         flag = bool.Parse(xmlReader.Value);
                     }
                     if (flag)
                     {
                         gameObj = new WaypointObj();
                         (gameObj as WaypointObj).OrbType = orbType;
                     }
                     else
                     {
                         gameObj = new EnemyOrbObj();
                         (gameObj as EnemyOrbObj).OrbType = orbType;
                         if (xmlReader.MoveToAttribute("ForceFlying"))
                         {
                             (gameObj as EnemyOrbObj).ForceFlying = bool.Parse(xmlReader.Value);
                         }
                     }
                     break;
                 }
                 case "SpriteObj":
                     xmlReader.MoveToAttribute("SpriteName");
                     if (xmlReader.Value == "LightSource_Sprite")
                     {
                         gameObj = new LightSourceObj();
                     }
                     else
                     {
                         gameObj = new SpriteObj(xmlReader.Value);
                     }
                     break;
                 case "PhysicsObj":
                 {
                     xmlReader.MoveToAttribute("SpriteName");
                     gameObj = new PhysicsObj(xmlReader.Value, null);
                     PhysicsObj physicsObj = gameObj as PhysicsObj;
                     physicsObj.CollisionTypeTag = 5;
                     physicsObj.CollidesBottom = false;
                     physicsObj.CollidesLeft = false;
                     physicsObj.CollidesRight = false;
                     break;
                 }
                 case "PhysicsObjContainer":
                 {
                     bool flag2 = false;
                     if (xmlReader.MoveToAttribute("Breakable"))
                     {
                         flag2 = bool.Parse(xmlReader.Value);
                     }
                     xmlReader.MoveToAttribute("SpriteName");
                     if (flag2)
                     {
                         gameObj = new BreakableObj(xmlReader.Value);
                     }
                     else
                     {
                         gameObj = new PhysicsObjContainer(xmlReader.Value, null);
                     }
                     break;
                 }
                 case "ObjContainer":
                     xmlReader.MoveToAttribute("SpriteName");
                     gameObj = new ObjContainer(xmlReader.Value);
                     break;
                 case "PlayerStartObj":
                     gameObj = new PlayerStartObj();
                     break;
                 }
                 LevelParser.ParseGenericXML(xmlReader, gameObj);
                 GameTypes.LevelType levelType = GameTypes.LevelType.NONE;
                 if (xmlReader.MoveToAttribute("LevelType"))
                 {
                     levelType = (GameTypes.LevelType)int.Parse(xmlReader.Value, NumberStyles.Any, cultureInfo);
                 }
                 if (levelType == GameTypes.LevelType.CASTLE)
                 {
                     LevelParser.StoreObj(gameObj, roomObj2);
                     LevelParser.StoreSwappedObj(gameObj, GameTypes.LevelType.DUNGEON, roomObj3);
                     LevelParser.StoreSwappedObj(gameObj, GameTypes.LevelType.TOWER, roomObj5);
                     LevelParser.StoreSwappedObj(gameObj, GameTypes.LevelType.GARDEN, roomObj4);
                     SpriteObj spriteObj = gameObj as SpriteObj;
                     if (spriteObj != null && spriteObj.SpriteName == "CastleAssetFrame_Sprite")
                     {
                         spriteObj.ChangeSprite("FramePicture" + CDGMath.RandomInt(1, 16) + "_Sprite");
                     }
                 }
                 else if (levelType == GameTypes.LevelType.DUNGEON)
                 {
                     LevelParser.StoreObj(gameObj, roomObj3);
                 }
                 else if (levelType == GameTypes.LevelType.TOWER)
                 {
                     LevelParser.StoreObj(gameObj, roomObj5);
                 }
                 else if (levelType == GameTypes.LevelType.GARDEN)
                 {
                     LevelParser.StoreObj(gameObj, roomObj4);
                 }
                 else
                 {
                     LevelParser.StoreObj(gameObj, roomObj2);
                     LevelParser.StoreObj(gameObj, roomObj3);
                     LevelParser.StoreObj(gameObj, roomObj5);
                     LevelParser.StoreObj(gameObj, roomObj4);
                     LevelParser.StoreObj(gameObj, roomObj);
                 }
                 if (LevelEV.RUN_TESTROOM && (levelType == LevelEV.TESTROOM_LEVELTYPE || levelType == GameTypes.LevelType.CASTLE))
                 {
                     if (levelType == LevelEV.TESTROOM_LEVELTYPE)
                     {
                         LevelParser.StoreObj(gameObj, roomObj);
                     }
                     else if (levelType == GameTypes.LevelType.CASTLE)
                     {
                         LevelParser.StoreSwappedObj(gameObj, LevelEV.TESTROOM_LEVELTYPE, roomObj);
                     }
                 }
                 if (gameObj is PlayerStartObj)
                 {
                     RoomObj expr_65E = roomObj;
                     expr_65E.Name += "DEBUG_ROOM";
                 }
             }
         }
         else if (xmlReader.NodeType == XmlNodeType.EndElement && xmlReader.Name == "RoomObject")
         {
             if (roomObj.X < 10000f && roomObj.Name != "Boss" && roomObj.Name != "ChallengeBoss")
             {
                 if (!roomObj.Name.Contains("DEBUG_ROOM"))
                 {
                     if (roomObj.AddToCastlePool)
                     {
                         LevelBuilder2.StoreRoom(roomObj2, GameTypes.LevelType.CASTLE);
                         LevelBuilder2.StoreSpecialRoom(roomObj2, GameTypes.LevelType.CASTLE, false);
                     }
                     if (roomObj.AddToDungeonPool)
                     {
                         LevelBuilder2.StoreRoom(roomObj3, GameTypes.LevelType.DUNGEON);
                         LevelBuilder2.StoreSpecialRoom(roomObj3, GameTypes.LevelType.DUNGEON, false);
                     }
                     if (roomObj.AddToGardenPool)
                     {
                         LevelBuilder2.StoreRoom(roomObj4, GameTypes.LevelType.GARDEN);
                         LevelBuilder2.StoreSpecialRoom(roomObj4, GameTypes.LevelType.GARDEN, false);
                     }
                     if (roomObj.AddToTowerPool)
                     {
                         LevelBuilder2.StoreRoom(roomObj5, GameTypes.LevelType.TOWER);
                         LevelBuilder2.StoreSpecialRoom(roomObj5, GameTypes.LevelType.TOWER, false);
                     }
                 }
                 if (roomObj.Name.Contains("DEBUG_ROOM"))
                 {
                     roomObj.Name = roomObj.Name.Replace("DEBUG_ROOM", "");
                     if (LevelEV.TESTROOM_LEVELTYPE != GameTypes.LevelType.CASTLE)
                     {
                         LevelBuilder2.StoreSpecialRoom(roomObj, GameTypes.LevelType.CASTLE, true);
                     }
                     LevelBuilder2.StoreSpecialRoom(roomObj, LevelEV.TESTROOM_LEVELTYPE, true);
                 }
             }
             if (roomObj.X < 10000f && (roomObj.Name == "Boss" || roomObj.Name == "ChallengeBoss"))
             {
                 LevelBuilder2.StoreSpecialRoom(roomObj, GameTypes.LevelType.CASTLE, false);
             }
         }
     }
 }
Example #8
0
        public static void ParseRooms(string filePath, ContentManager contentManager = null, bool isDLCMap = false)
        {
            var cultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();

            cultureInfo.NumberFormat.CurrencyDecimalSeparator = ".";
            var xmlReaderSettings = new XmlReaderSettings();

            xmlReaderSettings.IgnoreComments   = true;
            xmlReaderSettings.IgnoreWhitespace = true;
            XmlReader xmlReader;

            if (contentManager == null)
            {
                xmlReader = XmlReader.Create(filePath, xmlReaderSettings);
            }
            else
            {
                xmlReader = XmlReader.Create(contentManager.RootDirectory + "\\Levels\\" + filePath + ".xml",
                                             xmlReaderSettings);
            }
            RoomObj roomObj  = null;
            RoomObj roomObj2 = null;
            RoomObj roomObj3 = null;
            RoomObj roomObj4 = null;
            RoomObj roomObj5 = null;

            while (xmlReader.Read())
            {
                if (xmlReader.NodeType == XmlNodeType.Element)
                {
                    if (xmlReader.Name == "RoomObject")
                    {
                        roomObj = new RoomObj();
                        ParseGenericXML(xmlReader, roomObj);
                        if (isDLCMap)
                        {
                            roomObj.IsDLCMap = true;
                        }
                        roomObj2 = (roomObj.Clone() as RoomObj);
                        roomObj3 = (roomObj.Clone() as RoomObj);
                        roomObj4 = (roomObj.Clone() as RoomObj);
                        roomObj5 = (roomObj.Clone() as RoomObj);
                    }
                    if (xmlReader.Name == "GameObject")
                    {
                        xmlReader.MoveToAttribute("Type");
                        var     value   = xmlReader.Value;
                        GameObj gameObj = null;
                        string  key;
                        switch (key = value)
                        {
                        case "CollHullObj":
                            gameObj = new TerrainObj(0, 0);
                            break;

                        case "DoorObj":
                            gameObj = new DoorObj(roomObj, 0, 0, GameTypes.DoorType.OPEN);
                            break;

                        case "ChestObj":
                            if (xmlReader.MoveToAttribute("Fairy"))
                            {
                                if (bool.Parse(xmlReader.Value))
                                {
                                    gameObj = new FairyChestObj(null);
                                    (gameObj as ChestObj).ChestType = 4;
                                }
                                else
                                {
                                    gameObj = new ChestObj(null);
                                }
                            }
                            else
                            {
                                gameObj = new ChestObj(null);
                            }
                            break;

                        case "HazardObj":
                            gameObj = new HazardObj(0, 0);
                            break;

                        case "BorderObj":
                            gameObj = new BorderObj();
                            break;

                        case "EnemyObj":
                            xmlReader.MoveToAttribute("Procedural");
                            if (!bool.Parse(xmlReader.Value))
                            {
                                xmlReader.MoveToAttribute("EnemyType");
                                var enemyType = byte.Parse(xmlReader.Value, NumberStyles.Any, cultureInfo);
                                xmlReader.MoveToAttribute("Difficulty");
                                var difficulty =
                                    (GameTypes.EnemyDifficulty)
                                    Enum.Parse(typeof(GameTypes.EnemyDifficulty), xmlReader.Value, true);
                                gameObj = EnemyBuilder.BuildEnemy(enemyType, null, null, null, difficulty);
                                if (xmlReader.MoveToAttribute("Flip") && bool.Parse(xmlReader.Value))
                                {
                                    gameObj.Flip = SpriteEffects.FlipHorizontally;
                                }
                                if (xmlReader.MoveToAttribute("InitialDelay"))
                                {
                                    (gameObj as EnemyObj).InitialLogicDelay = float.Parse(xmlReader.Value,
                                                                                          NumberStyles.Any, cultureInfo);
                                }
                            }
                            else
                            {
                                xmlReader.MoveToAttribute("EnemyType");
                                var value2 = xmlReader.Value;
                                gameObj = new EnemyTagObj();
                                (gameObj as EnemyTagObj).EnemyType = value2;
                            }
                            break;

                        case "EnemyOrbObj":
                        {
                            xmlReader.MoveToAttribute("OrbType");
                            var orbType = int.Parse(xmlReader.Value, NumberStyles.Any, cultureInfo);
                            var flag    = false;
                            if (xmlReader.MoveToAttribute("IsWaypoint"))
                            {
                                flag = bool.Parse(xmlReader.Value);
                            }
                            if (flag)
                            {
                                gameObj = new WaypointObj();
                                (gameObj as WaypointObj).OrbType = orbType;
                            }
                            else
                            {
                                gameObj = new EnemyOrbObj();
                                (gameObj as EnemyOrbObj).OrbType = orbType;
                                if (xmlReader.MoveToAttribute("ForceFlying"))
                                {
                                    (gameObj as EnemyOrbObj).ForceFlying = bool.Parse(xmlReader.Value);
                                }
                            }
                            break;
                        }

                        case "SpriteObj":
                            xmlReader.MoveToAttribute("SpriteName");
                            if (xmlReader.Value == "LightSource_Sprite")
                            {
                                gameObj = new LightSourceObj();
                            }
                            else
                            {
                                gameObj = new SpriteObj(xmlReader.Value);
                            }
                            break;

                        case "PhysicsObj":
                        {
                            xmlReader.MoveToAttribute("SpriteName");
                            gameObj = new PhysicsObj(xmlReader.Value);
                            var physicsObj = gameObj as PhysicsObj;
                            physicsObj.CollisionTypeTag = 5;
                            physicsObj.CollidesBottom   = false;
                            physicsObj.CollidesLeft     = false;
                            physicsObj.CollidesRight    = false;
                            break;
                        }

                        case "PhysicsObjContainer":
                        {
                            var flag2 = false;
                            if (xmlReader.MoveToAttribute("Breakable"))
                            {
                                flag2 = bool.Parse(xmlReader.Value);
                            }
                            xmlReader.MoveToAttribute("SpriteName");
                            if (flag2)
                            {
                                gameObj = new BreakableObj(xmlReader.Value);
                            }
                            else
                            {
                                gameObj = new PhysicsObjContainer(xmlReader.Value);
                            }
                            break;
                        }

                        case "ObjContainer":
                            xmlReader.MoveToAttribute("SpriteName");
                            gameObj = new ObjContainer(xmlReader.Value);
                            break;

                        case "PlayerStartObj":
                            gameObj = new PlayerStartObj();
                            break;
                        }
                        ParseGenericXML(xmlReader, gameObj);
                        var levelType = GameTypes.LevelType.NONE;
                        if (xmlReader.MoveToAttribute("LevelType"))
                        {
                            levelType = (GameTypes.LevelType) int.Parse(xmlReader.Value, NumberStyles.Any, cultureInfo);
                        }
                        if (levelType == GameTypes.LevelType.CASTLE)
                        {
                            StoreObj(gameObj, roomObj2);
                            StoreSwappedObj(gameObj, GameTypes.LevelType.DUNGEON, roomObj3);
                            StoreSwappedObj(gameObj, GameTypes.LevelType.TOWER, roomObj5);
                            StoreSwappedObj(gameObj, GameTypes.LevelType.GARDEN, roomObj4);
                            var spriteObj = gameObj as SpriteObj;
                            if (spriteObj != null && spriteObj.SpriteName == "CastleAssetFrame_Sprite")
                            {
                                spriteObj.ChangeSprite("FramePicture" + CDGMath.RandomInt(1, 16) + "_Sprite");
                            }
                        }
                        else if (levelType == GameTypes.LevelType.DUNGEON)
                        {
                            StoreObj(gameObj, roomObj3);
                        }
                        else if (levelType == GameTypes.LevelType.TOWER)
                        {
                            StoreObj(gameObj, roomObj5);
                        }
                        else if (levelType == GameTypes.LevelType.GARDEN)
                        {
                            StoreObj(gameObj, roomObj4);
                        }
                        else
                        {
                            StoreObj(gameObj, roomObj2);
                            StoreObj(gameObj, roomObj3);
                            StoreObj(gameObj, roomObj5);
                            StoreObj(gameObj, roomObj4);
                            StoreObj(gameObj, roomObj);
                        }
                        if (LevelEV.RUN_TESTROOM &&
                            (levelType == LevelEV.TESTROOM_LEVELTYPE || levelType == GameTypes.LevelType.CASTLE))
                        {
                            if (levelType == LevelEV.TESTROOM_LEVELTYPE)
                            {
                                StoreObj(gameObj, roomObj);
                            }
                            else if (levelType == GameTypes.LevelType.CASTLE)
                            {
                                StoreSwappedObj(gameObj, LevelEV.TESTROOM_LEVELTYPE, roomObj);
                            }
                        }
                        if (gameObj is PlayerStartObj)
                        {
                            var expr_65E = roomObj;
                            expr_65E.Name += "DEBUG_ROOM";
                        }
                    }
                }
                else if (xmlReader.NodeType == XmlNodeType.EndElement && xmlReader.Name == "RoomObject")
                {
                    if (roomObj.X < 10000f && roomObj.Name != "Boss" && roomObj.Name != "ChallengeBoss")
                    {
                        if (!roomObj.Name.Contains("DEBUG_ROOM"))
                        {
                            if (roomObj.AddToCastlePool)
                            {
                                LevelBuilder2.StoreRoom(roomObj2, GameTypes.LevelType.CASTLE);
                                LevelBuilder2.StoreSpecialRoom(roomObj2, GameTypes.LevelType.CASTLE);
                            }
                            if (roomObj.AddToDungeonPool)
                            {
                                LevelBuilder2.StoreRoom(roomObj3, GameTypes.LevelType.DUNGEON);
                                LevelBuilder2.StoreSpecialRoom(roomObj3, GameTypes.LevelType.DUNGEON);
                            }
                            if (roomObj.AddToGardenPool)
                            {
                                LevelBuilder2.StoreRoom(roomObj4, GameTypes.LevelType.GARDEN);
                                LevelBuilder2.StoreSpecialRoom(roomObj4, GameTypes.LevelType.GARDEN);
                            }
                            if (roomObj.AddToTowerPool)
                            {
                                LevelBuilder2.StoreRoom(roomObj5, GameTypes.LevelType.TOWER);
                                LevelBuilder2.StoreSpecialRoom(roomObj5, GameTypes.LevelType.TOWER);
                            }
                        }
                        if (roomObj.Name.Contains("DEBUG_ROOM"))
                        {
                            roomObj.Name = roomObj.Name.Replace("DEBUG_ROOM", "");
                            if (LevelEV.TESTROOM_LEVELTYPE != GameTypes.LevelType.CASTLE)
                            {
                                LevelBuilder2.StoreSpecialRoom(roomObj, GameTypes.LevelType.CASTLE, true);
                            }
                            LevelBuilder2.StoreSpecialRoom(roomObj, LevelEV.TESTROOM_LEVELTYPE, true);
                        }
                    }
                    if (roomObj.X < 10000f && (roomObj.Name == "Boss" || roomObj.Name == "ChallengeBoss"))
                    {
                        LevelBuilder2.StoreSpecialRoom(roomObj, GameTypes.LevelType.CASTLE);
                    }
                }
            }
        }
Example #9
0
        public override void Initialize()
        {
            m_gate                  = new PhysicsObj("CastleEntranceGate_Sprite");
            m_gate.IsWeighted       = false;
            m_gate.IsCollidable     = true;
            m_gate.CollisionTypeTag = 1;
            m_gate.Layer            = -1f;
            m_gate.OutlineWidth     = 2;
            GameObjList.Add(m_gate);
            var rectangle = default(Rectangle);

            Color[] array =
            {
                Color.Red,
                Color.Blue,
                Color.Green,
                Color.Yellow,
                Color.Orange,
                Color.Purple,
                Color.Pink,
                Color.MediumTurquoise,
                Color.CornflowerBlue
            };
            foreach (var current in GameObjList)
            {
                if (current is WaypointObj)
                {
                    m_elf.X = current.X;
                }
                if (current.Name == "Balloon")
                {
                    m_balloonList.Add(current as ObjContainer);
                    (current as ObjContainer).GetChildAt(1).TextureColor = array[CDGMath.RandomInt(0, array.Length - 1)];
                }
            }
            foreach (var current2 in TerrainObjList)
            {
                if (current2.Name == "Floor")
                {
                    m_elf.Y = current2.Y - (m_elf.Bounds.Bottom - m_elf.Y) - 2f;
                }
                if (current2.Name == "GatePosition")
                {
                    rectangle = current2.Bounds;
                }
            }
            m_gate.X = rectangle.X;
            m_gate.Y = rectangle.Bottom;
            if (!IsReversed)
            {
                m_elf.Flip = SpriteEffects.FlipHorizontally;
            }
            GameObjList.Add(m_elf);
            foreach (var current3 in TerrainObjList)
            {
                if (current3.Name == "Boundary")
                {
                    current3.Visible = false;
                    m_targetBounds   = current3.Bounds;
                    break;
                }
            }
            var   num  = 10f;
            float num2 = m_targetBounds.X + 40;
            float num3 = m_targetBounds.Y;
            var   num4 = m_targetBounds.Width / num;
            var   num5 = m_targetBounds.Height / num;
            var   num6 = 0;

            while (num6 < num * num)
            {
                var breakableObj = new BreakableObj("Target2_Character");
                breakableObj.X               = num2;
                breakableObj.Y               = num3;
                breakableObj.Scale           = new Vector2(1.6f, 1.6f);
                breakableObj.OutlineWidth    = 2;
                breakableObj.HitBySpellsOnly = true;
                breakableObj.IsWeighted      = false;
                m_targetList.Add(breakableObj);
                breakableObj.SameTypesCollide = false;
                breakableObj.DropItem         = false;
                GameObjList.Add(breakableObj);
                num2 += num4;
                if ((num6 + 1) % num == 0f)
                {
                    num2  = m_targetBounds.X + 40;
                    num3 += num5;
                }
                num6++;
            }
            m_rewardChest           = new ChestObj(null);
            m_rewardChest.ChestType = 3;
            if (!IsReversed)
            {
                m_rewardChest.Flip     = SpriteEffects.FlipHorizontally;
                m_rewardChest.Position = new Vector2(m_elf.X + 100f, m_elf.Bounds.Bottom - m_rewardChest.Height - 8);
            }
            else
            {
                m_rewardChest.Position = new Vector2(m_elf.X - 150f, m_elf.Bounds.Bottom - m_rewardChest.Height - 8);
            }
            m_rewardChest.Visible = false;
            GameObjList.Add(m_rewardChest);
            base.Initialize();
        }
 public override void Initialize()
 {
     this.m_gate = new PhysicsObj("CastleEntranceGate_Sprite", null);
     this.m_gate.IsWeighted = false;
     this.m_gate.IsCollidable = true;
     this.m_gate.CollisionTypeTag = 1;
     this.m_gate.Layer = -1f;
     this.m_gate.OutlineWidth = 2;
     base.GameObjList.Add(this.m_gate);
     Rectangle rectangle = default(Rectangle);
     Color[] array = new Color[]
     {
         Color.Red,
         Color.Blue,
         Color.Green,
         Color.Yellow,
         Color.Orange,
         Color.Purple,
         Color.Pink,
         Color.MediumTurquoise,
         Color.CornflowerBlue
     };
     foreach (GameObj current in base.GameObjList)
     {
         if (current is WaypointObj)
         {
             this.m_elf.X = current.X;
         }
         if (current.Name == "Balloon")
         {
             this.m_balloonList.Add(current as ObjContainer);
             (current as ObjContainer).GetChildAt(1).TextureColor = array[CDGMath.RandomInt(0, array.Length - 1)];
         }
     }
     foreach (TerrainObj current2 in base.TerrainObjList)
     {
         if (current2.Name == "Floor")
         {
             this.m_elf.Y = current2.Y - ((float)this.m_elf.Bounds.Bottom - this.m_elf.Y) - 2f;
         }
         if (current2.Name == "GatePosition")
         {
             rectangle = current2.Bounds;
         }
     }
     this.m_gate.X = (float)rectangle.X;
     this.m_gate.Y = (float)rectangle.Bottom;
     if (!base.IsReversed)
     {
         this.m_elf.Flip = SpriteEffects.FlipHorizontally;
     }
     base.GameObjList.Add(this.m_elf);
     foreach (TerrainObj current3 in base.TerrainObjList)
     {
         if (current3.Name == "Boundary")
         {
             current3.Visible = false;
             this.m_targetBounds = current3.Bounds;
             break;
         }
     }
     float num = 10f;
     float num2 = (float)(this.m_targetBounds.X + 40);
     float num3 = (float)this.m_targetBounds.Y;
     float num4 = (float)this.m_targetBounds.Width / num;
     float num5 = (float)this.m_targetBounds.Height / num;
     int num6 = 0;
     while ((float)num6 < num * num)
     {
         BreakableObj breakableObj = new BreakableObj("Target2_Character");
         breakableObj.X = num2;
         breakableObj.Y = num3;
         breakableObj.Scale = new Vector2(1.6f, 1.6f);
         breakableObj.OutlineWidth = 2;
         breakableObj.HitBySpellsOnly = true;
         breakableObj.IsWeighted = false;
         this.m_targetList.Add(breakableObj);
         breakableObj.SameTypesCollide = false;
         breakableObj.DropItem = false;
         base.GameObjList.Add(breakableObj);
         num2 += num4;
         if ((float)(num6 + 1) % num == 0f)
         {
             num2 = (float)(this.m_targetBounds.X + 40);
             num3 += num5;
         }
         num6++;
     }
     this.m_rewardChest = new ChestObj(null);
     this.m_rewardChest.ChestType = 3;
     if (!base.IsReversed)
     {
         this.m_rewardChest.Flip = SpriteEffects.FlipHorizontally;
         this.m_rewardChest.Position = new Vector2(this.m_elf.X + 100f, (float)(this.m_elf.Bounds.Bottom - this.m_rewardChest.Height - 8));
     }
     else
     {
         this.m_rewardChest.Position = new Vector2(this.m_elf.X - 150f, (float)(this.m_elf.Bounds.Bottom - this.m_rewardChest.Height - 8));
     }
     this.m_rewardChest.Visible = false;
     base.GameObjList.Add(this.m_rewardChest);
     base.Initialize();
 }