-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6fe0a7
commit fe946af
Showing
81 changed files
with
3,016 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"dotnet-mgcb": { | ||
"version": "3.8.1.303", | ||
"commands": [ | ||
"mgcb" | ||
] | ||
}, | ||
"dotnet-mgcb-editor": { | ||
"version": "3.8.1.303", | ||
"commands": [ | ||
"mgcb-editor" | ||
] | ||
}, | ||
"dotnet-mgcb-editor-linux": { | ||
"version": "3.8.1.303", | ||
"commands": [ | ||
"mgcb-editor-linux" | ||
] | ||
}, | ||
"dotnet-mgcb-editor-windows": { | ||
"version": "3.8.1.303", | ||
"commands": [ | ||
"mgcb-editor-windows" | ||
] | ||
}, | ||
"dotnet-mgcb-editor-mac": { | ||
"version": "3.8.1.303", | ||
"commands": [ | ||
"mgcb-editor-mac" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using CodeSummonary.Components; | ||
using Microsoft.Xna.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CodeSummonary.Animations | ||
{ | ||
public class Animation | ||
{ | ||
public Animation(Component target, float maxTime, string tag = "") | ||
{ | ||
Target = target; | ||
MaxTime = maxTime; | ||
Time = 0; | ||
Tag = tag; | ||
} | ||
|
||
public string Tag; | ||
|
||
public static Animation Empty => new Animation(null, 0); | ||
|
||
public float MaxTime; | ||
|
||
public float Time; | ||
|
||
public Component Target; | ||
|
||
public EventHandler<Component> DoAnimation; | ||
|
||
public virtual void Update(GameTime gameTime) | ||
{ | ||
if (MaxTime != 0) | ||
{ | ||
DoAnimation?.Invoke(this, Target); | ||
|
||
Time += 0.05f; | ||
|
||
if (Time >= MaxTime) End(); | ||
} | ||
} | ||
|
||
public virtual void End() | ||
{ | ||
MaxTime = 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using CodeSummonary.Components; | ||
using Microsoft.Xna.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CodeSummonary.Animations | ||
{ | ||
public class DirectMoveAnimation : Animation | ||
{ | ||
public DirectMoveAnimation(Component target, float maxTime, Vector2 dir, int speed, string tag = "") : base(target, maxTime, tag) | ||
{ | ||
MoveDirection = dir; | ||
|
||
MoveSpeed = speed; | ||
|
||
DoAnimation += (object sender, Component target) => | ||
{ | ||
target.RelativePosition += MoveDirection * MoveSpeed; | ||
}; | ||
} | ||
|
||
public Vector2 MoveDirection; | ||
|
||
public int MoveSpeed; | ||
|
||
public override void Update(GameTime gameTime) | ||
{ | ||
if(gameTime.TotalGameTime.TotalMilliseconds % 10 <= 1) | ||
base.Update(gameTime); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using CodeSummonary.Components; | ||
using CodeSummonary.Extensions; | ||
using Microsoft.Xna.Framework; | ||
using System; | ||
|
||
namespace CodeSummonary.Animations | ||
{ | ||
public class PunchAnimation : Animation | ||
{ | ||
public PunchAnimation(Component target, float maxTime, float strength, string tag = "") : base(target, maxTime, tag) | ||
{ | ||
_strength = strength; | ||
|
||
_direction = ((float)Main.Random.NextDouble() * 6.2831855f).GetAngle(); | ||
|
||
_startPosition = target.Position + new Vector2(target.Width, target.Height) / 2; | ||
|
||
_distanceFalloff = -1f; | ||
|
||
_vibrationCyclesPerSecond = 1f; | ||
|
||
_framesToLast = (int)maxTime; | ||
} | ||
|
||
public float Remap(float fromValue, float fromMin, float fromMax, float toMin, float toMax, bool clamped = true) | ||
{ | ||
return MathHelper.Lerp(toMin, toMax, GetLerpValue(fromMin, fromMax, fromValue, clamped)); | ||
} | ||
|
||
public float GetLerpValue(float from, float to, float t, bool clamped = false) | ||
{ | ||
if (clamped) | ||
{ | ||
if (from < to) | ||
{ | ||
if (t < from) | ||
{ | ||
return 0f; | ||
} | ||
if (t > to) | ||
{ | ||
return 1f; | ||
} | ||
} | ||
else | ||
{ | ||
if (t < to) | ||
{ | ||
return 1f; | ||
} | ||
if (t > from) | ||
{ | ||
return 0f; | ||
} | ||
} | ||
} | ||
return (t - from) / (to - from); | ||
} | ||
|
||
public override void Update(GameTime gameTime) | ||
{ | ||
float scaleFactor = (float)Math.Cos((double)(_framesLasted / 60f * _vibrationCyclesPerSecond * 6.2831855f)); | ||
float scaleFactor2 = Remap(_framesLasted, 0f, _framesToLast, 1f, 0f, true); | ||
float scaleFactor3 = Remap(Vector2.Distance(_startPosition, Target.Position + new Vector2(Target.Width, Target.Height) / 2 + Target.DrawOffset), 0f, _distanceFalloff, 1f, 0f, true); | ||
if (_distanceFalloff == -1f) | ||
scaleFactor3 = 1f; | ||
Target.DrawOffset += _direction * scaleFactor * _strength * scaleFactor2 * scaleFactor3; | ||
_framesLasted++; | ||
if (_framesLasted >= _framesToLast) | ||
End(); | ||
} | ||
private int _framesToLast; | ||
private Vector2 _startPosition; | ||
private Vector2 _direction; | ||
private float _distanceFalloff; | ||
private float _strength; | ||
private float _vibrationCyclesPerSecond; | ||
private int _framesLasted; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using CodeSummonary.Components; | ||
using Microsoft.Xna.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CodeSummonary.Animations | ||
{ | ||
public class ToAndReturnAnimation : DirectMoveAnimation | ||
{ | ||
public ToAndReturnAnimation(Component target, float maxTime, Vector2 dir, int speed, int times, string tag = "") | ||
: base(target, maxTime, dir, speed, tag) { Times = times; } | ||
|
||
public int Times; | ||
|
||
public override void End() | ||
{ | ||
if(Times > 0) | ||
Target.CurrentAnimation = new ToAndReturnAnimation(Target, MaxTime, -MoveDirection, MoveSpeed, Times - 1, Tag); | ||
base.End(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<RollForward>Major</RollForward> | ||
<PublishReadyToRun>false</PublishReadyToRun> | ||
<TieredCompilation>false</TieredCompilation> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
<ApplicationIcon>Icon.ico</ApplicationIcon> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Remove="Content\UI\**" /> | ||
<EmbeddedResource Remove="Content\UI\**" /> | ||
<None Remove="Content\UI\**" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Remove="Icon.bmp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Icon.ico" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Icon.bmp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="FontStashSharp.MonoGame" Version="1.3.6" /> | ||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" /> | ||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="Content\**"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<Target Name="RestoreDotnetTools" BeforeTargets="Restore"> | ||
<Message Text="Restoring dotnet tools" Importance="High" /> | ||
<Exec Command="dotnet tool restore" /> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.7.34024.191 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeSummonary", "CodeSummonary.csproj", "{9C33284B-E47D-4C9B-93BF-4A4AB0B49EEA}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9C33284B-E47D-4C9B-93BF-4A4AB0B49EEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9C33284B-E47D-4C9B-93BF-4A4AB0B49EEA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9C33284B-E47D-4C9B-93BF-4A4AB0B49EEA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9C33284B-E47D-4C9B-93BF-4A4AB0B49EEA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {77228259-DB99-4261-BC68-E3C61E036048} | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.