This commit is contained in:
Timofey06 2023-08-18 05:56:49 +03:00
commit 0bcd6f29cb
29 changed files with 192 additions and 76 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -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"}

View file

@ -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"}

View file

@ -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"}

View file

@ -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>

View file

@ -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)

View file

@ -31,8 +31,9 @@ internal class MenuGUI : AbstractGui
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;
@ -40,6 +41,7 @@ internal class MenuGUI : AbstractGui
{
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" };
@ -77,10 +79,21 @@ internal class MenuGUI : AbstractGui
{
for (int i = 0; i < MainLetterLabels.Count; i++)
{
MainLetterLabels[i].fontColor = Color.FromNonPremultiplied(colors[i].ToVector4() * (float)((Math.Sin(gameTime.TotalGameTime.TotalSeconds*2) + 1) / 2f + 0.5f)
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 * 2) + 1) / 2f + 0.5f)
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);
}

View 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)
{
}
}
}

View file

@ -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);

View file

@ -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();
}
}
}

View file

@ -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)
{
}

View file

@ -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();
}

View file

@ -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)
{
}

View file

@ -81,7 +81,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
}
public void Attack(GameTime gameTime)
public override void Attack(GameTime gameTime)
{
}

View file

@ -27,7 +27,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public void Attack(GameTime gameTime)
public override void Attack(GameTime gameTime)
{
}

View file

@ -10,7 +10,8 @@ using System.Threading.Tasks;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class SilasHands : CoreEnemy
public class
SilasHands : CoreEnemy
{
public SilasHands(Vector2 position) : base(position)
{
@ -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()

View file

@ -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>();
@ -71,7 +70,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public void Attack(GameTime gameTime)
public override void Attack(GameTime gameTime)
{
}

View file

@ -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)
{
}

View file

@ -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;
}
}
}
}

View file

@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public void Attack(GameTime gameTime)
public override void Attack(GameTime gameTime)
{
}

View file

@ -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)
{
}

View file

@ -13,7 +13,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Zombie : CoreEnemy
{
private bool isGoRight;
private bool isAttack;
float leftBorder;
@ -128,18 +127,19 @@ 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)
{
if (isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
{
isTarget = true;
leftBorder = Pos.X - 10;
rightBorder = Pos.X + AppManager.Instance.GameManager.players[0].Pos.X;
}
else if (!isGoRight && this._pos.X >= AppManager.Instance.GameManager.players[0].Pos.X)
else if(!isGoRight && this._pos.X >= AppManager.Instance.GameManager.players[0].Pos.X)
{
isTarget = true;
rightBorder = Pos.X + 10;
@ -158,8 +158,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
rightBorder = 760;
}
}
public void Attack(GameTime gameTime)
public override void Attack(GameTime gameTime)
{}
public void TakeDamage()

View file

@ -94,7 +94,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}
public void Death(string monsterName)
{
return;
return; //godmode
isAttacked = true;
if(monsterName == "Zombie")
{
@ -107,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()

View file

@ -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);

View file

@ -205,7 +205,7 @@ namespace DangerousD.GameCore
case GameState.Lobby:
break;
case GameState.Game:
GameManager.mapManager.LoadLevel("lvl");
GameManager.mapManager.LoadLevel("map");
GameManager.FindBorders();
break;
case GameState.Death:

View file

@ -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();

View file

@ -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();

View file

@ -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);
}
}
}
}

View file

@ -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)