Merge pull request #90 from progtime-net/MinorOverallAndParticles
minor overall + shakeeffect
This commit is contained in:
commit
d819caeee2
16 changed files with 292 additions and 92 deletions
|
@ -101,6 +101,9 @@
|
|||
/processorParam:Quality=Best
|
||||
/build:sounds/Zombi stoit.wav
|
||||
|
||||
#begin Textures/Animations/explosion_1.animation
|
||||
/copy:Textures/Animations/explosion_1.animation
|
||||
|
||||
#begin Textures/Animations/player_down_idle.animation
|
||||
/copy:Textures/Animations/player_down_idle.animation
|
||||
|
||||
|
@ -137,54 +140,54 @@
|
|||
#begin Textures/Animations/player_left_idle.animation
|
||||
/copy:Textures/Animations/player_left_idle.animation
|
||||
|
||||
#begin Textures/Animations/player_look_down.animation
|
||||
/copy:Textures/Animations/player_look_down.animation
|
||||
|
||||
#begin Textures/Animations/player_look_down_weapon.animation
|
||||
/copy:Textures/Animations/player_look_down_weapon.animation
|
||||
|
||||
#begin Textures/Animations/player_look_left.animation
|
||||
/copy:Textures/Animations/player_look_left.animation
|
||||
|
||||
#begin Textures/Animations/player_look_left_down.animation
|
||||
/copy:Textures/Animations/player_look_left_down.animation
|
||||
#begin Textures/Animations/player_look_down.animation
|
||||
/copy:Textures/Animations/player_look_down.animation
|
||||
|
||||
#begin Textures/Animations/player_look_left_down_weapon.animation
|
||||
/copy:Textures/Animations/player_look_left_down_weapon.animation
|
||||
|
||||
#begin Textures/Animations/player_look_left_up.animation
|
||||
/copy:Textures/Animations/player_look_left_up.animation
|
||||
#begin Textures/Animations/player_look_left_down.animation
|
||||
/copy:Textures/Animations/player_look_left_down.animation
|
||||
|
||||
#begin Textures/Animations/player_look_left_up_weapon.animation
|
||||
/copy:Textures/Animations/player_look_left_up_weapon.animation
|
||||
|
||||
#begin Textures/Animations/player_look_left_up.animation
|
||||
/copy:Textures/Animations/player_look_left_up.animation
|
||||
|
||||
#begin Textures/Animations/player_look_left_weapon.animation
|
||||
/copy:Textures/Animations/player_look_left_weapon.animation
|
||||
|
||||
#begin Textures/Animations/player_look_right.animation
|
||||
/copy:Textures/Animations/player_look_right.animation
|
||||
|
||||
#begin Textures/Animations/player_look_right_down.animation
|
||||
/copy:Textures/Animations/player_look_right_down.animation
|
||||
#begin Textures/Animations/player_look_left.animation
|
||||
/copy:Textures/Animations/player_look_left.animation
|
||||
|
||||
#begin Textures/Animations/player_look_right_down_weapon.animation
|
||||
/copy:Textures/Animations/player_look_right_down_weapon.animation
|
||||
|
||||
#begin Textures/Animations/player_look_right_up.animation
|
||||
/copy:Textures/Animations/player_look_right_up.animation
|
||||
#begin Textures/Animations/player_look_right_down.animation
|
||||
/copy:Textures/Animations/player_look_right_down.animation
|
||||
|
||||
#begin Textures/Animations/player_look_right_up_weapon.animation
|
||||
/copy:Textures/Animations/player_look_right_up_weapon.animation
|
||||
|
||||
#begin Textures/Animations/player_look_right_up.animation
|
||||
/copy:Textures/Animations/player_look_right_up.animation
|
||||
|
||||
#begin Textures/Animations/player_look_right_weapon.animation
|
||||
/copy:Textures/Animations/player_look_right_weapon.animation
|
||||
|
||||
#begin Textures/Animations/player_look_up.animation
|
||||
/copy:Textures/Animations/player_look_up.animation
|
||||
#begin Textures/Animations/player_look_right.animation
|
||||
/copy:Textures/Animations/player_look_right.animation
|
||||
|
||||
#begin Textures/Animations/player_look_up_weapon.animation
|
||||
/copy:Textures/Animations/player_look_up_weapon.animation
|
||||
|
||||
#begin Textures/Animations/player_look_up.animation
|
||||
/copy:Textures/Animations/player_look_up.animation
|
||||
|
||||
#begin Textures/Animations/player_right_idle.animation
|
||||
/copy:Textures/Animations/player_right_idle.animation
|
||||
|
||||
|
@ -224,18 +227,6 @@
|
|||
#begin Textures/Animations/zombie_walk.animation
|
||||
/copy:Textures/Animations/zombie_walk.animation
|
||||
|
||||
#begin Textures/AnimationTextures/Character/hr-level1_idle.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Character/hr-level1_idle.png
|
||||
|
||||
#begin Textures/AnimationTextures/Character/hr-level1_idle_gun.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -248,6 +239,18 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Character/hr-level1_idle_gun.png
|
||||
|
||||
#begin Textures/AnimationTextures/Character/hr-level1_idle.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Character/hr-level1_idle.png
|
||||
|
||||
#begin Textures/AnimationTextures/Character/hr-level1_mining_tool-1.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -272,18 +275,6 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Character/hr-level1_mining_tool-2.png
|
||||
|
||||
#begin Textures/AnimationTextures/Character/hr-level1_running.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Character/hr-level1_running.png
|
||||
|
||||
#begin Textures/AnimationTextures/Character/hr-level1_running_gun.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -296,6 +287,18 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Character/hr-level1_running_gun.png
|
||||
|
||||
#begin Textures/AnimationTextures/Character/hr-level1_running.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Character/hr-level1_running.png
|
||||
|
||||
#begin Textures/AnimationTextures/unicorn.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -332,6 +335,18 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/AnimationTextures/Zombie/zombie_spritesheet_v2.png
|
||||
|
||||
#begin Textures/Effects/explosion.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/Effects/explosion.png
|
||||
|
||||
#begin Textures/GUI/background/base.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -416,18 +431,6 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/background/waiting.png
|
||||
|
||||
#begin Textures/GUI/checkboxs_off.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/checkboxs_off.png
|
||||
|
||||
#begin Textures/GUI/checkboxs_off-on.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -440,6 +443,18 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/checkboxs_off-on.png
|
||||
|
||||
#begin Textures/GUI/checkboxs_off.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/checkboxs_off.png
|
||||
|
||||
#begin Textures/GUI/checkboxs_on.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -476,18 +491,6 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/mouse.png
|
||||
|
||||
#begin Textures/GUI/switch.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/switch.png
|
||||
|
||||
#begin Textures/GUI/Switch_backgrownd.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -500,6 +503,18 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/Switch_backgrownd.png
|
||||
|
||||
#begin Textures/GUI/switch.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/switch.png
|
||||
|
||||
#begin Textures/icons/12.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
|
1
ZoFo/Content/Textures/Animations/explosion_1.animation
Normal file
1
ZoFo/Content/Textures/Animations/explosion_1.animation
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"explosion_1","textureName":"Textures/Effects/explosion","startSpriteRectangle":{"X":0,"Y":0,"Width":100,"Height":100},"frameSecond":[{"Item1":0,"Item2":1}],"textureFrameInterval":0,"framesCount":33,"isCycle":false,"offset":"0, 0"}
|
|
@ -1 +1 @@
|
|||
{"id":"zombie_death","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":96,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":9,"isCycle":true,"offset":"0, 0"}
|
||||
{"id":"zombie_death","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":96,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":9,"isCycle":false,"offset":"0, 0"}
|
||||
|
|
BIN
ZoFo/Content/Textures/Effects/explosion.png
Normal file
BIN
ZoFo/Content/Textures/Effects/explosion.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
|
@ -26,6 +26,7 @@ using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
|
|||
using ZoFo.GameCore.Graphics;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||
namespace ZoFo.GameCore
|
||||
{
|
||||
public class Client
|
||||
|
@ -97,6 +98,21 @@ namespace ZoFo.GameCore
|
|||
List<GameObject> gameObjects = new List<GameObject>();
|
||||
List<Player> players = new List<Player>();
|
||||
List<StopObject> stopObjects = new List<StopObject>();
|
||||
List<Particle> particles = new List<Particle>();
|
||||
|
||||
float shakeEffect = 0;
|
||||
public void AddShaking(float power)
|
||||
{
|
||||
shakeEffect += power;
|
||||
}
|
||||
public void UpdateShaking()
|
||||
{
|
||||
shakeEffect *= 0.99f;
|
||||
(GraphicsComponent.CameraPosition) += new Microsoft.Xna.Framework.Point(
|
||||
(int)((Random.Shared.NextDouble() - 0.5) * shakeEffect),
|
||||
(int)((Random.Shared.NextDouble() - 0.5) * shakeEffect)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Клиент должен обнговлять игру анимаций
|
||||
|
@ -104,11 +120,15 @@ namespace ZoFo.GameCore
|
|||
/// <param name="gameTime"></param>
|
||||
internal void Update(GameTime gameTime)
|
||||
{
|
||||
UpdateShaking();
|
||||
for (int i = 0; i < gameObjects.Count; i++)
|
||||
{
|
||||
AppManager.Instance.debugHud.Set("GameTime", gameTime.TotalGameTime.ToString());
|
||||
{
|
||||
gameObjects[i].UpdateAnimations();
|
||||
}
|
||||
for (int i = 0; i < particles.Count; i++)
|
||||
{
|
||||
particles[i].UpdateAnimations();
|
||||
}
|
||||
|
||||
networkManager.SendData();//set to ticks
|
||||
if (myPlayer != null)
|
||||
|
@ -133,6 +153,11 @@ namespace ZoFo.GameCore
|
|||
{
|
||||
gameObjects[i].Draw(spriteBatch);
|
||||
}
|
||||
for (int i = 0; i < particles.Count; i++)
|
||||
{
|
||||
particles[i].Draw(spriteBatch);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal void GotData(UpdateData update)
|
||||
|
@ -160,19 +185,14 @@ namespace ZoFo.GameCore
|
|||
}
|
||||
else if (update is UpdateGameObjectCreated)
|
||||
{
|
||||
GameObject created_gameObject;
|
||||
if((update as UpdateGameObjectCreated).GameObjectType == "Player")
|
||||
Entity created_gameObject;
|
||||
if ((update as UpdateGameObjectCreated).GameObjectType == "Player")
|
||||
{
|
||||
created_gameObject = new Player((update as UpdateGameObjectCreated).position);
|
||||
players.Add(created_gameObject as Player);
|
||||
myPlayer = players[0];
|
||||
gameObjects.Add(created_gameObject);
|
||||
(created_gameObject as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
|
||||
}
|
||||
else if ((update as UpdateGameObjectCreated).GameObjectType == "Ammo")
|
||||
gameObjects.Add(new Ammo((update as UpdateGameObjectCreated).position));
|
||||
else if ((update as UpdateGameObjectCreated).GameObjectType == "BottleOfWater")
|
||||
gameObjects.Add(new BottleOfWater((update as UpdateGameObjectCreated).position));
|
||||
myPlayer = players[0];
|
||||
gameObjects.Add(created_gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
Type t = Type.GetType("ZoFo.GameCore.GameObjects." + (update as UpdateGameObjectCreated).GameObjectType);
|
||||
|
@ -180,10 +200,17 @@ namespace ZoFo.GameCore
|
|||
if (gameObject is Entity)
|
||||
(gameObject as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
|
||||
gameObjects.Add(gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
(gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
|
||||
|
||||
}
|
||||
else if (update is UpdateGameOBjectWithoutIdCreated)
|
||||
{
|
||||
Type t = Type.GetType("ZoFo.GameCore.GameObjects." + (update as UpdateGameOBjectWithoutIdCreated).GameObjectClassName);
|
||||
GameObject gameObject = Activator.CreateInstance(t, (update as UpdateGameOBjectWithoutIdCreated).position) as GameObject;
|
||||
if (gameObject is Particle)
|
||||
particles.Add(gameObject as Particle);
|
||||
}
|
||||
else if (update is UpdatePosition)
|
||||
{
|
||||
var ent = FindEntityById(update.IdEntity);
|
||||
|
@ -223,7 +250,20 @@ namespace ZoFo.GameCore
|
|||
}
|
||||
return null;
|
||||
}
|
||||
public void DeleteObject(Entity entity)
|
||||
|
||||
public void DeleteObject(GameObject gameObject)
|
||||
{
|
||||
if (gameObject is Entity)
|
||||
{
|
||||
DeleteEntity(gameObject as Entity);
|
||||
}
|
||||
else if (gameObject is Particle)
|
||||
{
|
||||
if (particles.Contains(gameObject))
|
||||
particles.Remove(gameObject as Particle);
|
||||
}
|
||||
}
|
||||
public void DeleteEntity(Entity entity)
|
||||
{
|
||||
|
||||
if (gameObjects.Contains(entity))
|
||||
|
|
|
@ -233,6 +233,11 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
|||
rectangle.Y += (int)origin.Y;
|
||||
return rectangle;
|
||||
}
|
||||
public static Vector2 RandomVector()
|
||||
{
|
||||
return new Vector2((float)Random.Shared.NextDouble() - 0.5f, (float)Random.Shared.NextDouble() - 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace ZoFo.GameCore.GameManagers
|
|||
private bool isInteract;
|
||||
|
||||
private KeyboardState lastKeyboardState;
|
||||
private KeyboardState keyBoardState;
|
||||
private GamePadState lastGamePadState;
|
||||
public ScopeState ScopeState { get => currentScopeState; }
|
||||
public string currentControlsState;
|
||||
|
@ -161,13 +162,13 @@ namespace ZoFo.GameCore.GameManagers
|
|||
#endregion
|
||||
|
||||
#region Обработка нажатия выстрела. Вызывает событие ShootEvent
|
||||
if (keyBoardState.IsKeyDown(Keys.P) && !isShoot)
|
||||
if ((keyBoardState.IsKeyDown(Keys.P) || keyBoardState.IsKeyDown(Keys.F)) && !isShoot)
|
||||
{
|
||||
isShoot = true;
|
||||
ShootEvent?.Invoke();
|
||||
Debug.WriteLine("Выстрел");
|
||||
}
|
||||
else if (keyBoardState.IsKeyUp(Keys.P))
|
||||
else if (keyBoardState.IsKeyUp(Keys.F))
|
||||
{
|
||||
isShoot = false;
|
||||
}
|
||||
|
@ -245,5 +246,7 @@ namespace ZoFo.GameCore.GameManagers
|
|||
return currentScopeState;
|
||||
}
|
||||
#endregion
|
||||
public bool ButtonClicked(Keys key) => keyBoardState.IsKeyUp(key) && keyBoardState.IsKeyDown(key);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
using Microsoft.Xna.Framework;
|
||||
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Хранит новое сосотяние анимации
|
||||
/// </summary>
|
||||
public class UpdateGameOBjectWithoutIdCreated : UpdateData
|
||||
{
|
||||
public UpdateGameOBjectWithoutIdCreated() { UpdateType = "UpdateGameOBjectWithoutIdCreated"; }
|
||||
public string GameObjectClassName { get; set; }
|
||||
public Vector2 position { get; set; }
|
||||
}
|
||||
}
|
|
@ -53,6 +53,11 @@ namespace ZoFo.GameCore.GameObjects
|
|||
|
||||
base.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public virtual void Delete()
|
||||
{
|
||||
AppManager.Instance.server.DeleteObject(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,18 +4,38 @@ using System.Net.Mime;
|
|||
using System.Reflection;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using ZoFo.GameCore.GameManagers;
|
||||
using ZoFo.GameCore.Graphics;
|
||||
|
||||
namespace ZoFo.GameCore.GameObjects;
|
||||
public class Enemy : LivingEntity
|
||||
{
|
||||
protected float speed;
|
||||
protected int health;
|
||||
protected float health = 5;
|
||||
public bool isAttacking;
|
||||
public bool isDying;
|
||||
|
||||
public Enemy(Vector2 position) : base(position)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public virtual void TakeDamage(float damage)
|
||||
{
|
||||
if (isDying) return;
|
||||
health -= damage;
|
||||
if (health < 0)
|
||||
Die();
|
||||
}
|
||||
public override void Die()
|
||||
{
|
||||
isDying = true;
|
||||
base.Die();
|
||||
}
|
||||
public override void DeathEnd()
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ namespace ZoFo.GameCore.GameObjects
|
|||
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 bool isAttacking;
|
||||
|
||||
public Zombie(Vector2 position) : base(position)
|
||||
{
|
||||
health = 5;
|
||||
|
@ -32,10 +32,16 @@ namespace ZoFo.GameCore.GameObjects
|
|||
(graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += EndAttack;
|
||||
collisionComponent.OnTriggerZone += OnPlayerClose;
|
||||
collisionComponent.triggerRectangle = new Rectangle(-5, -5, 40, 40);
|
||||
(graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += (str) =>
|
||||
{
|
||||
if (str == "zombie_death")
|
||||
DeathEnd();
|
||||
};
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (isDying) return;
|
||||
Vector2 duration = Vector2.Normalize(
|
||||
AppManager.Instance.server.players[0].position - position
|
||||
);
|
||||
|
@ -64,14 +70,33 @@ namespace ZoFo.GameCore.GameObjects
|
|||
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);
|
||||
AppManager.Instance.client.AddShaking(2);
|
||||
}
|
||||
isAttacking = false;
|
||||
}
|
||||
|
||||
public override void Die()
|
||||
{
|
||||
StartAnimation("zombie_death");
|
||||
base.Die();
|
||||
}
|
||||
public override void DeathEnd()
|
||||
{
|
||||
|
||||
Instantiate(new Particle(collisionComponent.stopRectangle.Location.ToVector2() + position + ExtentionClass.RandomVector() * 20));
|
||||
Instantiate(new Particle(collisionComponent.stopRectangle.Location.ToVector2() + position + ExtentionClass.RandomVector() * 20));
|
||||
Instantiate(new Particle(collisionComponent.stopRectangle.Location.ToVector2() + position + ExtentionClass.RandomVector() * 20));
|
||||
|
||||
base.DeathEnd();
|
||||
}
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
DrawDebugRectangle(spriteBatch, collisionComponent.triggerRectangle.SetOrigin(position), Color.Blue);
|
||||
base.Draw(spriteBatch);
|
||||
}
|
||||
public override void TakeDamage(float damage)
|
||||
{
|
||||
base.TakeDamage(damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,17 @@ public class LivingEntity : Entity
|
|||
prevPosition_forClient = position;
|
||||
}
|
||||
|
||||
public virtual void Die()
|
||||
{
|
||||
//deathSound + animationStart
|
||||
}
|
||||
public virtual void DeathEnd()
|
||||
{
|
||||
//deathSound + animationStart
|
||||
Delete();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,12 +19,13 @@ public class Player : LivingEntity
|
|||
public Vector2 InputWeaponRotation { get; set; }
|
||||
public Vector2 InputPlayerRotation { get; set; }
|
||||
|
||||
private float speed;
|
||||
private float speed;
|
||||
public int reloading;
|
||||
public int health = 100;
|
||||
public int rad = 0;
|
||||
public LootData lootData;
|
||||
|
||||
|
||||
|
||||
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player);
|
||||
|
||||
public bool IsTryingToInteract { get; set; }
|
||||
|
@ -47,6 +48,12 @@ public class Player : LivingEntity
|
|||
|
||||
public override void Update()
|
||||
{
|
||||
if (reloading>0)
|
||||
{
|
||||
reloading--;
|
||||
|
||||
}
|
||||
|
||||
#region анимация управления, стрельбы
|
||||
switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation))
|
||||
{
|
||||
|
@ -94,12 +101,16 @@ public class Player : LivingEntity
|
|||
}
|
||||
public void HandleShoot(UpdateInputShoot updateInputShoot)
|
||||
{
|
||||
if (reloading > 0)
|
||||
return;
|
||||
reloading = 5;
|
||||
IsTryingToShoot = true;
|
||||
|
||||
var rect = collisionComponent.stopRectangle.SetOrigin(position);
|
||||
rect.Width += 100;
|
||||
rect.Height += 100;
|
||||
Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(rect, this);
|
||||
AppManager.Instance.server.RegisterGameObject(new Particle(rect.Location.ToVector2()));
|
||||
if (entities.Length>0)
|
||||
{
|
||||
DebugHUD.DebugSet("ent[0]", entities[0].ToString());
|
||||
|
@ -107,7 +118,10 @@ public class Player : LivingEntity
|
|||
{
|
||||
foreach (Entity entity in entities)
|
||||
{
|
||||
AppManager.Instance.server.DeleteObject(entity);
|
||||
if (entity is Enemy)
|
||||
{
|
||||
(entity as Enemy).TakeDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
27
ZoFo/GameCore/GameObjects/Entities/Particles/Particle.cs
Normal file
27
ZoFo/GameCore/GameObjects/Entities/Particles/Particle.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZoFo.GameCore.GameManagers;
|
||||
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||
using ZoFo.GameCore.Graphics;
|
||||
|
||||
namespace ZoFo.GameCore.GameObjects
|
||||
{
|
||||
internal class Particle : GameObject
|
||||
{
|
||||
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "explosion_1" }, "explosion_1");
|
||||
|
||||
public Particle(Vector2 position) : base(position)
|
||||
{
|
||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(-30, -30,60,60).SetOrigin(position);
|
||||
(graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += _ => {
|
||||
|
||||
AppManager.Instance.client.DeleteObject(this);
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,6 +41,10 @@ public abstract class GameObject
|
|||
graphicsComponent.Update();
|
||||
}
|
||||
|
||||
public void Instantiate(GameObject gameObject)
|
||||
{
|
||||
AppManager.Instance.server.RegisterGameObject(gameObject);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
|
|
@ -186,6 +186,7 @@ namespace ZoFo.GameCore
|
|||
{
|
||||
|
||||
gameObjects.Add(gameObject);
|
||||
|
||||
if (gameObject is StopObject)
|
||||
{
|
||||
AddData(new UpdateStopObjectCreated()
|
||||
|
@ -202,6 +203,7 @@ namespace ZoFo.GameCore
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameObject is MapObject)
|
||||
{
|
||||
AddData(new UpdateTileCreated()
|
||||
|
@ -213,6 +215,18 @@ namespace ZoFo.GameCore
|
|||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameObject is Particle)
|
||||
{
|
||||
|
||||
AddData(new UpdateGameOBjectWithoutIdCreated()
|
||||
{
|
||||
GameObjectClassName = gameObject.GetType().Name,
|
||||
position = gameObject.position
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameObject is Entity entity)
|
||||
{
|
||||
AddData(new UpdateGameObjectCreated()
|
||||
|
|
Loading…
Add table
Reference in a new issue