Last active
August 29, 2015 14:17
-
-
Save TORISOUP/0a07ae5f5c29bef77068 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var enemyNames = Enemys.GetComponentsInChildren<Enemy>() | |
.Where(x => x.HP > 0) | |
.Where(x => | |
{ | |
var enemyPos = x.transform.position; | |
var playerPos = player.transform.position; | |
return Vector3.Distance(enemyPos, playerPos) <= 10; | |
}) | |
.Where(x => | |
{ | |
var playerPos = player.transform.position; | |
var enemyPos = x.transform.position; | |
var playerDirection = player.transform.forward; | |
var toEnemyDirection = enemyPos - playerPos; | |
var angle = Vector3.Angle(playerDirection, toEnemyDirection); | |
return angle < 30.0f; | |
}) | |
.OrderBy(x =>{ | |
var enemyPos = x.transform.position; | |
var playerPos = player.transform.position; | |
return Vector3.Distance(enemyPos, playerPos); | |
}) | |
.Select(x => x.ScreenName); | |
var enemyNames = Enemys.GetComponentsInChildren<Enemy>() | |
.Where(x => x.HP > 0) | |
.Where(x => Vector3.Distance(x.transform.position, player.transform.position) <= 10) | |
.Where(x => Vector3.Angle(player.transform.forward, | |
x.transform.position - player.transform.position) < 30.0f) | |
.OrderBy(x => Vector3.Distance(x.transform.position, player.transform.position)) | |
.Select(x => x.ScreenName); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment