diff --git a/AnimationsFileCreator/Program.cs b/AnimationsFileCreator/Program.cs index 223db5d..1287e6f 100644 --- a/AnimationsFileCreator/Program.cs +++ b/AnimationsFileCreator/Program.cs @@ -21,6 +21,7 @@ namespace AnimationsFileCreator OpenFileDialog dialog = new OpenFileDialog(); dialog.ShowDialog(); textureName = dialog.FileName.Split('\\').Last(); + textureName = textureName.Split('.')[0]; } Console.WriteLine("Введите количество кадров анимации: "); int framesCount = int.Parse(Console.ReadLine()); diff --git a/AnimatorCreatorGraphical/AnimatorCreatorGraphical.csproj b/AnimatorCreatorGraphical/AnimatorCreatorGraphical.csproj new file mode 100644 index 0000000..5392df9 --- /dev/null +++ b/AnimatorCreatorGraphical/AnimatorCreatorGraphical.csproj @@ -0,0 +1,23 @@ + + + WinExe + netcoreapp3.1 + false + false + true + + + app.manifest + Icon.ico + + + + + + + + + + + + \ No newline at end of file diff --git a/AnimatorCreatorGraphical/Content/Content.mgcb b/AnimatorCreatorGraphical/Content/Content.mgcb new file mode 100644 index 0000000..3c42606 --- /dev/null +++ b/AnimatorCreatorGraphical/Content/Content.mgcb @@ -0,0 +1,15 @@ + +#----------------------------- Global Properties ----------------------------# + +/outputDir:bin/$(Platform) +/intermediateDir:obj/$(Platform) +/platform:Windows +/config: +/profile:Reach +/compress:False + +#-------------------------------- References --------------------------------# + + +#---------------------------------- Content ---------------------------------# + diff --git a/AnimatorCreatorGraphical/Game1.cs b/AnimatorCreatorGraphical/Game1.cs new file mode 100644 index 0000000..66f9a30 --- /dev/null +++ b/AnimatorCreatorGraphical/Game1.cs @@ -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); + } + } +} diff --git a/AnimatorCreatorGraphical/Icon.ico b/AnimatorCreatorGraphical/Icon.ico new file mode 100644 index 0000000..7d9dec1 Binary files /dev/null and b/AnimatorCreatorGraphical/Icon.ico differ diff --git a/AnimatorCreatorGraphical/Program.cs b/AnimatorCreatorGraphical/Program.cs new file mode 100644 index 0000000..7b6eeb6 --- /dev/null +++ b/AnimatorCreatorGraphical/Program.cs @@ -0,0 +1,14 @@ +using System; + +namespace AnimatorCreatorGraphical +{ + public static class Program + { + [STAThread] + static void Main() + { + using (var game = new Game1()) + game.Run(); + } + } +} diff --git a/AnimatorCreatorGraphical/app.manifest b/AnimatorCreatorGraphical/app.manifest new file mode 100644 index 0000000..9c00a30 --- /dev/null +++ b/AnimatorCreatorGraphical/app.manifest @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true/pm + permonitorv2,permonitor + + + + diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index df82e29..97afe2e 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -13,6 +13,18 @@ #---------------------------------- 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 /importer:TextureImporter /processor:TextureProcessor diff --git a/DangerousD/Content/PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png b/DangerousD/Content/PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png new file mode 100644 index 0000000..3eb4a52 Binary files /dev/null and b/DangerousD/Content/PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png differ diff --git a/DangerousD/Content/animations/death1 b/DangerousD/Content/animations/death1 new file mode 100644 index 0000000..ea447b6 --- /dev/null +++ b/DangerousD/Content/animations/death1 @@ -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} diff --git a/DangerousD/Content/animations/deathbear b/DangerousD/Content/animations/deathbear new file mode 100644 index 0000000..dd5fd49 --- /dev/null +++ b/DangerousD/Content/animations/deathbear @@ -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} diff --git a/DangerousD/GameCore/GUI/AbstractGui.cs b/DangerousD/GameCore/GUI/AbstractGui.cs index 755f1cc..4704620 100644 --- a/DangerousD/GameCore/GUI/AbstractGui.cs +++ b/DangerousD/GameCore/GUI/AbstractGui.cs @@ -10,7 +10,7 @@ public abstract class AbstractGui : IDrawableObject { protected UIManager Manager = new(); protected List Elements = new(); - + protected string font; public AbstractGui() { } @@ -19,7 +19,7 @@ public abstract class AbstractGui : IDrawableObject public virtual void Initialize(GraphicsDevice graphicsDevice) { - Manager.Initialize("", graphicsDevice); + Manager.Initialize(font, graphicsDevice); CreateUI(); } diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs index 83bc3f8..82648d4 100644 --- a/DangerousD/GameCore/GameObjects/GameObject.cs +++ b/DangerousD/GameCore/GameObjects/GameObject.cs @@ -6,6 +6,7 @@ using DangerousD.GameCore.GUI; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; +using DangerousD.GameCore.GameObjects.LivingEntities; namespace DangerousD.GameCore { @@ -16,7 +17,6 @@ namespace DangerousD.GameCore public int Height { get; protected set; } public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height); protected abstract GraphicsComponent GraphicsComponent { get; } - public GameObject(Vector2 pos) { Pos = pos; diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs new file mode 100644 index 0000000..897a1ef --- /dev/null +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs @@ -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() + { + + } + } +} diff --git a/DangerousD/GameCore/GameObjects/MapObjects/TestAnimationDeath.cs b/DangerousD/GameCore/GameObjects/MapObjects/TestAnimationDeath.cs new file mode 100644 index 0000000..6937c56 --- /dev/null +++ b/DangerousD/GameCore/GameObjects/MapObjects/TestAnimationDeath.cs @@ -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 { "death1", "deathbear" },"death1"); + + public TestAnimationDeath(Vector2 position) : base(position) + { + Width = 64; + Height = 64; + + GraphicsComponent.StartAnimation("deathbear"); + + } + } +} diff --git a/DangerousD/GameCore/Graphics/AnimationBuilder.cs b/DangerousD/GameCore/Graphics/AnimationBuilder.cs index 9a64339..8f35b5a 100644 --- a/DangerousD/GameCore/Graphics/AnimationBuilder.cs +++ b/DangerousD/GameCore/Graphics/AnimationBuilder.cs @@ -9,16 +9,12 @@ namespace DangerousD.GameCore.Graphics public class AnimationBuilder { public List Animations { get; private set; } - void LoadAnimations(string nameOfMainFile) + public void LoadAnimations() { Animations = new List(); - List animationFilesNames = new List(); - StreamReader reader = new StreamReader(nameOfMainFile); - while (reader.Peek() != -1) - { - animationFilesNames.Add(reader.ReadLine()); - } - reader.Close(); + string[] animationFilesNames = Directory.GetFiles("../../../Content/animations"); + + StreamReader reader; foreach (var fileName in animationFilesNames) { reader = new StreamReader(fileName); diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index fad85b5..e605684 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -35,6 +35,9 @@ namespace DangerousD.GameCore.Graphics lastInterval = 1; LoadAnimations(animationsId, neitralAnimationId); + currentAnimation = neitralAnimation; + SetInterval(); + buildSourceRectangle(); } public GraphicsComponent(string textureName) diff --git a/DangerousD/GameCore/Graphics/SettingsManager.cs b/DangerousD/GameCore/Graphics/SettingsManager.cs new file mode 100644 index 0000000..3c1122a --- /dev/null +++ b/DangerousD/GameCore/Graphics/SettingsManager.cs @@ -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 + { + } +} diff --git a/DangerousD/GameCore/Levels/ILevel.cs b/DangerousD/GameCore/Levels/ILevel.cs new file mode 100644 index 0000000..7fbec35 --- /dev/null +++ b/DangerousD/GameCore/Levels/ILevel.cs @@ -0,0 +1,7 @@ +namespace DangerousD.GameCore.Levels +{ + interface ILevel + { + void InitLevel(); + } +} diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs new file mode 100644 index 0000000..5ab7a66 --- /dev/null +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -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)); + + } + } +} diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 68cd6c6..c3c60fb 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -38,6 +38,7 @@ namespace DangerousD.GameCore protected override void Initialize() { MenuGUI.Initialize(GraphicsDevice); + AnimationBuilder.LoadAnimations(); base.Initialize(); } diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 25021cd..497fa9c 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -1,4 +1,5 @@ using DangerousD.GameCore.GameObjects; +using DangerousD.GameCore.GameObjects.LivingEntities; using DangerousD.GameCore.Graphics; using DangerousD.GameCore.Managers; using Microsoft.Xna.Framework; @@ -14,8 +15,8 @@ namespace DangerousD.GameCore List livingEntities; List entities; List mapObjects; - public MapManager mapManager; - + public MapManager mapManager; + public Player Player { get; set; } public GameManager() { livingEntities = new List(); diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs index 6b85e53..f5c9d28 100644 --- a/DangerousD/GameCore/Managers/MapManager.cs +++ b/DangerousD/GameCore/Managers/MapManager.cs @@ -1,7 +1,6 @@ using DangerousD.GameCore.GameObjects; -using DangerousD.GameCore.GameObjects.MapObjects; using DangerousD.GameCore.Graphics; -using Microsoft.Xna.Framework; +using DangerousD.GameCore.Levels; using System; using System.Collections.Generic; using System.Linq; @@ -11,17 +10,6 @@ using System.Threading.Tasks; 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 { ILevel Level; diff --git a/MonogameLibrary/UI/Base/DrawableTextedUiElement.cs b/MonogameLibrary/UI/Base/DrawableTextedUiElement.cs index 2527ccc..2a45c2c 100644 --- a/MonogameLibrary/UI/Base/DrawableTextedUiElement.cs +++ b/MonogameLibrary/UI/Base/DrawableTextedUiElement.cs @@ -13,7 +13,7 @@ namespace MonogameLibrary.UI.Base public class DrawableTextedUiElement : DrawableUIElement { protected SpriteFont spriteFont; - protected string fontName; + public string fontName; public string text = ""; public float scale = 0.5f; public Color fontColor = Color.Black;