Example #1
0
    private void Start()
    {
        // Load bundles
        AssetBundleManager.GetAssetBundle("animations");
        AssetBundleManager.GetAssetBundle("audio");
        AssetBundleManager.GetAssetBundle("configs");
        AssetBundleManager.GetAssetBundle("images");
        AssetBundle materialsBundle = AssetBundleManager.GetAssetBundle("materials");

        AssetBundleManager.GetAssetBundle("models");
        AssetBundleManager.GetAssetBundle("prefabs");
        AssetBundleManager.GetAssetBundle("shaders");
        AssetBundle fontsBundle = AssetBundleManager.GetAssetBundle("fonts");

        // Instantiate prefab assets
        GameObject      gameUI                 = InstantiateAsset("prefabs", "Game UI");
        GameObject      musicPlayer            = InstantiateAsset("prefabs", "Music Player");
        GameObject      vfx                    = InstantiateAsset("prefabs", "VFX");
        Player          player                 = InstantiateAsset <Player>("prefabs", "Player");
        EnemyManager    enemyManager           = InstantiateAsset <EnemyManager>("prefabs", "Enemy Manager");
        GameObject      asteroidManager        = InstantiateAsset("prefabs", "Asteroid Manager");
        GameObject      bulletPooler           = InstantiateAsset("prefabs", "Bullet Pooler");
        GameObject      homingProjectilePooler = InstantiateAsset("prefabs", "Homing Projectile Pooler");
        GameObject      debrisPooler           = InstantiateAsset("prefabs", "Debris Pooler");
        ExplosionPooler explosionPooler        = InstantiateAsset <ExplosionPooler>("prefabs", "Explosion Pooler");

        IntValue       levelToLoad = AssetBundleManager.GetAsset <IntValue>("configs", "Level To Load");
        GameObjectList objToSpawn  = AssetBundleManager.GetAsset <GameObjectList>("configs", "Level Spawn Config " + (levelToLoad.Value + 1));

        foreach (GameObject toSpawn in objToSpawn)
        {
            InstantiateAsset("prefabs", toSpawn.name);
        }

#if UNITY_EDITOR
        // Reconnect shaders of all materials when in editor
        Material[] allMaterials = materialsBundle.LoadAllAssets <Material>();
        foreach (Material mat in allMaterials)
        {
            mat.shader = Shader.Find(mat.shader.name);
        }

        TMP_FontAsset[] fontAssets = fontsBundle.LoadAllAssets <TMP_FontAsset>();
        foreach (TMP_FontAsset fontAsset in fontAssets)
        {
            Material fontMaterial = fontAsset.material;
            fontMaterial.shader = Shader.Find(fontMaterial.shader.name);
        }
#endif

        // Get components
        PlayerFiringButton playerFiringButton = gameUI.GetComponentInChildren <PlayerFiringButton>(true);
        PlayerInput        playerInput        = player.GetComponent <PlayerInput>();
        EnemyPooler[]      enemyPoolers       = enemyManager.GetComponents <EnemyPooler>();

        // Initializations
        enemyManager.Boss.Initialize(player.ModelTransform, bossWaypoint);
        enemyManager.Initialize(enemySpawnLocations);
        playerFiringButton.Initialize(playerInput);
        foreach (EnemyPooler enemyPooler in enemyPoolers)
        {
            enemyPooler.Initialize(enemyWaypoints, player.ModelTransform);
        }
    }
Example #2
0
 void Awake()
 {
     SharedInstance = this;
 }
Example #3
0
 void Awake()
 {
     _Instance = this;
 }