Exemple #1
0
    protected void InitializeTeamMapAI()
    {
        Godot.Collections.Array <TeamMapAISetting> teamMapAISettings = GameStates.GetTeamMapAISettings();

        TeamMapAIs = new Godot.Collections.Array <TeamMapAI>();

        // Start with neutral and above
        for (int index = 0; index < (int)(Team.TeamCode.NEUTRAL); index++)
        {
            TeamMapAI ai = (TeamMapAI)((PackedScene)GD.Load("res://ai/TeamMapAI.tscn")).Instance();
            ai.Name = nameof(TeamMapAI) + "_" + (Team.TeamCode)index;
            AddChild(ai);

            ai.Initialize(this, _inventoryManager, CapaturableBaseManager.GetBases(), (Team.TeamCode)index, _pathFinding);

            if (teamMapAISettings != null)
            {
                ai.SetMaxUnitUsageAmount(teamMapAISettings[index].Budget);
                ai.SetAutoSpawnMember(teamMapAISettings[index].AutoSpawnMember);
            }

            TeamMapAIs.Add(ai);

            foreach (CapturableBase capturable in CapaturableBaseManager.GetBases())
            {
                capturable.Connect(nameof(CapturableBase.BaseTeamChangeSignal), ai, nameof(TeamMapAI.HandleCapturableBaseCaptured));
            }
        }
    }