Пример #1
0
        public void moat_played_against_witch()
        {
            var playerA = new Player(1, "a");
            var playerB = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                playerA, playerB
            };
            var supply = new Supply(
                new List <Pile> {
                new Pile(Card.Curse, 10)
            },
                new List <Pile>(),
                new List <Pile>());
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);

            playerA.GainToHand(Card.Witch);
            playerB.GainToHand(Card.Moat);
            playerA.PlayStatus = PlayStatus.ActionPhase;
            game.Submit(playerA.PlayerName, PlayerAction.Play, Card.Witch);
            game.Submit(playerB.PlayerName, ActionRequestType.SelectCards, new List <Card> {
                Card.Moat
            });

            Assert.Empty(playerB.DiscardPile);
        }
Пример #2
0
        public void artisan_card_too_expensive()
        {
            const Card card         = Card.Artisan;
            const int  supplyAmount = 10;

            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var supply = new Supply(new List <Pile>(), new List <Pile>(),
                                    new List <Pile>()
            {
                new Pile(card, supplyAmount),
                new Pile(Card.Chapel, 10)
            });
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);

            player.GainToHand(Card.Artisan);
            player.PlayStatus = PlayStatus.ActionPhase;
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Artisan);
            game.Submit(player.PlayerName, ActionRequestType.SelectCards, new List <Card> {
                card
            });

            var actualSupplyCount = game.Supply.KingdomSupply.First().Cards.Count;

            Assert.Empty(player.DiscardPile);
            Assert.Equal(actualSupplyCount, supplyAmount);
        }
Пример #3
0
	// Use this for initialization
	void Start ()
    {
        enemyPumpkinManager = GetComponent<EnemyPumpkinManager>();
        victoryCondition = GetComponent<VictoryCondition>();
        player = GameObject.FindGameObjectWithTag("Player");
        playerManagerBackup = player.GetComponent<PlayerManagerBackup>();
	}
Пример #4
0
        public void priest_is_played_with_trashing()
        {
            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var supply = new Supply(
                new List <Pile>(),
                new List <Pile>(),
                new List <Pile>());
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);


            player.PlayStatus = PlayStatus.ActionPhase;
            player.GainToHand(Card.Copper);
            player.GainToHand(Card.Copper);
            player.GainToHand(Card.Copper);
            player.GainToHand(Card.Priest);
            player.GainToHand(Card.Chapel);
            player.NumberOfActions = 2;
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Priest);
            game.Submit(player.PlayerName, ActionRequestType.SelectCards, new List <Card> {
                Card.Copper
            });
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Chapel);
            game.Submit(player.PlayerName, ActionRequestType.SelectCards, new List <Card> {
                Card.Copper, Card.Copper
            });

            Assert.Equal(6, player.MoneyPlayed);
        }
Пример #5
0
 // Use this for initialization
 void Start()
 {
     enemyPumpkinManager = GetComponent <EnemyPumpkinManager>();
     victoryCondition    = GetComponent <VictoryCondition>();
     player = GameObject.FindGameObjectWithTag("Player");
     playerManagerBackup = player.GetComponent <PlayerManagerBackup>();
 }
Пример #6
0
        public void cache_test_gain_during_action_phase()
        {
            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var supply = new Supply(
                new List <Pile>()
            {
                new Pile(Card.Copper, 10)
            },
                new List <Pile>(),
                new List <Pile>());
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);

            player.PlayStatus = PlayStatus.ActionPhase;
            player.Gain(Card.Cache);
            game.CheckPlayStack(player);

            var expected = new List <Card> {
                Card.Cache, Card.Copper, Card.Copper
            };

            Assert.Equal(expected, player.DiscardPile);
        }
Пример #7
0
    private void SetupVictoryCondition(AgeTransform item, VictoryCondition victoryCondition, int index)
    {
        VictoryStatusItem component = item.GetComponent <VictoryStatusItem>();

        component.SetContent(victoryCondition, base.GuiService.GuiPanelHelper, base.PlayerController, index);
        component.UpdateVictoryStatus(this.empires);
    }
Пример #8
0
        public void cellar_discard_success()
        {
            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var supply = new Supply(new List <Pile>(), new List <Pile>(), new List <Pile>());
            var vc     = new VictoryCondition();
            var game   = new Game.Game(0, players, supply, vc);

            player.GainToHand(Card.Cellar);
            player.Hand.AddRange(Enumerable.Repeat(Card.Copper, 4));
            player.Deck.AddRange(Enumerable.Repeat(Card.Silver, 5));
            player.PlayStatus = PlayStatus.ActionPhase;
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Cellar);
            game.Submit(player.PlayerName, ActionRequestType.SelectCards, Enumerable.Repeat(Card.Copper, 3));

            var coppersInHand = player.Hand.Count(x => x == Card.Copper);
            var silversInHand = player.Hand.Count(x => x == Card.Silver);
            var discardCount  = player.DiscardPile.Count();

            Assert.Equal(1, coppersInHand);
            Assert.Equal(3, silversInHand);
            Assert.Equal(3, discardCount);
            Assert.Equal(1, player.PlayedCards.Count);
            Assert.Equal(2, player.Deck.Count);
        }
