public override void Draw(JuixelTime Time, SpriteBatch SpriteBatch, Location Position, Angle Rotation, Location Scale, float Alpha) { Location Location = Scene.FromScene(new Location(Input.MouseX, Input.MouseY), this).Floor() + new Location(Bounds.X, Bounds.Y); Position = new Location(Position.X + Location.X * Scale.X, Position.Y + Location.Y * Scale.Y); Scale *= this.Scale; if (Scale.X < Render_Tiles_Zoom) { SpriteBatch.Draw(Texture, Position.ToVector2(), null, Color * this.Alpha, 0, Vector2.Zero, Scale.ToVector2(), SpriteEffects.None, 0); } else { for (int y = 0; y < Bounds.Height; y++) { for (int x = 0; x < Bounds.Width; x++) { var NTile = Tiles[x, y]; if (NTile != null) { var Tile = NTile.Value; SpriteBatch.Draw(Tile.Sprite.Texture, new Location(Position.X + x * Scale.X, Position.Y + y * Scale.Y).ToVector2(), Tile.Sprite.Source, Color * this.Alpha, 0, Vector2.Zero, (Scale / 8).ToVector2(), SpriteEffects.None, 0); } } } } }
public override void Update(JuixelTime Time) { if (Animation != null) { Animation.Update(Time, FrameRate, out Sprite.Reversed, out Sprite.AnchorPoint); } }
public void Draw(Texture2D Texture, JuixelTime Time, SpriteBatch SpriteBatch, Location Position, Location Scale, float Alpha) { Location DrawPosition = Position; SpriteBatch.Draw(Texture, DrawPosition.ToVector2(), Source, Color.White * Alpha, 0, Vector2.Zero, Scale.ToVector2(), SpriteEffects.None, 0); }
public override void Draw(JuixelTime Time, SpriteBatch SpriteBatch, Location Position, Angle Rotation, Location Scale, float Alpha) { if (Scale.X < Render_Tiles_Zoom) { Position = new Location(Position.X + Location.X * Scale.X, Position.Y + Location.Y * Scale.Y); Scale *= this.Scale; SpriteBatch.Draw(Texture, Position.ToVector2(), null, Color, 0, Vector2.Zero, Scale.ToVector2(), SpriteEffects.None, 0); } else { Position = new Location(Position.X + Location.X * Scale.X, Position.Y + Location.Y * Scale.Y); Scale *= this.Scale; for (int y = 0; y < TileCount; y++) { for (int x = 0; x < TileCount; x++) { var NTile = Tiles[x, y]; if (NTile != null) { var Tile = NTile.Value; SpriteBatch.Draw(Tile.Sprite.Texture, new Location(Position.X + x * Scale.X, Position.Y + y * Scale.Y).ToVector2(), Tile.Sprite.Source, Color, 0, Vector2.Zero, (Scale / 8).ToVector2(), SpriteEffects.None, 0); } } } } }
public override Location Update(JuixelTime Time, Location CurrentLocal, out bool Stop) { Alpha -= (float)Time.ElapsedSec; Height -= Time.ElapsedSec * 10; Stop = Alpha <= 0; Layer = Position.Y; return(0); }
public override void Update(JuixelTime Time) { base.Update(Time); Zoom.Text = $"Block {Map.BlockIndex(Map.BlockX, Map.BlockY)}: x{Map.Scale.X}"; Action.Text = Map.CurrentAction.ToString() + " " + Map.Details; DrawToolPreview.Sprite.Source = GetDrawPreviewRect(); }
public override void Draw(JuixelTime Time, SpriteBatch SpriteBatch, Location Position, Angle Rotation, Location Scale, float Alpha) { Location DrawPosition = Position + this.Position * Scale - new Location(0, Height * Scale.Y); Scale *= this.Scale; SpriteBatch.Draw(Sprite.Texture, DrawPosition.Round().ToVector2(), Sprite.Source, Color * (Alpha * this.Alpha), (float)(Rotation.Radians + this.Rotation.Radians), new Vector2(Sprite.Source.Width * Origin.X, Sprite.Source.Height * Origin.Y), Scale.ToVector2(), Reversed ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); base.Draw(Time, SpriteBatch, Position, Rotation, Scale, Alpha); }
public override void Draw(JuixelTime Time, SpriteBatch SpriteBatch, Location Position, Angle Rotation, Location Scale, float Alpha) { SortChildren(); Scale *= this.Scale; if (!_UseParentCoordinates) { for (int i = 0; i < Children.Count; i++) { Children[i].Draw(Time, SpriteBatch, Position + this.Position * Scale, Rotation + this.Rotation, Scale, Alpha * this.Alpha); } } }
public override void Draw(JuixelTime Time, SpriteBatch SpriteBatch, Location Position, Angle Rotation, Location Scale, float Alpha) { if (!Hidden) { CheckSamplerState(SpriteBatch); Location BaseLocation = Position + this.Position; Location BaseScale = Scale * this.Scale; float BaseAlpha = Alpha * this.Alpha; for (int Y = Focus.Y - ViewRadius.Y; Y < Focus.Y + ViewRadius.Y; Y++) { for (int X = Focus.X - ViewRadius.X; X < Focus.X + ViewRadius.X; X++) { if (X >= 0 && Y >= 0 && X < Width && Y < Height) { Tile Tile = Tiles[X, Y]; if (Tile != null) { Tile.Draw(Texture, Time, SpriteBatch, BaseLocation + new Location(X * TileSize * BaseScale.X, Y * TileSize * BaseScale.Y), BaseScale, BaseAlpha); } } } } // Draw blend SpriteBatch.End(); SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, effect: Effects.TileBlendEffect); for (int Y = Focus.Y - ViewRadius.Y; Y < Focus.Y + ViewRadius.Y; Y++) { for (int X = Focus.X - ViewRadius.X; X < Focus.X + ViewRadius.X; X++) { if (X >= 0 && Y >= 0 && X < Width && Y < Height) { Tile Tile = Tiles[X, Y]; if (Tile != null) { Tile.DrawBlend(Texture, Time, SpriteBatch, BaseLocation + new Location(X * TileSize * BaseScale.X, Y * TileSize * BaseScale.Y), BaseScale, BaseAlpha); } } } } SpriteBatch.End(); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp); } }
public override void Update(JuixelTime Time) { if (Moving) { Moving = false; WasMoving = true; } else if (WasMoving) { WasMoving = false; UpdateDirection(); } base.Update(Time); }
public void DrawBlend(Texture2D Texture, JuixelTime Time, SpriteBatch SpriteBatch, Location Position, Location Scale, float Alpha) { Vector2 BasePosition = new Vector2(MaskIndex % 5 * 24, MaskIndex / 5 * 24); for (int i = 0; i < Blend.Length; i++) { if (Blend[i]) { IntLocation Offset = TileManager.TileDirectionToPoint((TileDirection)i); Effects.TileBlendEffect.Parameters["MaskBasePosition"].SetValue(new Vector2((BasePosition.X + Offset.X * 8) / Masks.TileBlendMask.Width, (BasePosition.Y + Offset.Y * 8) / Masks.TileBlendMask.Height)); Effects.TileBlendEffect.Parameters["TileBasePosition"].SetValue(new Vector2((float)Source.X / Texture.Width, (float)Source.Y / Texture.Height)); Location DrawPosition = Position + new Location((Offset.X - 1) * Source.Width, (Offset.Y - 1) * Source.Height) * Scale; SpriteBatch.Draw(Texture, DrawPosition.ToVector2(), Source, Color.White * Alpha, 0, Vector2.Zero, Scale.ToVector2(), SpriteEffects.None, 0); } } }
public void Update(JuixelTime Time, double FrameRate, out bool Reverse, out Location AnchorPoint) { CurrentTime += Time.ElapsedSec; if (CurrentTime > FrameRate) { CurrentTime = 0; CurrentIndex++; if (CurrentIndex >= _Sources.Length) { CurrentIndex = 0; } } Frame CurrentFrame = _Sources[CurrentIndex]; Source = CurrentFrame.Source; Source.Offset(Offset.X, Offset.Y); AnchorPoint = CurrentFrame.AnchorPoint; Reverse = CurrentFrame.Reverse; }
public override void Update(JuixelTime Time) { base.Update(Time); for (int i = 0; i < Children.Count; i++) { Particle Particle = (Particle)Children[i]; bool Remove = false; if (_UseParentCoordinates) { Particle.Position += Particle.Update(Time, Particle.Position - Position, out Remove); } else { Particle.Position += Particle.Update(Time, Particle.Position, out Remove); } if (Remove) { RemoveParticle(Particle); i--; } } }
public void UpdateAnimations(JuixelTime Time) { HelmAnimation.Update(Time, FrameRate, out HelmSprite.Reversed, out HelmSprite.AnchorPoint); WeaponAnimation.Update(Time, FrameRate, out WeaponSprite.Reversed, out WeaponSprite.AnchorPoint); }
public override void Update(JuixelTime Time) { Location MoveVector = 0; if (Input.KeyIsDown(Keys.W)) { MoveVector += new Location(0, -1); } if (Input.KeyIsDown(Keys.S)) { MoveVector += new Location(0, 1); } if (Input.KeyIsDown(Keys.A)) { MoveVector += new Location(-1, 0); } if (Input.KeyIsDown(Keys.D)) { MoveVector += new Location(1, 0); } if (MoveVector.X != 0 || MoveVector.Y != 0) { Player.Position += MoveVector.Angle.Location * Pixels_Per_Second * Time.ElapsedSec; Tiles.Focus = (Player.Position / 40).Int; } base.Update(Time); if (Input.KeyIsDown(Keys.Y)) { var Player = new Player(); Player.Scale = 10; Player.Position = Location.Random * 1000; Player.Layer = Player.Position.Y; AddChild(Player); Players.Add(Player); Player = new Player(); Player.Scale = 10; Player.Position = Location.Random * 1000; Player.Layer = Player.Position.Y; AddChild(Player); Players.Add(Player); } if (Input.KeyIsDown(Keys.OemPlus)) { for (int i = 0; i < Players.Count; i++) { Players[i].Health += 0.01; } } if (Input.KeyIsDown(Keys.OemMinus)) { for (int i = 0; i < Players.Count; i++) { Players[i].Health -= 0.01; } } IntLocation TilePosition = (Player.Position / Tiles.Scale / 8).IntFloor; Tile CurrentTile = Tiles.Get(TilePosition.X, TilePosition.Y); int TileCount = 0; int WeatherCount = 0; if (CurrentTile != LastTile) { for (int Y = -Weather_Detect_Radius; Y <= Weather_Detect_Radius; Y++) { for (int X = -Weather_Detect_Radius; X <= Weather_Detect_Radius; X++) { Tile Tile = Tiles.Get(TilePosition.X + X, TilePosition.Y + Y); if (Tile != null) { WeatherCount += Tile.WeatherIntensity; TileCount++; } } } LastTile = CurrentTile; TargetIntensity = (WeatherCount / (double)TileCount) * 4; } if (Snow.Intensity != TargetIntensity) { double Difference = TargetIntensity - Snow.Intensity; double Change = Weather_Change_Per_Second * Time.ElapsedSec; if (Math.Abs(Difference) < Change) { Snow.Intensity = TargetIntensity; } else { Snow.Intensity += Change * (Difference / Math.Abs(Difference)); } } JuixelGame.ShowDebugText(NodeCount.ToString(), 2); if (Client != null) { Info.Text = Client.Latency.ToString(); } }
public virtual Location Update(JuixelTime Time, Location CurrentLocal, out bool Stop) { Stop = true; return(0); }