mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-27 21:56:19 -04:00
Added start of game screen. Added game state.
This commit is contained in:
parent
1983d0d40e
commit
b0869cc7d9
19
OpenDiablo2.Common/Enums/eHero.cs
Normal file
19
OpenDiablo2.Common/Enums/eHero.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OpenDiablo2.Common.Enums
|
||||||
|
{
|
||||||
|
public enum eHero
|
||||||
|
{
|
||||||
|
Barbarian,
|
||||||
|
Necromancer,
|
||||||
|
Paladin,
|
||||||
|
Assassin,
|
||||||
|
Sorceress,
|
||||||
|
Amazon,
|
||||||
|
Druid
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@ namespace OpenDiablo2.Common.Interfaces
|
|||||||
ILabel CreateLabel(IFont font, Point position, string text);
|
ILabel CreateLabel(IFont font, Point position, string text);
|
||||||
void Draw(ISprite sprite);
|
void Draw(ISprite sprite);
|
||||||
void Draw(ISprite sprite, Point location);
|
void Draw(ISprite sprite, Point location);
|
||||||
|
void Draw(ISprite sprite, int frame, Point location);
|
||||||
void Draw(ISprite sprite, int frame);
|
void Draw(ISprite sprite, int frame);
|
||||||
void Draw(ISprite sprite, int xSegments, int ySegments, int offset);
|
void Draw(ISprite sprite, int xSegments, int ySegments, int offset);
|
||||||
void Draw(ILabel label);
|
void Draw(ILabel label);
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Attributes\SceneAttribute.cs" />
|
<Compile Include="Attributes\SceneAttribute.cs" />
|
||||||
<Compile Include="Enums\eButtonType.cs" />
|
<Compile Include="Enums\eButtonType.cs" />
|
||||||
|
<Compile Include="Enums\eHero.cs" />
|
||||||
<Compile Include="Enums\eMPQFormatVersion.cs" />
|
<Compile Include="Enums\eMPQFormatVersion.cs" />
|
||||||
<Compile Include="Interfaces\IFont.cs" />
|
<Compile Include="Interfaces\IFont.cs" />
|
||||||
<Compile Include="Interfaces\IGameEngine.cs" />
|
<Compile Include="Interfaces\IGameEngine.cs" />
|
||||||
|
@ -74,6 +74,13 @@ namespace OpenDiablo2.Common
|
|||||||
public static string CharacterSelectDruidForwardWalk = "data\\global\\ui\\FrontEnd\\druid\\DZFW.DC6";
|
public static string CharacterSelectDruidForwardWalk = "data\\global\\ui\\FrontEnd\\druid\\DZFW.DC6";
|
||||||
public static string CharacterSelectDruidBackWalk = "data\\global\\ui\\FrontEnd\\druid\\DZBW.DC6";
|
public static string CharacterSelectDruidBackWalk = "data\\global\\ui\\FrontEnd\\druid\\DZBW.DC6";
|
||||||
|
|
||||||
|
// --- Game ---
|
||||||
|
public static string GamePanels = "data\\global\\ui\\PANEL\\800ctrlpnl7.dc6";
|
||||||
|
public static string GameGlobeOverlap = "data\\global\\ui\\PANEL\\overlap.DC6";
|
||||||
|
public static string HealthMana = "data\\global\\ui\\PANEL\\hlthmana.DC6";
|
||||||
|
public static string GameSmallMenuButton = "data\\global\\ui\\PANEL\\menubutton.DC6"; // TODO: Used for inventory popout
|
||||||
|
public static string SkillIcon = "data\\global\\ui\\PANEL\\Skillicon.DC6";
|
||||||
|
|
||||||
// --- Mouse Pointers ---
|
// --- Mouse Pointers ---
|
||||||
public static string CursorDefault = "data\\global\\ui\\CURSOR\\ohand.DC6";
|
public static string CursorDefault = "data\\global\\ui\\CURSOR\\ohand.DC6";
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using OpenDiablo2.Common.Interfaces;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
|
using OpenDiablo2.Core.GameState_;
|
||||||
using OpenDiablo2.Core.UI;
|
using OpenDiablo2.Core.UI;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -23,7 +24,7 @@ namespace OpenDiablo2.Core
|
|||||||
builder.RegisterType<TextDictionary>().As<ITextDictionary>().SingleInstance();
|
builder.RegisterType<TextDictionary>().As<ITextDictionary>().SingleInstance();
|
||||||
builder.RegisterType<Button>().AsSelf().InstancePerDependency();
|
builder.RegisterType<Button>().AsSelf().InstancePerDependency();
|
||||||
builder.RegisterType<TextBox>().AsSelf().InstancePerDependency();
|
builder.RegisterType<TextBox>().AsSelf().InstancePerDependency();
|
||||||
|
builder.RegisterType<GameState>().AsSelf().SingleInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
OpenDiablo2.Core/GameState/GameState.cs
Normal file
26
OpenDiablo2.Core/GameState/GameState.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using OpenDiablo2.Common.Enums;
|
||||||
|
using OpenDiablo2.Common.Interfaces;
|
||||||
|
|
||||||
|
namespace OpenDiablo2.Core.GameState_
|
||||||
|
{
|
||||||
|
public sealed class GameState
|
||||||
|
{
|
||||||
|
private readonly ISceneManager sceneManager;
|
||||||
|
|
||||||
|
public GameState(ISceneManager sceneManager)
|
||||||
|
{
|
||||||
|
this.sceneManager = sceneManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize(string characterName, eHero hero)
|
||||||
|
{
|
||||||
|
|
||||||
|
sceneManager.ChangeScene("Game");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -74,6 +74,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AutofacModule.cs" />
|
<Compile Include="AutofacModule.cs" />
|
||||||
<Compile Include="GameEngine.cs" />
|
<Compile Include="GameEngine.cs" />
|
||||||
|
<Compile Include="GameState\GameState.cs" />
|
||||||
<Compile Include="MPQProvider.cs" />
|
<Compile Include="MPQProvider.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ResourceManager.cs" />
|
<Compile Include="ResourceManager.cs" />
|
||||||
|
@ -153,6 +153,13 @@ namespace OpenDiablo2.SDL2_
|
|||||||
Draw(sprite);
|
Draw(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Draw(ISprite sprite, int frame, Point location)
|
||||||
|
{
|
||||||
|
sprite.Location = location;
|
||||||
|
sprite.Frame = frame;
|
||||||
|
Draw(sprite);
|
||||||
|
}
|
||||||
|
|
||||||
public void Draw(ISprite sprite, int frame)
|
public void Draw(ISprite sprite, int frame)
|
||||||
{
|
{
|
||||||
sprite.Frame = frame;
|
sprite.Frame = frame;
|
||||||
|
68
OpenDiablo2.Scenes/Game.cs
Normal file
68
OpenDiablo2.Scenes/Game.cs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using OpenDiablo2.Common;
|
||||||
|
using OpenDiablo2.Common.Attributes;
|
||||||
|
using OpenDiablo2.Common.Interfaces;
|
||||||
|
|
||||||
|
namespace OpenDiablo2.Scenes
|
||||||
|
{
|
||||||
|
[Scene("Game")]
|
||||||
|
public sealed class Game : IScene
|
||||||
|
{
|
||||||
|
private readonly IRenderWindow renderWindow;
|
||||||
|
private readonly IResourceManager resourceManager;
|
||||||
|
|
||||||
|
private ISprite panelSprite, healthManaSprite, gameGlobeOverlapSprite;
|
||||||
|
|
||||||
|
public Game(IRenderWindow renderWindow, IResourceManager resourceManager)
|
||||||
|
{
|
||||||
|
this.renderWindow = renderWindow;
|
||||||
|
this.resourceManager = resourceManager;
|
||||||
|
|
||||||
|
panelSprite = renderWindow.LoadSprite(ResourcePaths.GamePanels, Palettes.Act1);
|
||||||
|
healthManaSprite = renderWindow.LoadSprite(ResourcePaths.HealthMana, Palettes.Act1);
|
||||||
|
gameGlobeOverlapSprite = renderWindow.LoadSprite(ResourcePaths.GameGlobeOverlap, Palettes.Act1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Render()
|
||||||
|
{
|
||||||
|
|
||||||
|
DrawPanel();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawPanel()
|
||||||
|
{
|
||||||
|
// Render the background bottom bar
|
||||||
|
renderWindow.Draw(panelSprite, 0, new Point(0, 600));
|
||||||
|
renderWindow.Draw(panelSprite, 1, new Point(166, 600));
|
||||||
|
renderWindow.Draw(panelSprite, 2, new Point(294, 600));
|
||||||
|
renderWindow.Draw(panelSprite, 3, new Point(422, 600));
|
||||||
|
renderWindow.Draw(panelSprite, 4, new Point(550, 600));
|
||||||
|
renderWindow.Draw(panelSprite, 5, new Point(685, 600));
|
||||||
|
|
||||||
|
// Render the health bar
|
||||||
|
renderWindow.Draw(healthManaSprite, 0, new Point(28, 590));
|
||||||
|
renderWindow.Draw(gameGlobeOverlapSprite, 0, new Point(28, 595));
|
||||||
|
|
||||||
|
// Render the mana bar
|
||||||
|
renderWindow.Draw(healthManaSprite, 1, new Point(691, 590));
|
||||||
|
renderWindow.Draw(gameGlobeOverlapSprite, 1, new Point(693, 591));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(long ms)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -50,6 +50,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AutofacModule.cs" />
|
<Compile Include="AutofacModule.cs" />
|
||||||
|
<Compile Include="Game.cs" />
|
||||||
<Compile Include="MainMenu.cs" />
|
<Compile Include="MainMenu.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SelectHeroClass.cs" />
|
<Compile Include="SelectHeroClass.cs" />
|
||||||
|
@ -8,20 +8,11 @@ using OpenDiablo2.Common;
|
|||||||
using OpenDiablo2.Common.Attributes;
|
using OpenDiablo2.Common.Attributes;
|
||||||
using OpenDiablo2.Common.Enums;
|
using OpenDiablo2.Common.Enums;
|
||||||
using OpenDiablo2.Common.Interfaces;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
|
using OpenDiablo2.Core.GameState_;
|
||||||
using OpenDiablo2.Core.UI;
|
using OpenDiablo2.Core.UI;
|
||||||
|
|
||||||
namespace OpenDiablo2.Scenes
|
namespace OpenDiablo2.Scenes
|
||||||
{
|
{
|
||||||
enum eHero
|
|
||||||
{
|
|
||||||
Barbarian,
|
|
||||||
Necromancer,
|
|
||||||
Paladin,
|
|
||||||
Assassin,
|
|
||||||
Sorceress,
|
|
||||||
Amazon,
|
|
||||||
Druid
|
|
||||||
}
|
|
||||||
|
|
||||||
enum eHeroStance
|
enum eHeroStance
|
||||||
{
|
{
|
||||||
@ -54,6 +45,7 @@ namespace OpenDiablo2.Scenes
|
|||||||
private readonly ISceneManager sceneManager;
|
private readonly ISceneManager sceneManager;
|
||||||
private readonly ITextDictionary textDictionary;
|
private readonly ITextDictionary textDictionary;
|
||||||
private readonly IKeyboardInfoProvider keyboardInfoProvider;
|
private readonly IKeyboardInfoProvider keyboardInfoProvider;
|
||||||
|
private readonly GameState gameState;
|
||||||
|
|
||||||
private bool showEntryUi = false;
|
private bool showEntryUi = false;
|
||||||
private eHero? selectedHero = null;
|
private eHero? selectedHero = null;
|
||||||
@ -75,7 +67,8 @@ namespace OpenDiablo2.Scenes
|
|||||||
Func<eButtonType, Button> createButton,
|
Func<eButtonType, Button> createButton,
|
||||||
Func<TextBox> createTextBox,
|
Func<TextBox> createTextBox,
|
||||||
ITextDictionary textDictionary,
|
ITextDictionary textDictionary,
|
||||||
IKeyboardInfoProvider keyboardInfoProvider
|
IKeyboardInfoProvider keyboardInfoProvider,
|
||||||
|
GameState gameState
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.renderWindow = renderWindow;
|
this.renderWindow = renderWindow;
|
||||||
@ -85,6 +78,7 @@ namespace OpenDiablo2.Scenes
|
|||||||
this.sceneManager = sceneManager;
|
this.sceneManager = sceneManager;
|
||||||
this.textDictionary = textDictionary;
|
this.textDictionary = textDictionary;
|
||||||
this.keyboardInfoProvider = keyboardInfoProvider;
|
this.keyboardInfoProvider = keyboardInfoProvider;
|
||||||
|
this.gameState = gameState;
|
||||||
|
|
||||||
|
|
||||||
backgroundSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBackground, Palettes.Fechar);
|
backgroundSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBackground, Palettes.Fechar);
|
||||||
@ -238,7 +232,7 @@ namespace OpenDiablo2.Scenes
|
|||||||
|
|
||||||
private void OnOkclicked()
|
private void OnOkclicked()
|
||||||
{
|
{
|
||||||
|
gameState.Initialize(characterNameTextBox.Text, selectedHero.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExitClicked()
|
private void OnExitClicked()
|
||||||
|
Loading…
Reference in New Issue
Block a user