Esempio n. 1
0
 public override void Dispose()
 {
     if (!IsDisposed)
     {
         m_blacksmith.Dispose();
         m_blacksmith = null;
         m_blacksmithIcon.Dispose();
         m_blacksmithIcon = null;
         m_blacksmithNewIcon.Dispose();
         m_blacksmithNewIcon = null;
         m_blacksmithBoard.Dispose();
         m_blacksmithBoard = null;
         m_enchantress.Dispose();
         m_enchantress = null;
         m_enchantressIcon.Dispose();
         m_enchantressIcon = null;
         m_enchantressNewIcon.Dispose();
         m_enchantressNewIcon = null;
         m_tent.Dispose();
         m_tent = null;
         m_architect.Dispose();
         m_architect = null;
         m_architectIcon.Dispose();
         m_architectIcon = null;
         m_screw.Dispose();
         m_screw = null;
         if (m_blacksmithAnvilSound != null)
         {
             m_blacksmithAnvilSound.Dispose();
         }
         m_blacksmithAnvilSound = null;
         m_tree1 = null;
         m_tree2 = null;
         m_tree3 = null;
         m_fern1 = null;
         m_fern2 = null;
         m_fern3 = null;
         foreach (var current in m_rainFG)
         {
             current.Dispose();
         }
         m_rainFG.Clear();
         m_rainFG    = null;
         m_mountain1 = null;
         m_mountain2 = null;
         m_tollCollector.Dispose();
         m_tollCollector = null;
         m_tollCollectorIcon.Dispose();
         m_tollCollectorIcon = null;
         m_blacksmithBlock   = null;
         m_enchantressBlock  = null;
         m_architectBlock    = null;
         if (m_rainSFX != null)
         {
             m_rainSFX.Dispose();
         }
         m_rainSFX = null;
         base.Dispose();
     }
 }
Esempio n. 2
0
 public override void Initialize()
 {
     foreach (var current in TerrainObjList)
     {
         if (current.Name == "BlacksmithBlock")
         {
             m_blacksmithBlock = current;
         }
         if (current.Name == "EnchantressBlock")
         {
             m_enchantressBlock = current;
         }
         if (current.Name == "ArchitectBlock")
         {
             m_architectBlock = current;
         }
         if (current.Name == "bridge")
         {
             current.ShowTerrain = false;
         }
     }
     for (var i = 0; i < GameObjList.Count; i++)
     {
         if (GameObjList[i].Name == "Mountains 1")
         {
             m_mountain1 = (GameObjList[i] as SpriteObj);
         }
         if (GameObjList[i].Name == "Mountains 2")
         {
             m_mountain2 = (GameObjList[i] as SpriteObj);
         }
     }
     base.Initialize();
 }
Esempio n. 3
0
        private TerrainObj FindClosestCeiling()
        {
            var        num         = 2147483647;
            TerrainObj result      = null;
            var        currentRoom = m_levelScreen.CurrentRoom;

            foreach (var current in currentRoom.TerrainObjList)
            {
                var b = new Rectangle(Bounds.Left, Bounds.Top - 2000, Bounds.Width, Bounds.Height + 2000);
                if (current.CollidesBottom && CollisionMath.Intersects(current.Bounds, b))
                {
                    var num2 = 3.40282347E+38f;
                    if (current.Bounds.Bottom < TerrainBounds.Top)
                    {
                        num2 = TerrainBounds.Top - current.Bounds.Bottom;
                    }
                    if (num2 < num)
                    {
                        num    = (int)num2;
                        result = current;
                    }
                }
            }
            return(result);
        }
Esempio n. 4
0
 public override void Dispose()
 {
     if (!IsDisposed)
     {
         m_storedRoom = null;
         m_smoke.Dispose();
         m_smoke = null;
         m_log.Dispose();
         m_log            = null;
         m_closestCeiling = null;
         base.Dispose();
     }
 }
Esempio n. 5
0
 public void CreateSmoke()
 {
     if (m_levelScreen.CurrentRoom == m_storedRoom && m_closestCeiling != null)
     {
         UpdateCollisionBoxes();
         Y = m_closestCeiling.Bounds.Bottom + (Y - TerrainBounds.Top);
         X = m_target.X;
         ChangeSprite("EnemyNinjaAttack_Character");
         Visible          = true;
         AccelerationX    = 0f;
         AccelerationY    = 0f;
         CurrentSpeed     = 0f;
         IsCollidable     = true;
         m_smoke.Position = Position;
         m_smoke.Visible  = true;
         m_smoke.PlayAnimation(false);
         m_closestCeiling = null;
     }
 }
Esempio n. 6
0
 public override void HitEnemy(int damage, Vector2 position, bool isPlayer)
 {
     if (m_target != null && m_target.CurrentHealth > 0 && m_currentActiveLB != m_basicTeleportAttackLB &&
         m_currentActiveLB != m_expertTeleportAttackLB && CDGMath.RandomFloat(0f, 1f) <= ChanceToTeleport &&
         m_closestCeiling != null)
     {
         m_closestCeiling = FindClosestCeiling();
         var num = TerrainBounds.Top - m_closestCeiling.Bounds.Bottom;
         if (m_closestCeiling != null && num > 150 && num < 700)
         {
             m_currentActiveLB.StopLogicBlock();
             if (Difficulty == GameTypes.EnemyDifficulty.EXPERT)
             {
                 RunLogicBlock(false, m_expertTeleportAttackLB, 100);
             }
             else
             {
                 RunLogicBlock(false, m_basicTeleportAttackLB, 100);
             }
             damage = (int)Math.Round(damage * (1f - m_teleportDamageReduc), MidpointRounding.AwayFromZero);
         }
     }
     base.HitEnemy(damage, position, isPlayer);
 }
Esempio n. 7
0
 public void CreateSmoke()
 {
     if (this.m_levelScreen.CurrentRoom == this.m_storedRoom && this.m_closestCeiling != null)
     {
         base.UpdateCollisionBoxes();
         base.Y = (float)this.m_closestCeiling.Bounds.Bottom + (base.Y - (float)this.TerrainBounds.Top);
         base.X = this.m_target.X;
         this.ChangeSprite("EnemyNinjaAttack_Character");
         base.Visible = true;
         base.AccelerationX = 0f;
         base.AccelerationY = 0f;
         base.CurrentSpeed = 0f;
         base.IsCollidable = true;
         this.m_smoke.Position = base.Position;
         this.m_smoke.Visible = true;
         this.m_smoke.PlayAnimation(false);
         this.m_closestCeiling = null;
     }
 }
Esempio n. 8
0
 public override void HitEnemy(int damage, Vector2 position, bool isPlayer)
 {
     if (this.m_target != null && this.m_target.CurrentHealth > 0 && this.m_currentActiveLB != this.m_basicTeleportAttackLB && this.m_currentActiveLB != this.m_expertTeleportAttackLB && CDGMath.RandomFloat(0f, 1f) <= this.ChanceToTeleport && this.m_closestCeiling != null)
     {
         this.m_closestCeiling = this.FindClosestCeiling();
         int num = this.TerrainBounds.Top - this.m_closestCeiling.Bounds.Bottom;
         if (this.m_closestCeiling != null && num > 150 && num < 700)
         {
             this.m_currentActiveLB.StopLogicBlock();
             if (base.Difficulty == GameTypes.EnemyDifficulty.EXPERT)
             {
                 base.RunLogicBlock(false, this.m_expertTeleportAttackLB, new int[]
                 {
                     100
                 });
             }
             else
             {
                 base.RunLogicBlock(false, this.m_basicTeleportAttackLB, new int[]
                 {
                     100
                 });
             }
             damage = (int)Math.Round((double)((float)damage * (1f - this.m_teleportDamageReduc)), MidpointRounding.AwayFromZero);
         }
     }
     base.HitEnemy(damage, position, isPlayer);
 }
Esempio n. 9
0
 public override void Dispose()
 {
     if (!base.IsDisposed)
     {
         this.m_storedRoom = null;
         this.m_smoke.Dispose();
         this.m_smoke = null;
         this.m_log.Dispose();
         this.m_log = null;
         this.m_closestCeiling = null;
         base.Dispose();
     }
 }
Esempio n. 10
0
 private void HookEnemyToSlope(IPhysicsObj enemy, TerrainObj terrain)
 {
     Vector2 vector;
     Vector2 vector2;
     if (terrain.Width > terrain.Height)
     {
         vector = CollisionMath.UpperLeftCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero);
         vector2 = CollisionMath.UpperRightCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero);
     }
     else if (terrain.Rotation > 0f)
     {
         vector = CollisionMath.LowerLeftCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero);
         vector2 = CollisionMath.UpperLeftCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero);
     }
     else
     {
         vector = CollisionMath.UpperRightCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero);
         vector2 = CollisionMath.LowerRightCorner(terrain.TerrainBounds, terrain.Rotation, Vector2.Zero);
     }
     float num = vector2.X - vector.X;
     float num2 = vector2.Y - vector.Y;
     float x = vector.X;
     float y = vector.Y;
     float x2 = enemy.X;
     float num3 = y + (x2 - x) * (num2 / num);
     enemy.UpdateCollisionBoxes();
     num3 -= (float)enemy.Bounds.Bottom - enemy.Y + 5f * (enemy as GameObj).ScaleX;
     enemy.Y = (float)Math.Round((double)num3, MidpointRounding.ToEven);
 }
