Exemplo n.º 1
0
    // Use this for initialization
    void Awake()
    {
        enemyList = new List<Enemy>();
        basementManager = GetComponent<BasementManager>();
        playerManager = GetComponent<PlayerManager>();
        gameManager = GetComponent<GameManager>();

        enemyBodiesPrefabList = new List<GameObject>();

        for(int i = 0; i < 10; i++)
        {
            enemyBodiesPrefabList.Add(Resources.Load<GameObject>("Prefabs/Enemies/EnemyBody_" + i));
        }

        enemyPrefab = Resources.Load<Enemy>("Prefabs/Enemy");
        pathPrefab = Resources.Load<GameObject>("Prefabs/Path0");
        spawnersPrefab = Resources.Load<GameObject>("Prefabs/Spawners");

        spawnPoints = new List<Transform>();
        path = new List<Vector2>();

        var allChildren = pathPrefab.transform.Cast<Transform>().Select(t => t.gameObject).ToArray();
        foreach (GameObject t in allChildren)
        {
            path.Add(new Vector2(t.transform.position.x, t.transform.position.y));
        }

        allChildren = spawnersPrefab.transform.Cast<Transform>().Select(t => t.gameObject).ToArray();

        foreach (GameObject go in allChildren)
        {
            spawnPoints.Add(go.transform);
        }

        gameManager.GameStateChangedEvent += OnGameStateChangedEvent;
    }
Exemplo n.º 2
0
    void Awake()
    {
        playerManager = GetComponent<PlayerManager>();
        playerManager.AllPlayersDiedEvent += OnAllPlayersDiedEvent;
        playerManager.MonsterDiedEvent += OnMonsterDiedEvent;
        basementManager = GetComponent<BasementManager>();

        var audios = gameObject.GetComponents<AudioSource>();

        screamAudio = audios[0];

        basementManager.AllCitizensDiedEvent += OnAllCitiziensDiedEvent;
    }