Пример #9
0
 public void SetMetVictoryCondition(VictoryCondition victoryCondition)
 {
     if(!victoryCondition) return;
     metVictoryCondition = victoryCondition;
     winner = metVictoryCondition.GetWinner();
     SetUpMessage();
 }
Пример #10
0
 bool IsBarrier(VictoryCondition victor)
 {
     if(playersCar == null)
     {
         playersCar = victor.targets[0].GetComponent<CarProperty>();
     }
     return (playersCar.GetBarrierTime() >= victor.times);
 }
Пример #11
0
    public static void CreateVictoryCondition()
    {
        VictoryCondition theVC = ScriptableObject.CreateInstance <VictoryCondition>();

        AssetDatabase.CreateAsset(theVC, "Assets/Resources/VictoryConditions/NewVC.asset");
        AssetDatabase.SaveAssets();

        Selection.activeObject = theVC;
    }
Пример #12
0
 public void SetMetVictoryCondition(VictoryCondition victoryCondition)
 {
     if (!victoryCondition)
     {
         return;
     }
     metVictoryCondition = victoryCondition;
     winner = metVictoryCondition.GetWinner();
 }
Пример #13
0
    IEnumerator GameTimerFunction()
    {
        startTime = Time.fixedTime;
        yield return(new WaitForSeconds(initialGameTime));

        Debug.Log("Time is up");
        VictoryCondition vc = va.gameObject.GetComponentInChildren(typeof(VictoryCondition)) as VictoryCondition;

        vc.loseByTimeUp();
    }
Пример #14
0
    public void Victory(VictoryCondition endCondition)
    {
        if (endCondition == null)
        {
            return;
        }

        metWinCondition = endCondition;
        winner = metWinCondition.GetWinningPlayer();
    }
Пример #15
0
 bool IsFinishLap(VictoryCondition victor)
 {
     if(!playersLap && !playersLapB)
     {
         playersLap = victor.targets[0].GetComponent<DriftCar>();
         playersLapB = victor.targets[0].GetComponent<CarB>();
     }
     if(playersLap)
         return (playersLap.round == victor.times);
     else
         return (playersLapB.round == victor.times);
 }
Пример #16
0
        //TODO: rename echo hub or move logic to GameHub
        //TODO: refactor game startup as builder or factory
        //TODO: performance add homogenous pile class for most piles
        //you're going to invoke this method from the client app
        public void NewGame(bool randomizedKingdom)
        {
            var gameModel = new Models.Game()
            {
                DateTime = DateTime.Now
            };

            _context.Game.Add(gameModel);
            _context.SaveChanges();

            ISupplyFactory supplyFactory;

            if (randomizedKingdom)
            {
                supplyFactory = new RandomizedSupplyFactory();
            }
            else
            {
                supplyFactory = new DefaultSupplyFactory();
            }

            var supply = supplyFactory.Create(2);

            var ben   = new Player(1, "*****@*****.**");
            var maria = new Player(2, "*****@*****.**");

            var players = new List <IPlayer>()
            {
                ben, maria
            };

            var defaultVictoryCondition = new VictoryCondition();

            var game = new Game.Game(gameModel.GameId, players, supply, defaultVictoryCondition);

            game.Initialize();

            var gameState = new Models.GameState()
            {
                GameId = game.GameId,
                State  = game.GetGameState()
            };

            _context.GameState.Add(gameState);
            _context.SaveChanges();

            //you're going to configure your client app to listen for this
            Clients.All.SendAsync("Send", supply);
            Clients.All.SendAsync("Game", game.GameId);
            Clients.User(ben.PlayerName).SendAsync("Player", ben);
            Clients.User(maria.PlayerName).SendAsync("Player", maria);
        }
Пример #17
0
 bool IsDestroy(VictoryCondition victor)
 {
     int count = 0;
     foreach(GameObject target in victor.targets)
     {
         if(target)
             count++;
     }
     if(count == 0)
         return true;
     else
         return false;
 }
Пример #18
0
 void IVictoryManagementService.DiscardAllVictoryConditionsRaisedThisTurn()
 {
     if (this.VictoryConditionsRaisedThisTurn != null && this.VictoryConditionsRaisedThisTurn.Count > 0)
     {
         for (int i = 0; i < this.VictoryConditionsRaisedThisTurn.Count; i++)
         {
             VictoryCondition victoryCondition = this.VictoryConditionsRaisedThisTurn[i];
             if (!this.VictoryConditionsDiscardedThisGame.Contains(victoryCondition.Name))
             {
                 this.VictoryConditionsDiscardedThisGame.Add(victoryCondition.Name);
             }
         }
     }
 }
Пример #19
0
        public void VictoryConditionDiagonalBottomToTopLeftToRight()
        {
            Board board = CreateBoard();

            for (int i = 0; i < board.Size; i++)
            {
                board.MarkBoard(CreatePlay(i, board.Size - 1 - i, Marker.X));
            }

            Play play = CreatePlay(0, 2, Marker.X);

            VictoryCondition ticTacToe = new VictoryCondition();

            bool isWinCondition = ticTacToe.FoundVictoryCondition(board, play.PlayerId);

            Assert.AreEqual(true, isWinCondition);
        }
