player attack almost done
This commit is contained in:
parent
ae47b8697c
commit
eed94c2d7b
4 changed files with 87 additions and 9 deletions
|
@ -256,7 +256,35 @@ namespace ZoFo.GameCore.GameManagers
|
|||
DebugHUD.DebugSet("x", vector.X.ToString());
|
||||
}
|
||||
return currentScopeState;
|
||||
}
|
||||
}
|
||||
public static Vector2 ConvertStateToVector2(ScopeState scopeState)
|
||||
{
|
||||
switch (scopeState)
|
||||
{
|
||||
case ScopeState.Idle:
|
||||
return new Vector2(0, 0);
|
||||
case ScopeState.Left:
|
||||
return new Vector2(-1, 0);
|
||||
case ScopeState.Right:
|
||||
return new Vector2(1, 0);
|
||||
case ScopeState.Top:
|
||||
return new Vector2(0, -1);
|
||||
case ScopeState.Down:
|
||||
return new Vector2(0, 1);
|
||||
case ScopeState.TopLeft:
|
||||
return new Vector2(-1, -1);
|
||||
case ScopeState.TopRight:
|
||||
return new Vector2(-1, 1);
|
||||
case ScopeState.DownLeft:
|
||||
return new Vector2(1, -1);
|
||||
case ScopeState.DownRight:
|
||||
return new Vector2(1, 1);
|
||||
default:
|
||||
return new Vector2(0, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
public bool ButtonClicked(Keys key) => keyBoardState.IsKeyUp(key) && keyBoardState.IsKeyDown(key);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
|||
/// </summary>
|
||||
public class UpdatePlayerParametrs : UpdateData
|
||||
{
|
||||
public UpdatePlayerParametrs() { UpdateType = "UpdatePlayerParametrs"; }
|
||||
public float radiatoin;
|
||||
public float health;
|
||||
public UpdatePlayerParametrs() { UpdateType = "UpdatePlayerParametrs"; isImportant = true; }
|
||||
public float radiatoin { get; set; }
|
||||
public float health { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace ZoFo.GameCore.GameObjects
|
|||
duration = Vector2.Normalize(
|
||||
AppManager.Instance.server.players[j].position - position
|
||||
);
|
||||
if (new Random().Next(0, 1000) == 0)
|
||||
if (Random.Shared.NextDouble() > 0.999)
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartSound("zombie sound", position, AppManager.Instance.server.players[0].position, pitch: new Random().Next(-1, 2) * (float)new Random().NextDouble());
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ public class Player : LivingEntity
|
|||
/// Факт того, что плеер в этом апдейте пытается стрелять
|
||||
/// </summary>
|
||||
public bool IsTryingToShoot { get; set; }
|
||||
|
||||
ScopeState prevScopeState;
|
||||
public Player(Vector2 position) : base(position)
|
||||
{
|
||||
lootData = new LootData();
|
||||
|
@ -92,11 +94,59 @@ public class Player : LivingEntity
|
|||
if (idName != "player_run_right_down")
|
||||
StartAnimation("player_run_right_down");
|
||||
break;
|
||||
case ScopeState.Idle:
|
||||
if (idName != "player_look_down")
|
||||
StartAnimation("player_look_down");
|
||||
case ScopeState.Idle:
|
||||
break;
|
||||
}
|
||||
if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) != ScopeState.Idle)
|
||||
{
|
||||
prevScopeState = AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation);
|
||||
}
|
||||
else if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) == ScopeState.Idle)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
switch (prevScopeState)
|
||||
{
|
||||
case ScopeState.Top:
|
||||
if (idName != "player_look_up_weapon")
|
||||
StartAnimation("player_look_up_weapon");
|
||||
break;
|
||||
case ScopeState.Down:
|
||||
if (idName != "player_look_down_weapon")
|
||||
StartAnimation("player_look_down_weapon");
|
||||
break;
|
||||
case ScopeState.Right:
|
||||
case ScopeState.Left:
|
||||
if (idName != "player_look_right")
|
||||
StartAnimation("player_look_right");
|
||||
break;
|
||||
case ScopeState.TopRight:
|
||||
case ScopeState.TopLeft:
|
||||
if (idName != "player_look_right_up_weapon")
|
||||
StartAnimation("player_look_right_up_weapon");
|
||||
break;
|
||||
case ScopeState.DownRight:
|
||||
case ScopeState.DownLeft:
|
||||
if (idName != "player_look_right_down_weapon")
|
||||
StartAnimation("player_look_right_down_weapon");
|
||||
break;
|
||||
case ScopeState.Idle:
|
||||
if (idName != "player_look_down")
|
||||
StartAnimation("player_look_down");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region анимация поворота оружия
|
||||
|
@ -200,7 +250,7 @@ public class Player : LivingEntity
|
|||
reloading = 5;
|
||||
IsTryingToShoot = true;
|
||||
|
||||
Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputPlayerRotation), this);
|
||||
Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputManager.ConvertStateToVector2(prevScopeState)), this);
|
||||
if (entities != null)
|
||||
{
|
||||
foreach (Entity entity in entities)
|
||||
|
|
Loading…
Add table
Reference in a new issue