Esempio n. 11
0
        public void RunDisplacerEffect(RoomObj room, PlayerObj player)
        {
            var        num        = 2147483647;
            TerrainObj terrainObj = null;
            var        value      = Vector2.Zero;

            foreach (var current in room.TerrainObjList)
            {
                value = Vector2.Zero;
                var num2 = 3.40282347E+38f;
                if (player.Flip == SpriteEffects.None)
                {
                    if (current.X > X && current.Bounds.Top < Bounds.Bottom && current.Bounds.Bottom > Bounds.Top)
                    {
                        if (current.Rotation < 0f)
                        {
                            value = CollisionMath.LineToLineIntersect(Position, new Vector2(X + 6600f, Y),
                                                                      CollisionMath.UpperLeftCorner(current.NonRotatedBounds, current.Rotation, Vector2.Zero),
                                                                      CollisionMath.UpperRightCorner(current.NonRotatedBounds, current.Rotation, Vector2.Zero));
                        }
                        else if (current.Rotation > 0f)
                        {
                            value = CollisionMath.LineToLineIntersect(Position, new Vector2(X + 6600f, Y),
                                                                      CollisionMath.LowerLeftCorner(current.NonRotatedBounds, current.Rotation, Vector2.Zero),
                                                                      CollisionMath.UpperLeftCorner(current.NonRotatedBounds, current.Rotation, Vector2.Zero));
                        }
                        if (value != Vector2.Zero)
                        {
                            num2 = value.X - X;
                        }
                        else
                        {
                            num2 = current.Bounds.Left - Bounds.Right;
                        }
                    }
                }
                else if (current.X < X && current.Bounds.Top < Bounds.Bottom && current.Bounds.Bottom > Bounds.Top)
                {
                    if (current.Rotation < 0f)
                    {
                        value = CollisionMath.LineToLineIntersect(new Vector2(X - 6600f, Y), Position,
                                                                  CollisionMath.UpperRightCorner(current.NonRotatedBounds, current.Rotation, Vector2.Zero),
                                                                  CollisionMath.LowerRightCorner(current.NonRotatedBounds, current.Rotation, Vector2.Zero));
                    }
                    else if (current.Rotation > 0f)
                    {
                        value = CollisionMath.LineToLineIntersect(new Vector2(X - 6600f, Y), Position,
                                                                  CollisionMath.UpperLeftCorner(current.NonRotatedBounds, current.Rotation, Vector2.Zero),
                                                                  CollisionMath.UpperRightCorner(current.NonRotatedBounds, current.Rotation, Vector2.Zero));
                    }
                    if (value != Vector2.Zero)
                    {
                        num2 = X - value.X;
                    }
                    else
                    {
                        num2 = Bounds.Left - current.Bounds.Right;
                    }
                }
                if (num2 < num)
                {
                    num        = (int)num2;
                    terrainObj = current;
                }
            }
            if (terrainObj != null)
            {
                if (player.Flip == SpriteEffects.None)
                {
                    if (terrainObj.Rotation == 0f)
                    {
                        player.X += num - player.TerrainBounds.Width / 2f;
                        return;
                    }
                    player.X += num - player.Width / 2f;
                }
                else
                {
                    if (terrainObj.Rotation == 0f)
                    {
                        player.X -= num - player.TerrainBounds.Width / 2f;
                        return;
                    }
                    player.X -= num - player.Width / 2f;
                }
            }
        }
