Beispiel #1
0
        /// <summary>
        /// This is a client-side function, a seed ensures that the outcome is the same for all clients.
        /// Concludes the preparation phase when all players are ready and handles everything that happens:
        /// - AI actions
        /// - Locking player actions
        /// - Election result
        /// - Updating party values (seats, total seats, etc.)
        /// - Handling district effects
        /// - Starting next election cycle
        /// </summary>
        /// <param name="seed">Seed is used to synchronize in multiplayer</param>
        public void ConcludePreparationPhase(int seed)
        {
            UnityEngine.Random.InitState(seed);

            // Change state
            if (State != GameState.PreparationPhase)
            {
                return;
            }
            State = GameState.Election;

            // AI policies
            foreach (Party p in Parties.Where(p => !p.IsHuman))
            {
                p.AI.DistributePolicyPoints();
            }

            // Lock policies
            foreach (Party party in Parties)
            {
                foreach (Policy policy in party.Policies)
                {
                    policy.LockValue();
                }
            }

            // Reset seats
            foreach (Party p in Parties)
            {
                p.Seats = 0;
            }

            // Create and apply election result
            List <DistrictElectionResult> districtResults = new List <DistrictElectionResult>();

            foreach (District district in VisibleDistricts.Values)
            {
                DistrictElectionResult districtResult = district.RunElection(Parties);
                districtResults.Add(districtResult);
            }
            GeneralElectionResult electionResult = new GeneralElectionResult(ElectionCycle, Year, districtResults);

            electionResult.Apply(this);

            // District effects
            foreach (District d in VisibleDistricts.Values)
            {
                d.OnElectionEnd();
            }

            // Handle next election start
            StartNextElectionCycle();

            ElectionAnimationHandler.StartAnimation(electionResult);
        }
Beispiel #2
0
 public void StartAnimation(GeneralElectionResult result)
 {
     ElectionResult = result;
     State          = AnimationState.InitAnimation;
 }
Beispiel #3
0
 public void AddGeneralElectionResult(GeneralElectionResult electionResult)
 {
     ElectionResults.Add(electionResult);
 }