public void HandleKilledEntity(float damageAmount, UInt32 entityID) { RemoveEntity(entityID); AttackMessage newAttack = new AttackMessage(entityID, 0, 0, 0, 0, 1, damageAmount, 0, 0, 0, 1); UDPServer.getInstance().BroadcastMessage(newAttack); }
public void Visit(AttackMessage m) { Debug.Log("Inside AttackMessage Visit"); Server.instance.TaskQueue.Enqueue(new Action(() => { GameState.instance.PlayerAttack(m.GetEntityId(), m.GetWeaponType(), m.GetAttackPositionX(), m.GetAttackPositionY()); Debug.Log(m); })); }
/// <summary> /// A character takes damage. /// </summary> /// <param name="targetCharacterID">Id of damaged <c>Player</c>.</param> /// <param name="damageAmount">Amount of damage that the character takes.</param> public void AttackValid(UInt32 targetCharacterID, float damageAmount) { Character targetEntity = (Character)GetEntity(targetCharacterID); targetEntity.TakeDamage(damageAmount); AttackMessage newAttack = new AttackMessage(targetCharacterID, 0, 0, 0, 0, 1, damageAmount, 0, 0, 0, 0); //targetEntity.Client.MessageQueue.Enqueue(newAttack); UDPServer.getInstance().BroadcastMessage(newAttack); }
/// <summary> /// <c>Player</c> attack towards a direction. /// </summary> /// <param name="playerId">Id of attacking <c>Player</c>.</param> /// <param name="weaponId">weaponId of attacking <c>Player</c>.</param> /// <param name="clickPositionX">X position of the attack <c>Player</c>.</param> /// <param name="clickPositionY">Y position of the attack<c>Player</c>.</param> public void EnemyAttack(UInt32 enemyID, UInt32 targetPlayerID) { //Debug.Log("Start of EnemyAttack"); Enemy enemy = (Enemy)GetEntity(enemyID); Player player = (Player)GetEntity(targetPlayerID); AttackMessage AttackInit = new AttackMessage(enemyID, 0, 0, targetPlayerID, 0, 0, 0, player.X, player.Y, 1, 0); Debug.Log("Broadcasting in EnemyAttack"); UDPServer.getInstance().BroadcastMessage(AttackInit); }
/// <summary> /// <c>Player</c> attack towards a direction. /// </summary> /// <param name="playerId">Id of attacking <c>Player</c>.</param> /// <param name="weaponId">weaponId of attacking <c>Player</c>.</param> /// <param name="clickPositionX">X position of the attack <c>Player</c>.</param> /// <param name="clickPositionY">Y position of the attack<c>Player</c>.</param> public void PlayerAttack(UInt32 playerId, short weaponId, float clickPositionX, float clickPositionY) { //Debug.Log("Start of PlayerAttack"); Vector2 clickPosition; clickPosition.x = clickPositionX; clickPosition.y = clickPositionY; Player player = (Player)GetEntity(playerId); AttackMessage AttackInit = new AttackMessage(playerId, 0, 0, 0, weaponId, 0, 0, clickPositionX, clickPositionY, 1, 0); Debug.Log("Broadcasting in PlayerATtack"); UDPServer.getInstance().BroadcastMessage(AttackInit); player.TryToAttack(clickPosition, weaponId); }