Merge branch 'main' of https://github.com/progtime-net/DangerousD
This commit is contained in:
commit
393818d0b8
5 changed files with 44 additions and 24 deletions
|
@ -15,6 +15,7 @@ namespace DangerousD.GameCore
|
||||||
protected Vector2 _pos;
|
protected Vector2 _pos;
|
||||||
public Vector2 Pos => _pos;
|
public Vector2 Pos => _pos;
|
||||||
public int id;
|
public int id;
|
||||||
|
public bool isChildEntity = false;
|
||||||
public bool isIdFromHost = false;
|
public bool isIdFromHost = false;
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
|
|
|
@ -8,7 +8,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DangerousD.GameCore.Managers;
|
using DangerousD.GameCore.Managers;
|
||||||
using DangerousD.GameCore.GameObjects;
|
using DangerousD.GameCore.Network;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
|
@ -63,6 +63,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Attack()
|
public override void Attack()
|
||||||
|
{
|
||||||
|
AppManager.Instance.GameManager.GetPlayer1.Death(name);
|
||||||
|
}
|
||||||
|
public void PlayAttackAnimation()
|
||||||
{
|
{
|
||||||
velocity.X = 0;
|
velocity.X = 0;
|
||||||
isAttaking = true;
|
isAttaking = true;
|
||||||
|
@ -72,7 +76,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
GraphicsComponent.StartAnimation("ZombieRightAttack");
|
GraphicsComponent.StartAnimation("ZombieRightAttack");
|
||||||
}
|
}
|
||||||
AppManager.Instance.GameManager.players[0].Death(name);
|
|
||||||
}
|
}
|
||||||
else if (!isGoRight)
|
else if (!isGoRight)
|
||||||
{
|
{
|
||||||
|
@ -80,7 +83,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
GraphicsComponent.StartAnimation("ZombieLeftAttack");
|
GraphicsComponent.StartAnimation("ZombieLeftAttack");
|
||||||
}
|
}
|
||||||
AppManager.Instance.GameManager.players[0].Death(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,12 +123,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
}
|
}
|
||||||
public override void OnCollision(GameObject gameObject)
|
public override void OnCollision(GameObject gameObject)
|
||||||
{
|
{
|
||||||
if(gameObject is Player)
|
if (gameObject.id == AppManager.Instance.GameManager.GetPlayer1.id && AppManager.Instance.GameManager.GetPlayer1.IsAlive)
|
||||||
{
|
{
|
||||||
if (AppManager.Instance.GameManager.players[0].IsAlive)
|
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client)
|
||||||
{
|
{
|
||||||
Attack();
|
Attack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (gameObject is Player)
|
||||||
|
{
|
||||||
|
if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host)
|
||||||
|
{
|
||||||
|
NetworkTask task = new NetworkTask();
|
||||||
|
AppManager.Instance.NetworkTasks.Add(task.KillPlayer(gameObject.id, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
base.OnCollision(gameObject);
|
base.OnCollision(gameObject);
|
||||||
|
|
|
@ -222,7 +222,12 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
switch (networkTask.operation)
|
switch (networkTask.operation)
|
||||||
{
|
{
|
||||||
case NetworkTaskOperationEnum.TakeDamage:
|
case NetworkTaskOperationEnum.DeleteObject:
|
||||||
|
GameObject gameObject = GameManager.GetAllGameObjects.Find(x => x.id == networkTask.objId);
|
||||||
|
if (gameObject != null)
|
||||||
|
{
|
||||||
|
GameManager.Remove(gameObject);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NetworkTaskOperationEnum.SendSound:
|
case NetworkTaskOperationEnum.SendSound:
|
||||||
SoundManager.StartSound(networkTask.name, networkTask.position, GameManager.GetPlayer1.Pos);
|
SoundManager.StartSound(networkTask.name, networkTask.position, GameManager.GetPlayer1.Pos);
|
||||||
|
@ -283,7 +288,13 @@ namespace DangerousD.GameCore
|
||||||
remoteConnectedPlayer.id = networkTask.objId;
|
remoteConnectedPlayer.id = networkTask.objId;
|
||||||
remoteConnectedPlayer.GetGraphicsComponent().parentId = networkTask.objId;
|
remoteConnectedPlayer.GetGraphicsComponent().parentId = networkTask.objId;
|
||||||
break;
|
break;
|
||||||
default:
|
case NetworkTaskOperationEnum.KillPlayer:
|
||||||
|
Player player1 = GameManager.players.Find(x => x.id==networkTask.objId);
|
||||||
|
player1.Death(networkTask.name);
|
||||||
|
NetworkTask task1 = new NetworkTask();
|
||||||
|
NetworkTasks.Add(task1.DeleteObject(player1.id));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,18 +20,6 @@ namespace DangerousD.GameCore.Network
|
||||||
public Type type { get; set; }
|
public Type type { get; set; }
|
||||||
|
|
||||||
public NetworkTask() { }
|
public NetworkTask() { }
|
||||||
/// <summary>
|
|
||||||
/// Нанести урон сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="LivingEntityId"></param>
|
|
||||||
/// <param name="Damage"></param>
|
|
||||||
public NetworkTask(int LivingEntityId, int Damage)
|
|
||||||
{
|
|
||||||
operation = NetworkTaskOperationEnum.TakeDamage;
|
|
||||||
objId = LivingEntityId;
|
|
||||||
value = Damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Проиграть звук на позиции
|
/// Проиграть звук на позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -49,14 +37,12 @@ namespace DangerousD.GameCore.Network
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="EntityType"></param>
|
/// <param name="EntityType"></param>
|
||||||
/// <param name="EntityPosition"></param>
|
/// <param name="EntityPosition"></param>
|
||||||
/// <param name="EntityVelocity"></param>
|
|
||||||
/// <param name="ParentId"></param>
|
/// <param name="ParentId"></param>
|
||||||
public NetworkTask(Type EntityType, Vector2 EntityPosition, Vector2 EntityVelocity, int ParentId)
|
public NetworkTask(Type EntityType, Vector2 EntityPosition, int ParentId)
|
||||||
{
|
{
|
||||||
operation = NetworkTaskOperationEnum.CreateEntity;
|
operation = NetworkTaskOperationEnum.CreateEntity;
|
||||||
type = EntityType;
|
type = EntityType;
|
||||||
position = EntityPosition;
|
position = EntityPosition;
|
||||||
velocity = EntityVelocity;
|
|
||||||
objId = ParentId;
|
objId = ParentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,5 +120,18 @@ namespace DangerousD.GameCore.Network
|
||||||
position = playerPosition;
|
position = playerPosition;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public NetworkTask DeleteObject(int objectId)
|
||||||
|
{
|
||||||
|
operation = NetworkTaskOperationEnum.DeleteObject;
|
||||||
|
objId = objectId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public NetworkTask KillPlayer(int playerId, string mosterName)
|
||||||
|
{
|
||||||
|
operation = NetworkTaskOperationEnum.KillPlayer;
|
||||||
|
name = mosterName;
|
||||||
|
objId = playerId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,6 @@ namespace DangerousD.GameCore.Network
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public enum NetworkTaskOperationEnum
|
public enum NetworkTaskOperationEnum
|
||||||
{
|
{
|
||||||
TakeDamage, SendSound, CreateEntity, SendPosition, ChangeState, ConnectToHost, GetClientPlayerId, AddConnectedPlayer
|
DeleteObject, SendSound, CreateEntity, SendPosition, ChangeState, ConnectToHost, GetClientPlayerId, AddConnectedPlayer, KillPlayer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue