// Use this for initialization
    void Start()
    {
        int squad_size = 0;

        level_generator   = gameObject.GetComponent <LevelGenerator>();
        squad_generator   = gameObject.GetComponent <SquadGenerator>();
        enemy_generator   = gameObject.GetComponent <EnemyGenerator>();
        cover_manager     = gameObject.GetComponent <CoverManager>();
        formation_manager = gameObject.GetComponent <FormationManager>();

        squadies = new List <GameObject>();
        enemies  = new List <GameObject>();

        // Generate Squad
        if (no_of_squadies > 8)
        {
            no_of_squadies = 8;
        }

        //no_of_enemies = no_of_squadies * 2;

        level_generator.GenerateNewLevel(level_height, level_width, grid_section_size);

        Vector3 level_size = new Vector3(level_width * grid_section_size, 0.0f, level_height * grid_section_size);

        // This is to stop duplicate cover spots spawning!
        if (cover_spacing <= 0)
        {
            cover_spacing = 1;
        }

        cover_manager.GenerateCoverPoints(level_size, no_cover_passes_across, no_cover_passes_up, cover_spacing);

        // Set Player position
        player.transform.position = new Vector3(player.transform.position.x, 1.0f, player.transform.position.z);

        // Position ID's
        cover_manager.SetSquads(no_of_squadies);

        squad_generator.GenerateSquad(no_of_squadies, cover_manager.StartupCover(no_of_squadies, player.transform.position), ref squadies);

        if (no_of_squadies % 2 == 1)             // If we have a remainder ie Squad sizes are not even
        {
            squad_size = no_of_squadies / 2 + 1; // We use the biggest squad size
        }

        if (no_of_squadies % 2 == 0) // If they are even all good
        {
            squad_size = no_of_squadies / 2;
        }

        // Tell the formation manager about the largest squad size
        formation_manager.GenerateFormations(player, squad_size);

        //enemy_generator.GenerateEnemies(no_of_enemies, cover_manager.GetEnemyPositions(no_of_enemies, enemy_generator.GetSpawnPoints()), ref enemies);
    }
Example #2
0
    private void NewSquad()
    {
        HashSet <Vector2Int> tiles = new HashSet <Vector2Int>(trainingRoom.unitSpaceFloors);

        tiles.UnionWith(trainingRoom.unitSpaceWalls);
        Vector2Int offset = new Vector2Int(Mathf.RoundToInt(transform.position.x) + trainingRoom.Position.x, Mathf.RoundToInt(transform.position.z) + trainingRoom.Position.y);

        squad.currentRoom = trainingRoom;
        SquadGenerator.AttachNewSquadTo(this, unitPrefabs, tiles, unitsInSquad, random, trainingRoom, offset, instantiatedPlayer);
    }
Example #3
0
    private void NewSquadUnits()
    {
        //NOTE: it might be useful to just fill in empty positions of the squad instead.
        HashSet <Vector2Int> tiles = new HashSet <Vector2Int>(trainingRoom.unitSpaceFloors);

        tiles.UnionWith(trainingRoom.unitSpaceWalls);
        Vector2Int offset = new Vector2Int(Mathf.RoundToInt(transform.position.x) + trainingRoom.Position.x, Mathf.RoundToInt(transform.position.z) + trainingRoom.Position.y);

        squad.currentRoom = trainingRoom;
        for (int i = 0; i < MAX_SQUAD_SIZE - squad.NumberOfAliveUnits; i++)
        {
            SquadGenerator.AddUnitToSquad(this, unitPrefabs, tiles, trainingRoom, offset, random, instantiatedPlayer);
        }
    }