Esempio n. 12
0
        public void CastEarthSpellOut()
        {
            m_earthSummonOutSprite.Scale = Vector2.Zero;
            m_earthSummonOutSprite.X     = m_target.X;
            var        num        = 2147483647;
            TerrainObj terrainObj = null;

            foreach (var current in m_levelScreen.CurrentRoom.TerrainObjList)
            {
                if (CollisionMath.Intersects(new Rectangle((int)m_target.X, (int)m_target.Y, 2, 720), current.Bounds))
                {
                    var num2 = current.Bounds.Top - m_target.TerrainBounds.Bottom;
                    if (num2 < num)
                    {
                        num        = num2;
                        terrainObj = current;
                    }
                }
            }
            if (terrainObj != null)
            {
                if (terrainObj.Rotation == 0f)
                {
                    m_earthSummonOutSprite.Y = terrainObj.Bounds.Top;
                }
                else
                {
                    Vector2 vector;
                    Vector2 vector2;
                    if (terrainObj.Width > terrainObj.Height)
                    {
                        vector = CollisionMath.UpperLeftCorner(terrainObj.TerrainBounds, terrainObj.Rotation,
                                                               Vector2.Zero);
                        vector2 = CollisionMath.UpperRightCorner(terrainObj.TerrainBounds, terrainObj.Rotation,
                                                                 Vector2.Zero);
                    }
                    else if (terrainObj.Rotation > 0f)
                    {
                        vector = CollisionMath.LowerLeftCorner(terrainObj.TerrainBounds, terrainObj.Rotation,
                                                               Vector2.Zero);
                        vector2 = CollisionMath.UpperLeftCorner(terrainObj.TerrainBounds, terrainObj.Rotation,
                                                                Vector2.Zero);
                    }
                    else
                    {
                        vector = CollisionMath.UpperRightCorner(terrainObj.TerrainBounds, terrainObj.Rotation,
                                                                Vector2.Zero);
                        vector2 = CollisionMath.LowerRightCorner(terrainObj.TerrainBounds, terrainObj.Rotation,
                                                                 Vector2.Zero);
                    }
                    var num3 = vector2.X - vector.X;
                    var num4 = vector2.Y - vector.Y;
                    var x    = vector.X;
                    var y    = vector.Y;
                    var x2   = m_earthSummonOutSprite.X;
                    var num5 = y + (x2 - x) * (num4 / num3);
                    num5 -= m_earthSummonOutSprite.Bounds.Bottom - m_earthSummonOutSprite.Y;
                    m_earthSummonOutSprite.Y = (float)Math.Round(num5, MidpointRounding.ToEven);
                }
            }
            object arg_2A0_0 = m_earthSummonOutSprite;
            var    arg_2A0_1 = 0.5f;
            Easing arg_2A0_2 = Back.EaseOut;
            var    array     = new string[6];

            array[0] = "Opacity";
            array[1] = "1";
            array[2] = "ScaleX";
            var arg_28B_0 = array;
            var arg_28B_1 = 3;
            var x3        = ProjectileScale.X;

            arg_28B_0[arg_28B_1] = x3.ToString();
            array[4]             = "ScaleY";
            array[5]             = "1";
            Tween.To(arg_2A0_0, arg_2A0_1, arg_2A0_2, array);
        }
Esempio n. 13
0
        public override void Initialize()
        {
            TerrainObj terrainObj  = null;
            TerrainObj terrainObj2 = null;
            TerrainObj terrainObj3 = null;
            TerrainObj terrainObj4 = null;

            foreach (var current in TerrainObjList)
            {
                if (current.Name == "BlacksmithBlock")
                {
                    terrainObj = current;
                }
                if (current.Name == "EnchantressBlock")
                {
                    terrainObj2 = current;
                }
                if (current.Name == "ArchitectBlock")
                {
                    terrainObj3 = current;
                }
                if (current.Name == "SignBlock")
                {
                    terrainObj4 = current;
                }
            }
            if (terrainObj != null)
            {
                TerrainObjList.Remove(terrainObj);
            }
            if (terrainObj2 != null)
            {
                TerrainObjList.Remove(terrainObj2);
            }
            if (terrainObj3 != null)
            {
                TerrainObjList.Remove(terrainObj3);
            }
            if (terrainObj4 != null)
            {
                TerrainObjList.Remove(terrainObj4);
            }
            if (m_tree1 == null)
            {
                foreach (var current2 in GameObjList)
                {
                    if (current2.Name == "Mountains 1")
                    {
                        m_mountain1 = (current2 as SpriteObj);
                    }
                    else if (current2.Name == "Mountains 2")
                    {
                        m_mountain2 = (current2 as SpriteObj);
                    }
                    else if (current2.Name == "Sign")
                    {
                        current2.Visible = false;
                    }
                    if (current2.Name == "Tree1")
                    {
                        m_tree1 = current2;
                    }
                    else if (current2.Name == "Tree2")
                    {
                        m_tree2 = current2;
                    }
                    else if (current2.Name == "Tree3")
                    {
                        m_tree3 = current2;
                    }
                    else if (current2.Name == "Fern1")
                    {
                        m_fern1 = current2;
                    }
                    else if (current2.Name == "Fern2")
                    {
                        m_fern2 = current2;
                    }
                    else if (current2.Name == "Fern3")
                    {
                        m_fern3 = current2;
                    }
                }
            }
            EnemyList.Clear();
            base.Initialize();
        }
Esempio n. 14
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);
             }
         }
     }
 }
Esempio n. 15
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);
                    }
                }
            }
        }