Implementation Working

Used AnimationGenerator to port old animations into new system, tested and seems stable.
This commit is contained in:
quinnvoker
2018-11-17 14:55:38 -08:00
parent 65ed454707
commit fb85769677
12 changed files with 472 additions and 10 deletions
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B1938BD7-A474-427F-91F1-F8A1875B28CE}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>AnimationGenerator</RootNamespace>
<AssemblyName>AnimationGenerator</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MonoGame.Framework, Version=3.8.0.76, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="MonoGame.Framework.Content.Pipeline">
<HintPath>C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\MonoGame.Framework.Content.Pipeline.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AnimationLibrary\QURO.AnimationLibrary.csproj">
<Project>{69dadc27-fbeb-4625-9212-6eb5bed5102a}</Project>
<Name>QURO.AnimationLibrary</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Content\boardMap.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
+76
View File
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="System.Collections.Generic.Dictionary[System.String, Microsoft.Xna.Framework.Rectangle]">
<Item><Key>block0</Key><Value>0 0 16 16</Value></Item>
<Item><Key>block0_bounce1</Key><Value>16 0 16 16</Value></Item>
<Item><Key>block0_bounce2</Key><Value>32 0 16 16</Value></Item>
<Item><Key>block0_flash</Key><Value>48 0 16 16</Value></Item>
<Item><Key>block0_pop</Key><Value>64 0 16 16</Value></Item>
<Item><Key>block0_squish</Key><Value>80 0 16 16</Value></Item>
<Item><Key>block1</Key><Value>0 16 16 16</Value></Item>
<Item><Key>block1_bounce1</Key><Value>16 16 16 16</Value></Item>
<Item><Key>block1_bounce2</Key><Value>32 16 16 16</Value></Item>
<Item><Key>block1_flash</Key><Value>48 16 16 16</Value></Item>
<Item><Key>block1_pop</Key><Value>64 16 16 16</Value></Item>
<Item><Key>block1_squish</Key><Value>80 16 16 16</Value></Item>
<Item><Key>block2</Key><Value>0 32 16 16</Value></Item>
<Item><Key>block2_bounce1</Key><Value>16 32 16 16</Value></Item>
<Item><Key>block2_bounce2</Key><Value>32 32 16 16</Value></Item>
<Item><Key>block2_flash</Key><Value>48 32 16 16</Value></Item>
<Item><Key>block2_pop</Key><Value>64 32 16 16</Value></Item>
<Item><Key>block2_squish</Key><Value>80 32 16 16</Value></Item>
<Item><Key>block3</Key><Value>0 48 16 16</Value></Item>
<Item><Key>block3_bounce1</Key><Value>16 48 16 16</Value></Item>
<Item><Key>block3_bounce2</Key><Value>32 48 16 16</Value></Item>
<Item><Key>block3_flash</Key><Value>48 48 16 16</Value></Item>
<Item><Key>block3_pop</Key><Value>64 48 16 16</Value></Item>
<Item><Key>block3_squish</Key><Value>80 48 16 16</Value></Item>
<Item><Key>block4</Key><Value>0 64 16 16</Value></Item>
<Item><Key>block4_bounce1</Key><Value>16 64 16 16</Value></Item>
<Item><Key>block4_bounce2</Key><Value>32 64 16 16</Value></Item>
<Item><Key>block4_flash</Key><Value>48 64 16 16</Value></Item>
<Item><Key>block4_pop</Key><Value>64 64 16 16</Value></Item>
<Item><Key>block4_squish</Key><Value>80 64 16 16</Value></Item>
<Item><Key>soloCursor</Key><Value>16 80 23 23</Value></Item>
<Item><Key>soloCursor_pulse</Key><Value>39 80 23 23</Value></Item>
<Item><Key>tiledBG_default</Key><Value>0 80 16 16</Value></Item>
<Item><Key>twinCursor</Key><Value>0 103 39 23</Value></Item>
<Item><Key>twinCursor_pulse</Key><Value>39 103 39 23</Value></Item>
</Asset>
</XnaContent>
@@ -0,0 +1,50 @@
/*
* Class auto generated by TexturePacker
*
* Contains references to each image within the sprite sheet.
*
* https://www.codeandweb.com/texturepacker
* $TexturePacker:SmartUpdate:9c249f83b4f96ec61c8a09e8200742d5:d881ff5ec3da86acaaa577e6ab9bd7aa:05477a09d9d5a6dca0fdadde24fc3000$
*
*/
namespace TexturePackerSpriteDefinitions
{
public class SpriteNames
{
public const string Block0 = "block0";
public const string Block0_bounce1 = "block0_bounce1";
public const string Block0_bounce2 = "block0_bounce2";
public const string Block0_flash = "block0_flash";
public const string Block0_pop = "block0_pop";
public const string Block0_squish = "block0_squish";
public const string Block1 = "block1";
public const string Block1_bounce1 = "block1_bounce1";
public const string Block1_bounce2 = "block1_bounce2";
public const string Block1_flash = "block1_flash";
public const string Block1_pop = "block1_pop";
public const string Block1_squish = "block1_squish";
public const string Block2 = "block2";
public const string Block2_bounce1 = "block2_bounce1";
public const string Block2_bounce2 = "block2_bounce2";
public const string Block2_flash = "block2_flash";
public const string Block2_pop = "block2_pop";
public const string Block2_squish = "block2_squish";
public const string Block3 = "block3";
public const string Block3_bounce1 = "block3_bounce1";
public const string Block3_bounce2 = "block3_bounce2";
public const string Block3_flash = "block3_flash";
public const string Block3_pop = "block3_pop";
public const string Block3_squish = "block3_squish";
public const string Block4 = "block4";
public const string Block4_bounce1 = "block4_bounce1";
public const string Block4_bounce2 = "block4_bounce2";
public const string Block4_flash = "block4_flash";
public const string Block4_pop = "block4_pop";
public const string Block4_squish = "block4_squish";
public const string SoloCursor = "soloCursor";
public const string SoloCursor_pulse = "soloCursor_pulse";
public const string TiledBG_default = "tiledBG_default";
public const string TwinCursor = "twinCursor";
public const string TwinCursor_pulse = "twinCursor_pulse";
}
}
+160
View File
@@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using QURO.AnimationLibrary;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate;
namespace AnimationGenerator
{
class Program
{
public static Dictionary<string, Rectangle> loadedFrames;
public static AnimationSet output;
public static void Main(string[] args)
{
using(XmlReader xmlRead = XmlReader.Create("Content/boardMap.xml"))
{
loadedFrames = IntermediateSerializer.Deserialize<Dictionary<string, Rectangle>>(xmlRead, null);
}
output = new AnimationSet();
Frame[] soloCursor_pulse_frames = new Frame[]
{
new Frame(loadedFrames["soloCursor"], 20f / 60f),
new Frame(loadedFrames["soloCursor_pulse"], 20f / 60f),
};
output.Add(new Animation("soloCursor_pulse", soloCursor_pulse_frames, true));
Frame[] twinCursor_pulse_frames = new Frame[]
{
new Frame(loadedFrames["twinCursor"], 20f / 60f),
new Frame(loadedFrames["twinCursor_pulse"], 20f / 60f),
};
output.Add(new Animation("twinCursor_pulse", twinCursor_pulse_frames, true));
Frame[] block_default_frames = new Frame[]
{
new Frame(loadedFrames["block0"], 0),
};
output.Add(new Animation("block_default", block_default_frames, false));
Frame[] block_matched_frames = new Frame[]
{
new Frame(loadedFrames["block0"], 0),
new Frame(loadedFrames["block0_flash"], 0)
};
output.Add(new Animation("block_matched", block_matched_frames, true));
Frame[] block_pop_frames = new Frame[]
{
new Frame(loadedFrames["block0_pop"], 0),
};
output.Add(new Animation("block_pop", block_pop_frames, false));
Frame[] block_fall_frames = new Frame[]
{
new Frame(loadedFrames["block0"], 0),
new Frame(loadedFrames["block0_bounce1"], 0),
new Frame(loadedFrames["block0_bounce2"], 0),
};
output.Add(new Animation("block_fall", block_fall_frames, false));
Frame[] block_squished_frames = new Frame[]
{
new Frame(loadedFrames["block0_squish"], 0),
};
output.Add(new Animation("block_squished", block_squished_frames, false));
Frame[] block_bounce_frames = new Frame[]
{
new Frame(loadedFrames["block0_bounce2"], 1f / 60f),
new Frame(loadedFrames["block0"], 1f / 60f),
new Frame(loadedFrames["block0_squish"], 1f / 60f),
new Frame(loadedFrames["block0"], 1f / 60f),
new Frame(loadedFrames["block0_bounce1"], 2f / 60f),
new Frame(loadedFrames["block0"], 1f / 60f),
};
output.Add(new Animation("block_bounce", block_bounce_frames, false));
Frame[] tiledBG_default_frames = new Frame[]
{
new Frame(loadedFrames["tiledBG_default"], 0),
};
output.Add(new Animation("tiledBG_default", tiledBG_default_frames, false));
var xmlSettings = new XmlWriterSettings();
xmlSettings.Indent = true;
using(XmlWriter writer = XmlWriter.Create("output.xml"))
{
IntermediateSerializer.Serialize(writer, output, null);
}
}
/*
public Animation TwinCursor_pulse => new Animation("twinCursor_pulse", textureAtlas, twinCursor_pulse_frames, FrameTimerUtility.FramesToSeconds(20), true);
private readonly string[] twinCursor_pulse_frames = new string[]
{
SpriteNames.TwinCursor,
SpriteNames.TwinCursor_pulse
};
//red blocks
public Animation Block_default => new Animation("block_default", textureAtlas, block_default_frames, defaultDelay, false);
private readonly string[] block_default_frames = new string[]
{
SpriteNames.Block0
};
public Animation Block_matched => new Animation("block_matched", textureAtlas, block_matched_frames, defaultDelay, true);
private readonly string[] block_matched_frames = new string[]
{
SpriteNames.Block0,
SpriteNames.Block0_flash
};
public Animation Block_pop => new Animation("block_pop", textureAtlas, block_pop_frames, defaultDelay, true);
private readonly string[] block_pop_frames = new string[]
{
SpriteNames.Block0_pop
};
public Animation Block_fall => new Animation("block_fall", textureAtlas, block_fall_frames, defaultDelay, false);
private readonly string[] block_fall_frames = new string[]
{
SpriteNames.Block0,
SpriteNames.Block0_bounce1,
SpriteNames.Block0_bounce2,
};
public Animation Block_squished => new Animation("block_squished", textureAtlas, block_squished_frames, defaultDelay, false);
private readonly string[] block_squished_frames = new string[]
{
SpriteNames.Block0_squish
};
public Animation Block_bounce => new Animation("block_bounce", textureAtlas, block_bounce_frames, defaultDelay, false);
private readonly string[] block_bounce_frames = new string[]
{
SpriteNames.Block0_bounce2,
SpriteNames.Block0,
SpriteNames.Block0_squish,
SpriteNames.Block0,
SpriteNames.Block0_bounce1,
SpriteNames.Block0_bounce1,
SpriteNames.Block0
};
public Animation TiledBG_default => new Animation("tiledBG_default", textureAtlas, tiledBG_default_frames, defaultDelay, false);
private readonly string[] tiledBG_default_frames = new string[]
{
SpriteNames.TiledBG_default
};
*/
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AnimationGenerator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AnimationGenerator")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b1938bd7-a474-427f-91f1-f8a1875b28ce")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+6 -6
View File
@@ -17,7 +17,7 @@ namespace QURO.AnimationLibrary
}
}
public int CurrentFrameIndex { get; set; }
public Rectangle CurrentFrame => CurrentAnimation.Frames[CurrentFrameIndex];
public Frame CurrentFrame => CurrentAnimation.Frames[CurrentFrameIndex];
private float timer;
@@ -27,13 +27,13 @@ namespace QURO.AnimationLibrary
{
SpriteSheet = spriteSheet;
CurrentAnimation = startingAnimation;
timer = CurrentAnimation.Delay;
timer = CurrentFrame.Delay;
}
public void Reset()
{
CurrentFrameIndex = 0;
timer = CurrentAnimation.Delay;
timer = CurrentFrame.Delay;
}
public void Update(GameTime gameTime)
@@ -53,7 +53,7 @@ namespace QURO.AnimationLibrary
CurrentFrameIndex = 0;
}
}
timer = CurrentAnimation.Delay;
timer = CurrentFrame.Delay;
}
else
{
@@ -64,12 +64,12 @@ namespace QURO.AnimationLibrary
public void Draw(SpriteBatch spriteBatch, Vector2 position, Color tint)
{
spriteBatch.Draw(SpriteSheet, position, CurrentFrame, tint);
spriteBatch.Draw(SpriteSheet, position, CurrentFrame.SourceRect, tint);
}
public void Draw(SpriteBatch spriteBatch, Vector2 position, Vector2 spriteOffset, Color tint)
{
Rectangle sourceRect = CurrentFrame;
Rectangle sourceRect = CurrentFrame.SourceRect;
sourceRect.Offset(spriteOffset);
spriteBatch.Draw(SpriteSheet, position, sourceRect, tint);
+21 -2
View File
@@ -6,12 +6,31 @@ namespace QURO.AnimationLibrary
{
public string Name { get; set; }
public bool IsLooping { get; set; }
public float Delay { get; set; }
public Rectangle[] Frames { get; set; }
public Frame[] Frames { get; set; }
public bool IsStillImage => Frames.Length <= 1;
public Animation() { }
public Animation(string name, Frame[] frames, bool loop)
{
Name = name;
Frames = frames;
IsLooping = loop;
}
public Animation(string name, Rectangle[] sourceRects, float delay, bool loop)
{
Name = name;
Frames = new Frame[sourceRects.Length];
for(int index = 0; index < sourceRects.Length; index++)
{
Frames[index] = new Frame(sourceRects[index], delay);
}
IsLooping = loop;
}
}
}
+20
View File
@@ -5,5 +5,25 @@ namespace QURO.AnimationLibrary
public class AnimationSet
{
public Dictionary<string, Animation> Anims;
public AnimationSet()
{
Anims = new Dictionary<string, Animation>();
}
public void Add(Animation anim)
{
Anims.Add(anim.Name, anim);
}
public void Remove(Animation anim)
{
Anims.Remove(anim.Name);
}
public void Remove(string animName)
{
Anims.Remove(animName);
}
}
}
+18
View File
@@ -0,0 +1,18 @@
using Microsoft.Xna.Framework;
namespace QURO.AnimationLibrary
{
public class Frame
{
public Rectangle SourceRect { get; set; }
public float Delay { get; set; }
public Frame() { }
public Frame(Rectangle sourceRectangle, float delay)
{
SourceRect = sourceRectangle;
Delay = delay;
}
}
}
@@ -7,8 +7,8 @@
<ProjectGuid>{69DADC27-FBEB-4625-9212-6EB5BED5102A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AnimationLibrary</RootNamespace>
<AssemblyName>AnimationLibrary</AssemblyName>
<RootNamespace>QURO.AnimationLibrary</RootNamespace>
<AssemblyName>QURO.AnimationLibrary</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
@@ -48,6 +48,7 @@
<Compile Include="AnimatedSprite.cs" />
<Compile Include="Animation.cs" />
<Compile Include="AnimationSet.cs" />
<Compile Include="Frame.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+6
View File
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuzzSwap", "PuzzSwap\PuzzSw
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QURO.AnimationLibrary", "AnimationLibrary\QURO.AnimationLibrary.csproj", "{69DADC27-FBEB-4625-9212-6EB5BED5102A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimationGenerator", "AnimationGenerator\AnimationGenerator.csproj", "{B1938BD7-A474-427F-91F1-F8A1875B28CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
{69DADC27-FBEB-4625-9212-6EB5BED5102A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69DADC27-FBEB-4625-9212-6EB5BED5102A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69DADC27-FBEB-4625-9212-6EB5BED5102A}.Release|Any CPU.Build.0 = Release|Any CPU
{B1938BD7-A474-427F-91F1-F8A1875B28CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1938BD7-A474-427F-91F1-F8A1875B28CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1938BD7-A474-427F-91F1-F8A1875B28CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1938BD7-A474-427F-91F1-F8A1875B28CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE