finishZombie

This commit is contained in:
Kaktus200020 2024-08-19 18:56:18 +03:00
parent 53dede972f
commit 76a62a0a26
6 changed files with 69 additions and 64 deletions

View file

@ -1,78 +1,49 @@
{ {
"Map/SizeTest": {
"height": 4300,
"width": 2
},
"activeFile": "TileMaps/main.tmj", "activeFile": "TileMaps/main.tmj",
"expandedProjectPaths": [ "expandedProjectPaths": [
"TileMaps",
"Templates",
".", ".",
"TileSets", "TileSets"
"TileMaps"
], ],
"fileStates": { "fileStates": {
"": {
"scaleInDock": 1
},
"TileMaps/TileSets/TileSet 1.tsj": {
"scaleInDock": 1
},
"TileMaps/main.tmj": { "TileMaps/main.tmj": {
"scale": 0.33, "scale": 0.75,
"selectedLayer": 1, "selectedLayer": 1,
"viewCenter": { "viewCenter": {
"x": 1010.6060606060606, "x": 1860.6666666666665,
"y": 553.0303030303031 "y": 871.3333333333333
} }
}, },
"TileMaps/main.tmj#IconSet": {
"dynamicWrapping": true,
"scaleInEditor": 1
},
"TileSets/CollisionTileSet.tsj": {
"scaleInDock": 0.75,
"scaleInEditor": 1
},
"TileSets/IconSet.tsj": { "TileSets/IconSet.tsj": {
"dynamicWrapping": true "dynamicWrapping": true,
"scaleInDock": 1,
"scaleInEditor": 1
}, },
"TileSets/TileSet 1.tsj": { "TileSets/TileSet 1.tsj": {
"dynamicWrapping": false, "dynamicWrapping": false,
"scaleInDock": 1, "scaleInDock": 1.5,
"scaleInEditor": 1.5 "scaleInEditor": 3
}, },
"TileSets/TilesetNature.tsj": { "TileSets/TilesetNature.tsj": {
"dynamicWrapping": false "scaleInDock": 1.5,
"scaleInDock": 1
},
"TileSets/WallSet.tsj": {
"scaleInDock": 1,
"scaleInEditor": 1 "scaleInEditor": 1
}, },
"TileSets/tileset 1 collision.tsj": { "TileSets/tileset 1 collision.tsj": {
"scaleInDock": 1 "scaleInDock": 1
} }
}, },
"last.imagePath": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/Textures/icons",
"last.objectTemplatePath": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/MapData/Templates",
"openFiles": [ "openFiles": [
"TileMaps/main.tmj",
"TileSets/IconSet.tsj",
"TileSets/TileSet 1.tsj", "TileSets/TileSet 1.tsj",
"TileMaps/main.tmj" "TileSets/TilesetNature.tsj"
], ],
"project": "MapSession.tiled-project", "project": "MapSession.tiled-project",
"recentFiles": [ "recentFiles": [
"TileSets/TilesetNature.tsj",
"TileSets/TileSet 1.tsj", "TileSets/TileSet 1.tsj",
"TileMaps/main.tmj", "TileSets/IconSet.tsj",
"TileSets/CollisionTileSet.tsj", "TileMaps/main.tmj"
"TileSets/WallSet.tsj" ]
],
"stampsFolder": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/MapData/TileStamps",
"tileset.embedInMap": false,
"tileset.lastUsedFormat": "json",
"tileset.margin": 0,
"tileset.spacing": 0,
"tileset.tileSize": {
"height": 16,
"width": 16
},
"tileset.type": 1
} }

View file

@ -1 +1 @@
{"id":"zombie_attack","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":64,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":3,"isCycle":true,"offset":"0, 0"} {"id":"zombie_attack","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":64,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":3,"isCycle":false,"offset":"0, 0"}

View file

@ -1 +1 @@
{"id":"zombie_walk","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":32,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"} {"id":"zombie_walk","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":32,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"}

View file

@ -183,8 +183,9 @@ namespace ZoFo.GameCore
else if (update is UpdatePosition) else if (update is UpdatePosition)
{ {
var ent = FindEntityById(update.IdEntity); var ent = FindEntityById(update.IdEntity);
ent.position = (update as UpdatePosition).NewPosition; if (ent != null)
ent.position = (update as UpdatePosition).NewPosition;
} }
else if (update is UpdateAnimation) else if (update is UpdateAnimation)
{ {

View file

@ -1,24 +1,36 @@
using Microsoft.Xna.Framework; using Microsoft.VisualBasic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.Graphics; using ZoFo.GameCore.Graphics;
using ZoFo.GameCore.GUI;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
{ {
class Zombie : Enemy class Zombie : Enemy
{ {
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_damaged", "zombie_walk", "zombie_idle", "zombie_attack", "zombie_death" }, "zombie_walk"); public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_damaged", "zombie_walk", "zombie_idle", "zombie_attack", "zombie_death" }, "zombie_walk");
public bool isAttacking;
public Zombie(Vector2 position) : base(position) public Zombie(Vector2 position) : base(position)
{ {
health = 5; health = 5;
speed = 2; speed = 0.5f;
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30); graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
collisionComponent.stopRectangle = new Rectangle(10, 20, 10, 10); collisionComponent.stopRectangle = new Rectangle(10, 20, 10, 10);
isAttacking = false;
StartAnimation("zombie_walk"); StartAnimation("zombie_walk");
collisionComponent.isTrigger = true;
collisionComponent.hasCollision = false;
(graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += EndAttack;
collisionComponent.OnTriggerZone += OnPlayerClose;
collisionComponent.triggerRectangle = new Rectangle(-5, -5, 40, 40);
} }
public override void Update() public override void Update()
@ -26,18 +38,39 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
Vector2 duration = Vector2.Normalize( Vector2 duration = Vector2.Normalize(
AppManager.Instance.server.players[0].position - position AppManager.Instance.server.players[0].position - position
); );
velocity += new Vector2(duration.X * speed, duration.Y * speed);
if (Random.Shared.NextDouble() > 0.9)
if (!isAttacking) { velocity += new Vector2(duration.X * speed, duration.Y * speed); }
}
public void OnPlayerClose(GameObject sender)
{
if(!isAttacking)
{ {
StartAnimation("zombie_attack");
StartAnimation("zombie_walk"); isAttacking = true;
} }
if (Random.Shared.NextDouble() > 0.9)
{
//StartAnimation("zombie_idle");
}
public void EndAttack(string a)
{
var damagedPlayers=AppManager.Instance.server.collisionManager.GetPlayersInZone(collisionComponent.triggerRectangle.SetOrigin(position));
//TODO ДАМАЖИТЬ ИГРОКОВ В ЗОНЕ
if (damagedPlayers.Length>0) { DebugHUD.DebugLog("End of" + a);
AppManager.Instance.server.DeleteObject(this);
} }
isAttacking = false;
}
public override void Draw(SpriteBatch spriteBatch)
{
DrawDebugRectangle(spriteBatch, collisionComponent.triggerRectangle.SetOrigin(position), Color.Blue);
base.Draw(spriteBatch);
} }
} }
} }

View file

@ -162,9 +162,9 @@ namespace ZoFo.GameCore
{ {
if (ticks == 3) //ОБРАБАТЫВАЕТСЯ 20 РАЗ В СЕКУНДУ if (ticks == 3) //ОБРАБАТЫВАЕТСЯ 20 РАЗ В СЕКУНДУ
{ {
foreach (var go in gameObjects) for (int i = 0; i < gameObjects.Count; i++)
{ {
go.UpdateLogic(); gameObjects[i].UpdateLogic();
} }
collisionManager.ResolvePhysics(); collisionManager.ResolvePhysics();
ticks = 0; ticks = 0;