Esempio n. 1
0
 public RoundConfig(int round, int heat, bool completed, VesselSpawner.SpawnConfig config) : base(config)
 {
     this.round = round; this.heat = heat; this.completed = completed; SerializeTeams();
 }
Esempio n. 2
0
        private IEnumerator ExecuteHeat(string hash, HeatModel model)
        {
            Debug.Log(string.Format("[BDArmory.BDAScoreService] Running heat {0}/{1}", hash, model.order));
            Control.VesselSpawner spawner = Control.VesselSpawner.Instance;

            // orchestrate the match
            activePlayers.Clear();
            assists.Clear();
            damageIn.Clear();
            damageOut.Clear();
            deaths.Clear();
            hitsIn.Clear();
            hitsOnTarget.Clear();
            hitsOut.Clear();
            killsOnTarget.Clear();
            longestHitDistance.Clear();
            longestHitWeapon.Clear();
            missileDamageIn.Clear();
            missileDamageOut.Clear();
            missilePartsIn.Clear();
            missilePartsOut.Clear();
            rammedPartsIn.Clear();
            rammedPartsOut.Clear();

            status = StatusType.SpawningVessels;
            var spawnConfig = new VesselSpawner.SpawnConfig(BDArmorySettings.VESSEL_SPAWN_GEOCOORDS.x, BDArmorySettings.VESSEL_SPAWN_GEOCOORDS.y, BDArmorySettings.VESSEL_SPAWN_ALTITUDE, BDArmorySettings.VESSEL_SPAWN_DISTANCE_TOGGLE ? BDArmorySettings.VESSEL_SPAWN_DISTANCE : BDArmorySettings.VESSEL_SPAWN_DISTANCE_FACTOR, BDArmorySettings.VESSEL_SPAWN_DISTANCE_TOGGLE, BDArmorySettings.VESSEL_SPAWN_EASE_IN_SPEED, true, true, 0, null, null, hash);

            if (BDArmorySettings.RUNWAY_PROJECT)
            {
                switch (BDArmorySettings.RUNWAY_PROJECT_ROUND)
                {
                case 33:
                    spawnConfig = new VesselSpawner.SpawnConfig(BDArmorySettings.VESSEL_SPAWN_GEOCOORDS.x, BDArmorySettings.VESSEL_SPAWN_GEOCOORDS.y, 10f, BDArmorySettings.VESSEL_SPAWN_DISTANCE_TOGGLE ? BDArmorySettings.VESSEL_SPAWN_DISTANCE : BDArmorySettings.VESSEL_SPAWN_DISTANCE_FACTOR, BDArmorySettings.VESSEL_SPAWN_DISTANCE_TOGGLE, BDArmorySettings.VESSEL_SPAWN_EASE_IN_SPEED, true, true, 0, null, null, hash);
                    break;
                }
            }
            // spawner.SpawnAllVesselsOnce(BDArmorySettings.VESSEL_SPAWN_GEOCOORDS.x, BDArmorySettings.VESSEL_SPAWN_GEOCOORDS.y, BDArmorySettings.VESSEL_SPAWN_ALTITUDE, BDArmorySettings.VESSEL_SPAWN_DISTANCE_TOGGLE ? BDArmorySettings.VESSEL_SPAWN_DISTANCE : BDArmorySettings.VESSEL_SPAWN_DISTANCE_FACTOR, BDArmorySettings.VESSEL_SPAWN_DISTANCE_TOGGLE, BDArmorySettings.VESSEL_SPAWN_EASE_IN_SPEED, true, true, 0, null, null, hash);
            spawner.SpawnAllVesselsOnce(spawnConfig);
            while (spawner.vesselsSpawning)
            {
                yield return(new WaitForFixedUpdate());
            }
            if (!spawner.vesselSpawnSuccess)
            {
                Debug.Log("[BDArmory.BDAScoreService] Vessel spawning failed.");
                yield break;
            }
            yield return(new WaitForFixedUpdate());

            status = StatusType.RunningHeat;
            // NOTE: runs in separate coroutine
            if (BDArmorySettings.RUNWAY_PROJECT)
            {
                switch (BDArmorySettings.RUNWAY_PROJECT_ROUND)
                {
                case 33:
                    BDACompetitionMode.Instance.StartRapidDeployment(0);
                    break;

                default:
                    BDACompetitionMode.Instance.StartCompetitionMode(BDArmorySettings.COMPETITION_DISTANCE);
                    break;
                }
            }
            else
            {
                BDACompetitionMode.Instance.StartCompetitionMode(BDArmorySettings.COMPETITION_DISTANCE);
            }
            yield return(new WaitForFixedUpdate()); // Give the competition start a frame to get going.

            // start timer coroutine for the duration specified in settings UI
            var duration = Core.BDArmorySettings.COMPETITION_DURATION * 60d;
            var message  = "Starting " + (duration > 0 ? "a " + duration.ToString("F0") + "s" : "an unlimited") + " duration competition.";

            Debug.Log("[BDArmory.BDAScoreService]: " + message);
            BDACompetitionMode.Instance.competitionStatus.Add(message);
            while (BDACompetitionMode.Instance.competitionStarting || BDACompetitionMode.Instance.sequencedCompetitionStarting)
            {
                yield return(new WaitForFixedUpdate()); // Wait for the competition to actually start.
            }
            if (!BDACompetitionMode.Instance.competitionIsActive)
            {
                message = "Competition failed to start for heat " + hash + ".";
                BDACompetitionMode.Instance.competitionStatus.Add(message);
                Debug.Log("[BDArmory.BDAScoreService]: " + message);
                yield break;
            }
            competitionStarted = true;
            while (BDACompetitionMode.Instance.competitionIsActive) // Wait for the competition to finish (limited duration and log dumping is handled directly by the competition now).
            {
                yield return(new WaitForSeconds(1));
            }
        }