Ejemplo n.º 1
0
    private void HandleEntityDeath(Entity entity)
    {
        serverNetworkManager.SendEntityDeath(entity);
        //entity.EntityController.Die(0f); not necessary on server

        if (entity is Unit && playerUnits.ContainsKey(entity.playerId))
        {
            PlayerUnit playerUnit = (from pu in playerUnits[entity.playerId]
                                     where pu.playerUnitId == (entity as Unit).playerUnitId
                                     select pu).FirstOrDefault();
            if (playerUnit != null)
            {
                playerUnit.currentHealth = 0;

                if (CheckGameEnd(entity))
                {
                    serverGameManager.EndGame();
                }
            }
        }

        RemoveEntity(entity.uniqueId);
        Destroy(entity.gameObject);
    }