Exemplo n.º 1
0
    GameObject SpawnTurret(Vector3 position, PoolManager.PrefabType type)
    {
        MapManager map         = GameManager.Instance.Map;
        Vector2    mapPosition = map.WorldToMapPosition(position);

        if (!map.TileMap[(int)mapPosition.x, (int)mapPosition.y].HasTurret && (type == PoolManager.PrefabType.TURRET_CANNON ||
                                                                               type == PoolManager.PrefabType.TURRET_LASER))
        {
            map.TileMap[(int)mapPosition.x, (int)mapPosition.y].HasTurret = true;
            map.TileMap[(int)mapPosition.x, (int)mapPosition.y].Walkable  = false;
            if (Spawner.RecalculatePath())
            {
                GameObject tmp = PoolManager.Instance.GetObjectByType(type);
                tmp.transform.parent = transform;
                Vector3 world = map.MapToWorldPosition(mapPosition);
                tmp.transform.position = world;


                return(tmp);
            }
            else
            {
                map.TileMap[(int)mapPosition.x, (int)mapPosition.y].HasTurret = false;
                map.TileMap[(int)mapPosition.x, (int)mapPosition.y].Walkable  = true;
            }
        }

        return(null);
    }
Exemplo n.º 2
0
    public shopItem GetItem(PoolManager.PrefabType type)
    {
        foreach (var item in items)
        {
            if (item.type == type)
            {
                return(item);
            }
        }

        Debug.LogWarning("Item not found in items list");
        return(items[0]);
    }
Exemplo n.º 3
0
    Mobile SpawnEnemy(PoolManager.PrefabType enemyType)
    {
        GameObject tmp;

        tmp = PoolManager.Instance.GetObjectByType(enemyType);
        tmp.transform.parent   = containerObject.transform;
        tmp.transform.position = transform.position;

        Mobile ret = tmp.GetComponent <Mobile>();

        ret.SetPath(Path);

        return(ret);
    }