Пример #20
0
        public void VictoryConditionInVerticalLine(int columnIndex)
        {
            Board board = CreateBoard();

            for (int i = 0; i < board.Size; i++)
            {
                board.MarkBoard(CreatePlay(i, columnIndex, Marker.X));
            }

            const int anyStartingXPosition = 0;

            Play play = CreatePlay(anyStartingXPosition, columnIndex, Marker.X);

            VictoryCondition ticTacToe = new VictoryCondition();

            bool isWinCondition = ticTacToe.FoundVictoryCondition(board, play.PlayerId);

            Assert.AreEqual(true, isWinCondition);
        }
Пример #21
0
 bool IsAttak(VictoryCondition victor)
 {
     if(cars == null)
     {
         cars = new CarProperty[victor.targets.Length];
         int i = 0;
         foreach(GameObject target in victor.targets)
         {
             cars[i] = target.GetComponent<CarProperty>();
             i++;
         }
     }
     int count = 0;
     foreach(CarProperty car in cars)
     {
         count += car.GetSkillTime();
     }
     return (count >= victor.times);
 }
Пример #22
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)GameMode;
         hashCode = (hashCode * 397) ^ IsMatchComplete.GetHashCode();
         hashCode = (hashCode * 397) ^ (MapId?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ MatchDuration.GetHashCode();
         hashCode = (hashCode * 397) ^ MatchEndReason.GetHashCode();
         hashCode = (hashCode * 397) ^ MatchId.GetHashCode();
         hashCode = (hashCode * 397) ^ (MatchStartDate != null ? MatchStartDate.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)MatchType;
         hashCode = (hashCode * 397) ^ (Players?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ PlaylistId.GetHashCode();
         hashCode = (hashCode * 397) ^ SeasonId.GetHashCode();
         hashCode = (hashCode * 397) ^ (Teams?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ VictoryCondition.GetHashCode();
         return(hashCode);
     }
 }
Пример #23
0
 /// <summary>
 /// Load the data from the correspondant level info
 /// </summary>
 void LoadLevelDataArcade()
 {
     // TODO: Revisar como gestionamos esto
     //levelInfo = gameManager.GetCurrentLevelInfo();
     levelInfo        = gameManager.CurrentLevelInfo;
     victoryCondition = levelInfo.victoryCondition;
     enemiesToDestroy = levelInfo.enemiesToDefeat;
     // Esto habrá que manejarlo de otro modo
     // Forzamos provisonalmente que se equipen las asignadas
     // Attack
     gameManager.playerAttributes.unlockedAttackActions = levelInfo.attackActionsAvailable;
     // Control chorras para la Build
     if (PlayerReference.playerControl == null)
     {
         PlayerReference.Initiate(FindObjectOfType <RobotControl>().gameObject);
     }
     // Control de habilidades del prota para el formato de niveekes de ka demo
     // Attack
     //if (gameManager.unlockedAttackActions > 1)
     //    PlayerReference.playerControl.ActiveAttackMode = (AttackMode)(gameManager.unlockedAttackActions - 1);
     //// Defense
     //gameManager.unlockedDefenseActions = levelInfo.defenseActionsAvailable;
     //if (gameManager.unlockedDefenseActions > 1)
     //    PlayerReference.playerControl.ActiveDefenseMode = (DefenseMode)(gameManager.unlockedDefenseActions - 1);
     //// Jump
     //gameManager.unlockedJumpActions = levelInfo.jumpActionsAvailable;
     //if (gameManager.unlockedJumpActions > 1)
     //    PlayerReference.playerControl.ActiveJumpMode = (JumpMode)(gameManager.unlockedJumpActions - 1);
     //// Sprint
     //gameManager.unlockedSprintActions = levelInfo.sprintActionsAvailable;
     //if (gameManager.unlockedSprintActions > 1)
     //    PlayerReference.playerControl.ActiveSprintMode = (SprintMode)(gameManager.unlockedSprintActions - 1);
     //
     terrainManager.InitiateManager(levelInfo);
     //
     if (enemyManager != null)
     {
         enemyManager.InitiateManager(levelInfo);
     }
 }
Пример #24
0
        public void emporium_gained_from_remodel()
        {
            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var pileFactory = new PileFactory(1);
            var supply      = new Supply(
                new List <Pile>(),
                new List <Pile>(),
                pileFactory.Create(new List <Card> {
                Card.Emporium
            }));
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);


            player.GainToHand(Card.Village);
            player.GainToHand(Card.Village);
            player.GainToHand(Card.Village);
            player.GainToHand(Card.Village);
            player.GainToHand(Card.Gold);
            player.GainToHand(Card.Remodel);
            player.PlayStatus = PlayStatus.ActionPhase;
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Village);
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Village);
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Village);
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Village);
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Remodel);
            game.Submit(player.PlayerName, ActionRequestType.SelectCards, new List <Card> {
                Card.Gold
            });
            game.Submit(player.PlayerName, ActionRequestType.SelectCards, new List <Card> {
                Card.Emporium
            });

            Assert.Equal(2, player.VictoryTokens);
        }
