public Chunk(int Size, IntLocation Location) { this.Location = Location; Texture = new Texture2D(JuixelGame.Shared.GraphicsDevice, Size, Size); TextureData = new Color[Size * Size]; TileCount = Size; Tiles = new Tile?[TileCount, TileCount]; RTicks = new int[TileCount, TileCount]; Texture.SetData(TextureData); }
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); } } }
private void SetAnimationOffset(AnimationGroup Group, int Index, bool HasBow) { IntLocation Norm = new IntLocation(Index % 16 * 64, Index / 16 * 24); IntLocation Bow = new IntLocation(Index % 16 * 64 + 24, Index / 16 * 24); foreach (var Ani in Group.AllAnimations()) { if ((int)Ani.Key >= 8) { if (HasBow) { Ani.Value.Offset = Bow; } else { Ani.Value.Offset = Norm; } } else { Ani.Value.Offset = Norm; } } }
public static TileDirection PointToTileDirection(IntLocation Point) => (TileDirection)(Point.Y * 3 + Point.X);
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(); } }