private void DrawGameObjectTexture(EditorGameObject gameObject) { if (gameObject != null) { if (gameObject.TextureBoundings.IntersectsWith(CameraBounds)) { switch (gameObject.CurrentTexture.TextureLayout) { case TextureLayout.Default: case TextureLayout.Stretch: BaseCanvas.RazorGFX.DrawImage(gameObject.CurrentTexture.TextureImage, gameObject.TextureBoundings); break; case TextureLayout.Center: int xCenter = (gameObject.Width / 2) - (gameObject.CurrentTexture.TextureImage.Width / 2) + gameObject.X; int yCenter = (gameObject.Height / 2) - (gameObject.CurrentTexture.TextureImage.Height / 2) + gameObject.Y; BaseCanvas.RazorGFX.DrawImage(gameObject.CurrentTexture.TextureImage, xCenter, yCenter); break; case TextureLayout.Tile: if (!gameObject.IsTiledTextureCached) { Texture tiledTex = PrepareTiledTexture(gameObject.CurrentTexture, gameObject.TextureBoundings); gameObject.IsTiledTextureCached = true; gameObject.TiledTextureCache = tiledTex; BaseCanvas.RazorGFX.DrawImage(gameObject.TiledTextureCache.TextureImage, gameObject.TextureBoundings); } else { BaseCanvas.RazorGFX.DrawImage(gameObject.TiledTextureCache.TextureImage, gameObject.TextureBoundings); } break; } } BaseCanvas.RazorGFX.DrawRectangle(texBoundingsRects, gameObject.TextureBoundings); BaseCanvas.RazorGFX.DrawRectangle(collBoundingsRects, gameObject.BoundingBox); } else { //GameApplication.Log(Utils.LogEntryType.Warning, "GameEngine unable to draw game object!"); } }
/// <summary> /// Removes <paramref name="gameObject"/> from this scene /// </summary> /// <param name="gameObject"></param> public void RemoveGameObject(EditorGameObject gameObject) { GameObjects.Remove(gameObject); gameObject.OnDestroy(); }
/// <summary> /// Adds <paramref name="gameObject"/> at this scene /// </summary> /// <param name="gameObject"></param> public void AddGameObject(EditorGameObject gameObject) { GameObjects.Add(gameObject); gameObject.OnCreate(); }