Пример #25
0
 /// <summary>
 /// Check the victory condition in each frame.
 /// </summary>
 private void Update()
 {
     if (victoryCondition == null)
     {
         var vc = GameObject.Find("VictoryCondition");
         if (vc != null)
         {
             victoryCondition = vc.GetComponent <VictoryCondition>();
             victoryCondition.players.Add(this);
         }
     }
     if (hasAuthority && InGame && victoryCondition != null)
     {
         if (victoryCondition.PlayerMeetsLosingConditions(this))
         {
             Lose();
         }
         else if (victoryCondition.PlayerMeetsConditions(this))
         {
             Win();
         }
     }
 }
Пример #26
0
        public void survivors_reorder_top_2()
        {
            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var pileFactory = new PileFactory(1);
            var supply      = new Supply(
                new List <Pile>(),
                new List <Pile>(),
                new List <Pile>());
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);


            player.GainToHand(Card.Survivors);
            player.Deck.Add(Card.Copper);
            player.Deck.Add(Card.Silver);

            player.PlayStatus = PlayStatus.ActionPhase;
            player.NumberOfActions++;
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Survivors);
            game.Submit(player.PlayerName, ActionRequestType.SelectOptions, new List <ActionResponse> {
                ActionResponse.Put
            });
            game.Submit(player.PlayerName, ActionRequestType.SelectCards, new List <Card> {
                Card.Silver, Card.Copper
            });
            game.CheckPlayStack(player);

            var expected = new List <Card> {
                Card.Silver, Card.Copper
            };

            Assert.Equal(expected, player.Deck);
        }
Пример #27
0
        public void merchant_tests()
        {
            var playerA = new Player(1, "a");
            var players = new List <IPlayer>()
            {
                playerA
            };
            var supply = new Supply(
                new List <Pile>(),
                new List <Pile>(),
                new List <Pile>());
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);

            playerA.GainToHand(Card.Merchant);
            playerA.GainToHand(Card.Silver);

            playerA.PlayStatus = PlayStatus.ActionPhase;
            game.Submit(playerA.PlayerName, PlayerAction.Play, Card.Merchant);
            playerA.PlayStatus = PlayStatus.BuyPhase;
            game.Submit(playerA.PlayerName, PlayerAction.Play, Card.Silver);

            Assert.Equal(3, playerA.MoneyPlayed);
        }
Пример #28
0
        public void emporium_gained_with_5_actions_in_play()
        {
            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var pileFactory = new PileFactory(1);
            var supply      = new Supply(
                new List <Pile>(),
                new List <Pile>(),
                pileFactory.Create(new List <Card> {
                Card.Emporium
            }));
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);


            player.GainToHand(Card.Village);
            player.GainToHand(Card.Village);
            player.GainToHand(Card.Village);
            player.GainToHand(Card.Village);
            player.GainToHand(Card.Village);
            player.PlayStatus = PlayStatus.ActionPhase;
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Village);
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Village);
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Village);
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Village);
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Village);
            player.EndActionPhase();
            player.MoneyPlayed  = int.MaxValue;
            player.NumberOfBuys = int.MaxValue;
            game.Submit(player.PlayerName, PlayerAction.Buy, Card.Emporium);

            Assert.Equal(2, player.VictoryTokens);
        }
Пример #29
0
        public void ducat_is_gained_in_action_phase()
        {
            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var supply = new Supply(
                new List <Pile>(),
                new List <Pile>(),
                new List <Pile>());
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);


            player.PlayStatus = PlayStatus.ActionPhase;
            player.GainToHand(Card.Copper);
            player.GainToHand(Card.Ducat);
            game.CheckPlayStack(player);
            game.Submit(player.PlayerName, ActionRequestType.YesNo, ActionResponse.Yes);
            Assert.Equal(PlayStatus.ActionPhase, player.PlayStatus);
            Assert.Single(player.Hand);
            Assert.Single(supply.Trash);
        }
Пример #30
0
        public void lighthouse_is_played()
        {
            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var supply = new Supply(
                new List <Pile>(),
                new List <Pile>(),
                new List <Pile>());
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);

            player.GainToHand(Card.Lighthouse);
            player.PlayStatus = PlayStatus.ActionPhase;
            game.Submit(player.PlayerName, PlayerAction.Play, Card.Lighthouse);
            Assert.Equal(1, player.MoneyPlayed);
            player.EndTurn();
            player.StartTurn(game);
            game.CheckPlayStack(player);

            Assert.Equal(1, player.MoneyPlayed);
        }
Пример #31
0
        public void nomad_camp_gained_during_buy_phase()
        {
            var player  = new Player(1, "b");
            var players = new List <IPlayer>()
            {
                player
            };
            var supply = new Supply(
                new List <Pile>(),
                new List <Pile>(),
                new List <Pile>()
            {
                new Pile(Card.NomadCamp, 10)
            });
            var vc   = new VictoryCondition();
            var game = new Game.Game(0, players, supply, vc);

            player.PlayStatus   = PlayStatus.BuyPhase;
            player.NumberOfBuys = 1;
            player.MoneyPlayed  = 10;
            game.Submit(player.PlayerName, PlayerAction.Buy, Card.NomadCamp);
            Assert.Single(player.Deck);
            Assert.Empty(player.DiscardPile);
        }
