added player attack functioning
This commit is contained in:
parent
2047fc9552
commit
cfe4daa49f
3 changed files with 20 additions and 10 deletions
|
@ -9,7 +9,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UpdateGameObjectWithoutIdCreated : UpdateData
|
public class UpdateGameObjectWithoutIdCreated : UpdateData
|
||||||
{
|
{
|
||||||
public UpdateGameObjectWithoutIdCreated() { UpdateType = "UpdateGameObjectWithoutIdCreated"; }
|
public UpdateGameObjectWithoutIdCreated() { UpdateType = "UpdateGameObjectWithoutIdCreated"; isImportant = true; }
|
||||||
public string GameObjectClassName { get; set; }
|
public string GameObjectClassName { get; set; }
|
||||||
public SerializableVector2 position { get; set; }
|
public SerializableVector2 position { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class Player : LivingEntity
|
||||||
public float rad = 0;
|
public float rad = 0;
|
||||||
public float MaxRad = 100;
|
public float MaxRad = 100;
|
||||||
public LootData lootData;
|
public LootData lootData;
|
||||||
|
Vector2 prevPosition;
|
||||||
|
|
||||||
|
|
||||||
public bool IsTryingToInteract { get; set; }
|
public bool IsTryingToInteract { get; set; }
|
||||||
|
@ -95,13 +95,15 @@ public class Player : LivingEntity
|
||||||
StartAnimation("player_run_right_down");
|
StartAnimation("player_run_right_down");
|
||||||
break;
|
break;
|
||||||
case ScopeState.Idle:
|
case ScopeState.Idle:
|
||||||
|
if (idName != "player_look_down")
|
||||||
|
StartAnimation("player_look_down");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) != ScopeState.Idle)
|
if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) != ScopeState.Idle)
|
||||||
{
|
{
|
||||||
prevScopeState = AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation);
|
prevScopeState = AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation);
|
||||||
}
|
}
|
||||||
else if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) == ScopeState.Idle)
|
else if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) == ScopeState.Idle && false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,7 +221,7 @@ public class Player : LivingEntity
|
||||||
{
|
{
|
||||||
InputPlayerRotation = updateInput.InputMovementDirection.GetVector2();
|
InputPlayerRotation = updateInput.InputMovementDirection.GetVector2();
|
||||||
InputWeaponRotation = updateInput.InputAttackDirection.GetVector2();
|
InputWeaponRotation = updateInput.InputAttackDirection.GetVector2();
|
||||||
|
DebugHUD.DebugSet("dir", InputWeaponRotation.ToString());
|
||||||
}
|
}
|
||||||
public void HandleInteract(UpdateInputInteraction updateInputInteraction)
|
public void HandleInteract(UpdateInputInteraction updateInputInteraction)
|
||||||
{
|
{
|
||||||
|
@ -250,13 +252,21 @@ public class Player : LivingEntity
|
||||||
reloading = 5;
|
reloading = 5;
|
||||||
IsTryingToShoot = true;
|
IsTryingToShoot = true;
|
||||||
|
|
||||||
Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputManager.ConvertStateToVector2(prevScopeState)), this);
|
Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputWeaponRotation), this);
|
||||||
if (entities != null)
|
if (entities != null)
|
||||||
{
|
{
|
||||||
foreach (Entity entity in entities)
|
foreach (Entity entity in entities)
|
||||||
{
|
{
|
||||||
if (entity is Enemy)
|
if (entity is Enemy)
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
Instantiate(new Particle(
|
||||||
|
(collisionComponent.stopRectangle.Location.ToVector2() * i / 3f) +
|
||||||
|
(collisionComponent.stopRectangle.Location.ToVector2() * (3 - i) / 3f)
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
(entity as Enemy).TakeDamage(1);
|
(entity as Enemy).TakeDamage(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +275,7 @@ public class Player : LivingEntity
|
||||||
public override void Draw(SpriteBatch spriteBatch)
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
|
||||||
DrawDebugRectangle(spriteBatch, GetDamageArea((position - prevPosition_forClient)), Color.Green);
|
DrawDebugRectangle(spriteBatch, GetDamageArea(AppManager.Instance.InputManager.InputAttackDirection), Color.Green);
|
||||||
base.Draw(spriteBatch);
|
base.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
public Rectangle GetDamageArea(Vector2 direction)
|
public Rectangle GetDamageArea(Vector2 direction)
|
||||||
|
@ -277,7 +287,7 @@ public class Player : LivingEntity
|
||||||
rect.Y -= size;
|
rect.Y -= size;
|
||||||
rect.Width += 2 * size;
|
rect.Width += 2 * size;
|
||||||
rect.Height += 2 * size;
|
rect.Height += 2 * size;
|
||||||
rect = rect.SetOrigin(direction*15);
|
rect = rect.SetOrigin(direction * 40);
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue