Esempio n. 1
0
        /// <summary>
        /// Ends the turn of a player and starts the turn of the next on
        /// </summary>
        public void EndPlayerTurn()
        {
            Assert.IsTrue(isServer, "Only call EndPlayerTurn on the server");
            CurrentPlayer++;
            CurrentPlayer %= m_Players.Count;

            if (CurrentPlayer == FirstPlayerOfCurrentRound)
            {
                void DistributeVictoryPoints(VictoryPoints[] victoryPoints, uint first, uint second,
                                             uint third, VictoryPointCategory category)
                {
                    int pointsFirst  = 0;
                    int pointsSecond = 0;
                    int pointsThird  = 0;

                    switch (category)
                    {
                    case VictoryPointCategory.Science:
                    {
                        pointsFirst  = victoryPoints[0].Science;
                        pointsSecond = victoryPoints[1].Science;
                        pointsThird  = victoryPoints[2].Science;
                        break;
                    }

                    case VictoryPointCategory.Territory:
                    {
                        pointsFirst  = victoryPoints[0].Territory;
                        pointsSecond = victoryPoints[1].Territory;
                        pointsThird  = victoryPoints[2].Territory;
                        break;
                    }

                    case VictoryPointCategory.Economy:
                    {
                        pointsFirst  = victoryPoints[0].Economy;
                        pointsSecond = victoryPoints[1].Economy;
                        pointsThird  = victoryPoints[2].Economy;
                        break;
                    }

                    case VictoryPointCategory.Culture:
                    {
                        pointsFirst  = victoryPoints[0].Culture;
                        pointsSecond = victoryPoints[1].Culture;
                        pointsThird  = victoryPoints[2].Culture;
                        break;
                    }

                    default:
                    {
                        Debug.LogError($"Category {category} is not handled");
                        break;
                    }
                    }

                    if (pointsFirst != pointsSecond)
                    {
                        victoryPoints[0].WinPoints += first;
                        if (pointsSecond != pointsThird)
                        {
                            victoryPoints[1].WinPoints += second;
                            victoryPoints[2].WinPoints += third;
                        }
                        else
                        {
                            victoryPoints[1].WinPoints += third;
                            victoryPoints[2].WinPoints += third;
                        }
                    }
                    else
                    {
                        victoryPoints[0].WinPoints += second;
                        victoryPoints[1].WinPoints += second;
                        victoryPoints[2].WinPoints += third;
                    }
                }

                var playerPoints = new VictoryPoints[PLAYER_COUNT];
                for (int i = 0; i < PLAYER_COUNT; i++)
                {
                    playerPoints[i] = m_Players[i].VictoryPoints;
                }

                Array.Sort(playerPoints, VictoryPoints.CompareSience);
                DistributeVictoryPoints(playerPoints, 4, 2, 1, VictoryPointCategory.Science);

                Array.Sort(playerPoints, VictoryPoints.CompareTerritory);
                DistributeVictoryPoints(playerPoints, 4, 2, 1, VictoryPointCategory.Territory);

                Array.Sort(playerPoints, VictoryPoints.CompareEconomy);
                DistributeVictoryPoints(playerPoints, 4, 2, 1, VictoryPointCategory.Economy);

                Array.Sort(playerPoints, VictoryPoints.CompareCulture);
                DistributeVictoryPoints(playerPoints, 8, 3, 1, VictoryPointCategory.Culture);

                foreach (var victoryPoints in playerPoints)
                {
                    victoryPoints.TempScience   = 0;
                    victoryPoints.TempTerritory = 0;
                    victoryPoints.TempEconomy   = 0;
                    victoryPoints.TempCulture   = 0;
                }

                if (Round == 4 || Round == 8 || Round == 12)
                {
#if NUERNBERG_DEMO
                    if (Round == 8)
                    {
                        EndGame(playerPoints);
                        return;
                    }
#endif
                    CurrentState = State.LeaderCardSelection;
                    var keys = new List <Player>(HasSelectedLeaderCard.Keys);
                    foreach (var key in keys)
                    {
                        HasSelectedLeaderCard[key] = false;
                    }

                    m_Round++;
                    foreach (var player in m_Players)
                    {
                        player.SelectLeaderCard();
                    }

                    return;
                }

                if (Round == 16)
                {
                    EndGame(playerPoints);
                    return;
                }

                CurrentPlayer++;
                CurrentPlayer             %= m_Players.Count;
                FirstPlayerOfCurrentRound  = CurrentPlayer;
                CurrentPlayerMark.position = m_Players[CurrentPlayer].CurrentPlayerMarkPosition();
                m_Round++;
            }

            ChangeCurrentPlayer();
        }
Esempio n. 2
0
 public static int CompareWinPoints(VictoryPoints object1, VictoryPoints object2)
 {
     return(object2.WinPoints.CompareTo(object1.WinPoints));
 }
Esempio n. 3
0
 public static int CompareCulture(VictoryPoints object1, VictoryPoints object2)
 {
     return(object2.Culture.CompareTo(object1.Culture));
 }
Esempio n. 4
0
 public static int CompareEconomy(VictoryPoints object1, VictoryPoints object2)
 {
     return(object2.Economy.CompareTo(object1.Economy));
 }
Esempio n. 5
0
 public static int CompareTerritory(VictoryPoints object1, VictoryPoints object2)
 {
     return(object2.Territory.CompareTo(object1.Territory));
 }
Esempio n. 6
0
 // NOTE: These functions can be used as comparers between two victorypoint types.
 // The higher value is returned as the first value when used for sorting
 public static int CompareSience(VictoryPoints object1, VictoryPoints object2)
 {
     return(object2.Science.CompareTo(object1.Science));
 }