Exemple #1
0
    // If bogie is new, add to TMs bogie list, else replace preexisting with new data
    // Upon first spot, if the spotted vessel is capital ship, the team goes into defence
    public void BogieSpotted(RadarController.Bogie bogie)
    {
        if (teamMood == TeamMood.noContact)
        {
            if (bogie.bogieObject.GetComponent <ShipController>().shipType == ShipController.ShipType.capital)
            {
                teamMood = TeamMood.defensive;
            }
            else
            {
                teamMood = TeamMood.cautious;
            }
        }

        // Check if the gameObject is already described as a plot, if not, add to list of known contacts
        bool addToList = true;

        for (int i = bogies.Count - 1; i <= 0; i--)
        {
            if (bogie.bogieObject == bogies[i].bogieObject)
            {
                bogies[i] = bogie;
                addToList = false;
            }
        }

        if (addToList)
        {
            bogies.Add(bogie);
        }
    }
Exemple #2
0
    void Start()
    {
        perimeter.upToDate = false;

        missionState = MissionState.ongoing;

        teamMood = TeamMood.noContact;

        if (side == TeamSide.green)
        {
            updateRepeat = MissionMaker.difficulty / 2;
        }
        else if (side == TeamSide.red)
        {
            updateRepeat = MissionMaker.difficulty / 2;
        }

        updateRepeat = Mathf.Clamp(updateRepeat, 0.5f, 2f) + UnityEngine.Random.Range(-0.2f, 0.2f);

        InvokeRepeating("UpdateTeam", 2f, updateRepeat);
        InvokeRepeating("RepeatingChecks", 1f, updateRepeat * 0.81f);

        InvokeRepeating("BogieListRemoveOld", 5f, 10f + UnityEngine.Random.Range(0f, 5f));

        // Problem solving repeating calls
        InvokeRepeating("SolveTopProblem", 3f, 0.5f + UnityEngine.Random.Range(-0.1f, 0.1f));
        InvokeRepeating("SortNewProblemList", 10f, 5f + UnityEngine.Random.Range(-2f, 2f));
        InvokeRepeating("CheckProblemsBeingSolved", 12f, 10f + UnityEngine.Random.Range(-2f, 2f));
    }
Exemple #3
0
    void Start()
    {
        if (side == TeamSide.red)
        {
            TeamManager.RedPosUpdated = gameObject.transform.position;
        }
        else if (side == TeamSide.green)
        {
            TeamManager.GreenPosUpdated = gameObject.transform.position;
        }

        ScoreKeeper.kills  = 0;
        ScoreKeeper.losses = 0;

        debug = (SettingsManager.GetDebug() == 1);

        debugOn = false;

        perimeter          = new LFAI.Perimeter(new Vector2(0, 0), 0, sectorSize);
        perimeter.upToDate = false;

        missionState = MissionState.ongoing;
        teamMood     = TeamMood.noContact;

        fighterKills = 0; fighterLosses = 0; capitalKills = 0; capitalLosses = 0;

        if (side == TeamSide.green)
        {
            updateRepeat = MissionMaker.difficulty / 2;
        }
        else if (side == TeamSide.red)
        {
            updateRepeat = MissionMaker.difficulty / 2;
        }

        // Random is used so that different team managers would not run this at the same time

        updateRepeat = Mathf.Clamp(updateRepeat, 0.5f, 2f) + UnityEngine.Random.Range(-0.2f, 0.2f);

        // Delay to let the MissionMaker finish adding to Formations etc
        Invoke("FirstRun", 2f);
    }
Exemple #4
0
    // If bogie is new, add to TMs bogie list, else replace preexisting with new data
    // Upon first spot, if the spotted vessel is capital ship, the team goes into defence
    // UNUSED
    public void BogieSpotted(RadarController.Bogie bogie)
    {
        if (teamMood == TeamMood.noContact)
        {
            if (bogie.bogieObject.GetComponent <ShipController>().shipType == ShipController.ShipType.capital)
            {
                teamMood = TeamMood.cautious;
            }
            else
            {
                teamMood = TeamMood.offensive;
            }
        }

        // Check if the gameObject is already described as a plot, if not, add to list of known contacts
        bool addToList = true;

        if (bogies.Count != 0)
        {
            for (int i = 0; i < bogies.Count; i++)
            {
                // Debug.Log("Bogie count: " + bogies.Count + " i: " + i);

                if (bogie.bogieObject == bogies[i].bogieObject)
                {
                    bogies[i].timeOfContact = bogie.timeOfContact;
                    addToList = false;
                }
            }
        }

        if (addToList)
        {
            bogies.Add(bogie);
        }
    }
Exemple #5
0
    // untested, This gets and handles reports from all flights
    private void GetAndProcessReports()
    {
        LFAI.FormationReport report;

        // problem prioritization parameters, computed every time for being up to date
        float bingoPriority   = 0.5f;
        float dangerTolerance = (float)teamMood / 3;

        foreach (GameObject player in players)
        {
            report = player.GetComponent <PlayerController>().ReportRequest();

            foreach (RadarController.Bogie bogie in report.bogies)
            {
                bool bogieListed = false;

                for (int i = 0; i < bogies.Count; i++)
                {
                    if (bogie.bogieObject == bogies[i].bogieObject)
                    {
                        bogieListed = true;
                        break;
                    }
                }

                if (!bogieListed)
                {
                    bogies.Add(bogie);
                }
            }
        }

        foreach (LFAI.Formation formation in formations)
        {
            report = formation.Lead.GetComponent <VesselAI>().ReportRequest();

            // update formation info based on it's report
            formation.health         = report.health;
            formation.nrHostiles     = report.nrHostiles;
            formation.formationSize  = report.formationSize;
            formation.fuelIsBingo    = report.fuelIsBingo;
            formation.fuelPercentage = report.fuelPercentage;
            formation.hasWPs         = report.hasWp;

            float danger = EvaluateDanger(report.formationSize, report.nrHostiles);

            foreach (RadarController.Bogie bogie in report.bogies)
            {
                bool bogieListed = false;

                for (int i = 0; i < bogies.Count; i++)
                {
                    if (bogie.bogieObject == bogies[i].bogieObject)
                    {
                        bogieListed = true;
                        break;
                    }
                }

                if (!bogieListed)
                {
                    bogies.Add(bogie);
                }
            }

            // Add detected problems to problems list
            if (report.fuelIsBingo)
            {
                if (!CheckProblemDupe(LFAI.TMProbType.flightBingo, formation))
                {
                    newProblems.Add(new LFAI.TMProblem(
                                        LFAI.TMProbType.flightBingo,
                                        bingoPriority,
                                        90, // if fuel is again over 90% average for flight, problem is solved
                                        formation
                                        ));
                }
            }

            if (danger > dangerTolerance)
            {
                if (!CheckProblemDupe(LFAI.TMProbType.flightInDanger, formation))
                {
                    newProblems.Add(new LFAI.TMProblem(
                                        LFAI.TMProbType.flightInDanger,
                                        1f - dangerTolerance, // the higher the threat tolerance, the lower the priority and vice versa
                                        dangerTolerance,      // problem will be solved, if the threat level is lower than tolerance
                                        formation
                                        ));
                }
            }
        }

        if (teamMood == TeamMood.noContact && bogies.Count != 0)
        {
            teamMood = TeamMood.offensive;
        }

        DetermineUnassignedFormations();
    }