Network Fix 2.0
This commit is contained in:
commit
a1adb49918
21 changed files with 332 additions and 67 deletions
|
@ -14,14 +14,7 @@
|
||||||
|
|
||||||
#---------------------------------- Content ---------------------------------#
|
#---------------------------------- Content ---------------------------------#
|
||||||
|
|
||||||
#begin ButtonFont.spritefont
|
#begin MonstersAnimations.png
|
||||||
/importer:FontDescriptionImporter
|
|
||||||
/processor:FontDescriptionProcessor
|
|
||||||
/processorParam:PremultiplyAlpha=True
|
|
||||||
/processorParam:TextureFormat=Compressed
|
|
||||||
/build:ButtonFont.spritefont
|
|
||||||
|
|
||||||
#begin checkboxs_off-on.png
|
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
/processorParam:ColorKeyColor=255,0,255,255
|
/processorParam:ColorKeyColor=255,0,255,255
|
||||||
|
@ -259,7 +252,19 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:textboxbackground6-1.png
|
/build:textboxbackground6-1.png
|
||||||
|
|
||||||
#begin tiles.png
|
#begin MonstersAnimations.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:MonstersAnimations.png
|
||||||
|
|
||||||
|
#begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
/processorParam:ColorKeyColor=255,0,255,255
|
/processorParam:ColorKeyColor=255,0,255,255
|
||||||
|
@ -271,6 +276,18 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:tiles.png
|
/build:tiles.png
|
||||||
|
|
||||||
|
#begin playerAnimation.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:playerAnimation.png
|
||||||
|
|
||||||
#begin wall.jpg
|
#begin wall.jpg
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
|
1
DangerousD/Content/animations/HunchmanAttackLeft
Normal file
1
DangerousD/Content/animations/HunchmanAttackLeft
Normal file
|
@ -0,0 +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"}
|
1
DangerousD/Content/animations/HunchmanAttackRight
Normal file
1
DangerousD/Content/animations/HunchmanAttackRight
Normal file
|
@ -0,0 +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"}
|
1
DangerousD/Content/animations/HunchmanMoveLeft
Normal file
1
DangerousD/Content/animations/HunchmanMoveLeft
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"HunchmanMoveLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":124,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
|
3
DangerousD/Content/animations/HunchmanMoveRight
Normal file
3
DangerousD/Content/animations/HunchmanMoveRight
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
{"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"}
|
||||||
|
|
1
DangerousD/Content/animations/playerJumpLeft
Normal file
1
DangerousD/Content/animations/playerJumpLeft
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"playerJumpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":101,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"0, 0"}
|
1
DangerousD/Content/animations/playerJumpRight
Normal file
1
DangerousD/Content/animations/playerJumpRight
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"playerJumpRight","textureName":"playerAnimation","startSpriteRectangle":{"X":126,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"0, 0"}
|
20
DangerousD/Content/animations/playerMoveLeft
Normal file
20
DangerousD/Content/animations/playerMoveLeft
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"id": "playerMoveLeft",
|
||||||
|
"textureName": "playerAnimation",
|
||||||
|
"startSpriteRectangle": {
|
||||||
|
"X": 26,
|
||||||
|
"Y": 34,
|
||||||
|
"Width": 24,
|
||||||
|
"Height": 32
|
||||||
|
},
|
||||||
|
"frameSecond": [
|
||||||
|
{
|
||||||
|
"Item1": 0,
|
||||||
|
"Item2": 8
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"textureFrameInterval": 1,
|
||||||
|
"framesCount": 4,
|
||||||
|
"isCycle": true,
|
||||||
|
"offset": "0, 0"
|
||||||
|
}
|
20
DangerousD/Content/animations/playerMoveRight
Normal file
20
DangerousD/Content/animations/playerMoveRight
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"id": "playerMoveRight",
|
||||||
|
"textureName": "playerAnimation",
|
||||||
|
"startSpriteRectangle": {
|
||||||
|
"X": 26,
|
||||||
|
"Y": 1,
|
||||||
|
"Width": 24,
|
||||||
|
"Height": 32
|
||||||
|
},
|
||||||
|
"frameSecond": [
|
||||||
|
{
|
||||||
|
"Item1": 0,
|
||||||
|
"Item2": 8
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"textureFrameInterval": 1,
|
||||||
|
"framesCount": 4,
|
||||||
|
"isCycle": true,
|
||||||
|
"offset": "0, 0"
|
||||||
|
}
|
1
DangerousD/Content/animations/playerRightStay
Normal file
1
DangerousD/Content/animations/playerRightStay
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"playerRightStay","textureName":"playerAnimation","startSpriteRectangle":{"X":1,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/playerStayLeft
Normal file
1
DangerousD/Content/animations/playerStayLeft
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"playerStayLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":1,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
BIN
DangerousD/Content/playerAnimation.png
Normal file
BIN
DangerousD/Content/playerAnimation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -1,42 +1,40 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using MonogameLibrary.UI.Base;
|
||||||
using MonogameLibrary.UI.Elements;
|
using MonogameLibrary.UI.Elements;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using DangerousD.GameCore.Managers;
|
||||||
|
using DangerousD.GameCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GUI
|
namespace DangerousD.GameCore.GUI
|
||||||
{
|
{
|
||||||
public class HUD : IDrawableObject
|
public class HUD : AbstractGui
|
||||||
{
|
{
|
||||||
|
int ammout = 0;
|
||||||
|
List<Rect> rects = new List<Rect> { };
|
||||||
public HUD()
|
int wigth = AppManager.Instance.inGameResolution.X;
|
||||||
{
|
int height = AppManager.Instance.inGameResolution.Y;
|
||||||
}
|
protected override void CreateUI()
|
||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch)
|
|
||||||
{
|
{
|
||||||
;
|
DrawableUIElement background = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), mainColor = Color.Transparent };
|
||||||
}
|
Elements.Add(background);
|
||||||
|
Rect rect = new Rect(Manager) { rectangle = new Rectangle(wigth / 35, height / 35, 120, 70), mainColor = Color.DarkRed };
|
||||||
public void Initialize(GraphicsDevice graphicsDevice)
|
Elements.Add(rect);
|
||||||
{
|
Label label = new Label(Manager) { rectangle = new Rectangle(wigth / 34, height / 30, 120, 20), text = "ammout", fontName = "font2", scale = 0.2f, mainColor = Color.Transparent, fontColor = Color.Black };
|
||||||
throw new NotImplementedException();
|
Elements.Add(label);
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialize()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadContent()
|
|
||||||
{
|
|
||||||
var content = AppManager.Instance.Content;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
public void Update(GameTime gameTime)
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
|
rects.Clear();
|
||||||
|
for (int i = 0; i < ammout; i++)
|
||||||
|
{
|
||||||
|
rects.Add(new Rect(Manager) { rectangle = new Rectangle(wigth / 29 + i * 13, height / 17, 5, 20), mainColor = Color.Yellow });
|
||||||
|
rects[i].LoadTexture(AppManager.Instance.Content);
|
||||||
|
}
|
||||||
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,8 @@ namespace DangerousD.GameCore.GUI
|
||||||
Button bTExit = new Button(Manager)
|
Button bTExit = new Button(Manager)
|
||||||
{ fontName = "Font2", scale = 0.72f, text = "<-", rectangle = new Rectangle(wigth / 30, height / 30, (int)(40 * 2.4), (int)(40 * 2.4)), textureName = "textboxbackground1-1" };
|
{ fontName = "Font2", scale = 0.72f, text = "<-", rectangle = new Rectangle(wigth / 30, height / 30, (int)(40 * 2.4), (int)(40 * 2.4)), textureName = "textboxbackground1-1" };
|
||||||
Elements.Add(bTExit);
|
Elements.Add(bTExit);
|
||||||
bTExit.LeftButtonPressed += () => {
|
bTExit.LeftButtonPressed += () =>
|
||||||
|
{
|
||||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@ using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Authentication.ExtendedProtection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -12,15 +14,71 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class Hunchman : CoreEnemy
|
public class Hunchman : CoreEnemy
|
||||||
{
|
{
|
||||||
|
GameManager gameManager;
|
||||||
|
bool isAttacking;
|
||||||
public Hunchman(Vector2 position) : base(position)
|
public Hunchman(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
Width = 48;
|
||||||
|
Height = 48;
|
||||||
|
monster_speed = -2;
|
||||||
|
monster_health = 1;
|
||||||
|
name = "HunchMan";
|
||||||
|
velocity = new Vector2(monster_speed, 0);
|
||||||
|
gameManager = AppManager.Instance.GameManager;
|
||||||
|
isAttacking = false;
|
||||||
|
isAlive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight");
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string>
|
||||||
|
{ "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveLeft");
|
||||||
|
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
// P.S. Всё в классе можешь смело удалять и переписывать с нуля.
|
||||||
|
gameManager = AppManager.Instance.GameManager;
|
||||||
|
|
||||||
|
if (!isAttacking)
|
||||||
|
{
|
||||||
|
Attack();
|
||||||
|
Move(gameTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
velocity.X = 0;
|
||||||
|
}
|
||||||
|
Death();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void Attack()
|
public override void Attack()
|
||||||
{
|
{
|
||||||
|
GameObject gameObject;
|
||||||
|
foreach (var player in gameManager.players)
|
||||||
|
{
|
||||||
|
if (player.Pos.Y + player.Height >= Pos.Y && player.Pos.Y <= Pos.Y + Height)
|
||||||
|
{
|
||||||
|
gameObject = gameManager.physicsManager.RayCast(this, player);
|
||||||
|
if (gameObject is null)
|
||||||
|
{
|
||||||
|
isAttacking = true;
|
||||||
|
GraphicsComponent.StopAnimation();
|
||||||
|
if (velocity.X > 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackRight")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanAttackRight");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (velocity.X < 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackLeft")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanAttackLeft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Attack(GameTime gameTime)
|
public override void Attack(GameTime gameTime)
|
||||||
|
@ -30,12 +88,45 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
|
if (monster_health <= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
if (gameManager.physicsManager.RayCast(this, new Vector2(Pos.X + Width + 10, Pos.Y + Height)) is not null)
|
||||||
|
{
|
||||||
|
monster_speed *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
velocity.X = monster_speed;
|
||||||
|
|
||||||
|
if (velocity.X > 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanMoveRight");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (velocity.X < 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanMoveLeft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnCollision(GameObject gameObject)
|
||||||
|
{
|
||||||
|
monster_speed *= -1;
|
||||||
|
_pos.X += 5 * monster_speed;
|
||||||
|
Debug.WriteLine("Collision");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Target()
|
public override void Target()
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class Zombie : CoreEnemy
|
public class Zombie : CoreEnemy
|
||||||
{
|
{
|
||||||
private bool isGoRight = true;
|
|
||||||
float leftBorder;
|
float leftBorder;
|
||||||
float rightBorder;
|
float rightBorder;
|
||||||
bool isAttaking = false;
|
bool isAttaking = false;
|
||||||
|
@ -25,9 +24,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
Height = 40;
|
Height = 40;
|
||||||
monster_speed = 3;
|
monster_speed = 3;
|
||||||
name = "Zombie";
|
name = "Zombie";
|
||||||
leftBorder = (int)position.X - 100;
|
leftBorder = (int)position.X - 50;
|
||||||
rightBorder = (int)position.X + 100;
|
rightBorder = (int)position.X + 50;
|
||||||
physicsManager = new PhysicsManager();
|
physicsManager = new PhysicsManager();
|
||||||
|
Random random = new Random();
|
||||||
|
if(random.Next(0, 2) == 0)
|
||||||
|
{
|
||||||
|
isGoRight = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isGoRight = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft");
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft");
|
||||||
|
|
||||||
|
@ -38,7 +46,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
Target();
|
Target();
|
||||||
Move(gameTime);
|
Move(gameTime);
|
||||||
}
|
}
|
||||||
|
fixBorder();
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +58,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack")
|
if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack")
|
||||||
{
|
{
|
||||||
GraphicsComponent.StartAnimation("ZombieAttackRight");
|
GraphicsComponent.StartAnimation("ZombieRightAttack");
|
||||||
}
|
}
|
||||||
AppManager.Instance.GameManager.players[0].Death(name);
|
AppManager.Instance.GameManager.players[0].Death(name);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +79,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
|
||||||
if (isGoRight)
|
if (isGoRight)
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
||||||
|
@ -113,7 +120,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
}
|
}
|
||||||
public override void Target()
|
public override void Target()
|
||||||
{
|
{
|
||||||
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)) != null)
|
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)).Count > 0)
|
||||||
{
|
{
|
||||||
if (isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
|
if (isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
|
||||||
{
|
{
|
||||||
|
@ -130,10 +137,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override void Attack(GameTime gameTime)
|
public void fixBorder()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if(leftBorder <= 0)
|
||||||
|
{
|
||||||
|
leftBorder = 0;
|
||||||
|
}
|
||||||
|
if(rightBorder >= 800)
|
||||||
|
{
|
||||||
|
rightBorder = 760;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Attack(GameTime gameTime)
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath
|
||||||
{
|
{
|
||||||
public DeathRectangle(Vector2 pos, string DeathType) : base(pos)
|
public DeathRectangle(Vector2 pos, string DeathType) : base(pos)
|
||||||
{
|
{
|
||||||
Height = 128;
|
Height = 48;
|
||||||
Width = 128;
|
Width = 48;
|
||||||
PlayDeath(DeathType);
|
PlayDeath(DeathType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
public class Player : LivingEntity
|
public class Player : LivingEntity
|
||||||
{
|
{
|
||||||
bool isAlive = true;
|
bool isAlive = true;
|
||||||
|
bool isRight;
|
||||||
|
string stayAnimation;
|
||||||
bool isJump = false;
|
bool isJump = false;
|
||||||
public int health;
|
public int health;
|
||||||
public bool isGoRight = false;
|
public bool isGoRight = false;
|
||||||
|
@ -22,6 +24,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
public int rightBorder;
|
public int rightBorder;
|
||||||
public int leftBorder;
|
public int leftBorder;
|
||||||
public bool isVisible = true;
|
public bool isVisible = true;
|
||||||
|
private bool isAttacked = false;
|
||||||
public GameObject objectAttack;
|
public GameObject objectAttack;
|
||||||
|
|
||||||
public Player(Vector2 position) : base(position)
|
public Player(Vector2 position) : base(position)
|
||||||
|
@ -31,7 +34,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
|
|
||||||
AppManager.Instance.InputManager.ShootEvent += Shoot;
|
AppManager.Instance.InputManager.ShootEvent += Shoot;
|
||||||
|
|
||||||
AppManager.Instance.InputManager.MovEventJump += AnimationJump;
|
AppManager.Instance.InputManager.MovEventJump += Jump;
|
||||||
AppManager.Instance.InputManager.MovEventDown += MoveDown;
|
AppManager.Instance.InputManager.MovEventDown += MoveDown;
|
||||||
|
|
||||||
velocity = new Vector2(0, 0);
|
velocity = new Vector2(0, 0);
|
||||||
|
@ -39,9 +42,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
leftBorder = (int)position.X - 100;
|
leftBorder = (int)position.X - 100;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsAlive { get { return isAlive; } }
|
public bool IsAlive { get { return isAlive; } }
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack", "DeathFromZombie" }, "ZombieMoveLeft");//TODO: Change to player
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft",
|
||||||
|
"playerJumpRight" , "playerJumpLeft"}, "playerStayLeft");
|
||||||
|
|
||||||
public void Attack()
|
public void Attack()
|
||||||
{
|
{
|
||||||
|
@ -63,20 +68,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
}
|
}
|
||||||
public void Death(string monsterName)
|
public void Death(string monsterName)
|
||||||
{
|
{
|
||||||
/*if(monsterName == "Zombie")
|
isAttacked = true;
|
||||||
|
if(monsterName == "Zombie")
|
||||||
{
|
{
|
||||||
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
|
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
|
||||||
deathRectangle.Gr.actionOfAnimationEnd += (a) =>
|
deathRectangle.Gr.actionOfAnimationEnd += (a) =>
|
||||||
{
|
{
|
||||||
if (a == "DeathFrom" + monsterName)
|
if (a == "DeathFrom" + monsterName)
|
||||||
{
|
{
|
||||||
AppManager.Instance.ChangeGameState(GameState.GameOver);
|
AppManager.Instance.ChangeGameState(GameState.Death);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
isAlive = false;*/
|
isAlive = false;
|
||||||
}
|
}
|
||||||
public void AnimationJump()
|
public void Jump()
|
||||||
{
|
{
|
||||||
if (isOnGround)
|
if (isOnGround)
|
||||||
{
|
{
|
||||||
|
@ -92,8 +98,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
|
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
|
||||||
|
if (!isAttacked)
|
||||||
|
{
|
||||||
|
Move(gameTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
velocity.X = 0;
|
||||||
|
}
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
Move(gameTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Move(GameTime gameTime)
|
public void Move(GameTime gameTime)
|
||||||
|
@ -102,16 +115,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
velocity.X = 5 * AppManager.Instance.InputManager.VectorMovementDirection.X;
|
velocity.X = 5 * AppManager.Instance.InputManager.VectorMovementDirection.X;
|
||||||
if (AppManager.Instance.InputManager.VectorMovementDirection.X > 0)
|
if (AppManager.Instance.InputManager.VectorMovementDirection.X > 0)
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")//идёт направо
|
if (GraphicsComponent.GetCurrentAnimation != "playerMoveRight")//идёт направо
|
||||||
{
|
{
|
||||||
GraphicsComponent.StartAnimation("ZombieMoveRight");
|
GraphicsComponent.StartAnimation("playerMoveRight");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (AppManager.Instance.InputManager.VectorMovementDirection.X < 0)//идёт налево
|
else if (AppManager.Instance.InputManager.VectorMovementDirection.X < 0)//идёт налево
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft")
|
if (GraphicsComponent.GetCurrentAnimation != "playerMoveLeft")
|
||||||
{
|
{
|
||||||
GraphicsComponent.StartAnimation("ZombieMoveLeft");
|
GraphicsComponent.StartAnimation("playerMoveLeft");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит
|
else if(AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит
|
||||||
|
|
|
@ -16,7 +16,9 @@ using DangerousD.GameCore.GameObjects;
|
||||||
namespace DangerousD.GameCore
|
namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
public enum MultiPlayerStatus { SinglePlayer, Host, Client }
|
public enum MultiPlayerStatus { SinglePlayer, Host, Client }
|
||||||
public enum GameState { Menu, Options, Lobby, Game, Login, Death }
|
public enum GameState { Menu, Options, Lobby, Game, Login, Death, HUD,
|
||||||
|
GameOver
|
||||||
|
}
|
||||||
public class AppManager : Game
|
public class AppManager : Game
|
||||||
{
|
{
|
||||||
public static AppManager Instance { get; private set; }
|
public static AppManager Instance { get; private set; }
|
||||||
|
@ -32,6 +34,7 @@ namespace DangerousD.GameCore
|
||||||
IDrawableObject LoginGUI;
|
IDrawableObject LoginGUI;
|
||||||
IDrawableObject LobbyGUI;
|
IDrawableObject LobbyGUI;
|
||||||
IDrawableObject DeathGUI;
|
IDrawableObject DeathGUI;
|
||||||
|
IDrawableObject HUD;
|
||||||
public DebugHUD DebugHUD;
|
public DebugHUD DebugHUD;
|
||||||
public List<NetworkTask> NetworkTasks = new List<NetworkTask>();
|
public List<NetworkTask> NetworkTasks = new List<NetworkTask>();
|
||||||
|
|
||||||
|
@ -66,6 +69,7 @@ namespace DangerousD.GameCore
|
||||||
OptionsGUI = new OptionsGUI();
|
OptionsGUI = new OptionsGUI();
|
||||||
LobbyGUI = new LobbyGUI();
|
LobbyGUI = new LobbyGUI();
|
||||||
DeathGUI = new DeathGUI();
|
DeathGUI = new DeathGUI();
|
||||||
|
HUD = new HUD();
|
||||||
DebugHUD = new DebugHUD();
|
DebugHUD = new DebugHUD();
|
||||||
UIManager.resolution = resolution;
|
UIManager.resolution = resolution;
|
||||||
UIManager.resolutionInGame = inGameResolution;
|
UIManager.resolutionInGame = inGameResolution;
|
||||||
|
@ -79,7 +83,7 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
DebugHUD.Initialize();
|
DebugHUD.Initialize();
|
||||||
OptionsGUI.Initialize();
|
OptionsGUI.Initialize();
|
||||||
|
HUD.Initialize();
|
||||||
LobbyGUI.Initialize();
|
LobbyGUI.Initialize();
|
||||||
DeathGUI.Initialize();
|
DeathGUI.Initialize();
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
@ -94,6 +98,7 @@ namespace DangerousD.GameCore
|
||||||
OptionsGUI.LoadContent();
|
OptionsGUI.LoadContent();
|
||||||
LobbyGUI.LoadContent();
|
LobbyGUI.LoadContent();
|
||||||
DeathGUI.LoadContent();
|
DeathGUI.LoadContent();
|
||||||
|
HUD.LoadContent();
|
||||||
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
||||||
GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) });
|
GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) });
|
||||||
SoundManager.LoadSounds();
|
SoundManager.LoadSounds();
|
||||||
|
@ -126,6 +131,9 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Death:
|
case GameState.Death:
|
||||||
DeathGUI.Update(gameTime);
|
DeathGUI.Update(gameTime);
|
||||||
break;
|
break;
|
||||||
|
case GameState.HUD:
|
||||||
|
HUD.Update(gameTime);
|
||||||
|
break;
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
GameManager.Update(gameTime);
|
GameManager.Update(gameTime);
|
||||||
break;
|
break;
|
||||||
|
@ -159,6 +167,9 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Death:
|
case GameState.Death:
|
||||||
DeathGUI.Draw(_spriteBatch);
|
DeathGUI.Draw(_spriteBatch);
|
||||||
break;
|
break;
|
||||||
|
case GameState.HUD:
|
||||||
|
HUD.Draw(_spriteBatch);
|
||||||
|
break;
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
_spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);
|
_spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);
|
||||||
GameManager.Draw(_spriteBatch);
|
GameManager.Draw(_spriteBatch);
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace MonogameLibrary.UI.Base
|
||||||
protected Texture2D texture;
|
protected Texture2D texture;
|
||||||
protected int layerIndex;
|
protected int layerIndex;
|
||||||
protected UIManager Manager;
|
protected UIManager Manager;
|
||||||
public string textureName;
|
public string textureName = "";
|
||||||
public Rectangle rectangle = new Rectangle(0, 0, 10, 10);
|
public Rectangle rectangle = new Rectangle(0, 0, 10, 10);
|
||||||
public Color mainColor = Color.White;
|
public Color mainColor = Color.White;
|
||||||
|
|
||||||
|
|
68
MonogameLibrary/UI/Elements/Rect.cs
Normal file
68
MonogameLibrary/UI/Elements/Rect.cs
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
using MonogameLibrary.UI.Base;
|
||||||
|
using MonogameLibrary.UI.Enums;
|
||||||
|
using MonogameLibrary.UI.Interfaces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using static MonogameLibrary.UI.Elements.Button;
|
||||||
|
|
||||||
|
namespace MonogameLibrary.UI.Elements
|
||||||
|
{
|
||||||
|
public class Rect : DrawableTextedUiElement, IInteractable
|
||||||
|
{
|
||||||
|
public delegate void OnButtonPressed();
|
||||||
|
public event OnButtonPressed? RightButtonPressed;
|
||||||
|
public event OnButtonPressed? LeftButtonPressed;
|
||||||
|
protected HoverState hoverState = HoverState.None;
|
||||||
|
|
||||||
|
public Rect(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||||
|
{
|
||||||
|
//if (Manager.)
|
||||||
|
if (rectangle.Intersects(new Rectangle(mouseState.Position, Point.Zero)))
|
||||||
|
{
|
||||||
|
if (mouseState.LeftButton == ButtonState.Pressed || mouseState.RightButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
hoverState = HoverState.Pressing;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hoverState = HoverState.Hovering;
|
||||||
|
}
|
||||||
|
if (prevmouseState.LeftButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
if (mouseState.LeftButton != prevmouseState.LeftButton)
|
||||||
|
{
|
||||||
|
hoverState = HoverState.Pressing;
|
||||||
|
LeftButtonPressed?.Invoke();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(prevmouseState.RightButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
if (mouseState.RightButton != prevmouseState.RightButton)
|
||||||
|
{
|
||||||
|
RightButtonPressed?.Invoke();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hoverState = HoverState.None;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public override void Draw(SpriteBatch _spriteBatch)
|
||||||
|
{
|
||||||
|
_spriteBatch.Draw(texture, rectangle, Color.White);
|
||||||
|
DrawText(_spriteBatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue