diff --git a/DangerousD/Content/MonstersAnimations.png b/DangerousD/Content/MonstersAnimations.png index 5bc9cca..97e3e11 100644 Binary files a/DangerousD/Content/MonstersAnimations.png and b/DangerousD/Content/MonstersAnimations.png differ diff --git a/DangerousD/Content/animations/HunchmanAttackLeft b/DangerousD/Content/animations/HunchmanAttackLeft index f6b0634..a84b54b 100644 --- a/DangerousD/Content/animations/HunchmanAttackLeft +++ b/DangerousD/Content/animations/HunchmanAttackLeft @@ -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"} diff --git a/DangerousD/Content/animations/HunchmanAttackRight b/DangerousD/Content/animations/HunchmanAttackRight index 482d7f3..b4e8552 100644 --- a/DangerousD/Content/animations/HunchmanAttackRight +++ b/DangerousD/Content/animations/HunchmanAttackRight @@ -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"} diff --git a/DangerousD/Content/animations/HunchmanMoveRight b/DangerousD/Content/animations/HunchmanMoveRight index a289fa5..2719ebe 100644 --- a/DangerousD/Content/animations/HunchmanMoveRight +++ b/DangerousD/Content/animations/HunchmanMoveRight @@ -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"} diff --git a/DangerousD/Content/map.tmx b/DangerousD/Content/map.tmx index 813425e..9afca4d 100644 --- a/DangerousD/Content/map.tmx +++ b/DangerousD/Content/map.tmx @@ -62,7 +62,7 @@ - + diff --git a/DangerousD/GameCore/GUI/AbstractGui.cs b/DangerousD/GameCore/GUI/AbstractGui.cs index 7f7b212..a8dc9c0 100644 --- a/DangerousD/GameCore/GUI/AbstractGui.cs +++ b/DangerousD/GameCore/GUI/AbstractGui.cs @@ -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) diff --git a/DangerousD/GameCore/GUI/MenuGUI.cs b/DangerousD/GameCore/GUI/MenuGUI.cs index 5842e62..fedaacb 100644 --- a/DangerousD/GameCore/GUI/MenuGUI.cs +++ b/DangerousD/GameCore/GUI/MenuGUI.cs @@ -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); } diff --git a/DangerousD/GameCore/GameObjects/Entities/Trigger.cs b/DangerousD/GameCore/GameObjects/Entities/Trigger.cs new file mode 100644 index 0000000..72c1a80 --- /dev/null +++ b/DangerousD/GameCore/GameObjects/Entities/Trigger.cs @@ -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 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() { "SilasBallMove" }, "SilasBallMove"); + public override void OnCollision(GameObject gameObject) + { + OnCollisionAction?.Invoke(gameObject); + } + public override void Update(GameTime gameTime) + { + } + public override void Draw(SpriteBatch spriteBatch) + { + } + } +} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs index 06fed0f..38b1cc0 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs @@ -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); diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs index b4f3ec7..c93b40a 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs @@ -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(); + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs index fd25246..f164455 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs @@ -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) { } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs index 4c37e6a..013ed10 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs @@ -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(); } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs index 3df9012..214a4c2 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs @@ -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) { } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs index d804512..5db5359 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs @@ -81,7 +81,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } } - public void Attack(GameTime gameTime) + public override void Attack(GameTime gameTime) { } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs index 9c2415b..740c360 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs @@ -27,7 +27,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } - public void Attack(GameTime gameTime) + public override void Attack(GameTime gameTime) { } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs index a54a59b..15018ea 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs @@ -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() diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs index 34069af..6b436b7 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs @@ -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 hands = new List(); @@ -71,7 +70,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } - public void Attack(GameTime gameTime) + public override void Attack(GameTime gameTime) { } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs index 1cdf9bb..0f9e9c9 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs @@ -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) { } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs index 93f3ef4..a4963bf 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs @@ -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 { "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 /// Атака паука РАБОЧАЯ /// /// - 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) { - Width = 48; - Height = 72; - delay += (float)gameTime.ElapsedGameTime.TotalSeconds; if (delay > 0.5 && webLength <= 4 && isDown) { + Width = 48; + Height = 72; 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,23 +91,35 @@ 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; + } } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs index 8bd0af1..c5971de 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs @@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } - public void Attack(GameTime gameTime) + public override void Attack(GameTime gameTime) { } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs index c5f1b8c..837932f 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs @@ -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) { } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index 82dcc2a..5a5711e 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -13,7 +13,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { public class Zombie : CoreEnemy { - private bool isGoRight; private bool isAttack; float leftBorder; @@ -128,22 +127,23 @@ 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; - leftBorder = AppManager.Instance.GameManager.players[0].Pos.X; + leftBorder = AppManager.Instance.GameManager.players[0].Pos.X; } } } @@ -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() diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 0006914..d0c144a 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -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() diff --git a/DangerousD/GameCore/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs index 90a2170..d311095 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntity.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs @@ -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); diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 33327c7..1d75e73 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -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: diff --git a/DangerousD/GameCore/Managers/SoundManager.cs b/DangerousD/GameCore/Managers/SoundManager.cs index 8e2df9e..ab9a5d8 100644 --- a/DangerousD/GameCore/Managers/SoundManager.cs +++ b/DangerousD/GameCore/Managers/SoundManager.cs @@ -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(); diff --git a/MonogameLibrary/UI/Base/UIManager.cs b/MonogameLibrary/UI/Base/UIManager.cs index d37416d..826a0a1 100644 --- a/MonogameLibrary/UI/Base/UIManager.cs +++ b/MonogameLibrary/UI/Base/UIManager.cs @@ -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(); diff --git a/MonogameLibrary/UI/Elements/ButtonText.cs b/MonogameLibrary/UI/Elements/ButtonText.cs index ba6243d..58ad958 100644 --- a/MonogameLibrary/UI/Elements/ButtonText.cs +++ b/MonogameLibrary/UI/Elements/ButtonText.cs @@ -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); } - DrawText(_spriteBatch); + 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); + } } } } diff --git a/MonogameLibrary/UI/Elements/Label.cs b/MonogameLibrary/UI/Elements/Label.cs index e14fc0d..1a8871e 100644 --- a/MonogameLibrary/UI/Elements/Label.cs +++ b/MonogameLibrary/UI/Elements/Label.cs @@ -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)