Merge branch 'main' into particlesBranch
This commit is contained in:
commit
ae3d9dd65d
40 changed files with 629 additions and 145 deletions
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 22 KiB |
|
@ -1 +1 @@
|
|||
{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":124,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"}
|
||||
{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":112,"Y":124,"Width":27,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"4, 0"}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"id":"HunchmanAttackRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":99,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"}
|
||||
{"id":"HunchmanAttackRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":102,"Y":99,"Width":31,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"8, 0"}
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
|
||||
{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":99,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
|
||||
|
||||
{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":100,"Width":24,"Height":23},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
|
||||
|
|
162
DangerousD/Content/boss.tmx
Normal file
162
DangerousD/Content/boss.tmx
Normal file
|
@ -0,0 +1,162 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="200" height="200" tilewidth="16" tileheight="16" infinite="1" nextlayerid="4" nextobjectid="3">
|
||||
<tileset firstgid="1" source="../../../../../Desktop/DangerousD map/map.tsx"/>
|
||||
<layer id="1" name="Слой тайлов 1" class="StopTile" width="200" height="200">
|
||||
<data encoding="csv">
|
||||
<chunk x="-16" y="-32" width="16" height="16">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,799,799,799,799,799,799,799,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0
|
||||
</chunk>
|
||||
<chunk x="0" y="-32" width="16" height="16">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
799,799,799,799,799,799,799,799,799,799,799,799,799,799,799,799,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
</chunk>
|
||||
<chunk x="16" y="-32" width="16" height="16">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
799,799,799,799,799,799,799,799,799,799,799,799,799,799,799,799,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
</chunk>
|
||||
<chunk x="32" y="-32" width="16" height="16">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
799,799,799,799,799,799,799,799,799,799,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0
|
||||
</chunk>
|
||||
<chunk x="-16" y="-16" width="16" height="16">
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,799,799,799,799,799,799,799,799
|
||||
</chunk>
|
||||
<chunk x="0" y="-16" width="16" height="16">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
799,799,799,799,799,799,799,799,799,799,799,799,799,799,799,799
|
||||
</chunk>
|
||||
<chunk x="16" y="-16" width="16" height="16">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
799,799,799,799,799,799,799,799,799,799,799,799,799,799,799,799
|
||||
</chunk>
|
||||
<chunk x="32" y="-16" width="16" height="16">
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,799,0,0,0,0,0,
|
||||
799,799,799,799,799,799,799,799,799,799,799,0,0,0,0,0
|
||||
</chunk>
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="2" name="Слой объектов 1" class="LivingEntities">
|
||||
<object id="1" name="DEBUGUS" type="Player" x="293.333" y="-126.667">
|
||||
<point/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="3" name="Слой объектов 2" class="LivingEntities.Monsters">
|
||||
<object id="2" type="SilasMaster" x="82.6667" y="-186.667">
|
||||
<point/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
</map>
|
|
@ -752,7 +752,7 @@
|
|||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="10" name="Player" class="LivingEntities.Player">
|
||||
<object id="47" x="-525" y="461.333">
|
||||
<object id="47" x="-500" y="461.333">
|
||||
<point/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="5" name="Zombies" class="LivingEntities.Monsters.Spider">
|
||||
<object id="4" x="1" y="100">
|
||||
<object id="4" x="-80" y="100">
|
||||
<point/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
|
|
|
@ -20,7 +20,6 @@ public abstract class AbstractGui : IDrawableObject
|
|||
public virtual void Initialize()
|
||||
{
|
||||
Manager.Initialize(AppManager.Instance.GraphicsDevice);
|
||||
this.graphicsDevice = graphicsDevice;
|
||||
CreateUI();
|
||||
}
|
||||
|
||||
|
@ -31,7 +30,7 @@ public abstract class AbstractGui : IDrawableObject
|
|||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
Manager.Update();
|
||||
Manager.Update(gameTime);
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
private SpriteFont _spriteFont;
|
||||
private Dictionary<string, string> _text = new();
|
||||
private List<string> _log = new();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
@ -27,10 +28,11 @@ namespace DangerousD.GameCore.GUI
|
|||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList());
|
||||
spriteBatch.Begin();
|
||||
spriteBatch.DrawString(
|
||||
_spriteFont,
|
||||
Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()),
|
||||
keysString,
|
||||
new Vector2(10, 10),
|
||||
Color.Cyan,
|
||||
0,
|
||||
|
@ -39,6 +41,17 @@ namespace DangerousD.GameCore.GUI
|
|||
SpriteEffects.None,
|
||||
0
|
||||
);
|
||||
spriteBatch.DrawString(
|
||||
_spriteFont,
|
||||
Join("\n", _log),
|
||||
new Vector2(10, 10 + _spriteFont.MeasureString(keysString).Y),
|
||||
Color.Green,
|
||||
0,
|
||||
Vector2.Zero,
|
||||
1,
|
||||
SpriteEffects.None,
|
||||
0
|
||||
);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
|
@ -46,5 +59,14 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
_text[key] = value;
|
||||
}
|
||||
|
||||
public void Log(string value)
|
||||
{
|
||||
_log.Add(value);
|
||||
if (_log.Count > 30)
|
||||
{
|
||||
_log.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
using DangerousD.GameCore.Managers;
|
||||
using Microsoft.VisualBasic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DangerousD.GameCore.GUI;
|
||||
|
@ -11,6 +14,12 @@ namespace DangerousD.GameCore.GUI;
|
|||
internal class MenuGUI : AbstractGui
|
||||
{
|
||||
int selected = 0;
|
||||
Color[] colors = new Color[] { new Color(64, 53, 51), new Color(84, 58, 52),
|
||||
new Color(170, 101, 63), new Color(254, 208, 116), new Color(252, 231, 124) };
|
||||
List<Label> MainLetterLabels = new List<Label>();
|
||||
List<Label> BigLetterLabels = new List<Label>();
|
||||
List<Vector2> MainLetterPositions = new List<Vector2>();
|
||||
List<Vector2> BigLetterPositions = new List<Vector2>();
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int wigth = AppManager.Instance.inGameResolution.X;
|
||||
|
@ -20,16 +29,20 @@ internal class MenuGUI : AbstractGui
|
|||
Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
Color[] colors = new Color[] { new Color(64, 53, 51), new Color(84, 58, 52),
|
||||
new Color(170, 101, 63), new Color(254, 208, 116), new Color(252, 231, 124) };
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 - 60, 200, 50, 50), text = "Dangerous", mainColor = Color.Transparent, scale = 1.35f - 0.05f * i * i / 10, fontName = "Font2", fontColor = colors[i] });
|
||||
{
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 - 60, 220, 50, 50), text = "Dangerous", mainColor = Color.Transparent, scale = 1.35f - 0.05f * i * i / 10, fontName = "Font2", fontColor = colors[i] });
|
||||
MainLetterLabels.Add(Elements.Last() as Label);
|
||||
MainLetterPositions.Add(new Vector2(Elements.Last().rectangle.X, Elements.Last().rectangle.Y));
|
||||
}
|
||||
|
||||
int dx = 50;
|
||||
Color[] colors2 = new Color[] { new Color(64, 53, 51), new Color(84, 58, 52),
|
||||
new Color(170, 101, 63), new Color(254, 208, 116), new Color(252, 231, 124) };
|
||||
for (int i = 0; i < colors2.Length; i++)
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 + 480 + dx - i * i, 260 - i * i / 5, 50, 50), text = "D", mainColor = Color.Transparent, scale = 2.15f - 0.05f * i * i / 5, fontName = "Font2", fontColor = colors2[i] });
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
{
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 + 480 + dx - i * i, 260 - i * i / 5, 50, 50), text = "D", mainColor = Color.Transparent, scale = 2.15f - 0.05f * i * i / 5, fontName = "Font2", fontColor = colors[i] });
|
||||
BigLetterLabels.Add(Elements.Last() as Label);
|
||||
BigLetterPositions.Add(new Vector2(Elements.Last().rectangle.X, Elements.Last().rectangle.Y));
|
||||
}
|
||||
|
||||
var butSingle = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(300 * 2.4)) / 2, 350, (int)(300 * 2.4), (int)(50 * 2.4)), text = "Singleplayer", scale = 1.2f, fontName = "ButtonFont" };
|
||||
Elements.Add(butSingle);
|
||||
|
@ -61,8 +74,27 @@ internal class MenuGUI : AbstractGui
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
for (int i = 0; i < MainLetterLabels.Count; i++)
|
||||
{
|
||||
MainLetterLabels[i].fontColor = Color.FromNonPremultiplied(colors[i].ToVector4() *
|
||||
(float)(((Math.Sin(gameTime.TotalGameTime.TotalSeconds * 4) + 1) / 2f) * 0.3 + 0.8f)
|
||||
);
|
||||
BigLetterLabels[i].fontColor = Color.FromNonPremultiplied(colors[i].ToVector4()
|
||||
* (float)(((Math.Sin(gameTime.TotalGameTime.TotalSeconds * 4 - Math.PI) + 1) / 2f) * 0.3 + 0.8f)
|
||||
);
|
||||
MainLetterLabels[i].fontColor.A = 255;
|
||||
BigLetterLabels[i].fontColor.A = 255;
|
||||
MainLetterLabels[i].rectangle.Y = (int)(MainLetterPositions[i].Y +
|
||||
(20 * (Math.Sin(gameTime.TotalGameTime.TotalSeconds * 4) + 1) / 2f * 0.25) * (i - MainLetterLabels.Count / 2)
|
||||
);
|
||||
BigLetterLabels[i].rectangle.Y = (int)(BigLetterPositions[i].Y +
|
||||
(20 * (Math.Sin(gameTime.TotalGameTime.TotalSeconds * 4 - Math.PI) + 1) / 2f * 0.25) * (i - MainLetterLabels.Count / 2)
|
||||
);
|
||||
|
||||
}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
37
DangerousD/GameCore/GameObjects/Entities/Door.cs
Normal file
37
DangerousD/GameCore/GameObjects/Entities/Door.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||
using DangerousD.GameCore.Graphics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DangerousD.GameCore.GameObjects.Entities
|
||||
{
|
||||
public class Door : Entity
|
||||
{
|
||||
public Door(Vector2 position) : base(position)
|
||||
{
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SilasBallMove" }, "SilasBallMove");
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
|
||||
}
|
||||
public override void OnCollision(GameObject gameObject)
|
||||
{
|
||||
base.OnCollision(gameObject);
|
||||
if (gameObject is Player)
|
||||
{
|
||||
Player player = (Player)gameObject;
|
||||
if (player.isUping)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,20 +12,22 @@ namespace DangerousD.GameCore.GameObjects.Entities
|
|||
{
|
||||
public class SilasBall : LivingEntity
|
||||
{
|
||||
private bool IsVisibility=true;
|
||||
|
||||
private Vector2 v;
|
||||
public SilasBall(Vector2 position) : base(position)
|
||||
{
|
||||
Height = 60;
|
||||
Width = 60;
|
||||
Height = 24;
|
||||
Width = 24;
|
||||
acceleration = Vector2.Zero;
|
||||
|
||||
}
|
||||
public SilasBall(Vector2 position, Vector2 velosity) : base(position)
|
||||
{
|
||||
Height = 60;
|
||||
Width = 60;
|
||||
Height = 24;
|
||||
Width = 24;
|
||||
acceleration = Vector2.Zero;
|
||||
velocity = velosity;
|
||||
v = velosity;
|
||||
|
||||
}
|
||||
|
||||
|
@ -33,17 +35,17 @@ namespace DangerousD.GameCore.GameObjects.Entities
|
|||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(Rectangle).Count>0)
|
||||
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle( new Rectangle(Rectangle.X-2,Rectangle.Y-2,Rectangle.Width+8,Rectangle.Height+8)).Count>0)
|
||||
{
|
||||
IsVisibility = false;
|
||||
AppManager.Instance.GameManager.Remove(this);
|
||||
}
|
||||
velocity = v;
|
||||
}
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (IsVisibility)
|
||||
{
|
||||
|
||||
base.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
36
DangerousD/GameCore/GameObjects/Entities/Trigger.cs
Normal file
36
DangerousD/GameCore/GameObjects/Entities/Trigger.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
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.Entities
|
||||
{
|
||||
internal class Trigger : Entity
|
||||
{
|
||||
public Action<GameObject> OnCollisionAction;
|
||||
string trigger_Name;
|
||||
public Trigger(Rectangle rectangle, string trigger_Name) : base(new Vector2(rectangle.X, rectangle.Y))
|
||||
{
|
||||
_pos = new Vector2(rectangle.X, rectangle.Y);
|
||||
Width = rectangle.Width;
|
||||
Height = rectangle.Height;
|
||||
this.trigger_Name = trigger_Name;
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent => new GraphicsComponent(new List<string>() { "SilasBallMove" }, "SilasBallMove");
|
||||
public override void OnCollision(GameObject gameObject)
|
||||
{
|
||||
OnCollisionAction?.Invoke(gameObject);
|
||||
}
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ namespace DangerousD.GameCore
|
|||
protected Vector2 _pos;
|
||||
public Vector2 Pos => _pos;
|
||||
public int id;
|
||||
public bool isIdFromHost = false;
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height);
|
||||
|
|
|
@ -17,7 +17,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
protected string name;
|
||||
protected bool isAlive = true;
|
||||
protected int leftBoarder = 0;
|
||||
protected int rightBoarder = 700;
|
||||
protected int rightBoarder = 800;
|
||||
protected bool isGoRight;
|
||||
|
||||
public CoreEnemy(Vector2 position) : base(position)
|
||||
{
|
||||
|
@ -31,6 +32,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
public abstract void Death();
|
||||
|
||||
public abstract void Attack();
|
||||
public abstract void Attack(GameTime gameTime);
|
||||
|
||||
public abstract void Move(GameTime gameTime);
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
public class FlameSkull : CoreEnemy
|
||||
{
|
||||
private bool isGoRight;
|
||||
private bool isAttack;
|
||||
|
||||
public FlameSkull(Vector2 position) : base(position)
|
||||
|
@ -74,6 +73,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
internal class Frank : CoreEnemy
|
||||
{
|
||||
private bool isGoRight;
|
||||
|
||||
public Frank(Vector2 position) : base(position)
|
||||
{
|
||||
isGoRight = false;
|
||||
|
||||
Width = 112;
|
||||
Height = 160;
|
||||
leftBoarder = 50;
|
||||
|
@ -72,7 +69,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
private Rectangle collision;
|
||||
private Vector2 position;
|
||||
private int healthBall;
|
||||
private bool isFlyRight = true;
|
||||
private bool isAttacking = false;
|
||||
|
||||
|
@ -81,13 +80,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
velocity.Y -= monster_speed;
|
||||
}
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public void Target()
|
||||
{
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
public class Ghost : CoreEnemy
|
||||
{
|
||||
private bool isGoRight;
|
||||
private bool isAttack;
|
||||
|
||||
public Ghost(Vector2 position) : base(position)
|
||||
|
@ -79,7 +78,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -10,13 +10,14 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||
{
|
||||
public class SilasHands : CoreEnemy
|
||||
public class
|
||||
SilasHands : CoreEnemy
|
||||
{
|
||||
public SilasHands(Vector2 position) : base(position)
|
||||
{
|
||||
name = "SilasHand";
|
||||
Width = 48;
|
||||
Height = 48;
|
||||
Width = 16;
|
||||
Height = 16;
|
||||
monster_health = 2;
|
||||
monster_speed = 2;
|
||||
acceleration = Vector2.Zero;
|
||||
|
@ -30,9 +31,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Death()
|
||||
|
|
|
@ -16,7 +16,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
private int attackTime = 60;
|
||||
private int moveTime = 360;
|
||||
private int currentTime = 0;
|
||||
private bool isGoRight = true;
|
||||
int leftBorder;
|
||||
int rightBorder;
|
||||
List<SilasHands> hands = new List<SilasHands>();
|
||||
|
@ -24,21 +23,17 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
public SilasMaster(Vector2 position) : base(position)
|
||||
{
|
||||
name = "SilasMaster";
|
||||
Width = 144;
|
||||
Height = 160;
|
||||
Width = 48;
|
||||
Height = 53;
|
||||
monster_health = 15;
|
||||
monster_speed = 4;
|
||||
monster_speed = 2;
|
||||
acceleration = Vector2.Zero;
|
||||
leftBorder = (int)position.X - 60;
|
||||
rightBorder = (int)position.X + 120;
|
||||
acceleration = Vector2.Zero;
|
||||
hands.Add(new SilasHands(new Vector2(Pos.X+60,Pos.Y+120)));
|
||||
hands.Add(new SilasHands(new Vector2(Pos.X + 90, Pos.Y + 120)));
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
SilasBall silasball = new SilasBall(new Vector2(Pos.X + i * 40, Pos.Y + 120), new Vector2((i - 2) * 4, 6));
|
||||
balls.Add(silasball);
|
||||
}
|
||||
hands.Add(new SilasHands(new Vector2(Pos.X+0,Pos.Y+53)));
|
||||
hands.Add(new SilasHands(new Vector2(Pos.X + 24, Pos.Y + 53)));
|
||||
|
||||
}
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List<string>() { "SilasMove", "SilasAttack" }, "SilasMove");
|
||||
public override void Attack()
|
||||
|
@ -64,15 +59,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
private void SpawnAttackBall()
|
||||
{
|
||||
for (int i = 0; i < balls.Count; i++)
|
||||
balls.Clear();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
balls[i].SetPosition(new Vector2(Pos.X + i * 40, Pos.Y + 120));
|
||||
SilasBall silasball = new SilasBall(new Vector2(Pos.X + i * 12, Pos.Y + 53), new Vector2((i - 2) * 2, 2));
|
||||
|
||||
balls.Add(silasball);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
public class Slime : CoreEnemy
|
||||
{
|
||||
private bool isGoRight = true;
|
||||
private bool isDown = false;
|
||||
int leftBorder;
|
||||
int rightBorder;
|
||||
|
@ -238,7 +237,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using DangerousD.GameCore.Graphics;
|
||||
using DangerousD.GameCore.GameObjects.MapObjects;
|
||||
using DangerousD.GameCore.Graphics;
|
||||
using DangerousD.GameCore.Managers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
@ -12,7 +14,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
public class Spider : CoreEnemy
|
||||
{
|
||||
private bool isGoRight;
|
||||
private bool isAttack;
|
||||
|
||||
protected SpiderWeb web;
|
||||
|
@ -20,19 +21,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
protected int webLength;
|
||||
protected bool isDown;
|
||||
protected bool isDownUp;
|
||||
protected PhysicsManager physicsManager;
|
||||
protected Player player;
|
||||
|
||||
public Spider(Vector2 position) : base(position)
|
||||
{
|
||||
player = AppManager.Instance.GameManager.players[0];
|
||||
isDownUp = true;
|
||||
isDown = true;
|
||||
physicsManager = AppManager.Instance.GameManager.physicsManager;
|
||||
web = new SpiderWeb(Pos);
|
||||
name = "Spider";
|
||||
Width = 112;
|
||||
Height = 24;
|
||||
delay = 0;
|
||||
webLength = 0;
|
||||
monster_speed = 2;
|
||||
acceleration = Vector2.Zero;
|
||||
monster_speed = 3;
|
||||
acceleration = new Vector2(0, -50);
|
||||
isGoRight = true;
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SpiderMoveRight", "SpiderMoveLeft", "SpiderOnWeb" }, "SpiderMoveRight");
|
||||
|
@ -47,6 +53,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
Attack(gameTime);
|
||||
}
|
||||
Target();
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
@ -60,20 +67,22 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
/// Атака паука РАБОЧАЯ
|
||||
/// </summary>
|
||||
/// <param name="gameTime"></param>
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{ //48 72
|
||||
if (isDownUp)
|
||||
velocity.X = 0;
|
||||
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if (isAttack)
|
||||
{
|
||||
if (delay > 0.5 && webLength <= 4 && isDown)
|
||||
{
|
||||
Width = 48;
|
||||
Height = 72;
|
||||
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if (delay > 0.5 && webLength <= 4 && isDown)
|
||||
{
|
||||
StartCicycleAnimation("SpiderOnWeb");
|
||||
acceleration = Vector2.Zero;
|
||||
webLength++;
|
||||
_pos.Y += 25;
|
||||
web.Height = webLength * 25;
|
||||
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
|
||||
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength));
|
||||
delay = 0;
|
||||
if (webLength == 4)
|
||||
{
|
||||
|
@ -82,24 +91,36 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
else if (delay > 0.5 && webLength != 0 && !isDown)
|
||||
{
|
||||
Width = 48;
|
||||
Height = 72;
|
||||
StartCicycleAnimation("SpiderOnWeb");
|
||||
webLength--;
|
||||
_pos.Y -= 25;
|
||||
web.Height = webLength * 25;
|
||||
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
|
||||
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength));
|
||||
delay = 0;
|
||||
if (webLength == 0)
|
||||
{
|
||||
isDown = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
var entitiesInter = physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 200, 600));
|
||||
if (entitiesInter.Count > 0)
|
||||
{
|
||||
Width = 112;
|
||||
Height = 24;
|
||||
foreach (var entity in entitiesInter)
|
||||
{
|
||||
if (entity.GetType() == typeof(Player))
|
||||
{
|
||||
player.Death(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (webLength == 0)
|
||||
{
|
||||
isAttack = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
|
@ -121,6 +142,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
Width = 112;
|
||||
Height = 24;
|
||||
foreach (var entity in physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 7, (int)Pos.Y, 126, 10)))
|
||||
{
|
||||
if (entity.GetType() == typeof(StopTile))
|
||||
{
|
||||
isGoRight = !isGoRight;
|
||||
}
|
||||
}
|
||||
if (isGoRight)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SpiderMoveRight")
|
||||
|
@ -137,19 +167,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
velocity.X = -monster_speed;
|
||||
}
|
||||
if (Pos.X >= rightBoarder)
|
||||
{
|
||||
isGoRight = false;
|
||||
}
|
||||
else if (Pos.X <= leftBoarder)
|
||||
{
|
||||
isGoRight = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (player.Pos.X >= Pos.X && player.Pos.X <= Pos.X+Width)
|
||||
{
|
||||
isAttack = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
public class Werewolf : CoreEnemy
|
||||
{
|
||||
private bool isGoRight;
|
||||
private bool isAttack;
|
||||
|
||||
public Werewolf(Vector2 position) : base(position)
|
||||
|
@ -73,7 +72,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
public class Zombie : CoreEnemy
|
||||
{
|
||||
private bool isGoRight;
|
||||
private bool isAttack;
|
||||
|
||||
float leftBorder;
|
||||
|
@ -129,6 +128,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
base.OnCollision(gameObject);
|
||||
}
|
||||
|
||||
public void Target()
|
||||
{
|
||||
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)).Count > 0)
|
||||
|
@ -159,8 +159,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
rightBorder = 760;
|
||||
}
|
||||
}
|
||||
|
||||
public void Attack(GameTime gameTime)
|
||||
public override void Attack(GameTime gameTime)
|
||||
{}
|
||||
|
||||
public void TakeDamage()
|
||||
|
|
|
@ -28,20 +28,27 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
private bool isAttacked = false;
|
||||
private bool isShooting = false;
|
||||
public GameObject objectAttack;
|
||||
public bool isInvincible;
|
||||
private int bullets;
|
||||
public bool FallingThroughPlatform = false;
|
||||
public bool isUping = false;
|
||||
|
||||
|
||||
|
||||
public int Bullets { get { return bullets; } }
|
||||
|
||||
public Player(Vector2 position) : base(position)
|
||||
public Player(Vector2 position, bool isNetworkPlayer = false) : base(position)
|
||||
|
||||
{
|
||||
Width = 16;
|
||||
Height = 32;
|
||||
|
||||
if (!isNetworkPlayer)
|
||||
{
|
||||
AppManager.Instance.InputManager.ShootEvent += Shoot;
|
||||
|
||||
AppManager.Instance.InputManager.MovEventJump += Jump;
|
||||
AppManager.Instance.InputManager.MovEventDown += MoveDown;
|
||||
AppManager.Instance.InputManager.ShootEvent += Shoot;
|
||||
}
|
||||
|
||||
velocity = new Vector2(0, 0);
|
||||
rightBorder = (int)position.X + 100;
|
||||
|
@ -87,6 +94,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
}
|
||||
public void Death(string monsterName)
|
||||
{
|
||||
return; //godmode
|
||||
isAttacked = true;
|
||||
if(monsterName == "Zombie")
|
||||
{
|
||||
|
@ -99,6 +107,17 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
}
|
||||
};
|
||||
}
|
||||
else if(monsterName == "Spider")
|
||||
{
|
||||
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
|
||||
deathRectangle.Gr.actionOfAnimationEnd += (a) =>
|
||||
{
|
||||
if (a == "DeathFrom" + monsterName)
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Death);
|
||||
}
|
||||
};
|
||||
}
|
||||
isAlive = false;
|
||||
}
|
||||
public void Jump()
|
||||
|
@ -154,8 +173,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
}
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (AppManager.Instance.InputManager.ScopeState==ScopeState.Up)
|
||||
{
|
||||
isUping = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isUping = false;
|
||||
}
|
||||
if (isOnGround && FallingThroughPlatform)
|
||||
{
|
||||
FallingThroughPlatform = false;
|
||||
AppManager.Instance.DebugHUD.Log("not falling");
|
||||
}
|
||||
GraphicsComponent.SetCameraPosition(Pos);
|
||||
if (!isAttacked)
|
||||
if (!isAttacked || isInvincible)
|
||||
{
|
||||
Move(gameTime);
|
||||
}
|
||||
|
@ -215,8 +247,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
}
|
||||
public void MoveDown()
|
||||
{
|
||||
// ПОЧЕМУ
|
||||
velocity.Y = -11;
|
||||
FallingThroughPlatform = true;
|
||||
isOnGround = false;
|
||||
AppManager.Instance.DebugHUD.Log("FallingThroughPlatform");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ public abstract class LivingEntity : Entity
|
|||
public bool isOnGround = true;
|
||||
public Vector2 velocity;
|
||||
public Vector2 acceleration;
|
||||
|
||||
public LivingEntity(Vector2 position) : base(position)
|
||||
{
|
||||
acceleration = new Vector2(0, 30);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using DangerousD.GameCore.Managers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
@ -16,7 +17,7 @@ namespace DangerousD.GameCore.Graphics
|
|||
private List<Texture2D> textures;
|
||||
private List<string> texturesNames;
|
||||
private AnimationContainer currentAnimation;
|
||||
static private int scaling=3;
|
||||
static private int scaling = 4;
|
||||
public AnimationContainer CurrentAnimation
|
||||
{
|
||||
get
|
||||
|
@ -238,6 +239,23 @@ namespace DangerousD.GameCore.Graphics
|
|||
CameraPosition = (playerPosition).ToPoint();
|
||||
CameraPosition.X -= 300;
|
||||
CameraPosition.Y -= 200;
|
||||
if (CameraPosition.X < AppManager.Instance.GameManager.CameraBorder.X)
|
||||
{
|
||||
CameraPosition.X = (int)AppManager.Instance.GameManager.CameraBorder.X;
|
||||
}
|
||||
if (CameraPosition.X > AppManager.Instance.GameManager.CameraBorder.Y - 460)
|
||||
{
|
||||
CameraPosition.X = (int)AppManager.Instance.GameManager.CameraBorder.Y - 460;
|
||||
}
|
||||
if (CameraPosition.Y < AppManager.Instance.GameManager.CameraBorder.Z)
|
||||
{
|
||||
CameraPosition.Y = (int)AppManager.Instance.GameManager.CameraBorder.Z;
|
||||
}
|
||||
if (CameraPosition.Y > AppManager.Instance.GameManager.CameraBorder.W - 470)
|
||||
{
|
||||
CameraPosition.Y = (int)AppManager.Instance.GameManager.CameraBorder.W - 470;
|
||||
}
|
||||
AppManager.Instance.DebugHUD.Set("CameraPosition", $"{CameraPosition.X}, {CameraPosition.Y}");
|
||||
}
|
||||
public static Point CameraPosition = new Point(-700, 300);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ using MonogameLibrary.UI.Base;
|
|||
using DangerousD.GameCore.Managers;
|
||||
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||
using DangerousD.GameCore.GameObjects;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DangerousD.GameCore
|
||||
{
|
||||
|
@ -111,6 +112,8 @@ namespace DangerousD.GameCore
|
|||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
Exit();
|
||||
|
||||
if (GameManager.GetPlayer1 != null)
|
||||
DebugHUD.Set("Objid: ", GameManager.GetPlayer1.id.ToString());
|
||||
InputManager.Update();
|
||||
SoundManager.Update();
|
||||
|
||||
|
@ -203,6 +206,7 @@ namespace DangerousD.GameCore
|
|||
break;
|
||||
case GameState.Game:
|
||||
GameManager.mapManager.LoadLevel("lvl");
|
||||
GameManager.FindBorders();
|
||||
break;
|
||||
case GameState.Death:
|
||||
break;
|
||||
|
@ -225,24 +229,41 @@ namespace DangerousD.GameCore
|
|||
case NetworkTaskOperationEnum.CreateEntity:
|
||||
break;
|
||||
case NetworkTaskOperationEnum.SendPosition:
|
||||
if (networkTask.objId != GameManager.GetPlayer1.id)
|
||||
{
|
||||
LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId);
|
||||
entity.SetPosition(networkTask.position);
|
||||
if (multiPlayerStatus == MultiPlayerStatus.Host)
|
||||
{
|
||||
NetworkTasks.Add(networkTask);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NetworkTaskOperationEnum.ChangeState:
|
||||
break;
|
||||
case NetworkTaskOperationEnum.ConnectToHost:
|
||||
Player connectedPlayer = new Player(Vector2.Zero);
|
||||
Player connectedPlayer = new Player(Vector2.Zero, true);
|
||||
NetworkTasks.Add(new NetworkTask(connectedPlayer.id));
|
||||
NetworkTask task = new NetworkTask();
|
||||
NetworkTasks.Add(task.AddConnectedPlayer(GameManager.GetPlayer1.id, GameManager.GetPlayer1.Pos));
|
||||
foreach (Player player in GameManager.players)
|
||||
{
|
||||
if (player.id != connectedPlayer.id)
|
||||
{
|
||||
NetworkTasks.Add(task.AddConnectedPlayer(player.id, player.Pos));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NetworkTaskOperationEnum.GetClientPlayerId:
|
||||
if (!GameManager.GetPlayer1.isIdFromHost)
|
||||
{
|
||||
GameManager.GetPlayer1.id = networkTask.objId;
|
||||
GameManager.GetPlayer1.isIdFromHost = true;
|
||||
}
|
||||
break;
|
||||
case NetworkTaskOperationEnum.AddConnectedPlayer:
|
||||
Player remoteConnectedPlayer = new Player(networkTask.position);
|
||||
Player remoteConnectedPlayer = new Player(networkTask.position, true);
|
||||
remoteConnectedPlayer.id = networkTask.objId;
|
||||
GameManager.players.Add(remoteConnectedPlayer);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace DangerousD.GameCore
|
|||
public PhysicsManager physicsManager;
|
||||
public List<Player> players;
|
||||
public List<GameObject> otherObjects = new();
|
||||
|
||||
public Vector4 CameraBorder;
|
||||
public Player GetPlayer1 { get; private set; }
|
||||
public GameManager()
|
||||
{
|
||||
|
@ -42,6 +42,7 @@ namespace DangerousD.GameCore
|
|||
players = new List<Player>();
|
||||
mapManager = new MapManager(1);
|
||||
physicsManager = new PhysicsManager();
|
||||
CameraBorder = Vector4.Zero;
|
||||
|
||||
}
|
||||
|
||||
|
@ -129,7 +130,6 @@ namespace DangerousD.GameCore
|
|||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
AppManager.Instance.DebugHUD.Set("playerId: ", GetPlayer1.id.ToString());
|
||||
if (AppManager.Instance.NetworkTasks.Count > 0)
|
||||
{
|
||||
AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList());
|
||||
|
@ -147,21 +147,43 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
livingEntitiesWithoutPlayers[i].Update(gameTime);
|
||||
}
|
||||
GetPlayer1.Update(gameTime);
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
{
|
||||
for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++)
|
||||
{
|
||||
livingEntitiesWithoutPlayers[i].PlayAnimation();
|
||||
}
|
||||
GetPlayer1.Update(gameTime);
|
||||
}
|
||||
GetPlayer1.Update(gameTime);
|
||||
foreach (var item in otherObjects)
|
||||
item.Update(gameTime);
|
||||
|
||||
physicsManager.UpdateCollisions(entities, livingEntities, mapObjects, gameTime);
|
||||
physicsManager.UpdateCollisions(entities, livingEntities, mapObjects, players, gameTime);
|
||||
}
|
||||
public void FindBorders()
|
||||
{
|
||||
foreach (var item in GetAllGameObjects)
|
||||
{
|
||||
if (item.Pos.X<CameraBorder.X)
|
||||
{
|
||||
CameraBorder.X = item.Pos.X;
|
||||
}
|
||||
if (item.Pos.X > CameraBorder.Y)
|
||||
{
|
||||
CameraBorder.Y = item.Pos.X;
|
||||
}
|
||||
if (item.Pos.Y < CameraBorder.Z)
|
||||
{
|
||||
CameraBorder.Z = item.Pos.X;
|
||||
}
|
||||
if (item.Pos.Y > CameraBorder.W)
|
||||
{
|
||||
CameraBorder.W = item.Pos.X;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -98,9 +98,9 @@ namespace DangerousD.GameCore.Managers
|
|||
new Vector2(float.Parse(entity.Attributes["x"].Value, CultureInfo.InvariantCulture) + offsetX,
|
||||
float.Parse(entity.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY) * _scale;
|
||||
Entity inst;
|
||||
if (type.Equals(typeof(Player)) && entity.Attributes["name"] is not null && entity.Attributes["name"].Value == "DEBUGUS")
|
||||
if (type.Equals(typeof(Player)))
|
||||
{
|
||||
inst = (Entity)Activator.CreateInstance(type, pos, true);
|
||||
inst = (Entity)Activator.CreateInstance(type, pos, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||
using DangerousD.GameCore.GameObjects.MapObjects;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace DangerousD.GameCore.Managers
|
||||
|
@ -13,7 +14,7 @@ namespace DangerousD.GameCore.Managers
|
|||
{
|
||||
|
||||
public void UpdateCollisions(List<Entity> entities, List<LivingEntity> livingEntities,
|
||||
List<MapObject> mapObjects, GameTime gameTime)
|
||||
List<MapObject> mapObjects, List<Player> players, GameTime gameTime)
|
||||
{
|
||||
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
foreach (var item in livingEntities)
|
||||
|
@ -21,7 +22,8 @@ namespace DangerousD.GameCore.Managers
|
|||
item.velocity = item.velocity + item.acceleration * delta;
|
||||
}
|
||||
|
||||
CheckCollisionsLE_MO(livingEntities, mapObjects);
|
||||
CheckCollisionsLE_MO(livingEntities, mapObjects.Where(mo => mo is StopTile).ToList());
|
||||
CheckCollisionsPlayer_Platform(players, mapObjects.OfType<Platform>().ToList());
|
||||
CheckCollisionsE_LE(entities, livingEntities);
|
||||
CheckCollisionsLE_LE(livingEntities);
|
||||
|
||||
|
@ -75,6 +77,7 @@ namespace DangerousD.GameCore.Managers
|
|||
if (currentEntity is Player)
|
||||
{
|
||||
AppManager.Instance.DebugHUD.Set("velocity", currentEntity.velocity.ToString());
|
||||
AppManager.Instance.DebugHUD.Set("falling", (currentEntity as Player).FallingThroughPlatform.ToString());
|
||||
AppManager.Instance.DebugHUD.Set("intersects y", "");
|
||||
}
|
||||
foreach (var mapObject in mapObjects)
|
||||
|
@ -100,6 +103,42 @@ namespace DangerousD.GameCore.Managers
|
|||
currentEntity.SetPosition(new Vector2(newRect.X, newRect.Y));
|
||||
}
|
||||
|
||||
}
|
||||
private void CheckCollisionsPlayer_Platform(List<Player> players, List<Platform> platforms)
|
||||
{
|
||||
foreach (var player in players)
|
||||
{
|
||||
if (player.velocity.Y <= 0 || player.FallingThroughPlatform)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var currentRect = player.Rectangle;
|
||||
var newRect = currentRect;
|
||||
|
||||
var collidedY = false;
|
||||
var tryingRectY = currentRect;
|
||||
tryingRectY.Offset(0, (int)Math.Ceiling(player.velocity.Y));
|
||||
AppManager.Instance.DebugHUD.Set("intersects platform", "false");
|
||||
foreach (var platform in platforms)
|
||||
{
|
||||
if (tryingRectY.Intersects(platform.Rectangle))
|
||||
{
|
||||
AppManager.Instance.DebugHUD.Set("intersects platform", "true");
|
||||
collidedY = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (collidedY)
|
||||
{
|
||||
// костыль потому что в CheckCollisionsLE_MO он спускается
|
||||
newRect.Y -= (int)Math.Ceiling(player.velocity.Y);
|
||||
player.isOnGround = true;
|
||||
player.velocity.Y = 0;
|
||||
}
|
||||
|
||||
player.SetPosition(new Vector2(newRect.X, newRect.Y));
|
||||
}
|
||||
|
||||
}
|
||||
private void CheckCollisionsE_LE(List<Entity> entities, List<LivingEntity> livingEntities)
|
||||
{
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace DangerousD.GameCore
|
|||
|
||||
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
|
||||
{
|
||||
return;
|
||||
var sound = new Sound(Sounds[soundName]);
|
||||
sound.SoundEffect.IsLooped = false;
|
||||
sound.SoundEffect.Play();
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace DangerousD.GameCore.Network
|
|||
}
|
||||
catch { }
|
||||
}
|
||||
public void SendMsg(List<NetworkTask> networkTask)
|
||||
public void SendMsg(List<NetworkTask> networkTask, Socket ignoreSocket = null)
|
||||
{
|
||||
byte[] Data = Encoding.Unicode.GetBytes(JsonConvert.SerializeObject(networkTask));
|
||||
int count = Data.Length;
|
||||
|
@ -100,11 +100,14 @@ namespace DangerousD.GameCore.Network
|
|||
try
|
||||
{
|
||||
foreach (Socket socket in clientSockets)
|
||||
{
|
||||
if (!(socket == ignoreSocket))
|
||||
{
|
||||
socket.Send(BitConverter.GetBytes(count));
|
||||
socket.Send(Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
else
|
||||
|
@ -148,7 +151,8 @@ namespace DangerousD.GameCore.Network
|
|||
}
|
||||
else
|
||||
{
|
||||
GetReceivingMessages(JsonConvert.DeserializeObject<List<NetworkTask>>(so.sb.ToString()));
|
||||
List<NetworkTask> tasks = JsonConvert.DeserializeObject<List<NetworkTask>>(so.sb.ToString());
|
||||
GetReceivingMessages(tasks);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
|
|
@ -51,8 +51,10 @@ namespace MonogameLibrary.UI.Base
|
|||
}
|
||||
}
|
||||
}
|
||||
public void Update()
|
||||
public GameTime gameTime;
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
this.gameTime = gameTime;
|
||||
try
|
||||
{
|
||||
keyboardState = Keyboard.GetState();
|
||||
|
|
|
@ -16,22 +16,57 @@ namespace MonogameLibrary.UI.Elements
|
|||
public ButtonText(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
||||
{
|
||||
}
|
||||
float gameTime = 0;
|
||||
public override bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
{
|
||||
gameTime += (float)Manager.gameTime.ElapsedGameTime.TotalSeconds;
|
||||
return base.InteractUpdate(mouseState, prevmouseState);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch _spriteBatch)
|
||||
{
|
||||
if (hoverState == HoverState.None)
|
||||
{
|
||||
fontColor = Color.White;
|
||||
var d = (float)(((Math.Sin(gameTime * 2 - Math.PI) + 1) / 2f) * 0.1 + 0.7f);
|
||||
fontColor = Color.FromNonPremultiplied(new Vector4(0.8f,0.15f, 0.15f, 1) * d
|
||||
);
|
||||
}
|
||||
else if (hoverState == HoverState.Hovering)
|
||||
{
|
||||
fontColor = new Color(211, 211, 211);
|
||||
var d2 = (float)(((Math.Sin(gameTime * 2 - Math.PI) + 1) / 2f) * 0.1 + 0.7f);
|
||||
fontColor = Color.FromNonPremultiplied(new Vector4(0.8f, 0.15f, 0.15f, 1) * d2
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
fontColor = new Color(112, 128, 144);
|
||||
//fontColor = new Color(112, 128, 144);
|
||||
fontColor = new Color(212, 228, 244);
|
||||
}
|
||||
|
||||
if (hoverState == HoverState.Hovering)
|
||||
{
|
||||
int kk = 50;
|
||||
scale += 0.005f;
|
||||
var d = (float)(((Math.Sin(gameTime * 1 - Math.PI) + 1) / 2f) * 0.1 + 1f);
|
||||
Color oldColor = fontColor;
|
||||
fontColor = Color.FromNonPremultiplied(new Vector4(252 / 255f, 231 / 255f, 124 / 255f, 1) * d
|
||||
);
|
||||
DrawText(_spriteBatch);
|
||||
fontColor = oldColor;
|
||||
fontColor.A = 255;
|
||||
scale -= 0.005f;
|
||||
scale -= 0.0002f;
|
||||
}
|
||||
if (hoverState == HoverState.Pressing)
|
||||
{
|
||||
scale -= 0.025f;
|
||||
DrawText(_spriteBatch);
|
||||
scale += 0.025f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawText(_spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,10 @@ namespace MonogameLibrary.UI.Elements
|
|||
}
|
||||
protected HoverState hoverState = HoverState.None;
|
||||
|
||||
float gameTime = 0;
|
||||
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
{
|
||||
gameTime += (float)Manager.gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if (rectangle.Intersects(new Rectangle(mouseState.Position, Point.Zero)))
|
||||
{
|
||||
if (mouseState.LeftButton == ButtonState.Pressed)
|
||||
|
|
Loading…
Add table
Reference in a new issue