public void DrawAndUpdate(SpriteBatch spriteBatch, TimeSpan elapsedTime, Texture2D spriteSheet, float timescale, Texture2D grid)
        {
            if (timescale != 0)
            {
                currentFrameTimer -= TimeSpan.FromMilliseconds(elapsedTime.TotalMilliseconds * timescale);
                if (currentFrameTimer <= TimeSpan.Zero)
                {
                    AdvanceFrameAndReset();
                }
            }

            //threading issue
            if (currentFrameIndex >= frames.Count)
            {
                currentFrameIndex = 0;
            }

            if (frames.Count != 0)
            {
                spriteBatch.Draw(spriteSheet, frames[currentFrameIndex].DrawRectangle, frames[currentFrameIndex].SourceRectangle, Color.White);

                spriteBatch.Draw(grid, frames[currentFrameIndex].DrawRectangle, Color.Red);
                spriteBatch.Draw(grid, frames[currentFrameIndex].SourceRectangle, Color.Blue);
            }
        }
	public void Draw(SpriteBatch sb, int xx, ref int yy, int ww) {
		if (!Visible()) return;
		
		if (Main.mouseLeft && Main.mouseLeftRelease && ModWorld.GuiAchievements.MouseIn(sb.GraphicsDevice.ScissorRectangle,new Rectangle(xx,yy,ww,42))) {
			toggled = !toggled;
			if (toggled) GuiAchievements.setScroll = yy+GuiAchievements.scroll-120;
		}
		
		Color white = new Color(255,255,255,191);
		Color limish = new Color(136,255,0,191);
		bool achieved = Achieved();
		sb.Draw(ModWorld.Notifier.frame1,new Rectangle(xx+1,yy,ww-2,42),achieved ? limish : white);
		sb.Draw(ModWorld.Notifier.frame2,new Rectangle(xx,yy,1,42),achieved ? limish : white);
		sb.Draw(ModWorld.Notifier.frame2,new Rectangle(xx+ww-1,yy,1,42),achieved ? limish : white);
		
		ModWorld.DrawStringShadowed(sb,Main.fontMouseText,title,new Vector2(xx+8,yy+10),Color.White,Color.Black);
		string value = ""+Value(true)+"/"+Value(false);
		ModWorld.DrawStringShadowed(sb,Main.fontMouseText,value,new Vector2(xx+ww-12-Main.fontMouseText.MeasureString(value).X,yy+10),Color.White,Color.Black);
		
		yy += 42;
		
		if (toggled) {
			for (int i = 0; i < categories.Count; i++) categories[i].Draw(sb,xx+24,ref yy,ww-48);
			for (int i = 0; i < achievements.Count; i++) achievements[i].Draw(sb,xx+24,ref yy,ww-48);
		}
	}
 public void Draw(SpriteBatch SP)
 {
     Texture2D TEX = Main.goreTexture[Config.goreID["Observing eye"]];
     Vector2 NC = N.position+new Vector2(N.width,N.height)/2f - Main.screenPosition;
     Vector2 TC = new Vector2(TEX.Width,TEX.Height)/2f;
     SP.Draw(TEX,NC-TC*s1+Pos,new Rectangle(0,0,TEX.Width,TEX.Height),c1,0f,default(Vector2),s1,SpriteEffects.None,0f);
     SP.Draw(TEX,NC-TC*s2+Pos-Pos2,new Rectangle(0,0,TEX.Width,TEX.Height),c2,0f,default(Vector2),s2,SpriteEffects.None,0f);
 }
	protected virtual void OnDrawOne(SpriteBatch sb, Vector2 pos, float size, float alpha) {
		Color c = Color.GreenYellow;
		
		float sizeAmp = !IsActive() ? 1.5f : 1f;
		sb.Draw(ptFuzzy,pos-Main.screenPosition,GetRectFuzzy(),new Color(c.R,c.G,c.B,(byte)(c.A/2f)),0f,GetCenterFuzzy(),GetScaleFuzzy(size*sizeAmp),SpriteEffects.None,0f);
		sb.Draw(ptFuzzy,pos-Main.screenPosition,GetRectFuzzy(),c,0f,GetCenterFuzzy(),GetScaleFuzzy(size*sizeAmp/2f),SpriteEffects.None,0f);
		float lightAmp = !IsActive() ? 2f : 1f;
		if (addLight) Lighting.addLight((int)Math.Round(pos.X/16f),(int)Math.Round(pos.Y/16f),c.R/255f*size/32f*c.A/255f*lightAmp,c.G/255f*size/32f*c.A/255f*lightAmp,c.B/255f*size/32f*c.A/255f*lightAmp);
	}
Esempio n. 5
0
        protected override void OnDrawContent(SpriteBatch batch, Rectangle contentArea, GameTime gameTime, float alpha)
        {
            if (Scene == null || Scene.MiniMapTexture == null)
                return;

            batch.Draw(Skin.Pix, new Rectangle(contentArea.X - 2, contentArea.Y - 2, contentArea.Width + 4, contentArea.Height + 4), Color.Black);
            batch.Draw(Scene.MiniMapTexture, new Rectangle(contentArea.X, contentArea.Y, contentArea.Width, contentArea.Height), Color.White);

            Index2 center = new Index2((contentArea.Width / 2) + contentArea.X, (contentArea.Height / 2) + contentArea.Y);

            batch.Draw(Skin.Pix, new Rectangle(center.X - 1, center.Y - 1, 2, 2), Color.White);
        }
Esempio n. 6
0
        internal override void DrawScene(GameTime gameTime)
        {
            if (spriteBatch != null && playerSprite != null && plyerTextureTransform != null)
            {
                spriteBatch?.Begin();
                spriteBatch?.Draw(playerSprite, plyerTextureTransform);
                spriteBatch?.Draw(enemySprite, enemyTextureTransform);
                spriteBatch?.Draw(upArrowSprite, upArrowTransform);
                spriteBatch?.Draw(downArrowSprite, downArrowTransForm);
                spriteBatch?.End();
            }

            _guiSystem.Draw(gameTime);
        }
Esempio n. 7
0
        protected override void OnDrawContent(SpriteBatch batch, Rectangle contentArea, GameTime gameTime, float alpha)
        {
            if (!assets.Ready)
                return;

            batch.Draw(Texture, contentArea, Color * Transparency);
        }
Esempio n. 8
0
 public void Draw(SpriteBatch spriteBatch, Color color)
 {
     Vector2 tangent = B - A;
     float rotation = (float)Math.Atan2(tangent.Y, tangent.X);
  
     const float ImageThickness = 8;
     float thicknessScale = Thickness / ImageThickness;
  
     Vector2 capOrigin = new Vector2(Art.HalfCircle.Width, Art.HalfCircle.Height / 2f);
     Vector2 middleOrigin = new Vector2(0, Art.LightningSegment.Height / 2f);
     Vector2 middleScale = new Vector2(tangent.Length(), thicknessScale);
  
     spriteBatch.Draw(Art.LightningSegment, A, null, color, rotation, middleOrigin, middleScale, SpriteEffects.None, 0f);
     spriteBatch.Draw(Art.HalfCircle, A, null, color, rotation, capOrigin, thicknessScale, SpriteEffects.None, 0f);
     spriteBatch.Draw(Art.HalfCircle, B, null, color, rotation + MathHelper.Pi, capOrigin, thicknessScale, SpriteEffects.None, 0f);
 }
