public static void StoreSwappedObj(GameObj obj, GameTypes.LevelType levelType, RoomObj currentRoom) { string[] array; switch (levelType) { case GameTypes.LevelType.GARDEN: array = LevelEV.GARDEN_ASSETSWAP_LIST; break; case GameTypes.LevelType.DUNGEON: array = LevelEV.DUNGEON_ASSETSWAP_LIST; break; case GameTypes.LevelType.TOWER: array = LevelEV.TOWER_ASSETSWAP_LIST; break; default: throw new Exception("Cannot find asset swaplist for leveltype " + levelType); } BreakableObj breakableObj = obj as BreakableObj; if (breakableObj != null && breakableObj.SpriteName.Contains("CastleAssetUrn")) { breakableObj.CollidesTop = false; } bool flag = false; IAnimateableObj animateableObj = obj.Clone() as IAnimateableObj; if (animateableObj != null) { int i = 0; while (i < LevelEV.CASTLE_ASSETSWAP_LIST.Length) { if (animateableObj.SpriteName == LevelEV.CASTLE_ASSETSWAP_LIST[i]) { string text = array[i]; if (text.Contains("RANDOM")) { int max = int.Parse(Convert.ToString(text[text.IndexOf("RANDOM") + 6])); int num = CDGMath.RandomInt(1, max); text = text.Replace("RANDOM" + max.ToString(), num.ToString()); if (text.Contains("TowerHole")) { (animateableObj as GameObj).X += (float)CDGMath.RandomInt(-50, 50); (animateableObj as GameObj).Y += (float)CDGMath.RandomInt(-50, 50); if (CDGMath.RandomInt(1, 100) > 70) { (animateableObj as GameObj).Visible = false; } } if (text.Contains("GardenFloatingRock")) { animateableObj = new HoverObj(text) { Position = (animateableObj as GameObj).Position, Amplitude = CDGMath.RandomFloat(-50f, 50f), HoverSpeed = CDGMath.RandomFloat(-2f, 2f), Scale = (animateableObj as GameObj).Scale, Layer = (animateableObj as GameObj).Layer }; } } if (text == "CastleAssetFrame_Sprite") { text = "FramePicture" + CDGMath.RandomInt(1, 16) + "_Sprite"; } if (!(text != "")) { break; } animateableObj.ChangeSprite(text); flag = true; if (text.Contains("GardenFairy")) { (animateableObj as GameObj).X += (float)CDGMath.RandomInt(-25, 25); (animateableObj as GameObj).Y += (float)CDGMath.RandomInt(-25, 25); (animateableObj as GameObj).Opacity = 0.8f; break; } break; } else { i++; } } } if (flag) { LevelParser.StoreObj(animateableObj as GameObj, currentRoom); } }
public static void StoreSwappedObj(GameObj obj, GameTypes.LevelType levelType, RoomObj currentRoom) { string[] array; switch (levelType) { case GameTypes.LevelType.GARDEN: array = LevelEV.GARDEN_ASSETSWAP_LIST; break; case GameTypes.LevelType.DUNGEON: array = LevelEV.DUNGEON_ASSETSWAP_LIST; break; case GameTypes.LevelType.TOWER: array = LevelEV.TOWER_ASSETSWAP_LIST; break; default: throw new Exception("Cannot find asset swaplist for leveltype " + levelType); } var breakableObj = obj as BreakableObj; if (breakableObj != null && breakableObj.SpriteName.Contains("CastleAssetUrn")) { breakableObj.CollidesTop = false; } var flag = false; var animateableObj = obj.Clone() as IAnimateableObj; if (animateableObj != null) { var i = 0; while (i < LevelEV.CASTLE_ASSETSWAP_LIST.Length) { if (animateableObj.SpriteName == LevelEV.CASTLE_ASSETSWAP_LIST[i]) { var text = array[i]; if (text.Contains("RANDOM")) { var max = int.Parse(Convert.ToString(text[text.IndexOf("RANDOM") + 6])); var num = CDGMath.RandomInt(1, max); text = text.Replace("RANDOM" + max, num.ToString()); if (text.Contains("TowerHole")) { (animateableObj as GameObj).X += CDGMath.RandomInt(-50, 50); (animateableObj as GameObj).Y += CDGMath.RandomInt(-50, 50); if (CDGMath.RandomInt(1, 100) > 70) { (animateableObj as GameObj).Visible = false; } } if (text.Contains("GardenFloatingRock")) { animateableObj = new HoverObj(text) { Position = (animateableObj as GameObj).Position, Amplitude = CDGMath.RandomFloat(-50f, 50f), HoverSpeed = CDGMath.RandomFloat(-2f, 2f), Scale = (animateableObj as GameObj).Scale, Layer = (animateableObj as GameObj).Layer }; } } if (text == "CastleAssetFrame_Sprite") { text = "FramePicture" + CDGMath.RandomInt(1, 16) + "_Sprite"; } if (!(text != "")) { break; } animateableObj.ChangeSprite(text); flag = true; if (text.Contains("GardenFairy")) { (animateableObj as GameObj).X += CDGMath.RandomInt(-25, 25); (animateableObj as GameObj).Y += CDGMath.RandomInt(-25, 25); (animateableObj as GameObj).Opacity = 0.8f; } break; } i++; } } if (flag) { StoreObj(animateableObj as GameObj, currentRoom); } }