Пример #32
0
    public override IEnumerator LoadGame(Game game)
    {
        yield return(base.LoadGame(game));

        ISessionService service = Services.GetService <ISessionService>();

        this.InterpreterContext = new InterpreterContext(null);
        this.InterpreterContext.SimulationObject = new SimulationObject("VictoryController");
        this.InterpreterContext.SimulationObject.ModifierForward = ModifierForwardType.ParentOnly;
        float num = 1f;
        IDatabase <SimulationDescriptor> database = Databases.GetDatabase <SimulationDescriptor>(false);

        if (database != null)
        {
            SimulationDescriptor simulationDescriptor;
            if (database.TryGetValue("ClassVictoryController", out simulationDescriptor))
            {
                this.InterpreterContext.SimulationObject.AddDescriptor(simulationDescriptor);
            }
            string value = Amplitude.Unity.Runtime.Runtime.Registry.GetValue(VictoryManager.Registers.LobbyDataFilter);
            if (!string.IsNullOrEmpty(value))
            {
                string[] array = value.Split(Amplitude.String.Separators, StringSplitOptions.RemoveEmptyEntries);
                if (array.Length != 0 && service != null && service.Session != null)
                {
                    foreach (string text in array)
                    {
                        string lobbyData = service.Session.GetLobbyData <string>(text, null);
                        if (!string.IsNullOrEmpty(lobbyData))
                        {
                            string x = string.Format("VictoryModifier{0}{1}", text, lobbyData);
                            if (database.TryGetValue(x, out simulationDescriptor))
                            {
                                this.InterpreterContext.SimulationObject.AddDescriptor(simulationDescriptor);
                                SimulationModifierDescriptor simulationModifierDescriptor = Array.Find <SimulationModifierDescriptor>(simulationDescriptor.SimulationModifierDescriptors, (SimulationModifierDescriptor y) => y is SingleSimulationModifierDescriptor && y.TargetPropertyName == "PeacePointThreshold");
                                if (simulationModifierDescriptor != null)
                                {
                                    num *= float.Parse((simulationModifierDescriptor as SingleSimulationModifierDescriptor).Value);
                                }
                            }
                        }
                    }
                }
            }
            this.InterpreterContext.SimulationObject.Refresh();
        }
        foreach (Empire empire in base.Game.Empires)
        {
            if (empire is MajorEmpire)
            {
                (empire as MajorEmpire).SetPropertyBaseValue("TreatyPeacePointPerTurnMult", num);
            }
        }
        int  num2 = 0;
        int  num3 = 0;
        bool flag = Services.GetService <IDownloadableContentService>().IsShared(DownloadableContent16.ReadOnlyName);

        if (base.Game.World.Regions != null)
        {
            for (int j = 0; j < base.Game.World.Regions.Length; j++)
            {
                if (!base.Game.World.Regions[j].IsOcean && !base.Game.World.Regions[j].IsWasteland)
                {
                    num2++;
                }
                else if (flag && base.Game.World.Regions[j].IsOcean && base.Game.World.Regions[j].NavalEmpire != null)
                {
                    PirateCouncil agency = base.Game.World.Regions[j].NavalEmpire.GetAgency <PirateCouncil>();
                    if (agency != null && agency.GetRegionFortresses(base.Game.World.Regions[j]).Count > 0)
                    {
                        num3++;
                    }
                }
            }
        }
        if (num2 + num3 <= 0)
        {
            Diagnostics.LogError("Invalid number of regions (value: {0}), rounding up to '1'.", new object[]
            {
                num2
            });
            num2 = 1;
        }
        Diagnostics.Log("Registering new data (name: {0}, land: {1}, ocean: {2})", new object[]
        {
            "TotalNumberOfRegions",
            num2,
            num3
        });
        this.InterpreterContext.Register("NumberOfLandRegions", num2);
        this.InterpreterContext.Register("TotalNumberOfRegions", num2 + num3);
        if (game.Turn == 0 && service != null && service.Session != null)
        {
            using (IEnumerator <VictoryCondition> enumerator = this.VictoryConditions.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    VictoryCondition victoryCondition = enumerator.Current;
                    if (service.Session.GetLobbyData(victoryCondition.Name) != null && !service.Session.GetLobbyData <bool>(victoryCondition.Name, false))
                    {
                        if (!this.VictoryConditionsDiscabledThisGame.Contains(victoryCondition.Name))
                        {
                            this.VictoryConditionsDiscabledThisGame.Add(victoryCondition.Name);
                            Diagnostics.Log("Disabling victory condition '{0}'.", new object[]
                            {
                                victoryCondition.Name
                            });
                        }
                        if (!this.VictoryConditionsDiscardedThisGame.Contains(victoryCondition.Name))
                        {
                            this.VictoryConditionsDiscardedThisGame.Add(victoryCondition.Name);
                            Diagnostics.Log("Discarding victory condition '{0}'.", new object[]
                            {
                                victoryCondition.Name
                            });
                        }
                    }
                }
                yield break;
            }
        }
        yield break;
    }