Esempio n. 9
0
 public override void Draw(SpriteBatch myAnimation, Vector3 myPosition)
 {
     for (int i = 0; i < myLayers.Length; i++)
     {
         myAnimation?.Draw(myLayers[i].SpriteAtlas, new Vector2(myPosition.X, myPosition.Y), myLayers[i].SourceRectangle, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
     }
 }
	public void DrawOnScreen(SpriteBatch sb, double layer) {
		Player player = Main.player[Main.myPlayer];
		
		if (resetChat) Main.chatMode = false;
		resetChat = false;
		
		if (!Settings.GetBool("toggle") && Main.playerInventory && !Main.craftingHide && (!Codable.RunGlobalMethod("ModWorld","PreDrawAvailableRecipes",sb) || (bool)Codable.customMethodReturn)) {
			if (Main.reforge || player.chest != -1 || Main.npcShop != 0 || player.talkNPC != -1 || Main.craftGuide || Main.ForceGuideMenu) return;
			if (Config.tileInterface == null && Config.npcInterface == null) {
				if (shouldInit) {
					GuiCraft.Init();
					shouldInit = false;
				}
				GuiCraft.Create();
			}
		}
		
		if (Config.tileInterface != null && Config.tileInterface.code is GuiCraft) {
			Config.tileInterface.SetLocation(new Vector2(player.position.X/16f,player.position.Y/16f));
			((GuiCraft)Config.tileInterface.code).PreDrawInterface(sb);
		}
		
		if (Main.playerInventory && Settings.GetBool("toggle") && (Config.tileInterface == null || Config.tileInterface.code is GuiCraft)) {
			Color c = Config.tileInterface != null && Config.tileInterface.code is ModWorld.GuiCraft ? Color.White : Color.Gray;
			sb.Draw(ModWorld.texShow,new Vector2(414,210),GetTexRectangle(texShow),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
		}
	}
Esempio n. 11
0
        protected override void OnDrawingForeground(UltravioletTime time, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(blankTexture, new RectangleF(64, 64, Width - 128, Height - 128), Color.Black * 0.75f * TransitionPosition);

            var settings = new TextLayoutSettings(font, Width, Height, TextFlags.AlignCenter | TextFlags.AlignMiddle);
            textRenderer.Draw(spriteBatch, "Welcome to the game!", Vector2.Zero, Color.White * TransitionPosition, settings);

            base.OnDrawingForeground(time, spriteBatch);
        }
Esempio n. 12
0
 internal override void DrawScene(GameTime gameTime)
 {
     if (spriteBatch != null && wallSprite != null && transform != null)
     {
         spriteBatch?.Begin();
         spriteBatch?.Draw(wallSprite, transform);
         spriteBatch?.End();
     }
 }
Esempio n. 13
0
		public void Draw(int idx, SpriteBatch batch, float x, float y,
				float rotation, float sx, float sy, LColor color) {
			RectBox rect = this._rectList[idx];
			batch.SetColor(color);
			batch.Draw(_texture, x, y, anchor.x, anchor.y, rect.width, rect.height,
					sx, sy, MathUtils.ToDegrees(rotation), rect.x, rect.y,
					rect.width, rect.height, false, false);
			batch.ResetColor();
		}
Esempio n. 14
0
		public void Draw(int idx, SpriteBatch batch, Vector2f absPos,
				float rotation, Vector2f scale, LColor color) {
			RectBox rect = this._rectList[idx];
			batch.SetColor(color);
			batch.Draw(_texture, absPos.x, absPos.y, anchor.x, anchor.y,
					rect.width, rect.height, scale.x, scale.y,
					MathUtils.ToDegrees(rotation), rect.x, rect.y, rect.width,
					rect.height, false, false);
			batch.ResetColor();
		}
Esempio n. 15
0
		public override void Draw(SpriteBatch batch) {
			if (base._visible && (base._texture != null)) {
				pos = base.ConvertToWorldPos();
				rotation = base.ConvertToWorldRot();
				scale = base.ConvertToWorldScale();
				batch.SetColor(base._color.r, base._color.g, base._color.b,
						base._alpha);
				if (this._type == BarType.PROGRESS_BAR_LEFT) {
					batch.Draw(_texture, pos[0], pos[1], _anchor.x, _anchor.y,
							base._size_width, base._size_height, scale[0],
							scale[1], MathUtils.ToDegrees(rotation), base._left,
							base._top, base._orig_width * this._percent,
							base._orig_height, _flipX, _flipY);
				} else if (this._type == BarType.PROGRESS_BAR_RIGHT) {
					int offsetX = ((int) (base._orig_width * (1f - this._percent)));
					batch.Draw(_texture, pos[0] + offsetX, pos[1], _anchor.x,
							_anchor.y, base._size_width, base._size_height,
							scale[0], scale[1], MathUtils.ToDegrees(rotation),
							((int) base._left) + offsetX, (int) base._top,
							(int) (base._orig_width * this._percent),
							(int) base._orig_height, _flipX, _flipY);
				} else if (this._type == BarType.PROGRESS_BAR_TOP) {
                    batch.Draw(_texture, pos[0], pos[1], _anchor.x, _anchor.y,
							base._size_width, base._size_height, scale[0],
							scale[1], MathUtils.ToDegrees(rotation), base._left,
							base._top, base._orig_width,
							(base._orig_height * this._percent), _flipX, _flipY);
				} else if (this._type == BarType.PROGRESS_BAR_BOTTOM) {
					int offsetY = ((int) (base._orig_height * (1f - this._percent)));
                    batch.Draw(_texture, pos[0], pos[1] + offsetY, _anchor.x,
							_anchor.y, base._size_width, base._size_height,
							scale[0], scale[1], MathUtils.ToDegrees(rotation),
							(int) base._left, ((int) base._top)
									+ ((int) (base._orig_height * this._percent)),
							(int) base._orig_width,
							(int) (base._orig_height * this._percent), _flipX,
							_flipY);
	
				}
				batch.ResetColor();
			}
		}
Esempio n. 16
0
	public void DrawOnScreen(SpriteBatch sb, double layer) {
		Player player = Main.player[Main.myPlayer];
		
		if (resetChat) Main.chatMode = false;
		resetChat = false;
		
		if (Config.tileInterface != null && Config.tileInterface.code is GuiCheat) {
			Config.tileInterface.SetLocation(new Vector2(player.position.X/16f,player.position.Y/16f));
			((GuiCheat)Config.tileInterface.code).PreDrawInterface(sb);
		}
		
		if (Main.playerInventory && GetClientAdminLevel() == 2) {
			Color c;
			Vector2 v;
			int xx = 0;
			
			c = Config.tileInterface != null && Config.tileInterface.code is GuiItem ? Color.White : Color.Gray;
			v = new Vector2(8+xx,Main.screenHeight-8-texItem.Height);
			sb.Draw(texItem,v,GetTexRectangle(texItem),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
			xx += texItem.Width+2;
			
			c = Config.tileInterface != null && Config.tileInterface.code is GuiPrefix ? Color.White : Color.Gray;
			v = new Vector2(8+xx,Main.screenHeight-8-texPrefix.Height);
			sb.Draw(texPrefix,v,GetTexRectangle(texPrefix),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
			xx += texPrefix.Width+2;
			
			c = Config.tileInterface != null && Config.tileInterface.code is GuiNPC ? Color.White : Color.Gray;
			v = new Vector2(8+xx,Main.screenHeight-8-texNPC.Height);
			sb.Draw(texNPC,v,GetTexRectangle(texNPC),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
			xx += texNPC.Width+2;
			
			c = Config.tileInterface != null && Config.tileInterface.code is GuiBuff ? Color.White : Color.Gray;
			v = new Vector2(8+xx,Main.screenHeight-8-texBuff.Height);
			sb.Draw(texBuff,v,GetTexRectangle(texBuff),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
			xx += texBuff.Width+2;
			
			c = Config.tileInterface != null && Config.tileInterface.code is GuiMisc ? Color.White : Color.Gray;
			v = new Vector2(8+xx,Main.screenHeight-8-texMisc.Height);
			sb.Draw(texMisc,v,GetTexRectangle(texMisc),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
			xx += texMisc.Width+2;
		}
	}
Esempio n. 17
0
	public override void Draw(SpriteBatch sb, Projectile p, ModWorld.Firework f) {
		trail.Insert(0,new Vector2(pos.X,pos.Y));
		for (int i = 0; i < Math.Min(trail.Count,5); i++) {
			Vector2 v = trail[i];
			float alpha = (5-i)/5f;
			sb.Draw(ptFuzzy,v-Main.screenPosition,GetRectFuzzy(),new Color(color.R,color.G,color.B,(byte)(color.A*alpha*.5f)),0f,GetCenterFuzzy(),GetScaleFuzzy(12f),SpriteEffects.None,0f);
			sb.Draw(ptFuzzy,v-Main.screenPosition,GetRectFuzzy(),new Color(color.R,color.G,color.B,(byte)(color.A*alpha)),0f,GetCenterFuzzy(),GetScaleFuzzy(4f),SpriteEffects.None,0f);
		}
		if (trail.Count > 5) trail.RemoveAt(5);
		
		pos += vel;
		vel.Y += .05f;
		
		if (timeLeft > 0) {
			timeLeft--;
		} else {
			color.A = (byte)Math.Max(color.A-26,0);
			if (color.A == 0) dead = true;
		}
	}
		public override void Draw(SpriteBatch sb, Projectile p, Firework f) {
			trail.Insert(0,new Vector2(pos.X,pos.Y));
			for (int i = 0; i < Math.Min(trail.Count,10); i++) {
				Vector2 v = trail[i];
				float alpha = (10-i)/10f;
				sb.Draw(ptFuzzy,v-Main.screenPosition,GetRectFuzzy(),new Color(color.R,color.G,color.B,(byte)(color.A*alpha*.5f)),0f,GetCenterFuzzy(),GetScaleFuzzy(36f),SpriteEffects.None,0f);
				sb.Draw(ptFuzzy,v-Main.screenPosition,GetRectFuzzy(),new Color(color.R,color.G,color.B,(byte)(color.A*alpha)),0f,GetCenterFuzzy(),GetScaleFuzzy(12f),SpriteEffects.None,0f);
			}
			if (trail.Count > 10) trail.RemoveAt(10);
			Lighting.addLight((int)Math.Round(pos.X/16f),(int)Math.Round(pos.Y/16f),color.R/255f*(color.A/255f),color.G/255f*(color.A/255f),color.B/255f*(color.A/255f));
			
			pos += vel;
			vel.Y += .075f;
			
			if (timeLeft > 0) {
				timeLeft--;
			} else {
				color.A = (byte)Math.Max(color.A-10,0);
				if (color.A == 0) dead = true;
			}
		}
Esempio n. 19
0
	public void Draw(SpriteBatch sb, int index) {
		if (dead) return;
		int w = (int)(Math.Max(Main.fontMouseText.MeasureString(ac.title).X,Main.fontMouseText.MeasureString(ac.description).X*.75f)+(ac.tex == null ? 0 : 52)+8);
		
		int xx = (int)((Main.screenWidth-w)/2f), yy = Main.screenHeight-y;
		
		sb.Draw(frame1,new Rectangle(xx,yy,w,56),Color.White);
		sb.Draw(frame2,new Rectangle(xx,yy,1,56),Color.White);
		sb.Draw(frame2,new Rectangle(xx+w,yy,1,56),Color.White);
		
		xx += 4;
		if (ac.tex != null) {
			float scale = 1f;
			if (ac.tex.Width > 48) scale = 48f/ac.tex.Width;
			if (ac.tex.Height*scale > 48f) scale = 48f/ac.tex.Height;
			sb.Draw(ac.tex,new Rectangle((int)(xx+(48-ac.tex.Width*scale)/2f),(int)(yy+4+(48-ac.tex.Height*scale)/2f),(int)(ac.tex.Width*scale),(int)(ac.tex.Height*scale)),Color.White);
			xx += 52;
		}
		ModWorld.DrawStringShadowed(sb,Main.fontMouseText,ac.title,new Vector2(xx,yy+8),Color.White,Color.Black);
		ModWorld.DrawStringShadowed(sb,Main.fontMouseText,ac.description,new Vector2(xx,yy+28),Color.White,Color.Black,default(Vector2),.75f);
	}
Esempio n. 20
0
        protected override void Draw(GameTime gameTime)
        {
            // Big pixel graphics rendering
            {
                // Change the render target to surface
                GraphicsDevice.SetRenderTarget(renderSurface);
                GraphicsDevice.Clear(Color.Black);

                // Draws everything in the surface
                currentScene?.Draw();

                if (currentScene != null && currentScene.HasPreMainDisplayEffectDraws)
                {
                    GraphicsDevice.SetRenderTarget(preMainDisplayEffectRenderTarget);
                    currentScene.PreMainDisplayEffectDraw();
                }

                // Apply visual display effects
                if (EffectService is EffectService service && renderSurface != null)
                {
                    renderSurface = service.ApplyEnabledDisplayEffects(renderSurface);
                }

                // Debug visual representation
                currentScene?.DebugDraw();

                // Back to the normal render method
                GraphicsDevice.SetRenderTarget(null);

                // Render the surface to have the ingame screen
                SpriteBatch?.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointClamp);

                SpriteBatch?.Draw(
                    texture: renderSurface,
                    destinationRectangle: new Rectangle(0, 0, (int)WindowSize.Width, (int)WindowSize.Height),
                    sourceRectangle: new Rectangle(0, 0, InGameViewport.Width, InGameViewport.Height),
                    color: Color.White
                    );
                SpriteBatch?.End();
            }

            // Hi-res graphics rendering
            {
                // Render all UI elements in front of the render target texture
                currentScene?.UIDraw();
            }

            base.Draw(gameTime);
        }
Esempio n. 21
0
	public void DrawOnScreen(SpriteBatch sb, double layer) {
		if (ModWorld.display == "off") return;
		if (Config.tileInterface != null) return;
		if (Config.npcInterface != null) return;
		
		sb.End();
		sb.Begin(SpriteSortMode.Immediate,BlendState.NonPremultiplied);
		
		foreach (Player player in Main.player) {
			if (player == null) continue;
			if (!player.active) continue;
			if (player.dead || player.ghost) continue;
			
			if (ModWorld.display != "all") {
				if (player.whoAmi == Main.myPlayer && ModWorld.display != "my") continue;
				if (player.whoAmi != Main.myPlayer && ModWorld.display != "other") continue;
			}
			
			if (player.invis) continue;
			float alpha = GetBarAlpha(player);
			if (alpha <= 0) continue;
			
			int hp = player.statLife, hpMax = player.statLifeMax;
			int xx = (int)(player.position.X-Main.screenPosition.X)-12, yy = (int)(player.position.Y-16-Main.screenPosition.Y), ww = 44, hh = 12;
			
			Color color = new Color(255,255,255);
			color.A = (byte)(alpha*255);
			
			sb.Draw(texBack,new Rectangle(xx,yy,ww,hh),color);
			sb.Draw(texRed,new Rectangle(xx+2,yy+2,ww-4,hh-4),color);
			sb.Draw(texGreen,new Rectangle(xx+2,yy+2,(int)((1d*hp/hpMax)*(ww-4)),hh-4),color);
		}
		
		sb.End();
		sb.Begin();
	}
Esempio n. 22
0
        protected override void OnDrawingForeground(UltravioletTime time, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(blankTexture, new RectangleF(0, 0, Width, Height), new Color(180, 0, 0));

            #if ANDROID || IOS
            var text = "This is SampleScreen1\nTap to open SampleScreen2";
            #else
            var text = "This is SampleScreen1\nPress right arrow key to open SampleScreen2";
            #endif

            var settings = new TextLayoutSettings(font, Width, Height, TextFlags.AlignCenter | TextFlags.AlignMiddle);
            textRenderer.Draw(spriteBatch, text, Vector2.Zero, Color.White * TransitionPosition, settings);

            base.OnDrawingForeground(time, spriteBatch);
        }
Esempio n. 23
0
        protected override void OnDrawingForeground(UltravioletTime time, SpriteBatch spriteBatch)
        {
            var offset = GetScreenOffset();
            spriteBatch.Draw(blankTexture, new RectangleF(offset, 0, Width, Height), new Color(0, 0, 180));

#if ANDROID
            var text = "This is SampleScreen2\nTap to open SampleScreen1";
#else
            var text = "This is SampleScreen2\nPress left arrow key to open SampleScreen1";
#endif

            var settings = new TextLayoutSettings(font, Width, Height, TextFlags.AlignCenter | TextFlags.AlignMiddle);
            textRenderer.Draw(spriteBatch, text, new Vector2(offset, 0), Color.White, settings);

            base.OnDrawingForeground(time, spriteBatch);
        }
Esempio n. 24
0
        public void DrawText(SpriteBatch spriteBatch, int x, int y, string text)
        {
                int dx = x;
                int dy = y;
                foreach(char c in text)
                {
                        FontChar fc;
                        if(_characterMap.TryGetValue(c, out fc))
                        {
                                var sourceRectangle = new Rectangle(fc.X, fc.Y, fc.Width, fc.Height);
                                var position = new Vector2(dx + fc.XOffset, dy + fc.YOffset);

                                spriteBatch.Draw(_texture, position, sourceRectangle, Color.White);
                                dx += fc.XAdvance;
                        }
                }
Esempio n. 25
0
        protected override void OnDrawContent(SpriteBatch batch, Rectangle contentArea, GameTime gameTime, float alpha)
        {
            if (Player == null || Player.ActorHost == null || !assets.Ready)
                return;

            float compassValue = Player.ActorHost.Angle / (float)(2 * Math.PI);
            compassValue %= 1f;
            if (compassValue < 0)
                compassValue += 1f;

            int offset = (int)(compassTexture.Width * compassValue);
            offset -= contentArea.Width / 2;
            int offsetY = (compassTexture.Height -contentArea.Height) / 2;

            batch.Draw(compassTexture, new Rectangle(contentArea.X,contentArea.Y-offsetY,contentArea.Width,contentArea.Height), new Rectangle(offset, 0, contentArea.Width, contentArea.Height+offsetY), Color.White * alpha);
        }
Esempio n. 26
0
        public Vector2 Draw(SpriteBatch sb, string str, Vector2 position, Microsoft.Xna.Framework.Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
        {
            Vector2 maxBound = new Vector2(float.MaxValue, float.MaxValue);
            Vector2 vector   = position;
            float   num      = 0f;
            float   num2     = 0f;

            foreach (char c in str)
            {
                addTex(c);
                CharTile charTile = CharTiles[c];
                if (c == '\r' || vector.X + (float)charTile.rect.Width * scale.X > maxBound.X)
                {
                    if (vector.X > num2)
                    {
                        num2 = vector.X;
                    }
                    vector.X  = position.X;
                    vector.Y += num * scale.Y + Spacing.Y * scale.X;
                    num       = 0f;
                }
                else
                {
                    if (c == '\n')
                    {
                        continue;
                    }
                    if ((float)charTile.rect.Height > num)
                    {
                        num = charTile.rect.Height;
                        if (vector.Y + num * scale.Y > maxBound.Y)
                        {
                            break;
                        }
                    }
                    sb?.Draw(charTile.tex, vector, charTile.rect, color, rotation, origin, scale, effects, layerDepth);
                    vector.X += (float)charTile.rect.Width * scale.X + Spacing.X * scale.X;
                }
            }
            if (vector.X > num2)
            {
                num2 = vector.X;
            }
            vector.X  = num2 - Spacing.X * scale.X;
            vector.Y += num * scale.Y;
            return(vector - position);
        }
Esempio n. 27
0
        public override void EndScreenshot()
        {
            if (mScreenshotRenderTarget == null)
            {
                return;
            }

            ScreenshotRequests.ForEach(
                screenshotRequestStream =>
            {
                if (screenshotRequestStream == null)
                {
                    return;
                }

                mScreenshotRenderTarget.SaveAsPng(
                    screenshotRequestStream, mScreenshotRenderTarget.Width, mScreenshotRenderTarget.Height
                    );

                screenshotRequestStream.Close();
            }
                );

            ScreenshotRequests.Clear();

            if (mGraphicsDevice == null)
            {
                return;
            }

            var skippedFrame = mScreenshotRenderTarget;

            mScreenshotRenderTarget = null;
            mGraphicsDevice.SetRenderTarget(null);

            if (!Begin())
            {
                return;
            }

            mSpriteBatch?.Draw(skippedFrame, new XNARectangle(), XNAColor.White);
            End();
        }
Esempio n. 28
0
 public void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(Texture, Position, null, Color.White, 0f,
                      new Vector2(Width / 2, Height / 2), 1f, SpriteEffects.None, 0f);
 }
 public void Draw(SpriteBatch spriteBach)
 {
     SetRotationFromMousePosition(Mouse.GetState().Position);
     spriteBach.Draw(this.texture, new Vector2(MyMath.MetersToPixel(base.position.X), MyMath.MetersToPixel(base.position.Y)), null, Color.White, base.rotation, origin, scaleFactor, SpriteEffects.None, 0);
 }
Esempio n. 30
0
 protected override void OnDrawContent(SpriteBatch batch, Rectangle contentArea, GameTime gameTime, float alpha)
 {
     if (ControlTexture != null)
         batch.Draw(ControlTexture, contentArea, Color.White * alpha);
 }
Esempio n. 31
0
 public void Draw(SpriteBatch sb)
 {
     sb.Draw(card1, new Rectangle(0, 0, 320, 568), Color.White);
 }
Esempio n. 32
0
		public virtual void HandleDrawBack(SpriteBatch sb, int slot) {
			sb.Draw(Main.inventoryBack5Texture,new Rectangle((int)pos.X,(int)pos.Y,(int)size.X,(int)size.Y),new Rectangle?(new Rectangle(0,0,Main.inventoryBackTexture.Width,Main.inventoryBackTexture.Height)),Color.White);
		}
Esempio n. 33
0
 public override void Visit(Grass grass)
 {
     // TODO: add additinal logic for using different grass texture
     spriteBatch.Draw(texture, drawRectangle, new Rectangle(GameConfig.TILE_GRASS * GameConfig.TILE_DIM, GameConfig.TILE_START_Y, GameConfig.TILE_DIM, GameConfig.TILE_DIM), Color.White);
 }
 public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     spriteBatch.Begin();
     spriteBatch.Draw(Background, Vector2.Zero, color);
     spriteBatch.End();
 }
Esempio n. 35
0
 public static void Flush(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(FlushTexture, Vector2.Zero, Color.Black);
 }
Esempio n. 36
0
        public Vector2 Draw(SpriteBatch sb, char[] str, Vector2 position, Vector2 maxBound, Vector2 scale, Microsoft.Xna.Framework.Color color)
        {
            if (maxBound.X == 0f)
            {
                maxBound.X = float.MaxValue;
            }
            else
            {
                maxBound.X += position.X;
            }
            if (maxBound.Y == 0f)
            {
                maxBound.Y = float.MaxValue;
            }
            else
            {
                maxBound.Y += position.Y;
            }
            Vector2 vector = position;
            float   num    = 0f;
            float   num2   = 0f;

            foreach (char c in str)
            {
                addTex(c);
                CharTile charTile = CharTiles[c];
                if (c == '\r' || vector.X + (float)charTile.rect.Width * scale.X > maxBound.X)
                {
                    if (vector.X > num2)
                    {
                        num2 = vector.X;
                    }
                    vector.X  = position.X;
                    vector.Y += num * scale.Y + Spacing.Y * scale.X;
                    num       = 0f;
                }
                else
                {
                    if (c == '\n')
                    {
                        continue;
                    }
                    if ((float)charTile.rect.Height > num)
                    {
                        num = charTile.rect.Height;
                        if (vector.Y + num * scale.Y > maxBound.Y)
                        {
                            break;
                        }
                    }
                    sb?.Draw(charTile.tex, vector, charTile.rect, color, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
                    vector.X += (float)charTile.rect.Width * scale.X + Spacing.X * scale.X;
                }
            }
            if (vector.X > num2)
            {
                num2 = vector.X;
            }
            vector.X  = num2 - Spacing.X * scale.X;
            vector.Y += num * scale.Y;
            return(vector - position);
        }
Esempio n. 37
0
 public override void drawCharacter(SpriteBatch sb)
 {
     sb.Draw(texture, characterRec, Color.LightGoldenrodYellow);
 }
Esempio n. 38
0
 public void Draw(SpriteBatch spriteBatch, Vector2 position1)
 {
     spriteBatch.Draw(texture, position, Color.White);
     //foreach (Vector2 blockPosition in blockPositions)
     //spriteBatch.Draw(blockTexture, blockPosition, Color.White);
 }
Esempio n. 39
0
 public override void Draw(SpriteBatch spritebatch)
 {
     spritebatch.Draw(Texture, Position, null, Color.White, Rotation, SpriteCenter, Scale, SpriteEffects.None, 0f);
 }
Esempio n. 40
0
 public virtual void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(Image, Position, Source, Color, Rotation, Origin, Scale, SpriteEffects.None, 0);
 }
	public void DrawOnScreen(SpriteBatch sb, double layer) {
		switch (style) {
			case "horizontal_bottom": {
				int xx = 200, yy = Main.screenHeight-32, ww = Main.screenWidth-2*xx, hh = 32;
				
				List<ModWorld.NPCInst> list = ModWorld.GetActualNPCs();
				foreach (ModWorld.NPCInst npci in list) {
					if (!ModWorld.IsBoss(npci)) continue;
					
					Player p = Main.player[Main.myPlayer];
					if (Vector2.Distance(p.position+new Vector2(p.width/2f,p.height/2f),npci.GetCenterPos()) > 2*Math.Sqrt(Math.Pow(Main.screenWidth,2)+Math.Pow(Main.screenHeight,2))) continue;
					
					sb.Draw(ModWorld.texBack,new Rectangle(xx,yy+4,ww,hh-8),Color.White);
					sb.Draw(ModWorld.texWhite,new Rectangle(xx+2,yy+6,ww-4,hh-12),Color.Black);
					
					int phase = 0;
					float percent = 1f*npci.GetLife()/npci.GetLifeMax();
					Object[] ret = new Object[]{null,null};
					if (Codable.RunGlobalMethod("ModWorld","ExternalGetBossPhase",npci.parts,npci.GetName(),npci.GetCenterPos(),npci.GetLife(),npci.GetLifeMax(),ret)) if (ret[0] != null && ret[1] != null) {
						phase = (int)ret[0];
						percent = (float)ret[1];
					}
					if (phase > 0) sb.Draw(ModWorld.texPhase[phase-1],new Rectangle(xx+2,yy+6,(int)(1f*(ww-4)),hh-12),Color.White);
					sb.Draw(ModWorld.texPhase[phase],new Rectangle(xx+2,yy+6,(int)((percent)*(ww-4)),hh-12),Color.White);
					
					DrawStringShadowed(sb,Main.fontMouseText,npci.GetName(),new Vector2(xx+4,yy+4),Color.White,Color.Black);
					string s = ""+npci.GetLife()+"/"+npci.GetLifeMax();
					DrawStringShadowed(sb,Main.fontMouseText,s,new Vector2(xx+ww-4-Main.fontMouseText.MeasureString(s).X,yy+4),Color.White,Color.Black);
					
					yy -= hh;
				}
			} break;
			case "circular_bottomleft": {
				int xx = 4, yy = Main.screenHeight-100;
				
				List<ModWorld.NPCInst> list = ModWorld.GetActualNPCs();
				foreach (ModWorld.NPCInst npci in list) {
					if (!ModWorld.IsBoss(npci)) continue;
					
					Player p = Main.player[Main.myPlayer];
					if (Vector2.Distance(p.position+new Vector2(p.width/2f,p.height/2f),npci.GetCenterPos()) > 2*Math.Sqrt(Math.Pow(Main.screenWidth,2)+Math.Pow(Main.screenHeight,2))) continue;
					
					sb.Draw(ModWorld.texBack,new Vector2(xx,yy),Color.White);
					
					int phase = -1;
					Object[] ret = new Object[]{null,null};
					if (Codable.RunGlobalMethod("ModWorld","ExternalGetBossPhase",npci.parts,npci.GetName(),npci.GetCenterPos(),npci.GetLife(),npci.GetLifeMax(),ret)) if (ret[0] != null && ret[1] != null) phase = (int)ret[0];
					if (phase > 0) sb.Draw(ModWorld.texPhase[phase-1],new Vector2(xx,yy),Color.White);
					
					sb.Draw((Texture2D)rt,new Vector2(xx,yy),Color.White);
					string s = ""+npci.GetLife()+"/"+npci.GetLifeMax();
					DrawStringShadowed(sb,Main.fontMouseText,s,new Vector2(xx+52,yy+52),Color.White,Color.Black);
					DrawStringShadowed(sb,Main.fontMouseText,npci.GetName(),new Vector2(xx+52,yy+72),Color.White,Color.Black);
					
					xx += (int)(Math.Max(Main.fontMouseText.MeasureString(s).X,Main.fontMouseText.MeasureString(npci.GetName()).X)+68);
				}
			} break;
		}
	}
Esempio n. 42
0
        public Tuple <bool, Tile> IsSpaceOpen(Vector2 pos, Vector2 size, SpriteBatch s = null)
        {
            // Create a sprite with the collition points size and position
            Sprite spr = new Sprite();

            spr.X = (int)pos.X;
            spr.Y = (int)pos.Y;

            // Create a texture to fill it.
            // TODO: This is very RAM and CPU intensive and should be cleaned out.
            Texture2D tex = new Texture2D(GameManager.Game.GraphicsDevice, (int)size.X, (int)size.Y);

            uint[] pixels = new uint[(int)size.X * (int)size.Y];
            for (int i = 0; i < pixels.Length; i++)
            {
                pixels[i] = Color.Red.PackedValue;
            }
            tex.SetData(pixels);
            spr.Texture = tex;

            // Testing variables.
            bool isOpen = true;
            Tile t      = null;

            // Draw the collition point if the passed spritebatch is not null
            s?.Draw(GlobalAssets.WorldTiles["floor"].Texture, new Rectangle(pos.ToPoint(), size.ToPoint()), Color.Blue);

            foreach (Tile tile in Tiles)    // Loop through tiles.
            {
                if (spr.CollidesWith(tile)) // Check if we are just generally intersecting it
                {
                    if (tile.Physics)       // Check if it is actually collidable
                    {
                        // set testing variables.
                        t      = tile;
                        isOpen = false;

                        // Check if this tile needs to use per pixel colition.
                        if (t.TileInfo.UsePPC)
                        {
                            isOpen = !Sprite.PerPixelCollision(spr, tile);
                        }
                    }
                    break;
                }
            }

            // Same with entities.
            foreach (Entity ent in Entity)
            {
                if (spr.CollidesWith(ent) && ent.EntityTexture.Colidable)
                {
                    isOpen = !Sprite.PerPixelCollision(spr, ent);
                    break;
                }
            }

            // Dispose the texture to free RAM.
            tex.Dispose();

            return(new Tuple <bool, Tile>(isOpen, t));
        }
Esempio n. 43
0
        internal override void Draw(GameTime gameTime)
        {
            _preScreen.Draw(gameTime);

            _batch.Begin(samplerState: SamplerState.PointClamp);

            var(unit, startX, width, height) = Border.GetDefaultScreenValues();

            // fill background
            Border.DrawCenter(_batch, startX, 0, Border.SCREEN_WIDTH, Border.SCREEN_HEIGHT, Border.SCALE);

            // pokemon list box
            Border.Draw(_batch, startX + unit * 8, 0, 12, 14, Border.SCALE);

            // title box
            Border.Draw(_batch, startX + unit * 8, 0, 12, 3, Border.SCALE);
            _fontRenderer.DrawText(_batch, _title,
                                   new Vector2(startX + unit * 10, unit), Color.Black, Border.SCALE);

            if (CanChangeBox)
            {
                _batch.Draw(_arrow, new Rectangle(
                                startX + unit * 8, unit,
                                (int)(_arrow.Width * Border.SCALE),
                                (int)(_arrow.Height * Border.SCALE)),
                            null, Color.White, 0f, Vector2.Zero, SpriteEffects.FlipHorizontally, 0f);
                _batch.Draw(_arrow, new Rectangle(
                                startX + unit * 19, unit,
                                (int)(_arrow.Width * Border.SCALE),
                                (int)(_arrow.Height * Border.SCALE)), Color.White);
            }

            // pokemon list
            var visiblePokemon = _pokemon.Skip(_scrollIndex).Take(VISIBLE_POKEMON).Select(p => p.DisplayName).ToList();

            if (visiblePokemon.Count < VISIBLE_POKEMON)
            {
                visiblePokemon.Add("CANCEL");
            }
            var pokemonListText = string.Join(NewLine, visiblePokemon);

            _fontRenderer.DrawText(_batch, pokemonListText,
                                   new Vector2(startX + unit * 9, unit * 4), Color.Black, Border.SCALE);

            // selector
            if (!DialogVisible)
            {
                if (_isMoving)
                {
                    _batch.Draw(_moveSelector, new Rectangle(
                                    startX + unit * 9,
                                    unit * 3 + unit * 2 * _index,
                                    (int)(_moveSelector.Width * Border.SCALE),
                                    (int)(_moveSelector.Height * Border.SCALE)), Color.White);
                }
                else
                {
                    _batch.Draw(_selector, new Rectangle(
                                    (int)(startX + unit * 8 + 7 * Border.SCALE),
                                    (int)(unit * 3 + Border.SCALE + unit * 2 * _index),
                                    (int)(_selector.Width * Border.SCALE),
                                    (int)(_selector.Height * Border.SCALE)), Color.White);
                }
            }

            // portrait background
            var targetRect = new Rectangle(
                startX + unit, unit * 4,
                (int)(PokemonTextureManager.TEXTURE_SIZE * Border.SCALE),
                (int)(PokemonTextureManager.TEXTURE_SIZE * Border.SCALE));

            if (!_optionsBox.Visible && !_isMoving)
            {
                _batch.DrawRectangle(targetRect, POKEMON_PORTRAIT_BACKGROUND);
            }

            if ((_pokemon.Length > _index + _scrollIndex || _isMoving) && _showPokemon)
            {
                // pokemon portrait
                var       selectedPokemon = GetSelectedPokemon();
                Texture2D sprite;

                if (_optionsBox.Visible || _isMoving)
                {
                    sprite = selectedPokemon.GetFrontSprite();
                }
                else
                {
                    sprite = PokemonTextureManager.GetFront(selectedPokemon.Id, POKEMON_PORTRAIT_PALETTE, selectedPokemon.UnownLetter);
                }
                _batch.Draw(sprite, targetRect, Color.White);

                // pokemon info
                var levelStr = selectedPokemon.Level == Pokemon.MAX_LEVEL ?
                               Pokemon.MAX_LEVEL.ToString().PadRight(4) :
                               ("^:L" + selectedPokemon.Level).PadRight(6);
                var infoStr = levelStr + PokemonStatHelper.GetGenderChar(selectedPokemon.Gender) + NewLine +
                              selectedPokemon.Name;
                _fontRenderer.DrawText(_batch, infoStr,
                                       new Vector2(startX + unit, unit * 12), Color.Black, Border.SCALE);

                // draw item box if the pokemon holds an item
                var heldItem = selectedPokemon.HeldItem;
                if (heldItem != null)
                {
                    Texture2D icon;
                    if (heldItem.IsMail)
                    {
                        icon = _mailIcon;
                    }
                    else
                    {
                        icon = _itemIcon;
                    }
                    _batch.Draw(icon, new Rectangle(
                                    startX + unit * 7, unit * 12,
                                    (int)(Border.SCALE * _itemIcon.Width),
                                    (int)(Border.SCALE * _itemIcon.Height)), Color.White);
                }
            }

            // text box
            Border.Draw(_batch, startX, unit * 15, Border.SCREEN_WIDTH, 3, Border.SCALE);
            _fontRenderer.DrawText(_batch, _message,
                                   new Vector2(startX + unit, unit * 16), Color.Black, Border.SCALE);

            _optionsBox.Draw(_batch, Border.DefaultWhite);
            _confirmationBox.Draw(_batch, Border.DefaultWhite);

            _batch.End();
        }
Esempio n. 44
0
        public override void draw(SpriteBatch b)
        {
            unFixExternalDrawCallBoundaries();
            if (this.drawBG)
            {
                b.Draw(Game1.fadeToBlackRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.Black * 0.5f);
            }

            fixInternalDrawCallBoundaries();
            deepBaseCalls.pDraw(b, false, false, -1, -1, -1);
            unFixInternalDrawCallBoundaries();

            if (this.showReceivingMenu)
            {
                fixInternalDrawCallBoundaries();
                // backpack icon bg
                b.Draw(Game1.mouseCursors, new Vector2(this.xPositionOnScreen - 64, this.yPositionOnScreen + (this.height / 2) + 64 + 16), new Rectangle?(new Rectangle(16, 368, 12, 16)), Color.White, 4.712389f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
                b.Draw(Game1.mouseCursors, new Vector2(this.xPositionOnScreen - 64, this.yPositionOnScreen + (this.height / 2) + 64 - 16), new Rectangle?(new Rectangle(21, 368, 11, 16)), Color.White, 4.712389f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
                // backpack icon
                b.Draw(Game1.mouseCursors, new Vector2(this.xPositionOnScreen - 40, this.yPositionOnScreen + (this.height / 2) + 64 - 44), new Rectangle?(new Rectangle(4, 372, 8, 11)), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
                unFixInternalDrawCallBoundaries();

                Game1.drawDialogueBox(this.ItemsToGrabMenu.xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder,
                                      this.ItemsToGrabMenu.yPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + 16,
                                      this.ItemsToGrabMenu.width + (IClickableMenu.borderWidth * 2) + (IClickableMenu.spaceToClearSideBorder * 2),
                                      this.ItemsToGrabMenu.height + (IClickableMenu.borderWidth * 2) + IClickableMenu.spaceToClearTopBorder,
                                      false, true, null, false, true);
                this.ItemsToGrabMenu.draw(b);
                // chest icon bg
                b.Draw(Game1.mouseCursors, new Vector2(this.inventory.xPositionOnScreen + bgXDiff - 105, this.yPositionOnScreen + 64 + 16), new Rectangle?(new Rectangle(16, 368, 12, 16)), Color.White, 4.712389f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
                b.Draw(Game1.mouseCursors, new Vector2(this.inventory.xPositionOnScreen + bgXDiff - 105, this.yPositionOnScreen + 64 - 16), new Rectangle?(new Rectangle(21, 368, 11, 16)), Color.White, 4.712389f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
                // chest icon
                b.Draw(Game1.mouseCursors, new Vector2(this.inventory.xPositionOnScreen + bgXDiff - 85, this.yPositionOnScreen + 64 - 44), new Rectangle?(new Rectangle(127, 412, 10, 11)), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
            }
            else if (this.message != null)
            {
                Game1.drawDialogueBox(Game1.viewport.Width / 2, this.ItemsToGrabMenu.yPositionOnScreen + (this.ItemsToGrabMenu.height / 2), false, false, this.message);
            }
            foreach (ItemGrabMenu.TransferredItemSprite transferredItemSprite in this._transferredItemSprites)
            {
                transferredItemSprite.Draw(b);
            }
            if (this.colorPickerToggleButton != null)
            {
                this.colorPickerToggleButton.draw(b);
            }
            if (this.chestColorPicker != null)
            {
                this.chestColorPicker.draw(b);
            }
            if (this.organizeButton != null)
            {
                this.organizeButton.draw(b);
            }
            if (this.fillStacksButton != null)
            {
                this.fillStacksButton.draw(b);
            }
            if ((this.hoverText != null && !String.IsNullOrWhiteSpace(this.hoverText)) && (this.hoveredItem == null || this.hoveredItem == null || this.ItemsToGrabMenu == null))
            {
                if (this.hoverAmount > 0)
                {
                    IClickableMenu.drawToolTip(b, this.hoverText, "", null, true, -1, 0, -1, -1, null, this.hoverAmount);
                }
                else
                {
                    IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, 0, 0, -1, null, -1, null, null, 0, -1, -1, -1, -1, 1f, null, null);
                }
            }
            if (this.heldItem != null)
            {
                this.heldItem.drawInMenu(b, new Vector2(Game1.getOldMouseX() + 8, Game1.getOldMouseY() + 8), 1f);
            }
            if (this.hoveredItem != null)
            {
                IClickableMenu.drawToolTip(b, this.hoveredItem.getDescription(), this.hoveredItem.DisplayName, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, null, -1);
            }
            else if (this.hoveredItem != null && this.ItemsToGrabMenu != null)
            {
                IClickableMenu.drawToolTip(b, this.ItemsToGrabMenu.descriptionText, this.ItemsToGrabMenu.descriptionTitle, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, null, -1);
            }
            Game1.mouseCursorTransparency = 1f;

            deepBaseCalls.pDrawMouse(b);
            fixExternalDrawCallBoundaries();
        }
Esempio n. 45
0
        /// <summary>
        /// This method draws current frame for the animation.
        /// </summary>
        /// <param name="spriteBtach"></param>
        private void DrawAnimation(SpriteBatch spriteBtach)
        {
            if (m_currentAnimation == null)
                return;

            if (m_DrawPosition == null)
                return;

            Rectangle sourceRect = m_currentAnimation.GetCurrentFrameSource();

            spriteBtach.Draw(m_spriteTexture, m_DrawPosition, sourceRect, Color.White);
        }
	protected virtual void OnDrawOne(SpriteBatch sb, Vector2 pos, float size, float hue, float alpha) {
		int r,g,b;
		HsvToRgb(hue,1f,1f,out r,out g,out b);
		Color c = new Color(r,g,b,(byte)(this.alpha*alpha*255));
		
		float sizeAmp = hueSpeed != 0 && !IsActive() ? 1.5f : 1f;
		sb.Draw(ptFuzzy,pos-Main.screenPosition,GetRectFuzzy(),new Color(c.R,c.G,c.B,(byte)(c.A/2f)),0f,GetCenterFuzzy(),GetScaleFuzzy(size*sizeAmp),SpriteEffects.None,0f);
		sb.Draw(ptSpiralStar,pos-Main.screenPosition,GetRectSpiralStar(),c,(float)(rot1*Math.PI/180f),GetCenterSpiralStar(),GetScaleSpiralStar(size*sizeAmp/1.5f),dir*(flipped ? -1 : 1) == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None,0f);
		float lightAmp = hueSpeed != 0 && !IsActive() ? 2f : 1f;
		if (addLight) Lighting.addLight((int)Math.Round(pos.X/16f),(int)Math.Round(pos.Y/16f),c.R/255f*size/32f*c.A/255f*lightAmp,c.G/255f*size/32f*c.A/255f*lightAmp,c.B/255f*size/32f*c.A/255f*lightAmp);
	}
Esempio n. 47
0
        protected override void OnDrawingBackground(UltravioletTime time, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(photograph, new RectangleF(0, 0, Width, Height), Color.White * TransitionPosition);

            base.OnDrawingBackground(time, spriteBatch);
        }
        private void DrawLife()
        {
            Player      localPlayer = Main.LocalPlayer;
            SpriteBatch spriteBatch = Main.spriteBatch;
            Color       color       = new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor);

            UIDisplay_LifePerHeart = 20f;
            if (localPlayer.ghost)
            {
                return;
            }
            int num  = localPlayer.statLifeMax / 20;
            int num2 = (localPlayer.statLifeMax - 400) / 5;

            if (num2 < 0)
            {
                num2 = 0;
            }
            if (num2 > 0)
            {
                num = localPlayer.statLifeMax / (20 + num2 / 4);
                UIDisplay_LifePerHeart = (float)localPlayer.statLifeMax / 20f;
            }
            int num3 = localPlayer.statLifeMax2 - localPlayer.statLifeMax;

            UIDisplay_LifePerHeart += num3 / num;
            int num4 = (int)((float)localPlayer.statLifeMax2 / UIDisplay_LifePerHeart);

            if (num4 >= 10)
            {
                num4 = 10;
            }
            string  text   = Lang.inter[0].Value + " " + localPlayer.statLifeMax2 + "/" + localPlayer.statLifeMax2;
            Vector2 vector = FontAssets.MouseText.get_Value().MeasureString(text);

            if (!localPlayer.ghost)
            {
                DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.get_Value(), Lang.inter[0].Value, new Vector2((float)(500 + 13 * num4) - vector.X * 0.5f + (float)UI_ScreenAnchorX, 6f), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.get_Value(), localPlayer.statLife + "/" + localPlayer.statLifeMax2, new Vector2((float)(500 + 13 * num4) + vector.X * 0.5f + (float)UI_ScreenAnchorX, 6f), color, 0f, new Vector2(FontAssets.MouseText.get_Value().MeasureString(localPlayer.statLife + "/" + localPlayer.statLifeMax2).X, 0f), 1f, SpriteEffects.None, 0f);
            }
            for (int i = 1; i < (int)((float)localPlayer.statLifeMax2 / UIDisplay_LifePerHeart) + 1; i++)
            {
                int   num5 = 255;
                float num6 = 1f;
                bool  flag = false;
                if ((float)localPlayer.statLife >= (float)i * UIDisplay_LifePerHeart)
                {
                    num5 = 255;
                    if ((float)localPlayer.statLife == (float)i * UIDisplay_LifePerHeart)
                    {
                        flag = true;
                    }
                }
                else
                {
                    float num7 = ((float)localPlayer.statLife - (float)(i - 1) * UIDisplay_LifePerHeart) / UIDisplay_LifePerHeart;
                    num5 = (int)(30f + 225f * num7);
                    if (num5 < 30)
                    {
                        num5 = 30;
                    }
                    num6 = num7 / 4f + 0.75f;
                    if ((double)num6 < 0.75)
                    {
                        num6 = 0.75f;
                    }
                    if (num7 > 0f)
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    num6 += Main.cursorScale - 1f;
                }
                int num8 = 0;
                int num9 = 0;
                if (i > 10)
                {
                    num8 -= 260;
                    num9 += 26;
                }
                int a = (int)((double)num5 * 0.9);
                if (!localPlayer.ghost)
                {
                    if (num2 > 0)
                    {
                        num2--;
                        spriteBatch.Draw(TextureAssets.Heart2.get_Value(), new Vector2(500 + 26 * (i - 1) + num8 + UI_ScreenAnchorX + TextureAssets.Heart.Width() / 2, 32f + ((float)TextureAssets.Heart.Height() - (float)TextureAssets.Heart.Height() * num6) / 2f + (float)num9 + (float)(TextureAssets.Heart.Height() / 2)), new Rectangle(0, 0, TextureAssets.Heart.Width(), TextureAssets.Heart.Height()), new Color(num5, num5, num5, a), 0f, new Vector2(TextureAssets.Heart.Width() / 2, TextureAssets.Heart.Height() / 2), num6, SpriteEffects.None, 0f);
                    }
                    else
                    {
                        spriteBatch.Draw(TextureAssets.Heart.get_Value(), new Vector2(500 + 26 * (i - 1) + num8 + UI_ScreenAnchorX + TextureAssets.Heart.Width() / 2, 32f + ((float)TextureAssets.Heart.Height() - (float)TextureAssets.Heart.Height() * num6) / 2f + (float)num9 + (float)(TextureAssets.Heart.Height() / 2)), new Rectangle(0, 0, TextureAssets.Heart.Width(), TextureAssets.Heart.Height()), new Color(num5, num5, num5, a), 0f, new Vector2(TextureAssets.Heart.Width() / 2, TextureAssets.Heart.Height() / 2), num6, SpriteEffects.None, 0f);
                    }
                }
            }
        }
Esempio n. 49
0
 public override void Draw(SpriteBatch batch)
 {
     batch.Draw(TextureRegion.Texture, TextureRegion.Region, GlobalPosition.X, GlobalPosition.Y,
                TextureRegion.Width, TextureRegion.Height);
 }
Esempio n. 50
0
 public void Draw(SpriteBatch sb)
 {
     sb.Draw(texture, screenPosition, Color.White);
 }
Esempio n. 51
0
        /// <summary>The draw calls for the UI elements</summary>
        public override void draw(SpriteBatch b)
        {
            CursorPosition = Utilities.Globals.Helper.Input.GetCursorPosition();

            // suppress the Menu button
            Utilities.Globals.Helper.Input.Suppress(Utilities.Globals.MenuButton);

            // draw screen fade
            b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.75f);

            // draw menu box
            Game1.drawDialogueBox(xPositionOnScreen, yPositionOnScreen, width, height - 12, false, true);

            // draw title scroll
            SpriteText.drawStringWithScrollCenteredAt(b, Utilities.Globals.Helper.Translation.Get("display-reminder.title"), Game1.viewport.Width / 2, yPositionOnScreen, Utilities.Globals.Helper.Translation.Get("display-reminder.title"));

            // draw boxes
            foreach (ClickableTextureComponent box in Boxes)
            {
                box.draw(b);
            }

            // draw labels
            foreach (ClickableComponent label in ReminderMessages)
            {
                string text  = "";
                Color  color = Game1.textColor;
                Utility.drawTextWithShadow(b, label.name, Game1.smallFont, new Vector2(label.bounds.X, label.bounds.Y), color);
                if (text.Length > 0)
                {
                    Utility.drawTextWithShadow(b, text, Game1.smallFont, new Vector2((label.bounds.X + Game1.tileSize / 3) - Game1.smallFont.MeasureString(text).X / 2f, (label.bounds.Y + Game1.tileSize / 2)), color);
                }
            }
            if (Reminders.Count > (PageIndex + 1) * 5)
            {
                NextPageButton.draw(b);
            }
            if (PageIndex != 0)
            {
                PrevPageButton.draw(b);
            }

            // draw the delete buttons
            foreach (ClickableTextureComponent button in DeleteButtons)
            {
                button.draw(b);
            }

            // draw the warning for no reminder
            if (Reminders.Count <= 0)
            {
                Utility.drawTextWithShadow(b, NoRemindersWarning.name, Game1.smallFont, new Vector2(NoRemindersWarning.bounds.X, NoRemindersWarning.bounds.Y), Game1.textColor);
            }

            // draw new reminders button
            NewReminderButton.draw(b);

            // draw the boxes hover text
            foreach (ClickableTextureComponent box in Boxes)
            {
                if (box.containsPoint((int)CursorPosition.ScreenPixels.X, (int)CursorPosition.ScreenPixels.Y))
                {
                    if (box.hoverText != null)
                    {
                        int x = Game1.getMouseX() + 32;
                        int y = Game1.getMouseY() + 32 + 16;
                        IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), x, y - 16, Utilities.Extras.EstimateStringDimension(box.hoverText) + 8, Game1.tileSize + 16, Color.White, 1f, true);
                        SpriteText.drawString(b, box.hoverText, x + 32, y, 999, -1, 99, 1f, 0.88f, false, -1, "", 8, SpriteText.ScrollTextAlignment.Left);
                    }
                }
            }

            // draw cursor
            drawMouse(b);
        }
Esempio n. 52
0
        public void draw(GameTime gametime)
        {
            if (this.day)
            {
                Game1.graphics.GraphicsDevice.Clear(Utility.getSkyColorForSeason(Game1.currentSeason));
            }
            Game1.drawTitleScreenBackground(gametime, this.day ? "_day" : "_night", Utility.weatherDebrisOffsetForSeason(Game1.currentSeason));
            Viewport viewport = Game1.graphics.GraphicsDevice.Viewport;
            int      height   = viewport.TitleSafeArea.Height - Game1.tileSize * 2;

            viewport = Game1.graphics.GraphicsDevice.Viewport;
            int x1 = viewport.TitleSafeArea.X;

            viewport = Game1.graphics.GraphicsDevice.Viewport;
            int num1 = viewport.Width / 2;
            int x2   = x1 + num1 - (int)((double)((this.shippingItems.Count / (height / Game1.tileSize - 4) + 1) * Game1.tileSize) * 3.0);

            viewport = Game1.graphics.GraphicsDevice.Viewport;
            int y1    = viewport.TitleSafeArea.Y + Game1.tileSize;
            int width = (int)((double)((this.shippingItems.Count / (height / Game1.tileSize - 4) + 1) * Game1.tileSize) * 6.0);

            Game1.drawDialogueBox(x2, y1, width, height, false, true, (string)null, false);
            int   num2  = height - Game1.tileSize * 3;
            Point point = new Point(x2 + Game1.tileSize, y1 + Game1.tileSize);

            for (int index = 0; index < this.currentItemIndex; ++index)
            {
                SpriteBatch spriteBatch1      = Game1.spriteBatch;
                Texture2D   objectSpriteSheet = Game1.objectSpriteSheet;
                double      num3 = (double)(point.X + index * Game1.tileSize / (num2 - Game1.tileSize * 2) * Game1.tileSize * 4 + Game1.tileSize / 2);
                int         num4 = index * Game1.tileSize % (num2 - Game1.tileSize * 2) - index * Game1.tileSize % (num2 - Game1.tileSize * 2) % Game1.tileSize;
                viewport = Game1.graphics.GraphicsDevice.Viewport;
                int       y2              = viewport.TitleSafeArea.Y;
                double    num5            = (double)(num4 + y2 + Game1.tileSize * 3 + Game1.tileSize / 2);
                Vector2   position1       = new Vector2((float)num3, (float)num5);
                Rectangle?sourceRectangle = new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, this.shippingItems.Keys.ElementAt <ShippedItem>(index).index, -1, -1));
                Color     white           = Color.White;
                double    num6            = 0.0;
                Vector2   origin          = new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2));
                double    num7            = this.shippingItems.Keys.ElementAt <ShippedItem>(index).name.Contains("=") ? (double)this.starScale : 1.0;
                int       num8            = 0;
                double    num9            = 0.999998986721039;
                spriteBatch1.Draw(objectSpriteSheet, position1, sourceRectangle, white, (float)num6, origin, (float)num7, (SpriteEffects)num8, (float)num9);
                SpriteBatch spriteBatch2 = Game1.spriteBatch;
                SpriteFont  dialogueFont = Game1.dialogueFont;
                string      text         = "x" + (object)this.shippingItems[this.shippingItems.Keys.ElementAt <ShippedItem>(index)] + " : " + (object)(this.shippingItems.Keys.ElementAt <ShippedItem>(index).price *this.shippingItems[this.shippingItems.Keys.ElementAt <ShippedItem>(index)]) + "g";
                double      num10        = (double)(point.X + index * Game1.tileSize / (num2 - Game1.tileSize * 2) * Game1.tileSize * 4 + Game1.tileSize);
                double      num11        = (double)(index * Game1.tileSize % (num2 - Game1.tileSize * 2) - index * Game1.tileSize % (num2 - Game1.tileSize * 2) % Game1.tileSize + Game1.tileSize / 2) - (double)Game1.dialogueFont.MeasureString("9").Y / 2.0;
                viewport = Game1.graphics.GraphicsDevice.Viewport;
                double  y3        = (double)viewport.TitleSafeArea.Y;
                double  num12     = num11 + y3 + (double)(Game1.tileSize * 3);
                Vector2 position2 = new Vector2((float)num10, (float)num12);
                Color   textColor = Game1.textColor;
                spriteBatch2.DrawString(dialogueFont, text, position2, textColor);
            }
            if (!this.complete)
            {
                return;
            }
            SpriteBatch spriteBatch   = Game1.spriteBatch;
            SpriteFont  dialogueFont1 = Game1.dialogueFont;
            string      text1         = Game1.content.LoadString("Strings\\StringsFromCSFiles:MoneyMadeScreen.cs.3854", (object)this.total);
            double      num13         = (double)(x2 + width - Game1.tileSize) - (double)Game1.dialogueFont.MeasureString("Total: " + (object)this.total).X;

            viewport = Game1.graphics.GraphicsDevice.Viewport;
            double  num14      = (double)(viewport.TitleSafeArea.Bottom - Game1.tileSize * 5 / 2);
            Vector2 position   = new Vector2((float)num13, (float)num14);
            Color   textColor1 = Game1.textColor;

            spriteBatch.DrawString(dialogueFont1, text1, position, textColor1);
        }
 internal void DrawSelection(SpriteBatch spriteBatch, Rectangle CurrentSelection)
 {
     spriteBatch.Draw(debugTex, CurrentSelection, Color.Red);
 }
Esempio n. 54
0
 public void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(
         Sprite, Position, rectangle, Color.White,
         0, Vector2.Zero, 1, SpriteEffects.None, 0);
 }
Esempio n. 55
0
 private void DrawBorder(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(border, Rectangle, buttonColor);
 }
Esempio n. 56
0
 public void Draw(SpriteBatch batch)
 {
     batch.Draw(texture, getVertices(), 0, 4);
 }
Esempio n. 57
0
 public void Draw(SpriteBatch g)
 {
     g.Draw(m_Texture, m_DimObj, m_Color);
 }
        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();

            spriteBatch.Draw(background, new Vector2(0, 0), Color.White);
            spriteBatch.Draw(logo, new Vector2(Constants.WINDOW_WIDTH / 2 - (logo.Width / 1.6f), 25), Color.White);
            var boardX = ((Constants.WINDOW_WIDTH / 2) - gameBoard.Width / 2);
            var boardY = ((Constants.WINDOW_HEIGHT / 2) - gameBoard.Height / 2);

            spriteBatch.Draw(gameBoard, new Vector2(boardX, boardY), Color.White);
            spriteBatch.DrawString(spriteFont, messageText, new Vector2(Constants.WINDOW_WIDTH / 2, 225), Color.Red, 0, spriteFont.MeasureString(messageText) / 2, 1.3f, SpriteEffects.None, 0.5f);
            spriteBatch.DrawString(spriteFont, infoText, new Vector2(Constants.WINDOW_WIDTH / 2, 275), Color.Red, 0, spriteFont.MeasureString(infoText) / 2, 1.3f, SpriteEffects.None, 0.5f);
            spriteBatch.DrawString(spriteFont, gameText, new Vector2(Constants.WINDOW_WIDTH / 2, 715), Color.Red, 0, spriteFont.MeasureString(gameText) / 2, 1.3f, SpriteEffects.None, 0.5f);

            spriteBatch.Draw(player1sChip, new Vector2(140, 450), Color.White);
            spriteBatch.Draw(player2sChip, new Vector2(Constants.WINDOW_WIDTH - 140, 450), Color.White);

            foreach (var btnBoardPos in boardPositions)
            {
                if (!squaresTaken.Contains(btnBoardPos.ButtonId))
                {
                    btnBoardPos.Draw(spriteBatch);
                }
                else
                {
                    var pos = GetPositionFromId(btnBoardPos.ButtonId);
                    if (board[(int)pos.X, (int)pos.Y] == 1)
                    {
                        spriteBatch.Draw(xMarkers[(int)pos.X, (int)pos.Y], new Vector2(btnBoardPos._rectangle.X, btnBoardPos._rectangle.Y), Color.White);
                    }
                    else if (board[(int)pos.X, (int)pos.Y] == 2)
                    {
                        spriteBatch.Draw(oMarkers[(int)pos.X, (int)pos.Y], new Vector2(btnBoardPos._rectangle.X, btnBoardPos._rectangle.Y), Color.White);
                    }
                }
            }

            if (gameWon)
            {
                if (wayGameWon.Contains("ROW"))
                {
                    if (wayGameWon.Contains("1"))
                    {
                        spriteBatch.Draw(RowWinTextures[0], new Vector2(boardX, boardY - 30), Color.White);
                    }
                    else if (wayGameWon.Contains("2"))
                    {
                        spriteBatch.Draw(RowWinTextures[1], new Vector2(boardX, boardY), Color.White);
                    }
                    else
                    {
                        spriteBatch.Draw(RowWinTextures[2], new Vector2(boardX, boardY + 30), Color.White);
                    }
                }
                else if (wayGameWon.Contains("COLUMN"))
                {
                    if (wayGameWon.Contains("1"))
                    {
                        spriteBatch.Draw(ColumnWinTextures[0], new Vector2(boardX - 30, boardY), Color.White);
                    }
                    else if (wayGameWon.Contains("2"))
                    {
                        spriteBatch.Draw(ColumnWinTextures[1], new Vector2(boardX, boardY), Color.White);
                    }
                    else
                    {
                        spriteBatch.Draw(ColumnWinTextures[2], new Vector2(boardX + 30, boardY), Color.White);
                    }
                }
                else if (wayGameWon.Contains("Diag"))
                {
                    if (wayGameWon.Contains("left"))
                    {
                        spriteBatch.Draw(DiagWinTextures[1], new Vector2(boardX, boardY), Color.White);
                    }
                    else
                    {
                        spriteBatch.Draw(DiagWinTextures[0], new Vector2(boardX, boardY), Color.White);
                    }
                }
            }
            backButton.Draw(spriteBatch);
            if (drawReset)
            {
                resetButton.Draw(spriteBatch);
            }

            spriteBatch.End();
        }
    public void DrawLine(SpriteBatch SP,Vector2 start,Vector2 end,Texture2D TEX,float S,Color C,float Jump)
    {
        float TEXW = (float)TEX.Width;
        float TEXH = (float)TEX.Height;
        Vector2 TC = new Vector2(TEXW / 2f, TEXH / 2f);
        TC*=S;
        Vector2 Pstart = start;
        Vector2 Pend = end;
        Vector2 dir = Pend - Pstart;
        dir.Normalize();
        //dir/=dir.Length();
        bool screenSafety = true;
        if(screenSafety)
        {
            int alloRad = 16;
            #region pstart
            if(Pstart.X < Main.screenPosition.X-alloRad)
            {
                Pstart.Y+=((Main.screenPosition.X-alloRad-Pstart.X)/dir.X)*dir.Y;
                Pstart.X = Main.screenPosition.X-alloRad;
            }
            if(Pstart.X > Main.screenPosition.X+Main.screenWidth+alloRad)
            {
                Pstart.Y-=((Pstart.X-Main.screenPosition.X-Main.screenWidth-alloRad)/dir.X)*dir.Y;
                Pstart.X = Main.screenPosition.X+Main.screenWidth+alloRad;
            }
            if(Pstart.Y < Main.screenPosition.Y-alloRad)
            {
                Pstart.X+=((Main.screenPosition.Y-alloRad-Pstart.Y)/dir.Y)*dir.X;
                Pstart.Y = Main.screenPosition.Y-alloRad;
            }
            if(Pstart.Y > Main.screenPosition.Y+Main.screenHeight+alloRad)
            {
                Pstart.X-=((Pstart.Y-Main.screenPosition.Y-Main.screenHeight-alloRad)/dir.Y)*dir.X;
                Pstart.Y = Main.screenPosition.Y+Main.screenHeight+alloRad;
            }
            #endregion
            #region pend
            if(Pend.X < Main.screenPosition.X-alloRad)
            {
                Pend.Y+=((Main.screenPosition.X-alloRad-Pend.X)/dir.X)*dir.Y;
                Pend.X = Main.screenPosition.X-alloRad;
            }
            if(Pend.X > Main.screenPosition.X+Main.screenWidth+alloRad)
            {
                Pend.Y-=((Pend.X-Main.screenPosition.X-Main.screenWidth-alloRad)/dir.X)*dir.Y;
                Pend.X = Main.screenPosition.X+Main.screenWidth+alloRad;
            }
            if(Pend.Y < Main.screenPosition.Y-alloRad)
            {
                Pend.X+=((Main.screenPosition.Y-alloRad-Pend.Y)/dir.Y)*dir.X;
                Pend.Y = Main.screenPosition.Y-alloRad;
            }
            if(Pend.Y > Main.screenPosition.Y+Main.screenHeight+alloRad)
            {
                Pend.X-=((Pend.Y-Main.screenPosition.Y-Main.screenHeight-alloRad)/dir.Y)*dir.X;
                Pend.Y = Main.screenPosition.Y+Main.screenHeight+alloRad;
            }
            #endregion
        }
        float rot = (float)Math.Atan2(dir.Y,dir.X) + (float)Math.PI/2f;
        float length = Vector2.Distance(Pstart,Pend);
        float Way = 0f;

        while (Way < length)
        {
            Vector2 v = (Pstart + dir * Way) - Main.screenPosition + TC;
            Color C2 = Lighting.GetColor((int)(v.X+Main.screenPosition.X)/16,(int)(v.Y+Main.screenPosition.Y)/16,C);
            SP.Draw(
            TEX,
            v,
            new Rectangle?(new Rectangle(0, 0, (int)TEXW, (int)TEXH)),
            C2,
            rot,
            TC,
            S,
            SpriteEffects.None, 0f
            );
            Way += Jump;
        }
    }
