player attack fixes
This commit is contained in:
parent
e88b697b2c
commit
3a978ea51b
4 changed files with 95 additions and 86 deletions
|
@ -74,7 +74,7 @@ namespace ZoFo.GameCore.GameObjects
|
|||
//TODO ДАМАЖИТЬ ИГРОКОВ В ЗОНЕ
|
||||
if (damagedPlayers.Length>0) { DebugHUD.DebugLog("End of" + a);
|
||||
foreach (var item in damagedPlayers)
|
||||
item.TakeDamage(5);
|
||||
item.TakeDamage(1);
|
||||
}
|
||||
isAttacking = false;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class LivingEntity : Entity
|
|||
{
|
||||
base.UpdateAnimations();
|
||||
}
|
||||
Vector2 prevPosition_forClient;
|
||||
protected Vector2 prevPosition_forClient;
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if ((positionDraw - prevPosition_forClient).X < 0)
|
||||
|
|
|
@ -16,150 +16,151 @@ using System.Runtime.InteropServices;
|
|||
namespace ZoFo.GameCore.GameObjects;
|
||||
|
||||
public class Player : LivingEntity
|
||||
{
|
||||
{
|
||||
public Vector2 InputWeaponRotation { get; set; }
|
||||
public Vector2 InputPlayerRotation { get; set; }
|
||||
|
||||
private float speed;
|
||||
public int reloading;
|
||||
public float health= 100;
|
||||
|
||||
private float speed;
|
||||
public int reloading;
|
||||
public float health = 100;
|
||||
public float MaxHealth = 100;
|
||||
|
||||
|
||||
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player.Animations, AppManager.Instance.AssetManager.Player.IdleAnimation);
|
||||
|
||||
public AnimatedGraphicsComponent animatedGraphicsComponent => graphicsComponent as AnimatedGraphicsComponent;
|
||||
|
||||
|
||||
public float rad = 0;
|
||||
public float MaxRad = 100;
|
||||
public LootData lootData;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public bool IsTryingToInteract { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Факт того, что плеер в этом апдейте пытается стрелять
|
||||
/// </summary>
|
||||
public bool IsTryingToShoot { get; set; }
|
||||
public bool IsTryingToShoot { get; set; }
|
||||
public Player(Vector2 position) : base(position)
|
||||
{
|
||||
lootData = new LootData();
|
||||
lootData.loots = new Dictionary<string, int>();
|
||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
|
||||
collisionComponent.stopRectangle = new Rectangle(10, 15, 10, 15);
|
||||
speed = 5;
|
||||
collisionComponent.stopRectangle = new Rectangle(10, 15, 10, 15);
|
||||
speed = 5;
|
||||
|
||||
StartAnimation("player_look_down");
|
||||
StartAnimation("player_look_down");
|
||||
}
|
||||
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
public override void Update()
|
||||
{
|
||||
#region название current текстуры
|
||||
var idName = animatedGraphicsComponent.CurrentAnimation.Id;
|
||||
var idName = animatedGraphicsComponent.CurrentAnimation.Id;
|
||||
#endregion
|
||||
|
||||
|
||||
#region анимация управления подбора лута
|
||||
DebugHUD.DebugSet("texture name", idName);
|
||||
if (reloading>0)
|
||||
DebugHUD.DebugSet("texture name", idName);
|
||||
if (reloading > 0)
|
||||
{
|
||||
reloading--;
|
||||
|
||||
}
|
||||
|
||||
switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation))
|
||||
|
||||
switch (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation))
|
||||
{
|
||||
case ScopeState.Top:
|
||||
if (idName!="player_run_up")
|
||||
if (idName != "player_run_up")
|
||||
StartAnimation("player_run_up");
|
||||
break;
|
||||
case ScopeState.Down:
|
||||
if (idName!="player_run_down")
|
||||
if (idName != "player_run_down")
|
||||
StartAnimation("player_run_down");
|
||||
break;
|
||||
case ScopeState.Right:
|
||||
case ScopeState.Left:
|
||||
if (idName!="player_run_right")
|
||||
if (idName != "player_run_right")
|
||||
StartAnimation("player_run_right");
|
||||
break;
|
||||
case ScopeState.TopRight:
|
||||
case ScopeState.TopLeft:
|
||||
if (idName!="player_run_right_up")
|
||||
if (idName != "player_run_right_up")
|
||||
StartAnimation("player_run_right_up");
|
||||
break;
|
||||
break;
|
||||
case ScopeState.DownRight:
|
||||
case ScopeState.DownLeft:
|
||||
if (idName!="player_run_right_down")
|
||||
if (idName != "player_run_right_down")
|
||||
StartAnimation("player_run_right_down");
|
||||
break;
|
||||
break;
|
||||
case ScopeState.Idle:
|
||||
if (idName!="player_look_down")
|
||||
if (idName != "player_look_down")
|
||||
StartAnimation("player_look_down");
|
||||
break;
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region анимация поворота оружия
|
||||
int currentAttackSection = AppManager.Instance.InputManager.ConvertAttackVector2ToState(InputWeaponRotation);
|
||||
switch(currentAttackSection)
|
||||
{
|
||||
case 0 or 1:
|
||||
//right
|
||||
int currentAttackSection = AppManager.Instance.InputManager.ConvertAttackVector2ToState(InputWeaponRotation);
|
||||
switch (currentAttackSection)
|
||||
{
|
||||
case 0 or 1:
|
||||
//right
|
||||
break;
|
||||
case 2 or 3:
|
||||
//down_right_right
|
||||
case 2 or 3:
|
||||
//down_right_right
|
||||
break;
|
||||
case 4 or 5:
|
||||
//down_right
|
||||
case 4 or 5:
|
||||
//down_right
|
||||
break;
|
||||
case 6 or 7:
|
||||
//down_right_left
|
||||
case 6 or 7:
|
||||
//down_right_left
|
||||
break;
|
||||
case 8 or 9:
|
||||
//down
|
||||
case 8 or 9:
|
||||
//down
|
||||
break;
|
||||
case 10 or 11:
|
||||
//down_left_right
|
||||
case 10 or 11:
|
||||
//down_left_right
|
||||
break;
|
||||
case 12 or 13:
|
||||
//down_left
|
||||
case 12 or 13:
|
||||
//down_left
|
||||
break;
|
||||
case 14 or 15:
|
||||
//down_left_left
|
||||
case 14 or 15:
|
||||
//down_left_left
|
||||
break;
|
||||
case 16 or -14:
|
||||
//left
|
||||
case 16 or -14:
|
||||
//left
|
||||
break;
|
||||
case -13 or -12:
|
||||
//top_left_left
|
||||
case -13 or -12:
|
||||
//top_left_left
|
||||
break;
|
||||
case -11 or -10:
|
||||
//top_left
|
||||
case -11 or -10:
|
||||
//top_left
|
||||
break;
|
||||
case -9 or -8:
|
||||
//top_left_right
|
||||
case -9 or -8:
|
||||
//top_left_right
|
||||
break;
|
||||
case -7 or -6:
|
||||
//top
|
||||
case -7 or -6:
|
||||
//top
|
||||
break;
|
||||
case -5 or -4:
|
||||
//top_right_left
|
||||
case -5 or -4:
|
||||
//top_right_left
|
||||
break;
|
||||
case -3 or -2:
|
||||
//top_right
|
||||
case -3 or -2:
|
||||
//top_right
|
||||
break;
|
||||
case -1 or 0:
|
||||
//top_right_right
|
||||
case -1 or 0:
|
||||
//top_right_right
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
MovementLogic();
|
||||
}
|
||||
public void WeaponAttack(){
|
||||
public void WeaponAttack()
|
||||
{
|
||||
|
||||
}
|
||||
public void MovementLogic()
|
||||
public void MovementLogic()
|
||||
{
|
||||
velocity += InputPlayerRotation * speed;
|
||||
DebugHUD.DebugSet("player pos server", position.ToString());
|
||||
|
@ -191,7 +192,7 @@ public class Player : LivingEntity
|
|||
base.Die();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
public void HandleShoot(UpdateInputShoot updateInputShoot)
|
||||
{
|
||||
if (reloading > 0)
|
||||
|
@ -199,24 +200,34 @@ public class Player : LivingEntity
|
|||
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);
|
||||
if (entities != null)
|
||||
Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputPlayerRotation), this);
|
||||
if (entities != null)
|
||||
{
|
||||
foreach (Entity entity in entities)
|
||||
{
|
||||
if (entity is Enemy)
|
||||
{
|
||||
(entity as Enemy).TakeDamage(1);
|
||||
}
|
||||
if (entity is Enemy)
|
||||
{
|
||||
(entity as Enemy).TakeDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
//DrawDebugRectangle(spriteBatch, collisionComponent.stopRectangle.SetOrigin(position + new Vector2(10,10)), Color.Green);
|
||||
|
||||
DrawDebugRectangle(spriteBatch, GetDamageArea((position - prevPosition_forClient)), Color.Green);
|
||||
base.Draw(spriteBatch);
|
||||
}
|
||||
public Rectangle GetDamageArea(Vector2 direction)
|
||||
{
|
||||
direction.Normalize();
|
||||
var rect = collisionComponent.stopRectangle.SetOrigin(position);
|
||||
int size = 10;
|
||||
rect.X -= size;
|
||||
rect.Y -= size;
|
||||
rect.Width += 2 * size;
|
||||
rect.Height += 2 * size;
|
||||
rect = rect.SetOrigin(direction*15);
|
||||
return rect;
|
||||
}
|
||||
}
|
|
@ -125,13 +125,11 @@ namespace ZoFo.GameCore
|
|||
new MapManager().LoadMap();
|
||||
|
||||
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
|
||||
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(740, 140)));
|
||||
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(760, 140)));
|
||||
//for (int i = 0; i < 20; i++)
|
||||
// for (int j = 0; j < 20; j++)
|
||||
// AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300 + i*70, 1000+j*70)));
|
||||
|
||||
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(140, 440)));
|
||||
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440)));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Reference in a new issue