Exemplo n.º 1
0
    void SpawnFinish(Vector3 position, ConfiguredRoom room)
    {
        Debug.Log("Finish spawned!");
        var spawned = Instantiate(this.finish);

        room.finish      = spawned;
        spawned.position = position;
    }
Exemplo n.º 2
0
    void PopulateRoomWithEnemies(ConfiguredRoom room)
    {
        // Pick a number from 2 to 5
        var enemyCount = Random.Range(2, 6);

        for (int i = 0; i < enemyCount; i++)
        {
            var nType  = Random.Range(0, EnemyLevel + 1);
            var nEnemy = Instantiate(enemy[nType], GetRandomLocalEnemyPosition(room.room), Quaternion.identity, room.room);
            nEnemy.name = "Enemy Type " + nType + " [" + Random.Range(10000, 100000) + "]";
            var nEnemyControl = nEnemy.GetComponent <EnemyController>();
            nEnemyControl.Speed     = nEnemyControl.InitSpeed = Random.Range(0.2f, 1f);
            nEnemyControl.EnemyType = nType;
            //nEnemyControl.HitPoints = nEnemyControl.MaxHitPoints = Random.Range(3, 7);
        }
    }
Exemplo n.º 3
0
    void CreateRoom(Vector2Int cell)
    {
        var position = grid.CellToLocal(new Vector3Int(cell.x, cell.y, 0));

        var instance = Instantiate(room);

        instance.name     = string.Format("Room ({0},{1}) / #{2}", cell.x, cell.y, roomId++);
        instance.position = position;

        var result = new ConfiguredRoom(instance);

        // Either spawn the finish, or just enemies
        if (ShouldSpawnFinish())
        {
            SpawnFinish(position, result);
        }
        else
        {
            PopulateRoomWithEnemies(result);
        }

        active.Add(cell, result);
    }
Exemplo n.º 4
0
    bool HasEnemies(ConfiguredRoom room)
    {
        var enemies = room.room.gameObject.GetComponentsInChildren <EnemyController>();

        return(enemies.Any(enemy => enemy.MyState != EnemyController.EnemyState.Dead));
    }