Esempio n. 60
0
        public override void Render(IList <SceneNode> nodes, RenderContext context, RenderOrder order)
        {
            ThrowIfDisposed();

            if (nodes == null)
            {
                throw new ArgumentNullException("nodes");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            int numberOfNodes = nodes.Count;

            if (nodes.Count == 0)
            {
                return;
            }

            context.Validate(_spriteBatch);
            context.ThrowIfCameraMissing();

            var graphicsDevice   = context.GraphicsService.GraphicsDevice;
            var savedRenderState = new RenderStateSnapshot(graphicsDevice);

            // Camera properties
            var    cameraNode     = context.CameraNode;
            Matrix viewProjection = cameraNode.Camera.Projection * cameraNode.View;
            var    viewport       = graphicsDevice.Viewport;

            // Update SceneNode.LastFrame for all visible nodes.
            int frame = context.Frame;

            cameraNode.LastFrame = frame;

            SpriteSortMode sortMode;

            switch (order)
            {
            case RenderOrder.Default:
                sortMode = SpriteSortMode.Texture;
                break;

            case RenderOrder.FrontToBack:
                sortMode = SpriteSortMode.FrontToBack;
                break;

            case RenderOrder.BackToFront:
                sortMode = SpriteSortMode.BackToFront;
                break;

            case RenderOrder.UserDefined:
            default:
                sortMode = SpriteSortMode.Deferred;
                break;
            }

            _spriteBatch.Begin(sortMode, graphicsDevice.BlendState, null, graphicsDevice.DepthStencilState, null);

            for (int i = 0; i < numberOfNodes; i++)
            {
                var node = nodes[i] as SpriteNode;
                if (node == null)
                {
                    continue;
                }

                // SpriteNode is visible in current frame.
                node.LastFrame = frame;

                // Position, size, and origin in pixels.
                Vector3 position = new Vector3();
                Vector2 size     = new Vector2();
                Vector2 origin   = new Vector2();

                var bitmapSprite = node.Sprite as ImageSprite;
                if (bitmapSprite != null)
                {
                    var packedTexture = bitmapSprite.Texture;
                    if (packedTexture != null)
                    {
                        // Project into viewport and snap to pixels.
                        position   = viewport.ProjectToViewport(node.PoseWorld.Position, viewProjection);
                        position.X = (int)(position.X + 0.5f);
                        position.Y = (int)(position.Y + 0.5f);

                        // Get source rectangle (pixel bounds).
                        var sourceRectangle = packedTexture.GetBounds(node.AnimationTime);
                        size = new Vector2(sourceRectangle.Width, sourceRectangle.Height);

                        // Premultiply color.
                        Vector3 color3F = node.Color;
                        float   alpha   = node.Alpha;
                        Color   color   = new Color(color3F.X * alpha, color3F.Y * alpha, color3F.Z * alpha, alpha);

                        // Get absolute origin (relative to pixel bounds).
                        origin = (Vector2)node.Origin * size;

                        // Draw using SpriteBatch.
                        _spriteBatch.Draw(
                            packedTexture.TextureAtlas, new Vector2(position.X, position.Y), sourceRectangle,
                            color, node.Rotation, origin, (Vector2)node.Scale, SpriteEffects.None, position.Z);
                    }
                }
                else
                {
                    var textSprite = node.Sprite as TextSprite;
                    if (textSprite != null)
                    {
                        var font = textSprite.Font ?? _spriteFont;
                        if (font != null)
                        {
                            // Text can be a string or StringBuilder.
                            var text = textSprite.Text as string;
                            if (text != null)
                            {
                                if (text.Length > 0)
                                {
                                    // Project into viewport and snap to pixels.
                                    position   = viewport.ProjectToViewport(node.PoseWorld.Position, viewProjection);
                                    position.X = (int)(position.X + 0.5f);
                                    position.Y = (int)(position.Y + 0.5f);

                                    // Premultiply color.
                                    Vector3 color3F = node.Color;
                                    float   alpha   = node.Alpha;
                                    Color   color   = new Color(color3F.X * alpha, color3F.Y * alpha, color3F.Z * alpha, alpha);

                                    // Get absolute origin (relative to pixel bounds).
                                    size   = font.MeasureString(text);
                                    origin = (Vector2)node.Origin * size;

                                    // Draw using SpriteBatch.
                                    _spriteBatch.DrawString(
                                        font, text, new Vector2(position.X, position.Y),
                                        color, node.Rotation, origin, (Vector2)node.Scale,
                                        SpriteEffects.None, position.Z);
                                }
                            }
                            else
                            {
                                var stringBuilder = textSprite.Text as StringBuilder;
                                if (stringBuilder != null && stringBuilder.Length > 0)
                                {
                                    // Project into viewport and snap to pixels.
                                    position   = viewport.ProjectToViewport(node.PoseWorld.Position, viewProjection);
                                    position.X = (int)(position.X + 0.5f);
                                    position.Y = (int)(position.Y + 0.5f);

                                    // Premultiply color.
                                    Vector3 color3F = node.Color;
                                    float   alpha   = node.Alpha;
                                    Color   color   = new Color(color3F.X * alpha, color3F.Y * alpha, color3F.Z * alpha, alpha);

                                    // Get absolute origin (relative to pixel bounds).
                                    size   = font.MeasureString(stringBuilder);
                                    origin = (Vector2)node.Origin * size;

                                    // Draw using SpriteBatch.
                                    _spriteBatch.DrawString(
                                        font, stringBuilder, new Vector2(position.X, position.Y),
                                        color, node.Rotation, origin, (Vector2)node.Scale,
                                        SpriteEffects.None, position.Z);
                                }
                            }
                        }
                    }
                }

                // Store bounds an depth for hit tests.
                node.LastBounds = new Rectangle(
                    (int)(position.X - origin.X),
                    (int)(position.Y - origin.Y),
                    (int)(size.X * node.Scale.X),
                    (int)(size.Y * node.Scale.Y));

                node.LastDepth = position.Z;
            }

            _spriteBatch.End();
            savedRenderState.Restore();
        }