day commit refactoring
This commit is contained in:
parent
a70367eb27
commit
3e5e5192b8
24 changed files with 256 additions and 27 deletions
|
@ -21,6 +21,7 @@ namespace AnimationsFileCreator
|
||||||
OpenFileDialog dialog = new OpenFileDialog();
|
OpenFileDialog dialog = new OpenFileDialog();
|
||||||
dialog.ShowDialog();
|
dialog.ShowDialog();
|
||||||
textureName = dialog.FileName.Split('\\').Last();
|
textureName = dialog.FileName.Split('\\').Last();
|
||||||
|
textureName = textureName.Split('.')[0];
|
||||||
}
|
}
|
||||||
Console.WriteLine("Введите количество кадров анимации: ");
|
Console.WriteLine("Введите количество кадров анимации: ");
|
||||||
int framesCount = int.Parse(Console.ReadLine());
|
int framesCount = int.Parse(Console.ReadLine());
|
||||||
|
|
23
AnimatorCreatorGraphical/AnimatorCreatorGraphical.csproj
Normal file
23
AnimatorCreatorGraphical/AnimatorCreatorGraphical.csproj
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<PublishReadyToRun>false</PublishReadyToRun>
|
||||||
|
<TieredCompilation>false</TieredCompilation>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<TrimmerRootAssembly Include="Microsoft.Xna.Framework.Content.ContentTypeReader" Visible="false" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.0.1641" />
|
||||||
|
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<MonoGameContentReference Include="Content\Content.mgcb" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
15
AnimatorCreatorGraphical/Content/Content.mgcb
Normal file
15
AnimatorCreatorGraphical/Content/Content.mgcb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
#----------------------------- Global Properties ----------------------------#
|
||||||
|
|
||||||
|
/outputDir:bin/$(Platform)
|
||||||
|
/intermediateDir:obj/$(Platform)
|
||||||
|
/platform:Windows
|
||||||
|
/config:
|
||||||
|
/profile:Reach
|
||||||
|
/compress:False
|
||||||
|
|
||||||
|
#-------------------------------- References --------------------------------#
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------- Content ---------------------------------#
|
||||||
|
|
52
AnimatorCreatorGraphical/Game1.cs
Normal file
52
AnimatorCreatorGraphical/Game1.cs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
|
||||||
|
namespace AnimatorCreatorGraphical
|
||||||
|
{
|
||||||
|
public class Game1 : Game
|
||||||
|
{
|
||||||
|
private GraphicsDeviceManager _graphics;
|
||||||
|
private SpriteBatch _spriteBatch;
|
||||||
|
|
||||||
|
public Game1()
|
||||||
|
{
|
||||||
|
_graphics = new GraphicsDeviceManager(this);
|
||||||
|
Content.RootDirectory = "Content";
|
||||||
|
IsMouseVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Initialize()
|
||||||
|
{
|
||||||
|
// TODO: Add your initialization logic here
|
||||||
|
|
||||||
|
base.Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadContent()
|
||||||
|
{
|
||||||
|
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
|
|
||||||
|
// TODO: use this.Content to load your game content here
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||||
|
Exit();
|
||||||
|
|
||||||
|
// TODO: Add your update logic here
|
||||||
|
|
||||||
|
base.Update(gameTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Draw(GameTime gameTime)
|
||||||
|
{
|
||||||
|
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||||
|
|
||||||
|
// TODO: Add your drawing code here
|
||||||
|
|
||||||
|
base.Draw(gameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
AnimatorCreatorGraphical/Icon.ico
Normal file
BIN
AnimatorCreatorGraphical/Icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 144 KiB |
14
AnimatorCreatorGraphical/Program.cs
Normal file
14
AnimatorCreatorGraphical/Program.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AnimatorCreatorGraphical
|
||||||
|
{
|
||||||
|
public static class Program
|
||||||
|
{
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
using (var game = new Game1())
|
||||||
|
game.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
43
AnimatorCreatorGraphical/app.manifest
Normal file
43
AnimatorCreatorGraphical/app.manifest
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="AnimatorCreatorGraphical"/>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
<!-- A list of the Windows versions that this application has been tested on and is
|
||||||
|
is designed to work with. Uncomment the appropriate elements and Windows will
|
||||||
|
automatically selected the most compatible environment. -->
|
||||||
|
|
||||||
|
<!-- Windows Vista -->
|
||||||
|
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
|
||||||
|
|
||||||
|
<!-- Windows 7 -->
|
||||||
|
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
|
||||||
|
|
||||||
|
<!-- Windows 8 -->
|
||||||
|
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
|
||||||
|
|
||||||
|
<!-- Windows 8.1 -->
|
||||||
|
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
|
||||||
|
|
||||||
|
<!-- Windows 10 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||||
|
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
|
|
||||||
|
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<windowsSettings>
|
||||||
|
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
||||||
|
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness>
|
||||||
|
</windowsSettings>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</assembly>
|
|
@ -13,6 +13,18 @@
|
||||||
|
|
||||||
#---------------------------------- Content ---------------------------------#
|
#---------------------------------- Content ---------------------------------#
|
||||||
|
|
||||||
|
#begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.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:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||||
|
|
||||||
#begin wall.jpg
|
#begin wall.jpg
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
1
DangerousD/Content/animations/death1
Normal file
1
DangerousD/Content/animations/death1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"death1","textureName":"PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences","startSpriteRectangle":{"X":1,"Y":1,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":15}],"textureFrameInterval":1,"framesCount":5,"isCycle":false}
|
1
DangerousD/Content/animations/deathbear
Normal file
1
DangerousD/Content/animations/deathbear
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"deathbear","textureName":"PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences","startSpriteRectangle":{"X":1,"Y":99,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false}
|
|
@ -10,7 +10,7 @@ public abstract class AbstractGui : IDrawableObject
|
||||||
{
|
{
|
||||||
protected UIManager Manager = new();
|
protected UIManager Manager = new();
|
||||||
protected List<DrawableUIElement> Elements = new();
|
protected List<DrawableUIElement> Elements = new();
|
||||||
|
protected string font;
|
||||||
public AbstractGui()
|
public AbstractGui()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public abstract class AbstractGui : IDrawableObject
|
||||||
|
|
||||||
public virtual void Initialize(GraphicsDevice graphicsDevice)
|
public virtual void Initialize(GraphicsDevice graphicsDevice)
|
||||||
{
|
{
|
||||||
Manager.Initialize("", graphicsDevice);
|
Manager.Initialize(font, graphicsDevice);
|
||||||
CreateUI();
|
CreateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ using DangerousD.GameCore.GUI;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||||
|
|
||||||
namespace DangerousD.GameCore
|
namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
|
@ -16,7 +17,6 @@ namespace DangerousD.GameCore
|
||||||
public int Height { get; protected set; }
|
public int Height { get; protected set; }
|
||||||
public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height);
|
public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height);
|
||||||
protected abstract GraphicsComponent GraphicsComponent { get; }
|
protected abstract GraphicsComponent GraphicsComponent { get; }
|
||||||
|
|
||||||
public GameObject(Vector2 pos)
|
public GameObject(Vector2 pos)
|
||||||
{
|
{
|
||||||
Pos = pos;
|
Pos = pos;
|
||||||
|
|
16
DangerousD/GameCore/GameObjects/LivingEntities/Player.cs
Normal file
16
DangerousD/GameCore/GameObjects/LivingEntities/Player.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
|
{
|
||||||
|
public class Player
|
||||||
|
{
|
||||||
|
public void Kill()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
using DangerousD.GameCore.Graphics;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GameObjects.MapObjects
|
||||||
|
{
|
||||||
|
internal class TestAnimationDeath : Entity
|
||||||
|
{
|
||||||
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "death1", "deathbear" },"death1");
|
||||||
|
|
||||||
|
public TestAnimationDeath(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
Width = 64;
|
||||||
|
Height = 64;
|
||||||
|
|
||||||
|
GraphicsComponent.StartAnimation("deathbear");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,16 +9,12 @@ namespace DangerousD.GameCore.Graphics
|
||||||
public class AnimationBuilder
|
public class AnimationBuilder
|
||||||
{
|
{
|
||||||
public List<AnimationContainer> Animations { get; private set; }
|
public List<AnimationContainer> Animations { get; private set; }
|
||||||
void LoadAnimations(string nameOfMainFile)
|
public void LoadAnimations()
|
||||||
{
|
{
|
||||||
Animations = new List<AnimationContainer>();
|
Animations = new List<AnimationContainer>();
|
||||||
List<string> animationFilesNames = new List<string>();
|
string[] animationFilesNames = Directory.GetFiles("../../../Content/animations");
|
||||||
StreamReader reader = new StreamReader(nameOfMainFile);
|
|
||||||
while (reader.Peek() != -1)
|
StreamReader reader;
|
||||||
{
|
|
||||||
animationFilesNames.Add(reader.ReadLine());
|
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
foreach (var fileName in animationFilesNames)
|
foreach (var fileName in animationFilesNames)
|
||||||
{
|
{
|
||||||
reader = new StreamReader(fileName);
|
reader = new StreamReader(fileName);
|
||||||
|
|
|
@ -35,6 +35,9 @@ namespace DangerousD.GameCore.Graphics
|
||||||
lastInterval = 1;
|
lastInterval = 1;
|
||||||
|
|
||||||
LoadAnimations(animationsId, neitralAnimationId);
|
LoadAnimations(animationsId, neitralAnimationId);
|
||||||
|
currentAnimation = neitralAnimation;
|
||||||
|
SetInterval();
|
||||||
|
buildSourceRectangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphicsComponent(string textureName)
|
public GraphicsComponent(string textureName)
|
||||||
|
|
13
DangerousD/GameCore/Graphics/SettingsManager.cs
Normal file
13
DangerousD/GameCore/Graphics/SettingsManager.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.Graphics
|
||||||
|
{
|
||||||
|
internal class SettingsManager
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
7
DangerousD/GameCore/Levels/ILevel.cs
Normal file
7
DangerousD/GameCore/Levels/ILevel.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
namespace DangerousD.GameCore.Levels
|
||||||
|
{
|
||||||
|
interface ILevel
|
||||||
|
{
|
||||||
|
void InitLevel();
|
||||||
|
}
|
||||||
|
}
|
17
DangerousD/GameCore/Levels/Level1.cs
Normal file
17
DangerousD/GameCore/Levels/Level1.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||||
|
using DangerousD.GameCore.GameObjects.MapObjects;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.Levels
|
||||||
|
{
|
||||||
|
public class Level1 : ILevel
|
||||||
|
{
|
||||||
|
public void InitLevel()
|
||||||
|
{
|
||||||
|
new Player();
|
||||||
|
var Трава = new GrassBlock(new Vector2(0, 128));
|
||||||
|
var Death = new TestAnimationDeath(new Vector2(128, 128));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,6 +38,7 @@ namespace DangerousD.GameCore
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
MenuGUI.Initialize(GraphicsDevice);
|
MenuGUI.Initialize(GraphicsDevice);
|
||||||
|
AnimationBuilder.LoadAnimations();
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using DangerousD.GameCore.GameObjects;
|
using DangerousD.GameCore.GameObjects;
|
||||||
|
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||||
using DangerousD.GameCore.Graphics;
|
using DangerousD.GameCore.Graphics;
|
||||||
using DangerousD.GameCore.Managers;
|
using DangerousD.GameCore.Managers;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
@ -14,8 +15,8 @@ namespace DangerousD.GameCore
|
||||||
List<LivingEntity> livingEntities;
|
List<LivingEntity> livingEntities;
|
||||||
List<Entity> entities;
|
List<Entity> entities;
|
||||||
List<MapObject> mapObjects;
|
List<MapObject> mapObjects;
|
||||||
public MapManager mapManager;
|
public MapManager mapManager;
|
||||||
|
public Player Player { get; set; }
|
||||||
public GameManager()
|
public GameManager()
|
||||||
{
|
{
|
||||||
livingEntities = new List<LivingEntity>();
|
livingEntities = new List<LivingEntity>();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using DangerousD.GameCore.GameObjects;
|
using DangerousD.GameCore.GameObjects;
|
||||||
using DangerousD.GameCore.GameObjects.MapObjects;
|
|
||||||
using DangerousD.GameCore.Graphics;
|
using DangerousD.GameCore.Graphics;
|
||||||
using Microsoft.Xna.Framework;
|
using DangerousD.GameCore.Levels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -11,17 +10,6 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.Managers
|
namespace DangerousD.GameCore.Managers
|
||||||
{
|
{
|
||||||
interface ILevel
|
|
||||||
{
|
|
||||||
void InitLevel();
|
|
||||||
}
|
|
||||||
public class Level1 : ILevel
|
|
||||||
{
|
|
||||||
public void InitLevel()
|
|
||||||
{
|
|
||||||
var Трава = new GrassBlock(new Vector2(0,128));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class MapManager
|
public class MapManager
|
||||||
{
|
{
|
||||||
ILevel Level;
|
ILevel Level;
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace MonogameLibrary.UI.Base
|
||||||
public class DrawableTextedUiElement : DrawableUIElement
|
public class DrawableTextedUiElement : DrawableUIElement
|
||||||
{
|
{
|
||||||
protected SpriteFont spriteFont;
|
protected SpriteFont spriteFont;
|
||||||
protected string fontName;
|
public string fontName;
|
||||||
public string text = "";
|
public string text = "";
|
||||||
public float scale = 0.5f;
|
public float scale = 0.5f;
|
||||||
public Color fontColor = Color.Black;
|
public Color fontColor = Color.Black;
|
||||||
|
|
Loading…
Add table
Reference in a new issue