Compare commits
No commits in common. "b15a55afd1b1741a0c723385ea7ae88d05d47ebd" and "7ed2f3ebb66bdb81c58e1ec18afc2efffaa15a01" have entirely different histories.
b15a55afd1
...
7ed2f3ebb6
@ -27,7 +27,6 @@
|
|||||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
|
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
|
||||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
|
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="System.Text.Json" Version="5.0.2" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="..\Shared\Shared.projitems" Label="Shared" />
|
<Import Project="..\Shared\Shared.projitems" Label="Shared" />
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace SemiColinGames {
|
namespace SemiColinGames {
|
||||||
public static class Sprites {
|
public static class Sprites {
|
||||||
@ -61,32 +61,29 @@ namespace SemiColinGames {
|
|||||||
Texture = texture;
|
Texture = texture;
|
||||||
animations = new Dictionary<string, SpriteAnimation>();
|
animations = new Dictionary<string, SpriteAnimation>();
|
||||||
|
|
||||||
JsonElement jsonRoot = JsonDocument.Parse(metadataJson).RootElement;
|
JObject json = JObject.Parse(metadataJson);
|
||||||
|
|
||||||
frames = new List<Frame>();
|
frames = new List<Frame>();
|
||||||
foreach (JsonElement child in jsonRoot.GetProperty("frames").EnumerateArray()) {
|
foreach (JToken child in json.SelectToken("frames").Children()) {
|
||||||
JsonElement frame = child.GetProperty("frame");
|
|
||||||
Rectangle source = new Rectangle(
|
Rectangle source = new Rectangle(
|
||||||
frame.GetProperty("x").GetInt32(),
|
child.SelectToken("frame.x").Value<int>(),
|
||||||
frame.GetProperty("y").GetInt32(),
|
child.SelectToken("frame.y").Value<int>(),
|
||||||
frame.GetProperty("w").GetInt32(),
|
child.SelectToken("frame.w").Value<int>(),
|
||||||
frame.GetProperty("h").GetInt32());
|
child.SelectToken("frame.h").Value<int>());
|
||||||
|
double duration = child.SelectToken("duration").Value<double>() / 1000;
|
||||||
double duration = child.GetProperty("duration").GetDouble() / 1000;
|
|
||||||
frames.Add(new Frame(source, duration));
|
frames.Add(new Frame(source, duration));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We assume that all frames are the same size (which right now is assured by the
|
// We assume that all frames are the same size (which right now is assured by the
|
||||||
// Aseprite-based spritesheet export process).
|
// Aseprite-based spritesheet export process).
|
||||||
Width = frames[0].Source.Width;
|
Width = frames[0].Source.Width;
|
||||||
Height = frames[0].Source.Height;
|
Height = frames[0].Source.Height;
|
||||||
|
|
||||||
JsonElement frameTags = jsonRoot.GetProperty("meta").GetProperty("frameTags");
|
JToken frameTags = json.SelectToken("meta.frameTags");
|
||||||
foreach (JsonElement child in frameTags.EnumerateArray()) {
|
foreach (JToken child in frameTags.Children()) {
|
||||||
string name = child.GetProperty("name").GetString();
|
string name = child.SelectToken("name").Value<string>();
|
||||||
int start = child.GetProperty("from").GetInt32();
|
int start = child.SelectToken("from").Value<int>();
|
||||||
int end = child.GetProperty("to").GetInt32();
|
int end = child.SelectToken("to").Value<int>();
|
||||||
string directionString = child.GetProperty("direction").GetString();
|
string directionString = child.SelectToken("direction").Value<string>();
|
||||||
AnimationDirection direction = directionString == "pingpong" ?
|
AnimationDirection direction = directionString == "pingpong" ?
|
||||||
AnimationDirection.PingPong : AnimationDirection.Forward;
|
AnimationDirection.PingPong : AnimationDirection.Forward;
|
||||||
double duration = 0;
|
double duration = 0;
|
||||||
|
@ -179,19 +179,18 @@
|
|||||||
<PackageReference Include="SharpDX.XAudio2">
|
<PackageReference Include="SharpDX.XAudio2">
|
||||||
<Version>4.2.0</Version>
|
<Version>4.2.0</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="System.Text.Json">
|
|
||||||
<Version>5.0.2</Version>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="..\Shared\Shared.projitems" Label="Shared" />
|
<Import Project="..\Shared\Shared.projitems" Label="Shared" />
|
||||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MonoGame.Framework.WindowsUniversal" Version="3.8.0.*" />
|
<PackageReference Include="MonoGame.Framework.WindowsUniversal" Version="3.8.0.*" />
|
||||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.*" />
|
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
Loading…
Reference in New Issue
Block a user