public override void Render(Graphics g, TexturedObject obj, Vector2D cameraPos) { GridTexture tex = (GridTexture)obj.GetActualTexture(); g.InterpolationMode = tex.InterpolationMode; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; if (tex.Image == null) { Exception ex = new RenderException("Image was not initialized in texture \"" + tex.Name); Log.Exception(ex); throw ex; } for (int x = 0; x < tex.xCount; x++) { for (int y = 0; y < tex.yCount; y++) { g.DrawImage( tex.Image, new Rectangle( new Point( (int)(obj.GetStartPosition().X - cameraPos.X + x * obj.Scale.Width * obj.Size.Width), (int)(obj.GetStartPosition().Y - cameraPos.Y + y * obj.Scale.Height * obj.Size.Height) ), new System.Drawing.Size( (int)(obj.Scale.Width * obj.Size.Width), (int)(obj.Scale.Height * obj.Size.Height) ) ) ); } } }
public override void Init() { base.Init(); CanUpdateGameTime = false; CanUpdateWorld = false; //set background var backGround = new TexturedObject("background", HUD, new SpriteSheet("Textures/HUD/MainMenu")); //calculate new HighScore var time = GameModeManager.TimeManager.TotalSeconds; var oldHighScore = HighScoreManager.HighScore; var newHighScore = HighScoreManager.CalculateNewHighScore(time, !World.Player.Death); //if the newHighScore is higher than the previous one, upload it to the website if (newHighScore > oldHighScore) { HighScoreManager.uploadHighscore(newHighScore); } //add highScorePopUpWindow to HUD var highScorePopUpWindow = new HighScorePopUp(HUD, oldHighScore, newHighScore); highScorePopUpWindow.Position = new Microsoft.Xna.Framework.Vector2(backGround.Width / 2 - highScorePopUpWindow.Width / 2, backGround.Height / 2 - highScorePopUpWindow.Height / 2); //add objects to HUD AddToHud(backGround); AddToHud(highScorePopUpWindow); //reset world for next playthrough GameStateManager.GameMode.Reset(); }
public override void Render(Graphics g, TexturedObject obj, Vector2D cameraPos) { RegularTexture tex = (RegularTexture)obj.GetActualTexture(); g.InterpolationMode = tex.InterpolationMode; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; if (tex.Image == null) { Exception ex = new RenderException("Image was not initialized in texture \"" + tex.Name); Log.Exception(ex); throw ex; } g.DrawImage( tex.Image, new Rectangle( new Point( (int)(obj.GetStartPosition().X - cameraPos.X), (int)(obj.GetStartPosition().Y - cameraPos.Y) ), new System.Drawing.Size( (int)Math.Round(obj.Scale.Width * obj.Size.Width, MidpointRounding.AwayFromZero), (int)Math.Round(obj.Scale.Height * obj.Size.Height, MidpointRounding.AwayFromZero) ) ) ); }
private TexturedObject WalkableTile(string id, string assetName) { TexturedObject Tile = new TexturedObject(id, this, new SpriteSheet("Textures/Tiles/" + assetName)); Tile.CanCollide = false; Tile.CanBlock = false; return(Tile); }
private TexturedObject SetupCollisionTile(string id, string assetName) { TexturedObject Tile = new TexturedObject(id, this, new SpriteSheet("Textures/Tiles/" + assetName)); Tile.CanCollide = true; Tile.CanBlock = true; return(Tile); }
public TexturedSquareService(IServiceContainer wObj, VirtualWorld VW, string texturePath, int textureSize) : base(wObj, VW) { if (VW.render != null && texturePath != "") { VW.render.ShaderProgramList.TryGetValue("textureProgram", out sp); rObj = new TexturedObject(VertexFactory.CreateTexturedSquare(textureSize, 1, textureSize, textureSize), sp.Id, texturePath); VW.render.DrawServices.Add(nameService.name, this); } }
public override void Render(Graphics g, TexturedObject obj, System.Windows.Point cameraPos) { Rendering.Render.FromCamera(view, viewGraphics, Cam); g.DrawImage( view, new Rectangle( new Point( (int)(obj.GetStartPosition().X - cameraPos.X), (int)(obj.GetStartPosition().Y - cameraPos.Y) ), new Size( (int)(obj.SizeMultipler.Width * obj.BaseSize.Width), (int)(obj.SizeMultipler.Height * obj.BaseSize.Height) ) ) ); }
public Slider(string id, Object parent, SpriteSheet spriteSheetBar, SpriteSheet spriteSheetSlider) : base(id, parent) { _bar = new TexturedObject("bar", this, spriteSheetBar); _slider = new TexturedObject("slider", this, spriteSheetSlider); //set Slider boundingbox equal to boundingBox of bar BoundingBox = _bar.BoundingBox; //centerSlider _slider.Position = new Vector2(_bar.Width / 2 - _slider.Width / 2, _bar.Height / 2 - _slider.Height / 2); //only slider itself can collide, the bar cannot _slider.CanCollide = true; CanCollide = true; //add objects Add(_bar); Add(_slider); }
private TexturedObject Platform(string id, string assetName, int size) { TexturedObject Tile = new TexturedObject(id, this, new SpriteSheet("Textures/Tiles/" + assetName)); Tile.CanCollide = true; Tile.CanBlock = true; if (size == 1) { Tile.BoundingBox = new Rectangle((int)Tile.PositionX, (int)Tile.PositionY, 144, 96); } if (size == 2) { Tile.BoundingBox = new Rectangle((int)Tile.PositionX, (int)Tile.PositionY, 240, 96); } if (size == 3) { Tile.BoundingBox = new Rectangle((int)Tile.PositionX, (int)Tile.PositionY, 500, 96); } return(Tile); }
public LoginPopUp(Engine.Object parent) : base("LoginPopUp", parent) { //create texturedObjects var backGround = new TexturedObject("background", this, new SpriteSheet("Textures/HUD/LoginPopUpWindow")); //set boundingBox equal to boundingBox of background BoundingBox = backGround.BoundingBox; //create textObjects var warningMessage = new TextObject("warningMessage", "Hud", this); warningMessage.Text = "Your account information is invalid"; warningMessage.Color = Microsoft.Xna.Framework.Color.Red; warningMessage.Position = new Microsoft.Xna.Framework.Vector2(31, 112); warningMessage.FitIntoRectangle(new Microsoft.Xna.Framework.Rectangle(0, 0, 230, 50)); warningMessage.Visible = false; //create textBoxes _userNameBox = new TextBox(this); _passWordBox = new TextBox(this); _userNameBox.Position = new Microsoft.Xna.Framework.Vector2(119, 138); _passWordBox.Position = new Microsoft.Xna.Framework.Vector2(119, 176); //create buttons var buttonLogin = new ButtonLogin(this, _userNameBox, _passWordBox, warningMessage); var buttonSignUp = new ButtonSignUp(this); buttonLogin.Position = new Microsoft.Xna.Framework.Vector2(193, 228); buttonSignUp.Position = new Microsoft.Xna.Framework.Vector2(193, 338); //add Objects Add(backGround); Add(warningMessage); Add(_userNameBox); Add(_passWordBox); Add(buttonLogin); Add(buttonSignUp); }
public GSSettings(GameStateManager gameStateManager) : base("GSSettings", gameStateManager) { //add background var backGround = new TexturedObject("background", HUD, new SpriteSheet("Textures/HUD/MainMenuGeneralBackGround")); var sliderMusicVolumeText = new TextObject("sliderMusicVolumeText", "Hud", HUD); sliderMusicVolumeText.Text = "Music Volume"; sliderMusicVolumeText.Color = new Color(124, 93, 72); var sliderSFXVolumeText = new TextObject("sliderSFXvolume", "Hud", HUD); sliderSFXVolumeText.Text = "SFX Volume"; sliderSFXVolumeText.Color = new Color(124, 93, 72); SliderMusicVolume sliderMusicVolume = new SliderMusicVolume(HUD); SliderSFXVolume sliderSFXVolume = new SliderSFXVolume(HUD); //add buttons var buttonBack = new ButtonBack(HUD, "GSMainMenu"); buttonBack.Position = new Vector2(backGround.Width / 2 - buttonBack.Width / 2, 430); //center objects sliderMusicVolumeText.Position = new Vector2(backGround.Width / 2 - sliderMusicVolumeText.Width / 2, 225); sliderMusicVolume.Position = new Vector2(backGround.Width / 2 - sliderMusicVolume.Width / 2, 275); sliderSFXVolumeText.Position = new Vector2(backGround.Width / 2 - sliderSFXVolumeText.Width / 2, 325); sliderSFXVolume.Position = new Vector2(backGround.Width / 2 - sliderSFXVolume.Width / 2, 375); //Add objects to HUD AddToHud(backGround); AddToHud(sliderMusicVolume); AddToHud(sliderSFXVolume); AddToHud(buttonBack); AddToHud(sliderMusicVolumeText); AddToHud(sliderSFXVolumeText); }
public HighScorePopUp(Engine.Object parent, int oldHighScore, int newHighScore) : base("highScorePopUp", parent) { //create background var backGround = new TexturedObject("background", this, new SpriteSheet("Textures/HUD/HighScorePopUpWindow")); //set boundingbox to boundingbox of background BoundingBox = backGround.BoundingBox; //create TextObjects var oldScore = new TextObject("oldHighScore", "Hud", this); oldScore.Text = oldHighScore.ToString(); oldScore.Color = new Color(124, 93, 72); oldScore.Position = new Vector2(160, 120); var newScore = new TextObject("newHighScore", "Hud", this); newScore.Text = newHighScore.ToString(); newScore.Color = new Color(124, 93, 72); newScore.Position = new Vector2(160, 305); var totalDamageDealt = new TextObject("totalDamageDealt", "Hud", this); totalDamageDealt.Text = HighScoreManager.TotalDamageDealt.ToString(); totalDamageDealt.Color = new Color(124, 93, 72); totalDamageDealt.Position = new Vector2(160, 175); totalDamageDealt.Scale = 0.6f; var totalDamageTaken = new TextObject("totalDamageTaken", "Hud", this); totalDamageTaken.Text = HighScoreManager.TotalDamageTaken.ToString(); totalDamageTaken.Color = new Color(124, 93, 72); totalDamageTaken.Position = new Vector2(160, 202); totalDamageTaken.Scale = 0.6f; var time = new TextObject("time", "Hud", this); time.Text = GameModeManager.TimeManager.TotalSeconds.ToString(); time.Scale = 0.6f; time.Color = new Color(124, 93, 72); time.Position = new Vector2(160, 230); var finished = new TextObject("finished", "Hud", this); finished.Text = World.Player.Death ? "no" : "yes"; finished.Scale = 0.6f; finished.Color = new Color(124, 93, 72); finished.Position = new Vector2(160, 255); //create buttons var buttonContinue = new ButtonContinue(this, "GSMainMenu"); buttonContinue.Position = new Vector2(backGround.Width / 2 - buttonContinue.Width / 2, 350); //add objects Add(backGround); Add(buttonContinue); Add(oldScore); Add(newScore); Add(time); Add(finished); Add(totalDamageDealt); Add(totalDamageTaken); setupPossibleNewHighScore(oldHighScore, newHighScore); }