SilasAlgorimVersion1End

This commit is contained in:
Timofey06 2023-08-17 14:32:14 +03:00
parent 232c8b309d
commit ea0506beec
6 changed files with 105 additions and 10 deletions

View file

@ -0,0 +1 @@
{"id":"SilasBallMove","textureName":"MonstersAnimations","startSpriteRectangle":{"X":147,"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,36 @@
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 SilasBall : LivingEntity
{
public SilasBall(Vector2 position) : base(position)
{
Height = 60;
Width = 60;
acceleration = Vector2.Zero;
}
public SilasBall(Vector2 position, Vector2 velosity) : base(position)
{
Height = 60;
Width = 60;
acceleration = Vector2.Zero;
velocity = velosity;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SilasBallMove" }, "SilasBallMove");
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
}
}

View file

@ -39,12 +39,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
if (Pos.Y> AppManager.Instance.GameManager.GetPlayer1.Pos.Y)
{
velocity.Y = monster_speed;
velocity.Y = -monster_speed;
}
else
{
velocity.Y = 0;
velocity.Y = monster_speed;
}
if (Pos.X> AppManager.Instance.GameManager.GetPlayer1.Pos.X)
{
@ -58,6 +58,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
Move(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))
{

View file

@ -1,4 +1,5 @@
using DangerousD.GameCore.Graphics;
using DangerousD.GameCore.GameObjects.Entities;
using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
@ -15,6 +16,11 @@ 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>();
List<SilasBall> balls = new List<SilasBall>();
public SilasMaster(Vector2 position) : base(position)
{
name = "SilasMaster";
@ -23,22 +29,47 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
monster_health = 15;
monster_speed = 4;
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);
}
}
protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List<string>() { "SilasMove", "SilasAttack" }, "SilasMove");
public override void Attack()
{
if (currentTime==0)
if (currentTime == 0)
{
GraphicsComponent.StartAnimation("SilasAttack");
}
else if (currentTime == attackTime / 2)
{
SpawnAttackBall();
}
else if (currentTime >= attackTime)
{
GraphicsComponent.StartAnimation("SilasMove");
currentTime = 0;
}
currentTime++;
}
private void SpawnAttackBall()
{
for (int i = 0; i < balls.Count; i++)
{
balls[i].SetPosition(new Vector2(Pos.X + i * 40, Pos.Y + 120));
}
}
public override void Death()
{
throw new NotImplementedException();
@ -56,16 +87,38 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
currentTime = 0;
}
currentTime++;
if (isGoRight)
{
velocity.X = monster_speed;
}
else if (!isGoRight)
{
velocity.X = -monster_speed;
}
if (Pos.X >= rightBorder)
{
isGoRight = false;
}
else if (Pos.X <= leftBorder)
{
isGoRight = true;
}
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
if (GraphicsComponent.CurrentAnimation.Id=="SilasMove")
if (hands.Count<2)
{
hands.Add(new SilasHands(new Vector2(Pos.X + 60, Pos.Y + 120)));
}
if (GraphicsComponent.CurrentAnimation.Id == "SilasMove")
{
Move(gameTime);
}
else
{
velocity = Vector2.Zero;
Attack();
}
}

View file

@ -3,6 +3,7 @@ using DangerousD.GameCore.GameObjects.MapObjects;
using Microsoft.Xna.Framework;
using DangerousD.GameCore.GameObjects.LivingEntities.Monsters;
using System.Collections.Generic;
using DangerousD.GameCore.GameObjects.Entities;
namespace DangerousD.GameCore.Levels
{
@ -19,9 +20,9 @@ namespace DangerousD.GameCore.Levels
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 SilasBall = new SilasBall(new Vector2(550, 64));
var SilasHand = new SilasHands(new Vector2(200,64));
var SilasMaster = new SilasMaster(new Vector2(400, 64));
var SilasMaster = new SilasMaster(new Vector2(400, 300));
new GrassBlock(new Vector2(0, 224));
for (int i = 0; i < 50; i++)
{

View file

@ -76,8 +76,11 @@ namespace DangerousD.GameCore
item.Update(gameTime);
foreach (var item in entities)
item.Update(gameTime);
foreach (var item in livingEntities)
item.Update(gameTime);
for (int i = 0; i < livingEntities.Count; i++)
{
livingEntities[i].Update(gameTime);
}
foreach (var item in otherObjects)
item.Update(gameTime);