Exemple #1
0
    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);
    }
Exemple #2
0
    public void SpawnPlayer()
    {
        LevelModel model = LevelController.Instance.Model;

        Vector3 spawnPosition = LevelHelpers.WorldPosFromTilePos((int)model.HellSpawn.x, (int)model.HellSpawn.y);

        SpawnPlayer(spawnPosition);
    }
Exemple #3
0
    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>();
    }
Exemple #4
0
    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);
    }