Пример #33
0
 bool IsPosition(VictoryCondition victor)
 {
     int count = 0;
     if(positions == null)
     {
         positions = new PositionMission[victor.targets.Length];
         int i = 0;
         foreach(GameObject target in victor.targets)
         {
             positions[i] = target.AddComponent<PositionMission>();
             i++;
         }
     }
     foreach(PositionMission target in positions)
     {
         if(target.inNode)
             count++;
     }
     return (count == positions.Length);
 }
Пример #34
0
    void IVictoryManagementService.CheckForVictoryConditions(int turn)
    {
        if (turn <= this.TurnWhenVictoryConditionsWereLastChecked)
        {
            Diagnostics.Log("Skipping check because victory conditions have already been already checked for (turn: {0}, last checked: {1}).", new object[]
            {
                turn,
                this.TurnWhenVictoryConditionsWereLastChecked
            });
            return;
        }
        this.TurnWhenVictoryConditionsWereLastChecked = turn;
        this.VictoryConditionsRaisedThisTurn.Clear();
        Diagnostics.Assert(this.InterpreterContext != null);
        Snapshot snapshot = null;
        IGameStatisticsManagementService service = Services.GetService <IGameStatisticsManagementService>();

        if (service != null && service.Snapshot != null)
        {
            string name = string.Format("Turn #{0}", turn);
            if (!service.Snapshot.TryGetSnapshot(name, out snapshot))
            {
                Diagnostics.LogWarning("Skipping check because snapshot is missing (turn: {0}, last checked: {1}).", new object[]
                {
                    turn,
                    this.TurnWhenVictoryConditionsWereLastChecked
                });
                return;
            }
            if (snapshot != null)
            {
                foreach (KeyValuePair <string, float> keyValuePair in snapshot.KeyValuePairs)
                {
                    this.InterpreterContext.Register(keyValuePair.Key, keyValuePair.Value);
                }
            }
        }
        Diagnostics.Assert(base.Game != null);
        this.InterpreterContext.Register("Turn", base.Game.Turn);
        int num  = 0;
        int num2 = 0;
        int num3 = 0;
        int num4 = 0;
        int num5 = 0;

        for (int i = 0; i < base.Game.Empires.Length; i++)
        {
            MajorEmpire majorEmpire = base.Game.Empires[i] as MajorEmpire;
            if (majorEmpire == null)
            {
                break;
            }
            num++;
            num3++;
            if (majorEmpire.SimulationObject.Tags.Contains(Empire.TagEmpireEliminated))
            {
                num2++;
                num3--;
            }
            else
            {
                for (int j = 0; j < this.simulationPathNumberOfMainCities.Length; j++)
                {
                    num4 += (int)this.simulationPathNumberOfMainCities[j].CountValidatedObjects(majorEmpire);
                }
                DepartmentOfTheInterior agency = majorEmpire.GetAgency <DepartmentOfTheInterior>();
                if (agency != null)
                {
                    num5 += agency.Cities.Count;
                }
            }
        }
        this.InterpreterContext.Register("NumberOfMajorEmpires", num);
        this.InterpreterContext.Register("NumberOfMajorEmpiresEliminated", num2);
        this.InterpreterContext.Register("NumberOfMajorEmpiresLeft", num3);
        this.InterpreterContext.Register("NumberOfMainCitiesLeft", num4);
        this.InterpreterContext.Register("NumberOfCitiesLeft", num5);
        for (int k = 0; k < base.Game.Empires.Length; k++)
        {
            MajorEmpire majorEmpire2 = base.Game.Empires[k] as MajorEmpire;
            if (majorEmpire2 == null)
            {
                break;
            }
            if (snapshot != null)
            {
                Snapshot snapshot2 = snapshot.TakeSnapshot(majorEmpire2.Name);
                if (snapshot2 != null)
                {
                    foreach (KeyValuePair <string, float> keyValuePair2 in snapshot2.KeyValuePairs)
                    {
                        this.InterpreterContext.Register(keyValuePair2.Key, keyValuePair2.Value);
                    }
                }
            }
            try
            {
                int num6 = 0;
                for (int l = 0; l < this.simulationPathNumberOfMainCities.Length; l++)
                {
                    num6 += (int)this.simulationPathNumberOfMainCities[l].CountValidatedObjects(majorEmpire2);
                }
                this.InterpreterContext.Register("NumberOfMainCities", num6);
                majorEmpire2.SimulationObject.AddChild(this.InterpreterContext.SimulationObject);
                bool             flag             = false;
                VictoryCondition victoryCondition = null;
                foreach (VictoryCondition victoryCondition2 in this.VictoryConditionsFilteredThisGame)
                {
                    if (victoryCondition2.Evaluate(new object[]
                    {
                        this.InterpreterContext
                    }))
                    {
                        if (victoryCondition2.Name == "Shared")
                        {
                            victoryCondition = victoryCondition2;
                        }
                        else if (!majorEmpire2.SimulationObject.Tags.Contains(Empire.TagEmpireEliminated))
                        {
                            this.OnVictoryConditionRaised(new VictoryConditionRaisedEventArgs(victoryCondition2, majorEmpire2));
                            flag = true;
                        }
                    }
                }
                if (victoryCondition != null && flag)
                {
                    DepartmentOfForeignAffairs agency2 = majorEmpire2.GetAgency <DepartmentOfForeignAffairs>();
                    if (agency2 != null && agency2.DiplomaticRelations != null)
                    {
                        foreach (Empire empire in base.Game.Empires)
                        {
                            if (empire != majorEmpire2)
                            {
                                DiplomaticRelation diplomaticRelation = agency2.GetDiplomaticRelation(empire);
                                if (diplomaticRelation != null && diplomaticRelation.State != null && diplomaticRelation.State.Name == DiplomaticRelationState.Names.Alliance)
                                {
                                    this.OnVictoryConditionRaised(new VictoryConditionRaisedEventArgs(victoryCondition, empire));
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                majorEmpire2.SimulationObject.RemoveChild(this.InterpreterContext.SimulationObject);
            }
        }
    }
Пример #35
0
    void Start()
    {
        victoryCondition = GameObject.Find("GameController").GetComponent<VictoryCondition>();

        this.StartSlerpCoroutine(camera.gameObject, StartMarker, EndMarker, 2f);
    }
Пример #36
0
        private void WriteVictorConditions(BinaryWriter writer, VictoryCondition vc)
        {
            writer.Write((byte)vc.Type);
            if (vc.Type == VictoryConditionType.WinStandard)
            {
                return;
            }
            writer.Write(vc.AllowNormalVictory);
            writer.Write(vc.AppliesToAI);
            switch (vc.Type)
            {
            case VictoryConditionType.Artifact:
                writer.Write(vc.Identifier.Value);
                break;

            case VictoryConditionType.GatherTroop:
                writer.Write(vc.Identifier.Value);
                writer.Write(vc.Value);
                break;

            case VictoryConditionType.GatherResource:
                writer.Write((byte)vc.Resource);
                writer.Write(vc.Value);
                break;

            case VictoryConditionType.BuildCity:
                WritePosition(writer, vc.Position);
                writer.Write((byte)vc.HallLevel);
                writer.Write((byte)vc.CastleLevel);
                break;

            case VictoryConditionType.BuildGrail:
                if (vc.Position != null)
                {
                    WritePosition(writer, vc.Position);
                }
                break;

            case VictoryConditionType.BeatHero:
            case VictoryConditionType.CaptureCity:
            case VictoryConditionType.BeatMonster:
                WritePosition(writer, vc.Position);
                break;

            case VictoryConditionType.TransportItem:
                writer.Write(vc.Identifier.Value);
                WritePosition(writer, vc.Position);
                break;

            case VictoryConditionType.TakeDwellings:
            case VictoryConditionType.TakeMines:
                break;

            case VictoryConditionType.BeatAllMonsters:     // HotA
                break;

            case VictoryConditionType.Survive:     // HotA
                writer.Write(vc.Value);
                break;

            default:
                throw new NotSupportedException();
            }
        }
Пример #37
0
    private bool CheckCurrentStats()
    {
        bool[]         goalsReached = new bool[CurrentVC.StatsToTrack.Count];
        TargetLocation tl;

        for (int i = 0; i < CurrentVC.StatsToTrack.Count; i++)
        {
            switch (CurrentVC.StatLocation[i])
            {
            case Locations.ASHPARK:
                tl = _ashPark;

                switch (CurrentVC.StatsToTrack[i])
                {
                case Stats.CRIMERATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.STIRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.TEENPREGRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                default:
                    break;
                }
                break;

            case Locations.EASTBEAHEIGHTS:
                tl = _eastBeaHeights;

                switch (CurrentVC.StatsToTrack[i])
                {
                case Stats.CRIMERATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.STIRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.TEENPREGRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                default:
                    break;
                }
                break;

            case Locations.FREEMASON:
                tl = _freemason;

                switch (CurrentVC.StatsToTrack[i])
                {
                case Stats.CRIMERATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.STIRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.TEENPREGRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                default:
                    break;
                }
                break;

            case Locations.GLOBAL:
                switch (CurrentVC.StatsToTrack[i])
                {
                case Stats.CRIMERATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= WorldCrimeRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= WorldCrimeRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.EDUCATION:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] <= Education)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] <= Education)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.BUDGET:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] <= Budget)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] <= Budget)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.STIRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= WorldSTIRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= WorldSTIRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.TEENPREGRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= WorldTeenPregRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= WorldTeenPregRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                default:
                    break;
                }
                break;

            case Locations.PHILMONT:
                tl = _philmont;

                switch (CurrentVC.StatsToTrack[i])
                {
                case Stats.CRIMERATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.STIRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.TEENPREGRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                default:
                    break;
                }
                break;

            case Locations.QUINNSQUARE:
                tl = _quinnSquare;

                switch (CurrentVC.StatsToTrack[i])
                {
                case Stats.CRIMERATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.CrimeRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.STIRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.STIRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                case Stats.TEENPREGRATE:
                    if (CurrentVC.MaintainTimes[i] > 0 && CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        if (_turnsMaintained[i] >= CurrentVC.MaintainTimes[i])
                        {
                            goalsReached[i] = true;
                        }
                        else
                        {
                            _turnsMaintained[i]++;
                        }
                    }
                    else if (CurrentVC.MaintainTimes[i] > 0)
                    {
                        _turnsMaintained[i] = 0;
                    }
                    else if (CurrentVC.GoalAmounts[i] >= tl.TeenPregRate)
                    {
                        goalsReached[i] = true;
                    }
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
        }

        bool allGoalsReached = true;

        for (int i = 0; i < goalsReached.Length; i++)
        {
            if (goalsReached[i] == false)
            {
                allGoalsReached = false;
            }
        }

        if (allGoalsReached)
        {
            Debug.Log("Thing happens!");

            if (CurrentVC.NextVC != null)
            {
                CurrentVC        = CurrentVC.NextVC;
                _turnsMaintained = new int[CurrentVC.StatsToTrack.Count];
                UpdateGoalDisplay();
            }
            else
            {
                return(true);
            }
        }

        return(false);
    }
Пример #38
0
 bool IsTimeRace(VictoryCondition victor)
 {
     if(raceTime <= victor.times)
         return true;
     else
         return false;
 }
Пример #39
0
 bool IsWin(VictoryCondition victor)
 {
     if(!rank)
     {
         rank = FindObjectOfType(typeof(RankManager)) as RankManager;
     }
     return (rank.GetRank(victor.targets[0].transform) == 1);
 }
Пример #40
0
    public void SetContent(MajorEmpire empire, VictoryCondition victoryCondition, PlayerController playerController, int victoryRank)
    {
        this.Comparable = 0f;
        bool flag = true;

        if (empire != playerController.Empire && !playerController.Empire.SimulationObject.Tags.Contains(Empire.TagEmpireEliminated))
        {
            flag = false;
            Diagnostics.Assert(playerController.Empire != null);
            EmpireInfo.Accessibility lastAccessibilityLevel = EmpireInfo.LastAccessibilityLevel;
            if (lastAccessibilityLevel != EmpireInfo.Accessibility.Default)
            {
                if (lastAccessibilityLevel == EmpireInfo.Accessibility.Partial)
                {
                    DepartmentOfIntelligence agency = playerController.Empire.GetAgency <DepartmentOfIntelligence>();
                    if (agency != null && agency.IsEmpireInfiltrated(empire))
                    {
                        flag = true;
                    }
                }
            }
            else
            {
                DepartmentOfForeignAffairs agency2 = playerController.Empire.GetAgency <DepartmentOfForeignAffairs>();
                if (agency2 != null)
                {
                    DiplomaticRelation diplomaticRelation = agency2.GetDiplomaticRelation(empire);
                    flag |= (diplomaticRelation != null && diplomaticRelation.State != null && diplomaticRelation.State.Name != DiplomaticRelationState.Names.Unknown);
                }
                if (!flag)
                {
                    DepartmentOfIntelligence agency3 = playerController.Empire.GetAgency <DepartmentOfIntelligence>();
                    if (agency3 != null && agency3.IsEmpireInfiltrated(empire))
                    {
                        flag = true;
                    }
                }
            }
        }
        if (!empire.VictoryConditionStatuses.ContainsKey(victoryCondition.Name) || !flag)
        {
            base.GetComponent <AgeTransform>().Visible = false;
            return;
        }
        base.GetComponent <AgeTransform>().Visible = true;
        this.format = AgeLocalizer.Instance.LocalizeString(victoryCondition.Progression.Format);
        for (int i = 0; i < victoryCondition.Progression.Vars.Length; i++)
        {
            if (this.format.Contains(victoryCondition.Progression.Vars[i].Name))
            {
                this.varName = "$" + victoryCondition.Progression.Vars[i].Name;
                this.format  = this.format.Replace(this.varName, GuiFormater.FormatGui(empire.VictoryConditionStatuses[victoryCondition.Name].Variables[i], victoryCondition.Progression.Vars[i].Name == "Ratio", false, false, 0));
            }
            if (victoryCondition.Progression.Vars[i].Name == victoryCondition.Progression.SortVariable)
            {
                this.Comparable = empire.VictoryConditionStatuses[victoryCondition.Name].Variables[i];
            }
        }
        this.Title.Text = empire.LocalizedName;
        this.Value.Text = this.format;
        this.Value.AgeTransform.Width            = this.Value.Font.ComputeTextWidth(this.Value.Text, false, false);
        this.Title.AgeTransform.PixelMarginRight = this.Value.AgeTransform.PixelMarginRight + this.Value.AgeTransform.PixelMarginLeft + this.Value.AgeTransform.Width;
        this.Title.TintColor = empire.Color;
        this.Value.TintColor = empire.Color;
        if (empire == playerController.Empire)
        {
            this.TitleModifier.StartDelay = 0.3f * (float)victoryRank;
            this.TitleModifier.StartAnimation();
            return;
        }
        this.TitleModifier.Reset();
        this.Title.AgeTransform.Alpha = 1f;
    }
Пример #41
0
 public bool ConditionCheck()
 {
     VictoryCondition.CheckCondition();
     LossCondition.CheckCondition();
     return(ConditionResult());
 }