MergeWithBoss

This commit is contained in:
Timofey06 2023-08-17 12:40:23 +03:00
commit 232c8b309d
8 changed files with 186 additions and 10 deletions

View file

@ -5,6 +5,7 @@ using System;
using System.Windows.Forms;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
namespace AnimationsFileCreator
{
@ -62,7 +63,7 @@ namespace AnimationsFileCreator
container.TextureFrameInterval = 1;
container.Id = id;
string json = JsonConvert.SerializeObject(container);
StreamWriter writer = new StreamWriter("../../../../DangerousD/Content/animations/" + id);
StreamWriter writer = new StreamWriter("../../../../DangerousD/Content/animations/"+id);
writer.WriteLine(json);
writer.Close();
}

View file

@ -0,0 +1,20 @@
{
"id": "SilasAttack",
"textureName": "MonstersAnimations",
"startSpriteRectangle": {
"X": 1,
"Y": 618,
"Width": 72,
"Height": 80
},
"frameSecond": [
{
"Item1": 0,
"Item2": 5
}
],
"textureFrameInterval": 1,
"framesCount": 2,
"isCycle": true,
"offset": "0, 0"
}

View file

@ -0,0 +1 @@
{"id":"SilasHandMove","textureName":"MonstersAnimations","startSpriteRectangle":{"X":197,"Y":618,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1,20 @@
{
"id": "SilasMove",
"textureName": "MonstersAnimations",
"startSpriteRectangle": {
"X": 1,
"Y": 618,
"Width": 72,
"Height": 80
},
"frameSecond": [
{
"Item1": 0,
"Item2": 60
}
],
"textureFrameInterval": 1,
"framesCount": 2,
"isCycle": true,
"offset": "0, 0"
}

View file

@ -1,4 +1,8 @@
using System;
using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -6,7 +10,60 @@ using System.Threading.Tasks;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
internal class SilasHands
public class SilasHands : CoreEnemy
{
public SilasHands(Vector2 position) : base(position)
{
name = "SilasHand";
Width = 48;
Height = 48;
monster_health = 2;
monster_speed = 2;
acceleration = Vector2.Zero;
}
protected override GraphicsComponent GraphicsComponent { get; }=new GraphicsComponent(new List<string>() { "SilasHandMove" }, "SilasHandMove");
public override void Attack()
{
throw new NotImplementedException();
}
public override void Death()
{
throw new NotImplementedException();
}
public override void Move(GameTime gameTime)
{
if (Pos.Y> AppManager.Instance.GameManager.GetPlayer1.Pos.Y)
{
velocity.Y = monster_speed;
}
else
{
velocity.Y = 0;
}
if (Pos.X> AppManager.Instance.GameManager.GetPlayer1.Pos.X)
{
velocity.X = -monster_speed;
}
else
{
velocity.X = monster_speed;
}
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
if ((Pos.X + 20 <= AppManager.Instance.GameManager.GetPlayer1.Pos.X || Pos.X - 20 >= AppManager.Instance.GameManager.GetPlayer1.Pos.X)&&(Pos.Y + 20 <= AppManager.Instance.GameManager.GetPlayer1.Pos.Y || Pos.Y - 20 >= AppManager.Instance.GameManager.GetPlayer1.Pos.Y))
{
AppManager.Instance.GameManager.GetPlayer1.Death(name);
}
GraphicsComponent.Update();
}
}
}

View file

@ -1,4 +1,8 @@
using System;
using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -6,7 +10,64 @@ using System.Threading.Tasks;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class SilasMaster
public class SilasMaster : CoreEnemy
{
private int attackTime = 60;
private int moveTime = 360;
private int currentTime = 0;
public SilasMaster(Vector2 position) : base(position)
{
name = "SilasMaster";
Width = 144;
Height = 160;
monster_health = 15;
monster_speed = 4;
acceleration = Vector2.Zero;
}
protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List<string>() { "SilasMove", "SilasAttack" }, "SilasMove");
public override void Attack()
{
if (currentTime==0)
{
GraphicsComponent.StartAnimation("SilasAttack");
}
else if (currentTime >= attackTime)
{
GraphicsComponent.StartAnimation("SilasMove");
currentTime = 0;
}
currentTime++;
}
public override void Death()
{
throw new NotImplementedException();
}
public override void Move(GameTime gameTime)
{
if (currentTime == 0)
{
GraphicsComponent.StartAnimation("SilasMove");
}
else if (currentTime >= moveTime)
{
GraphicsComponent.StartAnimation("SilasAttack");
currentTime = 0;
}
currentTime++;
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
if (GraphicsComponent.CurrentAnimation.Id=="SilasMove")
{
Move(gameTime);
}
else
{
Attack();
}
}
}
}

View file

@ -16,7 +16,14 @@ namespace DangerousD.GameCore.Graphics
private List<Texture2D> textures;
private List<string> texturesNames;
private AnimationContainer currentAnimation;
public AnimationContainer CurrentAnimation
{
get
{
return currentAnimation;
}
}
public string LastAnimation { get; set; }
public string GetCurrentAnimation
{
get { return currentAnimation.Id; }
@ -26,6 +33,13 @@ namespace DangerousD.GameCore.Graphics
//private SpriteBatch _spriteBatch;
private int currentFrame;
public int CurrentFrame
{
get
{
return currentFrame;
}
}
private int interval;
private int lastInterval;
private Rectangle sourceRectangle;

View file

@ -10,16 +10,18 @@ namespace DangerousD.GameCore.Levels
{
public void InitLevel()
{
new Player(new Vector2(80,0));
var Zombie = new Zombie(new Vector2(140, 128));
var Frank = new Frank(new Vector2(384, 128));
new Player(new Vector2(0,0));
var Spider = new Spider(new Vector2(112, 0));
var FlameSkull = new FlameSkull(new Vector2(512, 0));
var Werewolf = new Werewolf(new Vector2(640, 0));
var Ghost = new Ghost(new Vector2(730, 0));
var Frank = new Frank(new Vector2(100, 64));
var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y));
var Zombie = new Zombie(new Vector2(300, 64));
var SilasHand = new SilasHands(new Vector2(200,64));
var SilasMaster = new SilasMaster(new Vector2(400, 64));
new GrassBlock(new Vector2(0, 224));
for (int i = 0; i < 50; i++)
{