public NWField(NWGameSpace space, NWLayer layer, ExtPoint coords) : base(StaticData.FieldWidth, StaticData.FieldHeight) { fSpace = space; fLayer = layer; fCoords = coords; fCreatures = new CreaturesList(this, true); fItems = new ItemsList(this, true); fEffects = new EffectsList(this, true); fEmitters = new EmitterList(); ValidCreatures = new List <int>(); if (Layer != null) { LayerEntry layerEntry = (LayerEntry)GlobalVars.nwrDB.GetEntry(Layer.EntryID); fEntry = layerEntry.GetFieldEntry(fCoords.X, fCoords.Y); EntryID = fEntry.GUID; fLandEntry = (LandEntry)GlobalVars.nwrDB.FindEntryBySign(fEntry.LandSign); LandID = fLandEntry.GUID; PrepareCreatures(); } else { fEntry = null; EntryID = -1; fLandEntry = null; LandID = -1; } }
void CustomInitialize() { mMenuSongReference = MenuSong; mEmitterList = BackgroundEmitters; mEmitterListStartingCount = BackgroundEmitters.Count; TestAchxReloading(); }
public EmitterList ToEmitterList(string contentManagerName) { string oldRelativeDirectory = FileManager.RelativeDirectory; FileManager.RelativeDirectory = FileManager.GetDirectory(this.Name); EmitterList emitterList = new EmitterList(); foreach (EmitterSave es in this.emitters) { emitterList.Add(es.ToEmitter(contentManagerName)); } FileManager.RelativeDirectory = oldRelativeDirectory; return(emitterList); }
private void AddNode(int id, TreeNode treeNode) { EmitterList.ForEach((Action <BaseEmitter_CS>)(b => { if (b.BindingID != id) { return; } string str1 = !(b is BaseCover_CS) ? b.EmitterMode.ToString() : "Cover"; TreeNode treeNode1 = new TreeNode(b.ID.ToString()); TreeNode treeNode2 = treeNode1; int id1 = b.ID; string str2 = id1.ToString(); treeNode2.Name = str2; TreeNode treeNode3 = treeNode1; id1 = b.ID; string str3 = "ID:" + id1.ToString() + " " + str1; treeNode3.Text = str3; treeNode.Nodes.Add(treeNode1); AddNode(b.ID, treeNode1); })); }
public T LoadFromFile <T>(string assetName) { string extension = FileManager.GetExtension(assetName); if (FileManager.IsRelative(assetName)) { // get the absolute path using the current relative directory assetName = FileManager.RelativeDirectory + assetName; } string fullNameWithType = assetName + typeof(T).Name; // get the dictionary by the contentManagerName. If it doesn't exist, GetDisposableDictionaryByName // will create it. if (mDisposableDictionary.ContainsKey(fullNameWithType)) { #if PROFILE mHistory.Add(new ContentLoadHistory( TimeManager.CurrentTime, typeof(T).Name, fullNameWithType, ContentLoadDetail.Cached)); #endif return((T)mDisposableDictionary[fullNameWithType]); } else if (mNonDisposableDictionary.ContainsKey(fullNameWithType)) { return((T)mNonDisposableDictionary[fullNameWithType]); } else { #if PROFILE mHistory.Add(new ContentLoadHistory( TimeManager.CurrentTime, typeof(T).Name, fullNameWithType, ContentLoadDetail.HddFromFile)); #endif #if DEBUG // The ThrowExceptionIfFileDoesntExist // call used to be done before the checks // in the dictionaries. But whatever is held // in there may not really be a file so let's check // if the file exists after we check the dictionaries. FileManager.ThrowExceptionIfFileDoesntExist(assetName); #endif IDisposable loadedAsset = null; if (typeof(T) == typeof(Texture2D) || typeof(T) == typeof(Microsoft.Xna.Framework.Graphics.Texture2D)) { // for now we'll create it here, eventually have it in a dictionary: loadedAsset = textureContentLoader.Load(assetName); } #region Scene else if (typeof(T) == typeof(FlatRedBall.Scene)) { FlatRedBall.Scene scene = FlatRedBall.Content.Scene.SceneSave.FromFile(assetName).ToScene(mName); object sceneAsObject = scene; lock (mNonDisposableDictionary) { if (!mNonDisposableDictionary.ContainsKey(fullNameWithType)) { mNonDisposableDictionary.Add(fullNameWithType, scene); } } return((T)sceneAsObject); } #endregion #region EmitterList else if (typeof(T) == typeof(EmitterList)) { EmitterList emitterList = EmitterSaveList.FromFile(assetName).ToEmitterList(mName); mNonDisposableDictionary.Add(fullNameWithType, emitterList); return((T)((object)emitterList)); } #endregion #region Image #if !MONOGAME else if (typeof(T) == typeof(Image)) { switch (extension.ToLowerInvariant()) { case "gif": Image image = Image.FromFile(assetName); loadedAsset = image; break; } } #endif #endregion #region BitmapList #if !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !MONOGAME else if (typeof(T) == typeof(BitmapList)) { loadedAsset = BitmapList.FromFile(assetName); } #endif #endregion #region NodeNetwork else if (typeof(T) == typeof(NodeNetwork)) { NodeNetwork nodeNetwork = NodeNetworkSave.FromFile(assetName).ToNodeNetwork(); mNonDisposableDictionary.Add(fullNameWithType, nodeNetwork); return((T)((object)nodeNetwork)); } #endregion #region ShapeCollection else if (typeof(T) == typeof(ShapeCollection)) { ShapeCollection shapeCollection = ShapeCollectionSave.FromFile(assetName).ToShapeCollection(); mNonDisposableDictionary.Add(fullNameWithType, shapeCollection); return((T)((object)shapeCollection)); } #endregion #region PositionedObjectList<Polygon> else if (typeof(T) == typeof(PositionedObjectList <FlatRedBall.Math.Geometry.Polygon>)) { PositionedObjectList <FlatRedBall.Math.Geometry.Polygon> polygons = PolygonSaveList.FromFile(assetName).ToPolygonList(); mNonDisposableDictionary.Add(fullNameWithType, polygons); return((T)((object)polygons)); } #endregion #region AnimationChainList else if (typeof(T) == typeof(AnimationChainList)) { if (assetName.EndsWith("gif")) { #if WINDOWS_8 || UWP || DESKTOP_GL throw new NotImplementedException(); #else AnimationChainList acl = new AnimationChainList(); acl.Add(FlatRedBall.Graphics.Animation.AnimationChain.FromGif(assetName, this.mName)); acl[0].ParentGifFileName = assetName; loadedAsset = acl; #endif } else { loadedAsset = AnimationChainListSave.FromFile(assetName).ToAnimationChainList(mName); } mNonDisposableDictionary.Add(fullNameWithType, loadedAsset); } #endregion else if (typeof(T) == typeof(Song)) { var loader = new SongLoader(); return((T)(object)loader.Load(assetName)); } #if MONOGAME else if (typeof(T) == typeof(SoundEffect)) { T soundEffect; if (assetName.StartsWith(@".\") || assetName.StartsWith(@"./")) { soundEffect = base.Load <T>(assetName.Substring(2)); } else { soundEffect = base.Load <T>(assetName); } return(soundEffect); } #endif #region RuntimeCsvRepresentation #if !SILVERLIGHT else if (typeof(T) == typeof(RuntimeCsvRepresentation)) { #if XBOX360 throw new NotImplementedException("Can't load CSV from file. Try instead to use the content pipeline."); #else return((T)((object)CsvFileManager.CsvDeserializeToRuntime(assetName))); #endif } #endif #endregion #region SplineList else if (typeof(T) == typeof(List <Spline>)) { List <Spline> splineList = SplineSaveList.FromFile(assetName).ToSplineList(); mNonDisposableDictionary.Add(fullNameWithType, splineList); object asObject = splineList; return((T)asObject); } else if (typeof(T) == typeof(SplineList)) { SplineList splineList = SplineSaveList.FromFile(assetName).ToSplineList(); mNonDisposableDictionary.Add(fullNameWithType, splineList); object asObject = splineList; return((T)asObject); } #endregion #region BitmapFont else if (typeof(T) == typeof(BitmapFont)) { // We used to assume the texture is named the same as the font file // But now FRB understands the .fnt file and gets the PNG from the font file //string pngFile = FileManager.RemoveExtension(assetName) + ".png"; string fntFile = FileManager.RemoveExtension(assetName) + ".fnt"; BitmapFont bitmapFont = new BitmapFont(fntFile, this.mName); object bitmapFontAsObject = bitmapFont; return((T)bitmapFontAsObject); } #endregion #region Text else if (typeof(T) == typeof(string)) { return((T)((object)FileManager.FromFileText(assetName))); } #endregion #region Catch mistakes #if DEBUG else if (typeof(T) == typeof(Spline)) { throw new Exception("Cannot load Splines. Try using the List<Spline> type instead."); } else if (typeof(T) == typeof(Emitter)) { throw new Exception("Cannot load Emitters. Try using the EmitterList type instead."); } #endif #endregion #region else, exception! else { throw new NotImplementedException("Cannot load content of type " + typeof(T).AssemblyQualifiedName + " from file. If you are loading " + "through the content pipeline be sure to remove the extension of the file " + "name."); } #endregion if (loadedAsset != null) { lock (mDisposableDictionary) { // Multiple threads could try to load this content simultaneously if (!mDisposableDictionary.ContainsKey(fullNameWithType)) { mDisposableDictionary.Add(fullNameWithType, loadedAsset); } } } return((T)loadedAsset); } }
public void TestEvaluation() { object evaluated = mExpressionParser.EvaluateExpression("3.1f", new CodeContext(null)); if ((evaluated is float) == false) { throw new Exception("Values with 'f' should be floats"); } TestEvaluation("-16", -16); TestEvaluation("1+1", 2); TestEvaluation("2.3f - 1", 2.3f - 1); TestEvaluation("1 + (2 * 3.0)", 1 + (2 * 3.0)); TestEvaluation("4/2.0f", 4 / 2.0f); TestEvaluation("true || false", true || false); TestEvaluation("true && false", true && false); // Test full evaluations and verify the results TestEvaluation("System.Math.Max(3, 5)", 5); TestEvaluation("System.Math.Min(8-1, 8)", 7); TestEvaluation("this", mElementRuntime, mElementRuntime); TestEvaluation("this.X", mElementRuntime.X, mElementRuntime); TestEvaluation("this.SomeNewVar", 3.333, mElementRuntime); TestEvaluation("System.Math.Max(this.X, this.Y)", System.Math.Max(mElementRuntime.X, mElementRuntime.Y), mElementRuntime); TestEvaluation("float.PositiveInfinity", float.PositiveInfinity); TestEvaluation("System.Math.Max(float.PositiveInfinity, 0)", float.PositiveInfinity); TestEvaluation("VariableState.Left", mElementRuntime.GetStateRecursively("Left"), mElementRuntime); TestEvaluation("new Vector3()", new Vector3()); TestEvaluation("Color.Red", Color.Red); // need this, but first need to be able to reorder cast properly TestEvaluation("new Color(.3f, .4f, .5f, .6f)", new Color(.3f, .4f, .5f, .6f)); TestEvaluation("\"a\" + \"b\"", "ab", null); TestEvaluation("1 + \"a\" + 2", "1a2", null); TestEvaluation("this.SpriteObject.ScaleX", 3.0f, mElementRuntime); EmitterList emitterList = new EmitterList(); var first = new Emitter(); first.Name = "First"; emitterList.Add(first); var second = new Emitter(); second.Name = "Second"; emitterList.Add(second); TestEvaluation("FindByName(\"First\")", emitterList.FindByName("First"), emitterList); }
void CustomInitialize() { mMenuSongReference = MenuSong; mEmitterList = BackgroundEmitters; mEmitterListStartingCount = BackgroundEmitters.Count; }
public void String2Data(StageDataPackage StageData) { EmitterList.Clear(); int num1 = 0; string[] mbGtext1 = MBGtext; int index1 = num1; int num2 = index1 + 1; if (mbGtext1[index1] != "Crazy Storm Data 1.01") { int num3 = (int)MessageBox.Show("当前暂不支持除1.01以外的数据格式", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { string[] mbGtext2 = MBGtext; int index2 = num2; int num4 = index2 + 1; string str1 = mbGtext2[index2]; if (str1.Contains("Types")) { int num5 = int.Parse(str1.Split(' ')[0]); for (int index3 = 0; index3 < num5; ++index3) { MBGtext[num4++].Split('_'); } str1 = MBGtext[num4++]; } if (str1.Contains("GlobalEvents")) { int num5 = int.Parse(str1.Split(' ')[0]); for (int index3 = 0; index3 < num5; ++index3) { string str2 = MBGtext[num4++]; } str1 = MBGtext[num4++]; } if (str1.Contains("Sounds")) { int num5 = int.Parse(str1.Split(' ')[0]); for (int index3 = 0; index3 < num5; ++index3) { string str2 = MBGtext[num4++]; } string str3 = MBGtext[num4++]; } string[] mbGtext3 = MBGtext; int index4 = num4; int num6 = index4 + 1; TimeTotal = int.Parse(mbGtext3[index4].Split(':')[1]); for (int index3 = 0; index3 < 4; ++index3) { string str2 = MBGtext[num6++]; if (str2.Split(':')[1].Split(',')[0] != "empty") { int num5 = int.Parse(str2.Split(':')[1].Split(',')[3]); for (int index5 = 0; index5 < num5; ++index5) { string[] strArray = MBGtext[num6++].Split(','); EmitterMode EmitterMode = EmitterMode.Bullet; if (strArray.Length > 91) { if (bool.Parse(strArray[81])) { EmitterMode = EmitterMode.Enemy; } else if (int.Parse(strArray[91]) > 0) { EmitterMode = EmitterMode.Effect; } } BaseEmitter_CS baseEmitterCs = new BaseEmitter_CS(StageData, this, EmitterMode); if (baseEmitterCs.EmitterMode == EmitterMode.Enemy) { EnemyFactory ef = new EnemyFactory(strArray[82]); ef.HealthPoint = int.Parse(strArray[83]); ef.RedCount = int.Parse(strArray[84]); ef.BlueCount = int.Parse(strArray[85]); ef.ColorType = byte.Parse(strArray[86]); ef.BackFire = bool.Parse(strArray[87]); ef.ClearRadius = int.Parse(strArray[88]); ef.GreenCount = int.Parse(strArray[89]); ef.StarFall = (strArray[90] != "0"); baseEmitterCs.SubBullet = ef.GenerateEnemy(StageData); } baseEmitterCs.ID = int.Parse(strArray[0]); baseEmitterCs.LayerID = int.Parse(strArray[1]); baseEmitterCs.BindingState = bool.Parse(strArray[2]); baseEmitterCs.BindingID = int.Parse(strArray[3]); baseEmitterCs.BindWithDirection = bool.Parse(strArray[4]); baseEmitterCs.CS_Position = new PointF(float.Parse(strArray[6]), float.Parse(strArray[7])); baseEmitterCs.StartTime = int.Parse(strArray[8]); baseEmitterCs.Duration = int.Parse(strArray[9]); baseEmitterCs.EmitPoint = new PointF(float.Parse(strArray[10]), float.Parse(strArray[11])); baseEmitterCs.EmitRadius = (float)int.Parse(strArray[12]); baseEmitterCs.RadiusDirection = (double)float.Parse(strArray[13]); string str3 = strArray[14].Replace("{", "").Replace("}", ""); baseEmitterCs.RadiusDirectionPoint = new PointF(float.Parse(str3.Split(' ')[0].Split(':')[1]), float.Parse(str3.Split(' ')[1].Split(':')[1])); baseEmitterCs.Way = int.Parse(strArray[15]); baseEmitterCs.Circle = int.Parse(strArray[16]); baseEmitterCs.EmitDirection = (double)float.Parse(strArray[17]); string str4 = strArray[18].Replace("{", "").Replace("}", ""); baseEmitterCs.EmitDirectionPoint = new PointF(float.Parse(str4.Split(' ')[0].Split(':')[1]), float.Parse(str4.Split(' ')[1].Split(':')[1])); baseEmitterCs.Range = (double)int.Parse(strArray[19]); baseEmitterCs.Velocity = float.Parse(strArray[20]); baseEmitterCs.DirectionDegree = (double)float.Parse(strArray[21]); string str5 = strArray[22].Replace("{", "").Replace("}", ""); baseEmitterCs.DestPoint = new PointF(float.Parse(str5.Split(' ')[0].Split(':')[1]), float.Parse(str5.Split(' ')[1].Split(':')[1])); baseEmitterCs.AccelerateCS = float.Parse(strArray[23]); baseEmitterCs.AccDirection = (double)float.Parse(strArray[24]); baseEmitterCs.SubBullet.LifeTime = int.Parse(strArray[26]); baseEmitterCs.SubBullet.Type = int.Parse(strArray[27]); baseEmitterCs.SubBullet.ScaleWidth = float.Parse(strArray[28]); baseEmitterCs.SubBullet.ScaleLength = float.Parse(strArray[29]); baseEmitterCs.SubBullet.ColorValue = Color.FromArgb(int.Parse(strArray[30]), int.Parse(strArray[31]), int.Parse(strArray[32])); baseEmitterCs.SubBullet.TransparentValueF = (float)(int.Parse(strArray[33]) * (int)byte.MaxValue / 100); baseEmitterCs.SubBullet.AngleDegree = (double)float.Parse(strArray[34]) + 180.0; baseEmitterCs.SubBullet.AngleWithDirection = bool.Parse(strArray[36]); baseEmitterCs.SubBullet.Velocity = float.Parse(strArray[37]); baseEmitterCs.SubBullet.DirectionDegree = (double)float.Parse(strArray[38]); baseEmitterCs.SubBullet.DestPoint = new PointF(float.Parse(str5.Split(' ')[0].Split(':')[1]), float.Parse(str5.Split(' ')[1].Split(':')[1])); baseEmitterCs.SubBullet.AccelerateCS = float.Parse(strArray[40]); baseEmitterCs.SubBullet.AccDirection = (double)float.Parse(strArray[41]); baseEmitterCs.SubBullet.ScaleX = float.Parse(strArray[43]); baseEmitterCs.SubBullet.ScaleY = float.Parse(strArray[44]); baseEmitterCs.SubBullet.BeginningEffect = bool.Parse(strArray[45]); baseEmitterCs.SubBullet.EndingEffect = bool.Parse(strArray[46]); baseEmitterCs.SubBullet.Active = bool.Parse(strArray[47]); baseEmitterCs.SubBullet.Ghosting = bool.Parse(strArray[48]); baseEmitterCs.SubBullet.OutBound = bool.Parse(strArray[49]); baseEmitterCs.SubBullet.UnRemoveable = bool.Parse(strArray[50]); string str6 = strArray[51]; int index6 = 0; while (true) { if (index6 < str6.Split('&').Length - 1) { string str7 = str6.Split('&')[index6]; EventGroup eventGroup = new EventGroup(); eventGroup.index = index6; eventGroup.tag = str7.Split('|')[0]; eventGroup.t = int.Parse(str7.Split('|')[1]); eventGroup.addtime = int.Parse(str7.Split('|')[2]); int index7 = 0; while (true) { if (index7 < str7.Split('|')[3].Split(';').Length - 1) { Event @event = new Event(); @event.EventString = str7.Split('|')[3].Split(';')[index7]; @event.String2EmitterEvent(); eventGroup.EventList.Add(@event); ++index7; } else { break; } } baseEmitterCs.EventGroupList.Add(eventGroup); ++index6; } else { break; } } string str8 = strArray[52]; int index8 = 0; while (true) { if (index8 < str8.Split('&').Length - 1) { string str7 = str8.Split('&')[index8]; EventGroup eventGroup = new EventGroup(); eventGroup.index = index8; eventGroup.tag = str7.Split('|')[0]; eventGroup.t = int.Parse(str7.Split('|')[1]); eventGroup.addtime = int.Parse(str7.Split('|')[2]); int index7 = 0; while (true) { if (index7 < str7.Split('|')[3].Split(';').Length - 1) { Event @event = new Event(); @event.EventString = str7.Split('|')[3].Split(';')[index7]; @event.String2BulletEvent(); eventGroup.EventList.Add(@event); ++index7; } else { break; } } baseEmitterCs.SubBullet.EventGroupList.Add(eventGroup); ++index8; } else { break; } } baseEmitterCs.RanX = float.Parse(strArray[53]); baseEmitterCs.RanY = float.Parse(strArray[54]); baseEmitterCs.RanRadius = (float)int.Parse(strArray[55]); baseEmitterCs.RanRadiusDirection = (double)float.Parse(strArray[56]); baseEmitterCs.RanWay = int.Parse(strArray[57]); baseEmitterCs.RanCircle = int.Parse(strArray[58]); baseEmitterCs.RanEmitDirection = (double)float.Parse(strArray[59]); baseEmitterCs.RanRange = (double)int.Parse(strArray[60]); baseEmitterCs.RanVelocity = float.Parse(strArray[61]); baseEmitterCs.RanDirection = (double)float.Parse(strArray[62]); baseEmitterCs.RanAccelerate = float.Parse(strArray[63]); baseEmitterCs.RanAccDirection = (double)float.Parse(strArray[64]); baseEmitterCs.SubBullet.RanAngle = (double)float.Parse(strArray[65]); baseEmitterCs.SubBullet.RanVelocity = float.Parse(strArray[66]); baseEmitterCs.SubBullet.RanDirection = (double)float.Parse(strArray[67]); baseEmitterCs.SubBullet.RanAccelerate = float.Parse(strArray[68]); baseEmitterCs.SubBullet.RanAccDirection = (double)float.Parse(strArray[69]); if (strArray.Length > 72) { baseEmitterCs.SubBullet.Cover = bool.Parse(strArray[70]); baseEmitterCs.SubBullet.Rebound = bool.Parse(strArray[71]); baseEmitterCs.SubBullet.Force = bool.Parse(strArray[72]); } if (strArray.Length > 73) { baseEmitterCs.DeepBinding = bool.Parse(strArray[73]); } if (strArray.Length > 79) { baseEmitterCs.MotionBinding = bool.Parse(strArray[74]); if (baseEmitterCs.SubBullet is BaseBullet_Touhou) { ((BaseBullet_Touhou)baseEmitterCs.SubBullet).Reflect = byte.Parse(strArray[75]); ((BaseBullet_Touhou)baseEmitterCs.SubBullet).Layer = int.Parse(strArray[78]); } baseEmitterCs.SoundName = strArray[76]; baseEmitterCs.SpecifySE = bool.Parse(strArray[77]); if (int.Parse(strArray[79]) != 0) { baseEmitterCs.SubBullet.Region = int.Parse(strArray[79]); ((BaseBullet_Touhou)baseEmitterCs.SubBullet).SizeValue = baseEmitterCs.SubBullet.Region * 2; } } if (strArray.Length > 95) { baseEmitterCs.EffectType = int.Parse(strArray[91]); if (strArray[92] != null && StageData.TextureObjectDictionary.ContainsKey(strArray[92])) { baseEmitterCs.SubBullet.TxtureObject = StageData.TextureObjectDictionary[strArray[92]]; } baseEmitterCs.Count = int.Parse(strArray[94]); baseEmitterCs.Count = baseEmitterCs.Count < 1 ? 1 : baseEmitterCs.Count; baseEmitterCs.DeltaV = float.Parse(strArray[95]); } if (strArray.Length > 110) { baseEmitterCs.RDirectionWithDirection = !(strArray[96] == "0"); } EmitterList.Add(baseEmitterCs); if (EmitterMode == EmitterMode.Bullet) { BaseEmitter_CS b2 = new BaseEmitter_CS(StageData, this, EmitterMode); b2 = (BaseEmitter_CS)baseEmitterCs.Clone(); b2.SubBullet.Velocity = baseEmitterCs.SubBullet.Velocity * 1.5f; b2.SubBullet.AccelerateCS = baseEmitterCs.SubBullet.AccelerateCS * 1.5f; EmitterList.Add(b2); } } if (str2.Split(':')[1].Split(',').Length >= 7) { int num7 = int.Parse(str2.Split(':')[1].Split(',')[4]); for (int index5 = 0; index5 < num7; ++index5) { string str3 = MBGtext[num6++]; string[] strArray = str3.Split(','); BaseEmitter_CS baseEmitterCs = !bool.Parse(strArray[29]) ? (strArray.Length <= 61 ? new BaseEmitter_CS(StageData, this, EmitterMode.StraightLaser) : (!bool.Parse(strArray[61]) ? new BaseEmitter_CS(StageData, this, EmitterMode.StraightLaser) : new BaseEmitter_CS(StageData, this, EmitterMode.BendLaser))) : new BaseEmitter_CS(StageData, this, EmitterMode.RadialLaser); baseEmitterCs.ID = int.Parse(strArray[0]); baseEmitterCs.LayerID = int.Parse(strArray[1]); baseEmitterCs.BindingState = bool.Parse(strArray[2]); baseEmitterCs.BindingID = int.Parse(strArray[3]); baseEmitterCs.BindWithDirection = bool.Parse(strArray[4]); baseEmitterCs.CS_Position = new PointF(float.Parse(strArray[6]), float.Parse(strArray[7])); baseEmitterCs.StartTime = int.Parse(strArray[8]); baseEmitterCs.Duration = int.Parse(strArray[9]); baseEmitterCs.EmitRadius = (float)int.Parse(strArray[10]); baseEmitterCs.RadiusDirection = (double)float.Parse(strArray[11]); baseEmitterCs.Way = int.Parse(strArray[13]); baseEmitterCs.Circle = int.Parse(strArray[14]); baseEmitterCs.EmitDirection = (double)float.Parse(strArray[15]); baseEmitterCs.Range = (double)int.Parse(strArray[17]); baseEmitterCs.Velocity = float.Parse(strArray[18]); baseEmitterCs.DirectionDegree = (double)float.Parse(strArray[19]); baseEmitterCs.AccelerateCS = float.Parse(strArray[21]); baseEmitterCs.AccDirection = (double)float.Parse(strArray[22]); baseEmitterCs.SubBullet.LifeTime = int.Parse(strArray[24]); baseEmitterCs.SubBullet.Type = int.Parse(strArray[25]); if (baseEmitterCs.EmitterMode == EmitterMode.StraightLaser || baseEmitterCs.EmitterMode == EmitterMode.BendLaser) { baseEmitterCs.SubBullet.ScaleLength = float.Parse(strArray[26]); baseEmitterCs.SubBullet.GhostingCount = int.Parse(strArray[27]); } else { baseEmitterCs.SubBullet.MaxScaleW = (float)int.Parse(strArray[27]) / 256f; baseEmitterCs.SubBullet.ScaleWidth = baseEmitterCs.SubBullet.MaxScaleW; baseEmitterCs.SubBullet.MaxScaleL = 1f; baseEmitterCs.SubBullet.ScaleLength = 0.2f; } baseEmitterCs.SubBullet.TransparentValueF = (float)(int.Parse(strArray[28]) * (int)byte.MaxValue / 100); baseEmitterCs.SubBullet.Velocity = float.Parse(strArray[30]); baseEmitterCs.SubBullet.DirectionDegree = (double)float.Parse(strArray[31]); baseEmitterCs.SubBullet.AccelerateCS = float.Parse(strArray[33]); baseEmitterCs.SubBullet.AccDirection = (double)float.Parse(strArray[34]); baseEmitterCs.SubBullet.Active = bool.Parse(strArray[38]); baseEmitterCs.SubBullet.UnRemoveable = bool.Parse(strArray[40]); string str4 = strArray[42]; int index6 = 0; while (true) { if (index6 < str4.Split('&').Length - 1) { string str5 = str4.Split('&')[index6]; EventGroup eventGroup = new EventGroup(); eventGroup.index = index6; eventGroup.tag = str5.Split('|')[0]; eventGroup.t = int.Parse(str5.Split('|')[1]); eventGroup.addtime = int.Parse(str5.Split('|')[2]); int index7 = 0; while (true) { if (index7 < str5.Split('|')[3].Split(';').Length - 1) { Event @event = new Event(); @event.EventString = str5.Split('|')[3].Split(';')[index7]; @event.String2EmitterEvent(); eventGroup.EventList.Add(@event); ++index7; } else { break; } } baseEmitterCs.EventGroupList.Add(eventGroup); ++index6; } else { break; } } string str6 = strArray[43]; int index8 = 0; while (true) { if (index8 < str6.Split('&').Length - 1) { string str5 = str6.Split('&')[index8]; EventGroup eventGroup = new EventGroup(); eventGroup.index = index8; eventGroup.tag = str5.Split('|')[0]; eventGroup.t = int.Parse(str5.Split('|')[1]); eventGroup.addtime = int.Parse(str5.Split('|')[2]); int index7 = 0; while (true) { if (index7 < str5.Split('|')[3].Split(';').Length - 1) { Event @event = new Event(); @event.EventString = str5.Split('|')[3].Split(';')[index7]; @event.String2BulletEvent(); eventGroup.EventList.Add(@event); ++index7; } else { break; } } baseEmitterCs.SubBullet.EventGroupList.Add(eventGroup); ++index8; } else { break; } } baseEmitterCs.RanRadius = (float)int.Parse(strArray[44]); baseEmitterCs.RanRadiusDirection = (double)float.Parse(strArray[45]); baseEmitterCs.RanWay = int.Parse(strArray[46]); baseEmitterCs.RanCircle = int.Parse(strArray[47]); baseEmitterCs.RanEmitDirection = (double)float.Parse(strArray[48]); baseEmitterCs.RanRange = (double)int.Parse(strArray[49]); baseEmitterCs.RanVelocity = float.Parse(strArray[50]); baseEmitterCs.RanDirection = (double)float.Parse(strArray[51]); baseEmitterCs.RanAccelerate = float.Parse(strArray[52]); baseEmitterCs.RanAccDirection = (double)float.Parse(strArray[53]); baseEmitterCs.SubBullet.RanVelocity = float.Parse(strArray[54]); baseEmitterCs.SubBullet.RanDirection = (double)float.Parse(strArray[55]); baseEmitterCs.SubBullet.RanAccelerate = float.Parse(strArray[56]); baseEmitterCs.SubBullet.RanAccDirection = (double)float.Parse(strArray[57]); if (strArray.Length > 58) { baseEmitterCs.DeepBinding = bool.Parse(strArray[58]); } if (strArray.Length > 62) { if (baseEmitterCs.SubBullet is BaseBullet_Touhou) { ((BaseBullet_Touhou)baseEmitterCs.SubBullet).Reflect = byte.Parse(str3.Split(',')[59]); } baseEmitterCs.MotionBinding = (bool.Parse(str3.Split(',')[60]) ? 1 : 0) != 0; if (baseEmitterCs.EmitterMode == EmitterMode.StraightLaser) { ((Bullet_StraightLaser)baseEmitterCs.SubBullet).LaserHead = (bool.Parse(str3.Split(',')[62]) ? 1 : 0) != 0; } } EmitterList.Add(baseEmitterCs); } int num8 = int.Parse(str2.Split(':')[1].Split(',')[5]); for (int index5 = 0; index5 < num8; ++index5) { string[] strArray = MBGtext[num6++].Split(','); BaseCover_CS baseCoverCs = new BaseCover_CS(StageData); baseCoverCs.MaxScale = 1000f; baseCoverCs.ID = int.Parse(strArray[0]); baseCoverCs.LayerID = int.Parse(strArray[1]); baseCoverCs.CS_Position = new PointF(float.Parse(strArray[2]), float.Parse(strArray[3])); baseCoverCs.StartTime = int.Parse(strArray[4]); baseCoverCs.Duration = int.Parse(strArray[5]); baseCoverCs.ScaleWidth = (float)int.Parse(strArray[6]); baseCoverCs.ScaleLength = (float)int.Parse(strArray[7]); baseCoverCs.Roundness = bool.Parse(strArray[8]); baseCoverCs.Type = int.Parse(strArray[9]); baseCoverCs.CtrlID = int.Parse(strArray[10]); baseCoverCs.Velocity = float.Parse(strArray[11]); baseCoverCs.DirectionDegree = (double)float.Parse(strArray[12]); baseCoverCs.AccelerateCS = float.Parse(strArray[14]); baseCoverCs.AccDirection = (double)float.Parse(strArray[15]); string str3 = strArray[17]; int index6 = 0; while (true) { if (index6 < str3.Split('&').Length - 1) { string str4 = str3.Split('&')[index6]; EventGroup eventGroup = new EventGroup(); eventGroup.index = index6; eventGroup.tag = str4.Split('|')[0]; eventGroup.t = int.Parse(str4.Split('|')[1]); eventGroup.addtime = int.Parse(str4.Split('|')[2]); int index7 = 0; while (true) { if (index7 < str4.Split('|')[3].Split(';').Length - 1) { Event @event = new Event(); @event.EventString = str4.Split('|')[3].Split(';')[index7]; @event.String2EmitterEvent(); eventGroup.EventList.Add(@event); ++index7; } else { break; } } baseCoverCs.EventGroupList.Add(eventGroup); ++index6; } else { break; } } string str5 = strArray[18]; int index8 = 0; while (true) { if (index8 < str5.Split('&').Length - 1) { string str4 = str5.Split('&')[index8]; EventGroup eventGroup = new EventGroup(); eventGroup.index = index8; eventGroup.tag = str4.Split('|')[0]; eventGroup.t = int.Parse(str4.Split('|')[1]); eventGroup.addtime = int.Parse(str4.Split('|')[2]); int index7 = 0; while (true) { if (index7 < str4.Split('|')[3].Split(';').Length - 1) { Event @event = new Event(); @event.EventString = str4.Split('|')[3].Split(';')[index7]; @event.String2BulletEvent(); eventGroup.EventList.Add(@event); ++index7; } else { break; } } baseCoverCs.SubEventGroupList.Add(eventGroup); ++index8; } else { break; } } baseCoverCs.RanVelocity = float.Parse(strArray[19]); baseCoverCs.RanDirection = (double)float.Parse(strArray[20]); baseCoverCs.RanAccelerate = float.Parse(strArray[21]); baseCoverCs.RanAccDirection = (double)float.Parse(strArray[22]); if (strArray.Length >= 24) { baseCoverCs.BindingID = int.Parse(strArray[23]); } if (strArray.Length >= 25 && strArray[24] != "") { baseCoverCs.DeepBinding = bool.Parse(strArray[24]); } EmitterList.Add((BaseEmitter_CS)baseCoverCs); } int num9 = int.Parse(str2.Split(':')[1].Split(',')[6]); string str7; for (int index5 = 0; index5 < num9; ++index5) { str7 = MBGtext[num6++]; } int num10 = int.Parse(str2.Split(':')[1].Split(',')[7]); for (int index5 = 0; index5 < num10; ++index5) { str7 = MBGtext[num6++]; } } } } } }
/// <summary> /// Creates a runtime object and adds the LoadedFile to the element. /// </summary> /// <param name="objectToLoad"></param> /// <param name="container"></param> /// <param name="elementRuntime"></param> /// <param name="objectType"></param> /// <param name="objectJustLoaded"></param> /// <param name="newElementRuntime"></param> /// <param name="toAddTo"></param> /// <param name="layerToAddTo"></param> /// <param name="rfs"></param> /// <param name="pullsFromEntireNamedObject"></param> /// <returns></returns> private static LoadedFile CreateRuntimeObjectForNamedObject(NamedObjectSave objectToLoad, IElement container, ElementRuntime elementRuntime, string objectType, LoadedFile objectJustLoaded, ElementRuntime newElementRuntime, object toAddTo, Layer layerToAddTo, ReferencedFileSave rfs, bool pullsFromEntireNamedObject) { var fileName = ElementRuntime.ContentDirectory + objectToLoad.SourceFile; bool shouldClone = rfs != null && (rfs.IsSharedStatic && !(container is ScreenSave)) && !pullsFromEntireNamedObject; LoadedFile toReturn = null; // This could have a ( in the name in a file like .scnx, so use the last ( //int indexOfType = objectToLoad.SourceName.IndexOf("("); int indexOfType = objectToLoad.SourceName.LastIndexOf("("); string objectName = objectToLoad.SourceName.Substring(0, indexOfType - 1); switch (objectType) { case "Scene": { Scene scene = objectJustLoaded.RuntimeObject as Scene; foreach (Text text in scene.Texts) { text.AdjustPositionForPixelPerfectDrawing = true; if (ObjectFinder.Self.GlueProject.UsesTranslation) { text.DisplayText = LocalizationManager.Translate(text.DisplayText); } } if (shouldClone) { scene = scene.Clone(); elementRuntime.EntireScenes.Add(objectToLoad.SourceFile, scene); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = scene; loadedFile.FilePath = objectToLoad.SourceFile; loadedFile.ReferencedFileSave = rfs; toReturn = loadedFile; newElementRuntime.ReferencedFileRuntimeList.Add(loadedFile); scene.AddToManagers(layerToAddTo); } } break; case "Sprite": { Sprite loadedSprite = null; Scene scene = objectJustLoaded.RuntimeObject as Scene; if (scene != null) { loadedSprite = scene.Sprites.FindByName(objectName); } if (loadedSprite == null) { System.Windows.Forms.MessageBox.Show("There is a missing Sprite called\n\n" + objectName + "\n\n" + "in the object\n\n" + elementRuntime.Name + "\n\n" + "This probably happened if someone changed the name of a Sprite in a .scnx file but didn't update " + "the associated object in Glue", "Missing Sprite"); } else { if (shouldClone) { loadedSprite = loadedSprite.Clone(); (toAddTo as Scene).Sprites.Add(loadedSprite); SpriteManager.AddToLayer(loadedSprite, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedSprite; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } } break; case "SpriteFrame": { Scene scene = objectJustLoaded.RuntimeObject as Scene; SpriteFrame loadedSpriteFrame = scene.SpriteFrames.FindByName(objectName); if (loadedSpriteFrame != null) { if (shouldClone) { loadedSpriteFrame = loadedSpriteFrame.Clone(); (toAddTo as Scene).SpriteFrames.Add(loadedSpriteFrame); SpriteManager.AddToLayer(loadedSpriteFrame, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedSpriteFrame; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } } break; case "SpriteGrid": { Scene scene = objectJustLoaded.RuntimeObject as Scene; SpriteGrid spriteGrid = null; for (int i = 0; i < scene.SpriteGrids.Count; i++) { if (scene.SpriteGrids[i].Name == objectName) { spriteGrid = scene.SpriteGrids[i]; break; } } if (spriteGrid != null) { if (shouldClone) { spriteGrid = spriteGrid.Clone(); (toAddTo as Scene).SpriteGrids.Add(spriteGrid); spriteGrid.Layer = layerToAddTo; spriteGrid.PopulateGrid(); spriteGrid.RefreshPaint(); spriteGrid.Manage(); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = spriteGrid; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } } break; case "Text": { Scene scene = objectJustLoaded.RuntimeObject as Scene; Text loadedText = scene.Texts.FindByName(objectName); if (loadedText != null) { if (shouldClone) { loadedText = loadedText.Clone(); (toAddTo as Scene).Texts.Add(loadedText); TextManager.AddToLayer(loadedText, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedText; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } loadedText.AdjustPositionForPixelPerfectDrawing = true; if (LocalizationManager.HasDatabase) { loadedText.DisplayText = LocalizationManager.Translate(loadedText.DisplayText); } } } break; case "ShapeCollection": { ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection; if (shouldClone) { shapeCollection = shapeCollection.Clone(); elementRuntime.EntireShapeCollections.Add(objectToLoad.SourceFile, shapeCollection); newElementRuntime.ReferencedFileRuntimeList.LoadedShapeCollections.Add(shapeCollection); shapeCollection.AddToManagers(layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = shapeCollection; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } // Most cases are handled below in an AttachTo method, but // ShapeCollection isn't a PositionedObject so we have to do it manually here if (objectToLoad.AttachToContainer) { shapeCollection.AttachTo(elementRuntime, true); } } break; case "AxisAlignedCube": { ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection; AxisAlignedCube loadedAxisAlignedCube = shapeCollection.AxisAlignedCubes.FindByName(objectName); if (shouldClone) { loadedAxisAlignedCube = loadedAxisAlignedCube.Clone(); (toAddTo as ShapeCollection).AxisAlignedCubes.Add(loadedAxisAlignedCube); ShapeManager.AddToLayer(loadedAxisAlignedCube, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedAxisAlignedCube; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "AxisAlignedRectangle": { ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection; AxisAlignedRectangle loadedAxisAlignedRectangle = shapeCollection.AxisAlignedRectangles.FindByName(objectName); if (shouldClone) { loadedAxisAlignedRectangle = loadedAxisAlignedRectangle.Clone(); (toAddTo as ShapeCollection).AxisAlignedRectangles.Add(loadedAxisAlignedRectangle); ShapeManager.AddToLayer(loadedAxisAlignedRectangle, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedAxisAlignedRectangle; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "Circle": { ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection; Circle loadedCircle = shapeCollection.Circles.FindByName(objectName); if (shouldClone) { loadedCircle = loadedCircle.Clone(); (toAddTo as ShapeCollection).Circles.Add(loadedCircle); ShapeManager.AddToLayer(loadedCircle, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedCircle; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "Polygon": { ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection; Polygon loadedPolygon = shapeCollection.Polygons.FindByName(objectName); if (shouldClone) { loadedPolygon = loadedPolygon.Clone(); (toAddTo as ShapeCollection).Polygons.Add(loadedPolygon); ShapeManager.AddToLayer(loadedPolygon, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedPolygon; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "Sphere": { ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection; Sphere loadedSphere = shapeCollection.Spheres.FindByName(objectName); if (shouldClone) { loadedSphere = loadedSphere.Clone(); (toAddTo as ShapeCollection).Spheres.Add(loadedSphere); ShapeManager.AddToLayer(loadedSphere, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedSphere; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "Capsule2D": { ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection; Capsule2D loadedCapsule2D = shapeCollection.Capsule2Ds.FindByName(objectName); if (shouldClone) { loadedCapsule2D = loadedCapsule2D.Clone(); (toAddTo as ShapeCollection).Capsule2Ds.Add(loadedCapsule2D); ShapeManager.AddToLayer(loadedCapsule2D, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedCapsule2D; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "Emitter": { EmitterList emitterList = objectJustLoaded.RuntimeObject as EmitterList; Emitter loadedEmitter = emitterList.FindByName(objectName); if (shouldClone && loadedEmitter != null) { loadedEmitter = loadedEmitter.Clone(); (toAddTo as EmitterList).Add(loadedEmitter); SpriteManager.AddEmitter(loadedEmitter, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = loadedEmitter; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "EmitterList": { EmitterList emitterList = objectJustLoaded.RuntimeObject as EmitterList; if (shouldClone && emitterList != null) { emitterList = emitterList.Clone(); foreach (var item in emitterList) { SpriteManager.AddEmitter(item); } var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = emitterList; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "NodeNetwork": { NodeNetwork nodeNetwork = objectJustLoaded.RuntimeObject as NodeNetwork; if (shouldClone) { nodeNetwork = nodeNetwork.Clone(); elementRuntime.EntireNodeNetworks.Add(objectToLoad.SourceFile, nodeNetwork); newElementRuntime.ReferencedFileRuntimeList.LoadedNodeNetworks.Add(nodeNetwork); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = nodeNetwork; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "SplineList": { SplineList splineList = objectJustLoaded.RuntimeObject as SplineList; if (shouldClone) { splineList = splineList.Clone(); elementRuntime.EntireSplineLists.Add(splineList.Name, splineList); foreach (var spline in splineList) { spline.CalculateVelocities(); spline.CalculateAccelerations(); } splineList.AddToManagers(); splineList[0].UpdateShapes(); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = splineList; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } } break; case "Spline": { SplineList splineList = objectJustLoaded.RuntimeObject as SplineList; Spline spline = splineList.FirstOrDefault(item => item.Name == objectName); if (shouldClone && spline != null) { spline = spline.Clone(); (toAddTo as SplineList).Add(spline); // Eventually support layers? //ShapeManager.AddToLayer(spline, layerToAddTo); var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = spline; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; } spline.CalculateVelocities(); spline.CalculateAccelerations(); } break; } if (toReturn == null) { foreach (var manager in ReferencedFileRuntimeList.FileManagers) { var objectFromFile = manager.TryGetObjectFromFile(elementRuntime.ReferencedFileRuntimeList.LoadedRfses, rfs, objectType, objectName); if (objectFromFile != null) { var runtimeObject = objectFromFile; var loadedFile = new LoadedFile(); loadedFile.RuntimeObject = runtimeObject; loadedFile.FilePath = objectJustLoaded.FilePath; loadedFile.DataModel = objectJustLoaded.DataModel; loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave; toReturn = loadedFile; break; } } } if (toReturn != null && objectToLoad.AttachToContainer) { if (toReturn.RuntimeObject is PositionedObject) { // If the object is already attached to something, that means it // came from a file, so we don't want to re-attach it. PositionedObject asPositionedObject = toReturn.RuntimeObject as PositionedObject; if (asPositionedObject.Parent == null) { asPositionedObject.AttachTo(elementRuntime, true); } } else if (toReturn.RuntimeObject is Scene) { ((Scene)toReturn.RuntimeObject).AttachAllDetachedTo(elementRuntime, true); } else if (toReturn.RuntimeObject is ShapeCollection) { ((ShapeCollection)toReturn.RuntimeObject).AttachAllDetachedTo(elementRuntime, true); } } return(toReturn); }
public EmitterList ToEmitterList(string contentManagerName) { string oldRelativeDirectory = FileManager.RelativeDirectory; FileManager.RelativeDirectory = FileManager.GetDirectory(this.Name); EmitterList emitterList = new EmitterList(); foreach (EmitterSave es in this.emitters) { emitterList.Add(es.ToEmitter(contentManagerName)); } FileManager.RelativeDirectory = oldRelativeDirectory; return emitterList; }
public void TestEvaluation() { object evaluated = mExpressionParser.EvaluateExpression("3.1f", new CodeContext(null)); if ((evaluated is float) == false) { throw new Exception("Values with 'f' should be floats"); } TestEvaluation("-16", -16); TestEvaluation("1+1", 2); TestEvaluation("2.3f - 1", 2.3f - 1); TestEvaluation("1 + (2 * 3.0)", 1 + (2 * 3.0)); TestEvaluation("4/2.0f", 4 / 2.0f); TestEvaluation("true || false", true || false); TestEvaluation("true && false", true && false); // Test full evaluations and verify the results TestEvaluation("System.Math.Max(3, 5)", 5); TestEvaluation("System.Math.Min(8-1, 8)", 7); TestEvaluation("this", mElementRuntime, mElementRuntime); TestEvaluation("this.X", mElementRuntime.X, mElementRuntime); TestEvaluation("this.SomeNewVar", 3.333, mElementRuntime); TestEvaluation("System.Math.Max(this.X, this.Y)", System.Math.Max(mElementRuntime.X, mElementRuntime.Y), mElementRuntime); TestEvaluation("float.PositiveInfinity", float.PositiveInfinity); TestEvaluation("System.Math.Max(float.PositiveInfinity, 0)", float.PositiveInfinity); TestEvaluation("VariableState.Left", mElementRuntime.GetStateRecursively("Left"), mElementRuntime); TestEvaluation("new Vector3()", new Vector3()); TestEvaluation("Color.Red", Color.Red); // need this, but first need to be able to reorder cast properly TestEvaluation("new Color(.3f, .4f, .5f, .6f)", new Color(.3f, .4f, .5f, .6f)); TestEvaluation("\"a\" + \"b\"", "ab", null); TestEvaluation("1 + \"a\" + 2", "1a2", null); TestEvaluation("this.SpriteObject.ScaleX", 3.0f, mElementRuntime); EmitterList emitterList = new EmitterList(); var first = new Emitter(); first.Name = "First"; emitterList.Add(first); var second = new Emitter(); second.Name = "Second"; emitterList.Add(second); TestEvaluation("FindByName(\"First\")", emitterList.FindByName("First"), emitterList); }
public static void UnloadStaticContent() { IsStaticContentLoaded = false; mHasRegisteredUnload = false; if (EmitterListFile != null) { EmitterListFile.RemoveFromManagers(ContentManagerName != "Global"); EmitterListFile= null; } }
public static void LoadStaticContent(string contentManagerName) { ContentManagerName = contentManagerName; #if DEBUG if (contentManagerName == FlatRedBallServices.GlobalContentManager) { HasBeenLoadedWithGlobalContentManager = true; } else if (HasBeenLoadedWithGlobalContentManager) { throw new Exception("This type has been loaded with a Global content manager, then loaded with a non-global. This can lead to a lot of bugs"); } #endif if (IsStaticContentLoaded == false) { IsStaticContentLoaded = true; lock (mLockObject) { if (!mHasRegisteredUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("EmmiterStaticUnload", UnloadStaticContent); mHasRegisteredUnload = true; } } bool registerUnload = false; if (!FlatRedBallServices.IsLoaded<FlatRedBall.Graphics.Particle.EmitterList>(@"content/screens/gamescreen/emitterlistfile.emix", ContentManagerName)) { registerUnload = true; } EmitterListFile = FlatRedBallServices.Load<FlatRedBall.Graphics.Particle.EmitterList>(@"content/screens/gamescreen/emitterlistfile.emix", ContentManagerName); if (registerUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { lock (mLockObject) { if (!mHasRegisteredUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("EmmiterStaticUnload", UnloadStaticContent); mHasRegisteredUnload = true; } } } CustomLoadStaticContent(contentManagerName); } }
public void String2Data(StageDataPackage StageData) { EmitterList.Clear(); int num1 = 0; string[] mbGtext1 = MBGtext; int index1 = num1; int num2 = index1 + 1; if (mbGtext1[index1] != "Crazy Storm Data 1.01") { MessageBox.Show("当前暂不支持除1.01以外的数据格式", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { string[] mbGtext2 = MBGtext; int index2 = num2; int num4 = index2 + 1; string str1 = mbGtext2[index2]; if (str1.Contains("Types")) { int num5 = int.Parse(str1.Split(' ')[0]); for (int index3 = 0; index3 < num5; ++index3) { MBGtext[num4++].Split('_'); } str1 = MBGtext[num4++]; } if (str1.Contains("GlobalEvents")) { int num5 = int.Parse(str1.Split(' ')[0]); for (int index3 = 0; index3 < num5; ++index3) { string str2 = MBGtext[num4++]; } str1 = MBGtext[num4++]; } if (str1.Contains("Sounds")) { int num5 = int.Parse(str1.Split(' ')[0]); for (int index3 = 0; index3 < num5; ++index3) { string str2 = MBGtext[num4++]; } string str3 = MBGtext[num4++]; } string[] mbGtext3 = MBGtext; int index4 = num4; int num6 = index4 + 1; TimeTotal = int.Parse(mbGtext3[index4].Split(':')[1]); for (int index3 = 0; index3 < 4; ++index3) { string str2 = MBGtext[num6++]; if (str2.Split(':')[1].Split(',')[0] != "empty") { int num5 = int.Parse(str2.Split(':')[1].Split(',')[3]); for (int index5 = 0; index5 < num5; ++index5) { string[] strArray = MBGtext[num6++].Split(','); EmitterMode EmitterMode = EmitterMode.Bullet; if (strArray.Length > 91) { if (bool.Parse(strArray[81])) { EmitterMode = EmitterMode.Enemy; } else if (int.Parse(strArray[91]) > 0) { EmitterMode = EmitterMode.Effect; } } BaseEmitter_CS baseEmitterCs = new BaseEmitter_CS(StageData, this, EmitterMode); if (baseEmitterCs.EmitterMode == EmitterMode.Enemy) { baseEmitterCs.SubBullet = new EnemyFactory(strArray[82]) { HealthPoint = int.Parse(strArray[83]), RedCount = int.Parse(strArray[84]), BlueCount = int.Parse(strArray[85]), ColorType = byte.Parse(strArray[86]), BackFire = bool.Parse(strArray[87]), ClearRadius = int.Parse(strArray[88]), GreenCount = int.Parse(strArray[89]), StarFall = (strArray[90] != "0") } }