public GameObject GetNearestNonBusyMinion(LevelTile tile) { float closestDist = Mathf.Infinity; GameObject closest = null; foreach (GameObject minion in minions) { if (minion.GetComponent <ActionQueue>().IsBusy()) { continue; } Vector3 pos = LevelHelpers.WorldPosFromTilePos(tile.X, tile.Z); float dist = (minion.transform.position - pos).sqrMagnitude; if (dist < closestDist) { closestDist = dist; closest = minion; } } return(closest); }
public void SpawnPlayer() { LevelModel model = LevelController.Instance.Model; Vector3 spawnPosition = LevelHelpers.WorldPosFromTilePos((int)model.HellSpawn.x, (int)model.HellSpawn.y); SpawnPlayer(spawnPosition); }
public DigAction(GameObject owner, Vector2 position) : base(owner, LevelHelpers.WorldPosFromTilePos((int)position.x, (int)position.y) + new Vector3(LevelHelpers.TileSize / 2, 0, LevelHelpers.TileSize / 2)) { stoppingDistance = LevelHelpers.TileSize / 2; digPosition = position; agent = owner.GetComponent <NavMeshAgent>(); }
private GameObject CreateObjectOnTile(LevelTile tile, GameObject prefab, Transform parent = null, bool isWall = false) { GameObject created = GameObject.Instantiate(prefab); Vector3 worldPosition = isWall ? LevelHelpers.WorldPosFromTilePosSetY(tile.X, tile.Z, LevelHelpers.WallPositionY) : LevelHelpers.WorldPosFromTilePos(tile.X, tile.Z); created.transform.position = worldPosition; created.transform.parent = (parent == null) ? transform : parent; return(created); }