public ChangeGrid(SpriteGrid referenceGrid, float x, float y, float z, long TimeToExecute) { this.referenceObject = referenceGrid; this.timeToExecute = TimeToExecute; this.x = x; this.y = y; this.z = z; }
public Bomb(int x, int y) { this.X = x; this.Y = y; Width = 16; Height = 16; animationGrid = new SpriteGrid("bomb", 3, 1); }
public Explodable(int x, int y) { this.X = x * 16; this.Y = y * 16; Width = 16; Height = 16; animationGrid = new SpriteGrid("explodable", 6, 1); this.IsSolid = true; }
public Button(int x, int y, String id) { spriteGrid = new SpriteGrid("button", 2, 1); this.id = id; X = x*16; Y = y*16 + 16 - 5; this.Width = spriteGrid.FrameSize.X; this.Height = 7; }
public BoatRope() { ropeGrid = new SpriteGrid("boat_rope", 2, 1); font = DiverGame.DefaultContent.Load<SpriteFont>("Font"); Size.X = 16; Size.Y = 5; X = 190; Y = 170; Reset(); }
public Decoration(SpriteGrid spriteGrid, int animationSpeed, Rectangle dimension, Room.Layer layer, Color color) { X = dimension.X; Y = dimension.Y; Width = dimension.Width; Height = dimension.Height; this.layer = layer; this.animationSpeed = animationSpeed; this.color = color; animationGrid = spriteGrid; }
public static ImageData RenderSpriteGrid(SpriteGrid spriteGrid) { int textureWidth = (int)(.5f + spriteGrid.FurthestRightX - spriteGrid.FurthestLeftX); int textureHeight = (int)(.5f + spriteGrid.FurthestTopY - spriteGrid.FurthestBottomY); ImageData imageData = new ImageData(textureWidth, textureHeight); RenderSpriteGrid(spriteGrid, imageData); return(imageData); }
public TinyDiver(ITool tool1, ITool tool2, int x, int y) : base(tool1, tool2, x, y) { Size = new Point(16, 28); StandingGrid = new SpriteGrid("tiny_standing", 2, 1); WalkingGrid = new SpriteGrid("tiny_walking", 12, 1); JumpingGrid = new SpriteGrid("tiny_jumping", 6, 1); ClimbingGrid = new SpriteGrid("tiny_climbing", 2, 1); Name = "Tiny"; originalBoatPosition = new Point(250, 224 - Height); }
public void ManageAll() { for (int i = 0; i < mSpriteGrids.Count; i++) { SpriteGrid spriteGrid = mSpriteGrids[i]; spriteGrid.Manage(); } // No need to manage SpriteFrames now that they're automatically managed by the SpriteManager. }
public void GridListBoxClick(Window callingWindow) { SpriteGrid tempGridGrabbed = this.SpriteGridListBox.GetFirstHighlightedObject() as SpriteGrid; GameData.sesgMan.ClickGrid(tempGridGrabbed, null); if (tempGridGrabbed != null) { SESpriteGridManager.CurrentSpriteGrid = tempGridGrabbed; SpriteEditorSettings.EditingSpriteGrids = true; } }
public FattyDiver(ITool tool1, ITool tool2, int x, int y) : base(tool1, tool2, x, y) { Size = new Point(16, 40); StandingGrid = new SpriteGrid("tiny_standing", 2, 1); WalkingGrid = new SpriteGrid("tiny_walking", 12, 1); JumpingGrid = new SpriteGrid("tiny_jumping", 6, 1); ClimbingGrid = new SpriteGrid("fatty_climbing", 2, 1); Name = "Fatty"; originalBoatPosition = new Point(200, 224 - Height); Strength = 20; }
public Fish(string spriteGridName, int sprites, int x, int y, Room.Layer layer) { this.position.X = x*16; this.position.Y = y*16; TriggerNewSpeedTarget(); this.layer = layer; this.sprites = sprites; animationGrid = new SpriteGrid(spriteGridName, sprites, 1); Width = animationGrid.FrameSize.X; Height = animationGrid.FrameSize.Y; }
public override void ExecuteOn(object target) { SpriteGrid asSpriteGrid = target as SpriteGrid; for (int i = 0; i < mTextureLocations.Count; i++) { TextureLocation <Texture2D> textureLocation = mTextureLocations[i]; asSpriteGrid.PaintSprite(textureLocation.X, textureLocation.Y, asSpriteGrid.Blueprint.Z, textureLocation.Texture); } }
public override void ExecuteOn(object target) { SpriteGrid asSpriteGrid = target as SpriteGrid; for (int i = 0; i < mDisplayRegions.Count; i++) { TextureLocation <FloatRectangle> displayRegion = mDisplayRegions[i]; FloatRectangle rectangle = displayRegion.Texture; asSpriteGrid.PaintSpriteDisplayRegion( displayRegion.X, displayRegion.Y, asSpriteGrid.Blueprint.Z, ref rectangle); } }
public virtual void Activity(bool firstTimeCalled) { if (IsPaused) { mAccumulatedPausedTime += TimeManager.SecondDifference; } if (mManageSpriteGrids) { for (int i = 0; i < mSpriteGrids.Count; i++) { SpriteGrid sg = mSpriteGrids[i]; sg.Manage(); } } for (int i = mPopups.Count - 1; i > -1; i--) { Screen popup = mPopups[i]; popup.Activity(false); popup.ActivityCallCount++; if (popup.IsActivityFinished) { string nextPopup = popup.NextScreen; popup.Destroy(); mPopups.RemoveAt(i); if (nextPopup != "" && nextPopup != null) { LoadPopup(nextPopup, false); } } } #if !MONODROID && !FRB_MDX && !SILVERLIGHT // This needs to happen after popup activity // in case the Screen creates a popup - we don't // want 2 activity calls for one frame. We also want // to make sure that popups have the opportunity to handle // back calls so that the base doesn't get it. if (PlatformServices.BackStackEnabled && InputManager.BackPressed && !firstTimeCalled) { this.HandleBackNavigation(); } #endif }
public Fishy(string spriteGridName, Color color, int sprites, int x, int y) { this.color = color; TargetX = x; TargetY = y; this.x = y; this.y = x; X = (int)this.x; Y = (int)this.y; this.sprites = sprites; animationGrid = new SpriteGrid(spriteGridName, sprites, 1); Width = animationGrid.FrameSize.X; Height = animationGrid.FrameSize.Y; }
public override void ExecuteOn(object target) { SpriteGrid asSpriteGrid = target as SpriteGrid; for (int i = 0; i < mAnimationChainLocations.Count; i++) { TextureLocation <AnimationChain> animationChainLocation = mAnimationChainLocations[i]; asSpriteGrid.PaintSpriteAnimationChain( animationChainLocation.X, animationChainLocation.Y, asSpriteGrid.Blueprint.Z, animationChainLocation.Texture); } }
public static Particle Debri(Point pos) { SpriteGrid spriteGrid = new SpriteGrid("debri", 4, 1); Random r = DiverGame.Random; return new Particle(spriteGrid, 1.0f, new Vector2((float)pos.X, (float)pos.Y), new Vector2(((float)r.NextDouble() - 0.5f) * 50, ((float)r.NextDouble() - 0.5f) * 50), new Vector2(0.0f,1.0f), 0.8f, Color.White, SpriteBlendMode.AlphaBlend, Room.Layer.Player, 1.0f, 40); }
/// <summary> /// Load sprites from the given source /// </summary> /// <remarks> /// Load sprites which can be drawn to display or offscreen surfaces. This method is used to load both <b>SheetType.SpriteSheet</b> and <b>SheetType.SpritePack</b>. /// There are various asset sources supported: /// <list type="bullet"> /// <item><b>Resources</b> - Synchronously loaded sprite assets from a <b>Resources</b> folder. This was the only asset source supported in RetroBlit prior to 3.0.</item> /// <item><b>ResourcesAsync</b> - Asynchronously loaded sprite assets from a <b>Resources</b> folder.</item> /// <item><b>WWW</b> - Asynchronously loaded sprite assets from a URL.</item> /// <item><b>AddressableAssets</b> - Asynchronously loaded sprite assets from Unity Addressable Assets.</item> /// <item><b>Existing Assets</b> - Synchronously loaded sprite assets from an existing Unity <b>Texture2D</b> or <b>RenderTexture</b>.</item> /// </list> /// /// If the asset is loaded via a synchronous method then <b>Load</b> will block until the loading is complete. /// If the asset is loaded via an asynchronous method then <b>Load</b> will immediately return and the asset loading will /// continue in a background thread. The status of an asynchronous loading asset can be check by looking at <see cref="RBAsset.status"/>, /// or by using the event system with <see cref="RBAsset.OnLoadComplete"/> to get a callback when the asset is done loading. /// /// <seedoc>Features:Sprites</seedoc> /// <seedoc>Features:Asynchronous Asset Loading</seedoc> /// </remarks> /// <code> /// SpriteSheetAsset spriteMain = new SpriteSheetAsset(); /// /// public void Initialize() /// { /// // Load asset from Resources asynchronously. This method call will immediately return without blocking. /// spriteMain.Load("main_spritepack", RB.SheetType.SpritePack, RB.AssetSource.ResourcesAsync); /// } /// /// public void Render() /// { /// // Don't draw anything until sprites are loaded /// if (spriteMain.status != RB.AssetStatus.Ready) /// { /// return; /// } /// /// RB.SpriteSheetSet(spriteMain); /// RB.DrawSprite("hero/walk1", playerPos); /// } /// </code> /// <param name="path">Path of the sprite sheet</param> /// <param name="sheetType">The type of sprite sheet, either <see cref="SheetType.SpriteSheet"/> or <see cref="SheetType.SpritePack"/></param> /// <param name="source">Source type of the asset</param> /// <returns>Load status</returns> /// <seealso cref="RB.Result"/> /// <seealso cref="RB.AssetStatus"/> /// <seealso cref="RB.AssetSource"/> /// <seealso cref="RB.SheetType"/> public RB.AssetStatus Load(string path, SheetType sheetType = SheetType.SpriteSheet, RB.AssetSource source = RB.AssetSource.Resources) { Unload(); if (!RetroBlitInternal.RBAssetManager.CheckSourceSupport(source)) { InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.NotSupported); return(status); } RetroBlitInternal.RBAPI.instance.AssetManager.SpriteSheetLoad(this, new Vector2i(0, 0), path, null, source, sheetType); grid = SpriteGrid.fullSheet; return(status); }
public static Particle ExplosionDust(Point pos) { SpriteGrid spriteGrid = new SpriteGrid("glow", 1, 1); Random r = DiverGame.Random; return new Particle(spriteGrid, 1.0f, new Vector2((float)pos.X, (float)pos.Y), new Vector2(((float)r.NextDouble() - 0.5f) * 3.0f, 0), new Vector2(0, 0), 0.9f, new Color(255, 255, 255, 255), SpriteBlendMode.Additive, Room.Layer.Player, 0.2f, 50); }
/// <summary> /// Load SpriteSheet from an already existing Unity *Texture2D* object. /// </summary> /// <remarks> /// Load SpriteSheet from an already existing Unity *Texture2D* object. During the loading process the *existingTexture* is copied, /// and the resulting SpriteSheetAsset no longer references the original *existingTexture*. /// </remarks> /// <param name="existingTexture">Existing texture</param> /// <returns>Load status</returns> public RB.AssetStatus Load(Texture2D existingTexture) { Unload(); grid = SpriteGrid.fullSheet; InternalSetErrorStatus(RB.AssetStatus.Invalid, RB.Result.Undefined); if (existingTexture == null) { InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.BadParam); return(status); } // First need to convert to RenderTexture RenderTexture newTexture; newTexture = new RenderTexture(existingTexture.width, existingTexture.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default); if (newTexture == null) { InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.NoResources); return(status); } newTexture.filterMode = existingTexture.filterMode; newTexture.wrapMode = existingTexture.wrapMode; newTexture.anisoLevel = existingTexture.anisoLevel; newTexture.antiAliasing = 1; newTexture.autoGenerateMips = false; newTexture.depth = 0; newTexture.useMipMap = false; newTexture.Create(); var oldActive = RenderTexture.active; RenderTexture.active = newTexture; Graphics.Blit(existingTexture, newTexture); RenderTexture.active = oldActive; SetExistingRenderTexture(newTexture); progress = 1; InternalSetErrorStatus(RB.AssetStatus.Ready, RB.Result.Success); return(status); }
public void GridListBoxDoubleClick(Window callingWindow) { SpriteGrid sg = ((CollapseListBox)callingWindow).GetFirstHighlightedObject() as SpriteGrid; if (sg != null) { this.camera.X = (sg.XLeftBound + sg.XRightBound) / 2f; if (sg.GridPlane == SpriteGrid.Plane.XY) { this.camera.Y = (sg.YBottomBound + sg.YTopBound) / 2f; } else { this.camera.Y = sg.Blueprint.Y; } } }
/// <summary> /// Load SpriteSheet from an already existing Unity *RenderTexture* object. /// </summary> /// <param name="existingTexture">Existing texture</param> /// <returns>Load status</returns> public RB.AssetStatus Load(RenderTexture existingTexture) { Unload(); grid = SpriteGrid.fullSheet; InternalSetErrorStatus(RB.AssetStatus.Invalid, RB.Result.Undefined); if (existingTexture == null) { InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.BadParam); return(status); } SetExistingRenderTexture(existingTexture); progress = 1; InternalSetErrorStatus(RB.AssetStatus.Ready, RB.Result.Success); return(status); }
public void Shift(Vector3 shiftVector) { mSprites.Shift(shiftVector); for (int i = 0; i < mSpriteGrids.Count; i++) { SpriteGrid spriteGrid = mSpriteGrids[i]; spriteGrid.Shift(shiftVector.X, shiftVector.Y, shiftVector.Z); spriteGrid.XLeftBound += shiftVector.X; spriteGrid.XRightBound += shiftVector.X; spriteGrid.YTopBound += shiftVector.Y; spriteGrid.YBottomBound += shiftVector.Y; spriteGrid.ZCloseBound += shiftVector.Z; spriteGrid.ZFarBound += shiftVector.Z; } mSpriteFrames.Shift(shiftVector); mTexts.Shift(shiftVector); }
public void Remove(Scene scene) { for (int i = scene.Sprites.Count - 1; i > -1; i--) { Remove(scene.Sprites[i]); } for (int i = scene.SpriteGrids.Count - 1; i > -1; i--) { SpriteGrid spriteGrid = scene.SpriteGrids[i]; spriteGrid.Layer = null; } for (int i = scene.SpriteFrames.Count - 1; i > -1; i--) { Remove(scene.SpriteFrames[i]); } for (int i = scene.Texts.Count - 1; i > -1; i--) { Remove(scene.Texts[i]); } }
public Particle(SpriteGrid spriteGrid, float framerate, Vector2 position, Vector2 velocity, Vector2 gravity, float damping, Color color, SpriteBlendMode blend, Room.Layer layer, float scale, int timeToLive) { this.spriteGrid = spriteGrid; this.framerate = framerate; this.position = position; this.velocity = velocity; this.gravity = gravity; this.damping = damping; this.color = color; this.blend = blend; this.layer = layer; this.timeToLive = timeToLive; CleanUpOnRoomLeft = true; Width = (int)(scale * spriteGrid.FrameSize.X); Height = (int)(scale * spriteGrid.FrameSize.Y); this.position.X -= Width / 2.0f; this.position.Y -= Height / 2.0f; X = (int)this.position.X; Y = (int)this.position.Y; }
public SpriteGridScaleX(SpriteGrid referenceGrid, float ScaleX, long TimeToExecute) { this.referenceObject = referenceGrid; this.timeToExecute = TimeToExecute; ScaleX = ScaleX; }
public DeleteSpriteGrid(SpriteGrid referenceSpriteGrid) { referenceObject = referenceSpriteGrid.Clone(); }
public SpriteGridTexturePaintInstruction(SpriteGrid spriteGrid, List<TextureLocation<Texture2D>> textureLocations) { mTarget = spriteGrid; mTextureLocations = textureLocations; }
public CreateSpriteGrid(SpriteGrid referenceGrid) { this.referenceObject = referenceGrid; }
public SpriteGridDisplayRegionPaintInstruction(SpriteGrid spriteGrid, List<TextureLocation<FloatRectangle>> displayRegions) { mTarget = spriteGrid; mDisplayRegions = displayRegions; }
public void CopyCurrentObjects(Window callingWindow) { if ((GameData.EditorLogic.CurrentSprites.Count != 0) || (GameData.EditorLogic.CurrentSpriteFrames.Count != 0) || (GameData.EditorLogic.CurrentPositionedModels.Count != 0) || (GameData.EditorLogic.CurrentTexts.Count != 0)) { int instructionNum = 0; #region Copy Sprites if (SpriteEditorSettings.EditingSprites) { // remove the in-screen markers and axes so they don't get touched by the copying GameData.EditorLogic.EditAxes.CurrentObject = null; Sprite topSpriteAdded = null; AttachableList <Sprite> oldestParents = AttachableList <Sprite> .GetTopParents <Sprite, Sprite>(GameData.EditorLogic.CurrentSprites); SpriteList addedSprites = new SpriteList(); // The appendedNumbers variable is used for improving performance when copying large groups. When a Sprite // is copied, it is given a number at the end of its name or if there is already a number present, // it is incremented. However, copying large groups can result in a lot of string checking which // can hurt performance. // Consider copying 100 Sprites with the same texture. Their names will likely be redball1, redball2, // redball3, ... redball100. Let's say redball1 gets copied first. The SpriteEditor increments the // number at the end to redball2, then checks to see if there is already a Sprite with that name. If // there is, it increments to redball3 and so on. This must be conducted on average 10,000 times and each // iteration requires string copying, concatenation, and parsing for integers. To cut this down, the // appendedNumbers variable associates a given name (in this case redball) with the last integer appended // to that particular name. Therefore, when the first Sprite is created, it will loop through 1 - 100 and // eventually end up at redball101. It will then associate the number 101 with the name redball. The next // Sprite (named redball2) will know to begin at redball101. This increases the performance of // copying large groups from O(n^2) to O(n). Dictionary <string, int> appendedNumbers = new Dictionary <string, int>(); foreach (Sprite s in oldestParents) { if (s is ISpriteEditorObject) { if (GuiData.ToolsWindow.groupHierarchyControlButton.IsPressed) { topSpriteAdded = GameData.copySpriteHierarchy( s, s.Parent as Sprite, GameData.EditorProperties.PixelSize, addedSprites, appendedNumbers); } else { topSpriteAdded = GameData.copySpriteHierarchy( s.TopParent as Sprite, null, GameData.EditorProperties.PixelSize, addedSprites, appendedNumbers); } } SpriteList tempSpriteArray = new SpriteList(); topSpriteAdded.GetAllDescendantsOneWay(tempSpriteArray); tempSpriteArray.Add(topSpriteAdded); } GameData.EditorLogic.EditAxes.CurrentObject = GameData.EditorLogic.CurrentSprites[0]; GameData.Cursor.ClickSprite(null); foreach (Sprite s in AttachableList <Sprite> .GetTopParents <Sprite, Sprite>(addedSprites)) { // the 2nd true forces selection of all Sprites GameData.Cursor.ClickObject <Sprite>(s, GameData.EditorLogic.CurrentSprites, true, true); } GameData.Cursor.VerifyAndUpdateGrabbedAgainstCurrent(); } #endregion #region Copy SpriteGrids else if (SpriteEditorSettings.EditingSpriteGrids) { SpriteGrid sg = SESpriteGridManager.CurrentSpriteGrid.Clone(); FlatRedBall.Utilities.StringFunctions.MakeNameUnique <SpriteGrid>(sg, GameData.Scene.SpriteGrids); this.sesgMan.PopulateAndAddGridToEngine(sg, GameData.EditorLogic.CurrentSprites[0]); sg.RefreshPaint(); } #endregion #region Copy SpriteFrames else if (SpriteEditorSettings.EditingSpriteFrames) { GameData.EditorLogic.EditAxes.CurrentObject = null; AttachableList <SpriteFrame> oldestParents = AttachableList <SpriteFrame> .GetTopParents <SpriteFrame, SpriteFrame>(GameData.EditorLogic.CurrentSpriteFrames); foreach (SpriteFrame sf in oldestParents) { SpriteFrame topSpriteFrameAdded = GameData.CopySpriteFrameHierarchy(sf, null, GameData.EditorProperties.PixelSize); GameData.Cursor.ClickSpriteFrame(topSpriteFrameAdded); } } #endregion #region Copy Models else if (SpriteEditorSettings.EditingModels) { GameData.EditorLogic.EditAxes.CurrentObject = null; AttachableList <PositionedModel> oldestParents = AttachableList <PositionedModel> .GetTopParents <PositionedModel, PositionedModel>(GameData.EditorLogic.CurrentPositionedModels); foreach (PositionedModel model in oldestParents) { PositionedModel topSpriteFrameAdded = GameData.CopyModelHierarchy(model, null, GameData.EditorProperties.PixelSize); // GameData.cursor.ClickSpriteFrame(topSpriteFrameAdded); } } #endregion #region Copy Texts else if (SpriteEditorSettings.EditingTexts) { GameData.EditorLogic.EditAxes.CurrentObject = null; AttachableList <Text> oldestParents = AttachableList <Text> .GetTopParents <Text, Text>(GameData.EditorLogic.CurrentTexts); foreach (Text text in oldestParents) { Text topText = GameData.CopyTextHierarchy(text, null, GameData.EditorProperties.PixelSize); // GameData.cursor.ClickSpriteFrame(topSpriteFrameAdded); } } #endregion } }
public SpriteGridAnimationChainPaintInstruction(SpriteGrid spriteGrid, List<TextureLocation<AnimationChain>> animationChainLocations) { mTarget = spriteGrid; mAnimationChainLocations = animationChainLocations; }
public static void RenderSpriteGrid(SpriteGrid spriteGrid, ImageData imageData) { throw new NotImplementedException(); //// The SpriteGrid should be full //spriteGrid.FillToBounds(); //int textureWidth = (int)(.5f + spriteGrid.FurthestRightX - spriteGrid.FurthestLeftX); //int textureHeight = (int)(.5f + spriteGrid.FurthestTopY - spriteGrid.FurthestBottomY); //if (imageData.Width != textureWidth || imageData.Height != textureHeight) //{ // throw new ArgumentException("Image data is the wrong dimensions"); //} //Dictionary<string, ImageData> mCachedImageDatas = new Dictionary<string, ImageData>(); //int pixelWidthPerSprite = (int)(.5f + (float)textureHeight / spriteGrid.VisibleSprites.Count); //for (int row = spriteGrid.MinDisplayedRowIndex(); row <= spriteGrid.MaxDisplayedRowIndex(); row++) //{ // for (int column = spriteGrid.MinDisplayedColIndex(); column <= spriteGrid.MaxDisplayedColIndex(); column++) // { // Sprite spriteAtIndex = spriteGrid.GetSpriteAtIndex(row, column); // if (!mCachedImageDatas.ContainsKey(spriteAtIndex.Texture.Name)) // { // ImageData imageDataForThisSprite = ImageData.FromTexture2D(spriteAtIndex.Texture); // mCachedImageDatas.Add(spriteAtIndex.Texture.Name, imageDataForThisSprite); // } // ImageData imageDataToPullFrom = mCachedImageDatas[spriteAtIndex.Texture.Name]; // for (int pixelX = 0; pixelX < pixelWidthPerSprite; pixelX++) // { // for (int pixelY = 0; pixelY < pixelWidthPerSprite; pixelY++) // { // float textureX = (.5f + pixelX) / pixelWidthPerSprite; // float textureY = (.5f + pixelY) / pixelWidthPerSprite; // int xToWriteAt = (column - spriteGrid.MinDisplayedColIndex()) * pixelWidthPerSprite + pixelX; // int yToWriteAt = (spriteGrid.MaxDisplayedRowIndex() - row) * pixelWidthPerSprite + pixelY; // int spriteXPixelCoordinate = (int)(.5f + spriteAtIndex.LeftTextureCoordinate * spriteAtIndex.Texture.Width) + pixelX; // int spriteYPixelCoordinate = (int)(.5f + spriteAtIndex.TopTextureCoordinate * spriteAtIndex.Texture.Height) + pixelY; // // For now we'll just handle the errors in a naive way. Return here if issues occur with pixel mismatchings // if (spriteXPixelCoordinate >= imageDataToPullFrom.Width) // { // spriteXPixelCoordinate = imageDataToPullFrom.Width - 1; // } // if (spriteYPixelCoordinate >= imageDataToPullFrom.Height) // { // spriteYPixelCoordinate = imageDataToPullFrom.Height - 1; // } // imageData.SetPixel(xToWriteAt, yToWriteAt, imageDataToPullFrom.Data[spriteXPixelCoordinate + spriteYPixelCoordinate * imageDataToPullFrom.Width]); // } // } // } //} }
public SpriteGridRotY(SpriteGrid referenceGrid, float roty, long TimeToExecute) { this.referenceObject = referenceGrid; this.timeToExecute = TimeToExecute; RotationY = roty; }
public static Particle MakeTinyBubble(Point pos) { SpriteGrid spriteGrid = new SpriteGrid("bubbletiny", 1, 1); Random r = DiverGame.Random; return new Particle(spriteGrid, 10.0f, new Vector2((float)pos.X, (float)pos.Y), new Vector2(((float)r.NextDouble() - 0.5f) * 3.0f, (float)-r.NextDouble() * 1.5f), new Vector2(0, -(float)r.NextDouble() * 0.1f - 0.07f), 0.9f, new Color(255, 255, 255, 64), SpriteBlendMode.AlphaBlend, Room.Layer.Background, 1.0f, -1); }
public static Particle MakeSpark(Point pos) { SpriteGrid spriteGrid = new SpriteGrid("glow", 1, 1); Random r = DiverGame.Random; return new Particle(spriteGrid, 1.0f, new Vector2((float)pos.X, (float)pos.Y), new Vector2(0, 0), new Vector2(0, -(float)r.NextDouble() * 0.1f - 0.07f), 0.9f, new Color(255, 255, 255, 255), SpriteBlendMode.Additive, Room.Layer.Player, 0.015f, 20); }
/// <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 SpriteGridRotX(SpriteGrid referenceGrid, float rotx, long TimeToExecute) { this.referenceObject = referenceGrid; this.timeToExecute = TimeToExecute; RotationX = rotx; }
public SpriteGridScaleY(SpriteGrid referenceGrid, float ScaleY, long TimeToExecute) { this.referenceObject = referenceGrid; this.timeToExecute = TimeToExecute; ScaleY = ScaleY; }
public TileRenderSystem() { this.m_SpriteMap = SpriteMap.Load(Assets.NameToPath("tiles.png"), 24); this.m_SpriteGrid = new SpriteGrid(this.m_SpriteMap, TileChunk.Tiles); }
public Decoration(SpriteGrid spriteGrid, int animationSpeed, int x, int y, Room.Layer layer, Color color) : this(spriteGrid, animationSpeed, new Rectangle(x, y, spriteGrid.FrameSize.X, spriteGrid.FrameSize.Y), layer, color) { }
public static Particle ExplosionGlow(Point pos) { SpriteGrid spriteGrid = new SpriteGrid("glow", 1, 1); Random r = DiverGame.Random; return new Particle(spriteGrid, 1.0f, new Vector2((float)pos.X, (float)pos.Y), new Vector2(0,0), new Vector2(0,0), 1.0f, Color.Tomato, SpriteBlendMode.Additive, Room.Layer.Foreground, 0.5f, 8); }
public Decoration(SpriteGrid spriteGrid, int animationSpeed, int x, int y, Room.Layer layer) : this(spriteGrid, animationSpeed, x, y, layer, Color.White) { }
public SpriteGridRotationZ(SpriteGrid referenceGrid, float RotationZ, long TimeToExecute) { this.referenceObject = referenceGrid; this.timeToExecute = TimeToExecute; RotationZ = RotationZ; }
public DBSpriteGrid(SpriteGrid spriteGrid) : base() { mSpriteGrid = spriteGrid; }
public SpriteGridTexturePaintInstruction(SpriteGrid spriteGrid, List <TextureLocation <Texture2D> > textureLocations) { mTarget = spriteGrid; mTextureLocations = textureLocations; }
public static ImageData RenderSpriteGrid(SpriteGrid spriteGrid) { int textureWidth = (int)(.5f + spriteGrid.FurthestRightX - spriteGrid.FurthestLeftX); int textureHeight = (int)(.5f + spriteGrid.FurthestTopY - spriteGrid.FurthestBottomY); ImageData imageData = new ImageData(textureWidth, textureHeight); RenderSpriteGrid(spriteGrid, imageData); return imageData; }
public SpriteGridAnimationChainPaintInstruction(SpriteGrid spriteGrid, List <TextureLocation <AnimationChain> > animationChainLocations) { mTarget = spriteGrid; mAnimationChainLocations = animationChainLocations; }
public void AddToManagers(Layer layer) { #region Add the Sprites if (layer == null) { for (int i = 0; i < Sprites.Count; i++) { Sprite sprite = Sprites[i]; if (sprite.mOrdered) { SpriteManager.AddSprite(sprite); } else { SpriteManager.AddZBufferedSprite(sprite); } } } else { for (int i = 0; i < Sprites.Count; i++) { Sprite sprite = Sprites[i]; SpriteManager.AddToLayer(sprite, layer); } } #endregion #region Add the SpriteGrids for (int i = 0; i < SpriteGrids.Count; i++) { SpriteGrid spriteGrid = SpriteGrids[i]; spriteGrid.Layer = layer; spriteGrid.PopulateGrid(); spriteGrid.RefreshPaint(); spriteGrid.Manage(); } #endregion #region Add the SpriteFrames for (int i = 0; i < SpriteFrames.Count; i++) { SpriteFrame frame = SpriteFrames[i]; if (frame.CenterSprite != null && frame.CenterSprite.mOrdered == false) { SpriteManager.AddToLayerZBuffered(frame, layer); } else { SpriteManager.AddSpriteFrame(frame); SpriteManager.AddToLayer(frame, layer); } } #endregion #region Add the Texts for (int i = 0; i < Texts.Count; i++) { if (layer == null) { TextManager.AddText(Texts[i]); } else { #if SILVERLIGHT throw new NotImplementedException(); #else TextManager.AddText(Texts[i], layer); #endif } } #endregion }
public Scene Clone() { Scene scene = new Scene(); #region Create the Sprites for (int i = 0; i < mSprites.Count; i++) { Sprite sprite = mSprites[i]; scene.mSprites.Add(sprite.Clone()); } for (int i = 0; i < mSprites.Count; i++) { Sprite thisSprite = mSprites[i]; if (thisSprite.Parent != null) { Sprite otherSprite = scene.mSprites[i]; otherSprite.AttachTo( scene.mSprites.FindByName(thisSprite.Parent.Name), false); } } #endregion #region Create the SpriteGrids for (int i = 0; i < mSpriteGrids.Count; i++) { SpriteGrid spriteGrid = mSpriteGrids[i]; scene.mSpriteGrids.Add(spriteGrid.Clone()); } #endregion #region Create and Attach the SpriteFrames for (int i = 0; i < mSpriteFrames.Count; i++) { SpriteFrame spriteFrame = mSpriteFrames[i]; scene.mSpriteFrames.Add(spriteFrame.Clone()); } #endregion #region Create and attach the Texts for (int i = 0; i < mTexts.Count; i++) { Text text = mTexts[i]; scene.mTexts.Add(text.Clone()); } for (int i = 0; i < mTexts.Count; i++) { Text thisText = mTexts[i]; if (thisText.Parent != null) { Text otherText = scene.mTexts[i]; otherText.AttachTo( scene.mTexts.FindByName(thisText.Parent.Name), false); } } #endregion scene.Name = Name; return(scene); }
private void GetLevel(string URL1) { #region textparsing string httpPage = HttpHelper.GetDataFromHttp(URL1); string level = TextParser.FindTextBetween(httpPage, "<form action=index.php method=get><input type=", "input"); string level2 = TextParser.FindTextBetween(level, "value", ">"); string level3 = level2.Substring(2); string level4 = level3.Substring(0, level3.Length - 3); redoURL = "http://www.hacker.org/coil/index.php?name=Allosentient&password=XXXXX&gotolevel=" + level4 + "&go=Go+To+Level"; string levelData = TextParser.FindTextBetween(httpPage, "<param name=\"FlashVars", "\" />"); string levelData2 = TextParser.FindTextBetween(levelData, "\" value=\"", "..."); int coordData = levelData2.IndexOf("&board"); string coordData1 = levelData2.Substring(0, coordData); string coordX = TextParser.FindTextBetween(coordData1, "=", "&"); string coordY = coordData1.Substring(coordData1.IndexOf('&') + 3); sizeX = Int32.Parse(coordX) + 2; sizeY = Int32.Parse(coordY) + 2; totalBlocks = sizeX * sizeY; string levelDataComplete = levelData.Substring(levelData.LastIndexOf('=') + 1); string s3 = levelData; #endregion levelDataArray = new int[sizeX, sizeY]; originalLevelDataArray = new int[sizeX, sizeY]; testGrid = new SpriteGrid(system); #region gridgeneration int p = 0; for (int j = 0; j < sizeY; j++) { int y = sizeY - j - 1; for (int i = 0; i < sizeX; i++) { if (i > 0 && i < sizeX - 1 && j > 0 && (j < sizeY - 1)) { char c = levelDataComplete[p]; if (c == '.') { SetWall(i, y, false); } else if (c == 'X') { SetWall(i, y, true); greenCount++; } else throw new InvalidOperationException("Unknown character in level data"); p++; } else { SetWall(i, y, true); greenCount++; } } } originalGreenCount = greenCount; #endregion }
public void spriteGridOkClick(Window callingWindow) { if (SelectedObject.GridSpacing <= 0f) { GuiManager.ShowMessageBox("GridSpacing must be greater than 0.", "SpriteGrid error"); } else if ((SelectedObject.Plane == SpriteGrid.Plane.XZ && (10000f < (SelectedObject.XRightBound - SelectedObject.XLeftBound) * (SelectedObject.ZFarBound - SelectedObject.ZCloseBound))) && (callingWindow.GetType() != typeof(OkCancelWindow))) { OkCancelWindow tempWindow = GuiManager.ShowOkCancelWindow("The grid you are creating is large and may result in sluggish performance or freezing of the SE. What would you like to do?", "Large Grid"); tempWindow.ScaleX = 15f; tempWindow.OkText = "Create anyway"; tempWindow.CancelText = "Cancel conversion"; tempWindow.OkClick += new GuiMessage(this.spriteGridOkClick); } else if (mCreatingNewSpriteGrid) { SpriteGrid tempGrid = null; if (SelectedObject.Plane == SpriteGrid.Plane.XY) { tempGrid = new SpriteGrid(this.camera, SpriteGrid.Plane.XY, mBlueprintSprite, null); } else { tempGrid = new SpriteGrid(this.camera, SpriteGrid.Plane.XZ, mBlueprintSprite, null); } if (string.IsNullOrEmpty(mBlueprintSprite.Name)) { tempGrid.Name = FileManager.RemovePath(mBlueprintSprite.Texture.Name); } else { tempGrid.Name = mBlueprintSprite.Name; } tempGrid.XLeftBound = SelectedObject.XLeftBound; tempGrid.XRightBound = SelectedObject.XRightBound; tempGrid.YTopBound = SelectedObject.YTopBound; tempGrid.YBottomBound = SelectedObject.YBottomBound; tempGrid.ZCloseBound = SelectedObject.ZCloseBound; tempGrid.ZFarBound = SelectedObject.ZFarBound; tempGrid.GridSpacing = SelectedObject.GridSpacing; this.sesgMan.PopulateAndAddGridToEngine(tempGrid, mBlueprintSprite); StringFunctions.MakeNameUnique <SpriteGrid>(tempGrid, GameData.Scene.SpriteGrids); //tempGrid.InitializeTextureGrid(); tempGrid.RefreshPaint(); this.Visible = false; SpriteEditorSettings.EditingSpriteGrids = true; GuiData.ToolsWindow.attachSprite.Enabled = false; } else { GameData.Cursor.ClickSprite(null); SESpriteGridManager.CurrentSpriteGrid.XLeftBound = SelectedObject.XLeftBound; SESpriteGridManager.CurrentSpriteGrid.XRightBound = SelectedObject.XRightBound; SESpriteGridManager.CurrentSpriteGrid.YTopBound = SelectedObject.YTopBound; SESpriteGridManager.CurrentSpriteGrid.YBottomBound = SelectedObject.YBottomBound; SESpriteGridManager.CurrentSpriteGrid.ZCloseBound = SelectedObject.ZCloseBound; SESpriteGridManager.CurrentSpriteGrid.ZFarBound = SelectedObject.ZFarBound; if (SESpriteGridManager.CurrentSpriteGrid.GridSpacing != SelectedObject.GridSpacing) { SESpriteGridManager.CurrentSpriteGrid.GridSpacing = SelectedObject.GridSpacing; SESpriteGridManager.CurrentSpriteGrid.ResetTextures(); SESpriteGridManager.CurrentSpriteGrid.PopulateGrid(this.camera.X, this.camera.Y, 0f); } SESpriteGridManager.CurrentSpriteGrid.Manage(); SESpriteGridManager.CurrentSpriteGrid.RefreshPaint(); this.Visible = false; } }
public void RemoveFromManagers(bool clearThis) { if (!clearThis) { MakeOneWay(); } for (int i = mSprites.Count - 1; i > -1; i--) { Sprite sprite = mSprites[i]; PositionedObject oldParent = sprite.Parent; SpriteManager.RemoveSprite(sprite); if (!clearThis && oldParent != null) { sprite.AttachTo(oldParent, false); } } for (int i = mSpriteGrids.Count - 1; i > -1; i--) { //SpriteGrids don't get attached, so there is no code to preserve Parent and re-attach SpriteGrid spriteGrid = mSpriteGrids[i]; spriteGrid.Destroy(); } for (int i = mSpriteFrames.Count - 1; i > -1; i--) { SpriteFrame spriteFrame = mSpriteFrames[i]; PositionedObject oldParent = spriteFrame.Parent; SpriteManager.RemoveSpriteFrame(spriteFrame); if (!clearThis && oldParent != null) { spriteFrame.AttachTo(oldParent, false); } } for (int i = mTexts.Count - 1; i > -1; i--) { Text text = mTexts[i]; PositionedObject oldParent = text.Parent; TextManager.RemoveText(text); if (!clearThis && oldParent != null) { text.AttachTo(oldParent, false); } } if (clearThis) { Clear(); } else { MakeTwoWay(); } }
public SpriteGridDisplayRegionPaintInstruction(SpriteGrid spriteGrid, List <TextureLocation <FloatRectangle> > displayRegions) { mTarget = spriteGrid; mDisplayRegions = displayRegions; }