animations added
This commit is contained in:
parent
71453c619c
commit
8dcfe82d2c
11 changed files with 122 additions and 32 deletions
|
@ -73,6 +73,8 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
|
|||
openFileButton.LeftButtonPressed += () =>
|
||||
{
|
||||
DialogResult result = Dialog.FileOpen();
|
||||
if (result.Path is null) return;
|
||||
|
||||
var temp = result.Path.Split('\\');
|
||||
string textureName = temp[temp.Length - 2] + "/" + temp[temp.Length - 1];
|
||||
textureName = textureName.Split('.')[0];
|
||||
|
@ -164,7 +166,9 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
|
|||
#region LowerPanel
|
||||
|
||||
|
||||
InputIdName = CreateInputAndTextPair(GetRelativeRectangle_SettingSizes(0.0f, 0.3f, 0.5f, 0.1f), 0.2f, "ID:", "run");
|
||||
InputIsCycle = CreateInputAndCheckBoxPair(GetRelativeRectangle_SettingSizes(0.0f, 0.3f, 0.3f, 0.1f), 0.2f, "Зациклено?:", "");
|
||||
TicksPerFrame = CreateInputAndTextPair(GetRelativeRectangle_SettingSizes(0.0f, 0.3f, 0.4f, 0.1f), 0.2f, "Тиков на кадр:", "5");
|
||||
InputIdName = CreateInputAndTextPair(GetRelativeRectangle_SettingSizes(0.0f, 0.3f, 0.5f, 0.1f), 0.8f, "ID:", "run");
|
||||
InputWidth = CreateInputAndTextPair(GetRelativeRectangle_SettingSizes(0.0f, 0.3f, 0.6f, 0.1f), 0.2f, "Колонн:", "1");
|
||||
InputHeight = CreateInputAndTextPair(GetRelativeRectangle_SettingSizes(0.0f, 0.3f, 0.7f, 0.1f), 0.2f, "Рядов:", "1");
|
||||
InputFramesCount = CreateInputAndTextPair(GetRelativeRectangle_SettingSizes(0.0f, 0.3f, 0.8f, 0.1f), 0.2f, "Кадров:", "1");
|
||||
|
@ -177,6 +181,7 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
|
|||
TextBox InputFramesCount;
|
||||
TextBox animationRow;
|
||||
TextBox InputIdName;
|
||||
TextBox TicksPerFrame;
|
||||
CheckBox InputIsCycle;
|
||||
|
||||
/// <summary>
|
||||
|
@ -218,6 +223,38 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
|
|||
return tb;
|
||||
}
|
||||
|
||||
public CheckBox CreateInputAndCheckBoxPair(Rectangle area, float ratio, string textString, string textBoxString)
|
||||
{
|
||||
int arWidth = area.Width;
|
||||
area.Width = arWidth - (int)(arWidth * ratio) + (int)(arWidth * (ratio / 2));
|
||||
Label lb = new Label(Manager)
|
||||
{
|
||||
rectangle = area,
|
||||
text = textString,
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
mainColor = Color.Black,
|
||||
fontName = "Fonts\\Font4",
|
||||
textureName = "GUI/Button",
|
||||
textAligment = MonogameLibrary.UI.Enums.TextAligment.Left
|
||||
};
|
||||
area.X += (int)(arWidth * (1 - ratio));
|
||||
area.Width = arWidth - (int)(arWidth * (1 - ratio));
|
||||
CheckBox tb = new CheckBox(Manager)
|
||||
{
|
||||
rectangle = area,
|
||||
text = textBoxString,
|
||||
scale = 0.4f,
|
||||
fontColor = Color.Black,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font4",
|
||||
textureName = "GUI/Button",
|
||||
textAligment = MonogameLibrary.UI.Enums.TextAligment.Center
|
||||
};
|
||||
return tb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Texture2D BlackTexture;
|
||||
Texture2D LoadedSample;
|
||||
|
@ -333,6 +370,8 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
|
|||
AppLogic.SetRow(int.Parse(animationRow.text));
|
||||
AppLogic.SetFrmesCount(int.Parse(InputFramesCount.text));
|
||||
AppLogic.SetAnimationId(InputIdName.text);
|
||||
AppLogic.SetIsCycle(InputIsCycle.GetChecked);
|
||||
AppLogic.SetTicksPerAllFrames(int.Parse(TicksPerFrame.text));
|
||||
|
||||
if (AppLogic.animationRectangle.Width / (float)AppLogic.animationRectangle.Height > ExampleAnimation.Width / (float)ExampleAnimation.Height)
|
||||
{
|
||||
|
@ -415,20 +454,25 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
|
|||
|
||||
}
|
||||
|
||||
public static int framesPassed = 0;
|
||||
public static int ticksPassed = 0;
|
||||
public static void Update()
|
||||
{
|
||||
if (!buildDone) return;
|
||||
framesPassed++;
|
||||
if (framesPassed > 5)
|
||||
ticksPassed++;
|
||||
if (ticksPassed > 3)
|
||||
{
|
||||
framesPassed = 0;
|
||||
ticksPassed = 0;
|
||||
SetNextFrame();
|
||||
}
|
||||
}
|
||||
static int curframe = 0;
|
||||
static int curtick = 0;
|
||||
private static void SetNextFrame()
|
||||
{
|
||||
curtick++;
|
||||
if (curtick < frameTimes.First().Item2) return;
|
||||
curtick = 0;
|
||||
|
||||
curframe++;
|
||||
if (curframe >= frameCount)
|
||||
{
|
||||
|
@ -454,6 +498,10 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
|
|||
public static string id;
|
||||
|
||||
public static List<Tuple<int, int>> frameTimes = new List<Tuple<int, int>>() { new Tuple<int, int>(0, 5) };
|
||||
|
||||
|
||||
public static void SetTicksPerAllFrames(int ticks) => frameTimes = new List<Tuple<int, int>>() { new Tuple<int, int>(0, ticks) };
|
||||
|
||||
public static void SaveCurrentAnimation(string saveString)
|
||||
{
|
||||
DialogResult result = Dialog.FolderPicker();
|
||||
|
@ -461,17 +509,18 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
|
|||
{
|
||||
return;
|
||||
}
|
||||
var temp = result.Path.Split("Animations")[1].Remove(0,2);
|
||||
var temp = result.Path.Split("Animations")[1].Remove(0, 1);
|
||||
//string textureName = temp[temp.Length - 2] + "/" + temp[temp.Length - 1];
|
||||
//textureName = textureName.Split('.')[0];
|
||||
//choose save folder (it will save for further animations)
|
||||
|
||||
|
||||
id = id.ToLower();
|
||||
AnimationContainer container = new AnimationContainer();
|
||||
|
||||
|
||||
if (!File.Exists("../../../../ZoFo/Content/Textures/AnimationTextures/" + textureEndName + ".png"))
|
||||
File.Copy(textureFilePath, "../../../../ZoFo/Content/Textures/AnimationTextures/" + textureEndName + ".png");
|
||||
if (!Directory.Exists("../../../../ZoFo/Content/Textures/AnimationTextures/" + temp))
|
||||
Directory.CreateDirectory("../../../../ZoFo/Content/Textures/AnimationTextures/" + temp);
|
||||
if (!File.Exists("../../../../ZoFo/Content/Textures/AnimationTextures/" + temp + "/" + textureEndName + ".png"))
|
||||
File.Copy(textureFilePath, "../../../../ZoFo/Content/Textures/AnimationTextures/" + temp + "/" + textureEndName + ".png");
|
||||
|
||||
container.Offset = new Vector2(0, animationRectangle.Y);
|
||||
container.FramesCount = frameCount;
|
||||
|
@ -481,7 +530,7 @@ namespace AnimatorFileCreatorAdvanced.Core.GUI
|
|||
container.TextureFrameInterval = 0;
|
||||
container.IsCycle = isCycle;
|
||||
container.Id = id;
|
||||
container.TextureName = "Textures/AnimationTextures/" + textureEndName;
|
||||
container.TextureName = "Textures/AnimationTextures/" + temp + "/" + textureEndName;
|
||||
string json = JsonConvert.SerializeObject(container);
|
||||
|
||||
StreamWriter writer = new StreamWriter(result.Path + "/" + id + ".animation");//"../../../../ZoFo/Content/Textures/Animations/" + id + ".animation");
|
||||
|
|
|
@ -251,6 +251,12 @@
|
|||
#begin Textures/Animations/player_top_mining.animation
|
||||
/copy:Textures/Animations/player_top_mining.animation
|
||||
|
||||
#begin Textures/Animations/Player/player_idle.animation
|
||||
/copy:Textures/Animations/Player/player_idle.animation
|
||||
|
||||
#begin Textures/Animations/Player/player_running.animation
|
||||
/copy:Textures/Animations/Player/player_running.animation
|
||||
|
||||
#begin Textures/Animations/running_top.animation
|
||||
/copy:Textures/Animations/running_top.animation
|
||||
|
||||
|
@ -368,6 +374,42 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Character/hr-level1_running.png
|
||||
|
||||
#begin Textures/AnimationTextures/Player/Idle.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Player/Idle.png
|
||||
|
||||
#begin Textures/AnimationTextures/Player/Recharge.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Player/Recharge.png
|
||||
|
||||
#begin Textures/AnimationTextures/Player/Run.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Player/Run.png
|
||||
|
||||
#begin Textures/AnimationTextures/unicorn.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
|
BIN
ZoFo/Content/Textures/AnimationTextures/Player/Idle.png
Normal file
BIN
ZoFo/Content/Textures/AnimationTextures/Player/Idle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
BIN
ZoFo/Content/Textures/AnimationTextures/Player/Recharge.png
Normal file
BIN
ZoFo/Content/Textures/AnimationTextures/Player/Recharge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
ZoFo/Content/Textures/AnimationTextures/Player/Run.png
Normal file
BIN
ZoFo/Content/Textures/AnimationTextures/Player/Run.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
|
@ -0,0 +1 @@
|
|||
{"id":"player_idle","textureName":"Textures/AnimationTextures/Player/Idle","startSpriteRectangle":{"X":0,"Y":0,"Width":128,"Height":128},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":7,"isCycle":true,"offset":"0, 0"}
|
|
@ -0,0 +1 @@
|
|||
{"id":"player_running","textureName":"Textures/AnimationTextures/Player/Run","startSpriteRectangle":{"X":0,"Y":0,"Width":128,"Height":128},"frameSecond":[{"Item1":0,"Item2":1}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"}
|
|
@ -14,7 +14,7 @@ public class AssetManager
|
|||
{
|
||||
Animations = [ "player_look_down", "player_run_up", "player_run_down", "player_run_right",
|
||||
"player_run_left", "player_run_right_up", "player_run_left_up", "player_run_right_down",
|
||||
"player_run_left_down" ],
|
||||
IdleAnimation = "player_look_down"
|
||||
"player_run_left_down","player_running","player_idle" ],
|
||||
IdleAnimation = "player_idle"
|
||||
};
|
||||
}
|
|
@ -48,11 +48,11 @@ public class Player : LivingEntity
|
|||
{
|
||||
lootData = new LootData();
|
||||
lootData.loots = new Dictionary<string, int>();
|
||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
|
||||
collisionComponent.stopRectangle = new Rectangle(10, 15, 10, 15);
|
||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 60, 60);
|
||||
collisionComponent.stopRectangle = new Rectangle(25, 45, 10, 15);
|
||||
speed = 7;
|
||||
|
||||
StartAnimation("player_look_down");
|
||||
StartAnimation("player_idle");
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,24 +80,18 @@ public class Player : LivingEntity
|
|||
if (idName != "player_run_down")
|
||||
StartAnimation("player_run_down");
|
||||
break;
|
||||
case ScopeState.Right:
|
||||
case ScopeState.Left:
|
||||
if (idName != "player_run_right")
|
||||
StartAnimation("player_run_right");
|
||||
break;
|
||||
case ScopeState.TopRight:
|
||||
case ScopeState.TopLeft:
|
||||
if (idName != "player_run_right_up")
|
||||
StartAnimation("player_run_right_up");
|
||||
break;
|
||||
case ScopeState.DownRight:
|
||||
case ScopeState.DownLeft:
|
||||
if (idName != "player_run_right_down")
|
||||
StartAnimation("player_run_right_down");
|
||||
case ScopeState.TopRight:
|
||||
case ScopeState.TopLeft:
|
||||
case ScopeState.Right:
|
||||
case ScopeState.Left:
|
||||
if (idName != "player_running")
|
||||
StartAnimation("player_running");
|
||||
break;
|
||||
case ScopeState.Idle:
|
||||
if (idName != "player_look_down")
|
||||
StartAnimation("player_look_down");
|
||||
if (idName != "player_idle")
|
||||
StartAnimation("player_idle");
|
||||
break;
|
||||
}
|
||||
if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) != ScopeState.Idle)
|
||||
|
|
|
@ -19,7 +19,8 @@ namespace ZoFo.GameCore.Graphics
|
|||
{
|
||||
try
|
||||
{
|
||||
if (!fileName.EndsWith(".animation")) continue;
|
||||
if (!fileName.EndsWith(".animation"))
|
||||
continue;
|
||||
reader = new StreamReader(fileName);
|
||||
string json = reader.ReadToEnd();
|
||||
AnimationContainer animation = JsonConvert.DeserializeObject<AnimationContainer>(json);
|
||||
|
|
|
@ -12,10 +12,13 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Content\sounds\Zombie\**" />
|
||||
<Compile Remove="Content\Textures\Animations\PlayerAFK\**" />
|
||||
<Compile Remove="GameCore\GameObjects\BaseClasses\**" />
|
||||
<EmbeddedResource Remove="Content\sounds\Zombie\**" />
|
||||
<EmbeddedResource Remove="Content\Textures\Animations\PlayerAFK\**" />
|
||||
<EmbeddedResource Remove="GameCore\GameObjects\BaseClasses\**" />
|
||||
<None Remove="Content\sounds\Zombie\**" />
|
||||
<None Remove="Content\Textures\Animations\PlayerAFK\**" />
|
||||
<None Remove="GameCore\GameObjects\BaseClasses\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -37,7 +40,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Content\sounds\Zombie\" />
|
||||
<Folder Include="Content\Textures\Animations\PlayerAFK\" />
|
||||
<Folder Include="Content\Textures\GUI\" />
|
||||
</ItemGroup>
|
||||
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
|
||||
|
|
Loading…
Add table
Reference in a new issue