Merge pull request #82 from progtime-net/UpdateZombie

Update zombie
This commit is contained in:
SergoDobro 2024-08-19 19:21:32 +03:00 committed by GitHub
commit bfda449911
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 70 additions and 66 deletions

View file

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

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

@ -1,25 +1,37 @@
using Microsoft.Xna.Framework;
using Microsoft.VisualBasic;
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;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.AssetsManager;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameManagers.AssetsManager;
using ZoFo.GameCore.Graphics;
using ZoFo.GameCore.GUI;
namespace ZoFo.GameCore.GameObjects
{
class Zombie : Enemy
{
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Zombie);
{
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)
{
health = 5;
speed = 2;
speed = 0.5f;
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
collisionComponent.stopRectangle = new Rectangle(10, 20, 10, 10);
isAttacking = false;
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()
@ -27,18 +39,39 @@ namespace ZoFo.GameCore.GameObjects
Vector2 duration = Vector2.Normalize(
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_walk");
StartAnimation("zombie_attack");
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

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