Esempio n. 1
0
        public override void OnStateMachineEnter(Animator animator, int stateMachinePathHash)
        {
            Brain.ClearListeners();
            Brain.EnableCameraMovement();

            VisibilityCanon.ResourceVisibilityMode = ResourceVisibilityMode.RevealAll;
            VisibilityCanon.CellVisibilityMode     = CellVisibilityMode.RevealAll;

            ExplorationCanon.ExplorationMode = CellExplorationMode.AllCellsExplored;

            VisibilityResponder.UpdateVisibility = true;

            UnitMapIconManager.BuildIcons();
            UnitMapIconManager.SetActive(true);

            foreach (var element in PlayModeSensitiveElements)
            {
                element.IsActive = false;
            }

            Grid.Build(10, 7);

            var playerCiv    = CivFactory.Create(CivConfig.DefaultTemplate);
            var barbarianCiv = CivFactory.Create(CivConfig.BarbarianTemplate);

            PlayerFactory.CreatePlayer(playerCiv, BrainPile.HumanBrain);
            PlayerFactory.CreatePlayer(barbarianCiv, BrainPile.BarbarianBrain);

            foreach (var chunk in Grid.Chunks)
            {
                chunk.Refresh(Simulation.MapRendering.TerrainRefreshType.All);
            }
        }
        private void GeneratePlayers(IMapGenerationVariables variables)
        {
            CivFactory.Clear();

            foreach (var civTemplate in variables.Civilizations)
            {
                var newCiv = CivFactory.Create(civTemplate, variables.StartingTechs);

                PlayerFactory.CreatePlayer(newCiv, BrainPile.HumanBrain);
            }

            var barbarianCiv = CivFactory.Create(CivConfig.BarbarianTemplate);

            PlayerFactory.CreatePlayer(barbarianCiv, BrainPile.BarbarianBrain);
        }
Esempio n. 3
0
        public void CreateNewPlayer()
        {
            var newCiv = CivilizationFactory.Create(SelectedTemplate);

            PlayerFactory.CreatePlayer(newCiv, BrainPile.HumanBrain);

            Refresh();
        }
        public void DecomposeCivilizations(SerializableMapData mapData)
        {
            foreach (var civData in mapData.Civilizations)
            {
                var civTemplate = AvailableCivTemplates.Where(template => template.Name.Equals(civData.TemplateName)).FirstOrDefault();

                var newCiv = CivilizationFactory.Create(civTemplate);

                newCiv.GoldStockpile    = civData.GoldStockpile;
                newCiv.CultureStockpile = civData.CultureStockpile;

                PolicyComposer.DecomposePoliciesIntoCiv(civData.SocialPolicies, newCiv);

                DecomposeTechs(civData, newCiv);

                if (civData.ExploredCells != null)
                {
                    foreach (var exploredCoords in civData.ExploredCells)
                    {
                        var exploredCell = Grid.GetCellAtCoordinates(exploredCoords);

                        ExplorationCanon.SetCellAsExploredByCiv(exploredCell, newCiv);
                    }
                }

                DecomposeFreeBuildings(civData, newCiv);

                GoldenAgeCanon.SetGoldenAgeProgressForCiv(newCiv, civData.GoldenAgeProgress);
                GoldenAgeCanon.SetPreviousGoldenAgesForCiv(newCiv, civData.PreviousGoldenAges);

                if (civData.GoldenAgeTurnsLeft > 0)
                {
                    GoldenAgeCanon.StartGoldenAgeForCiv(newCiv, civData.GoldenAgeTurnsLeft);
                }
            }

            foreach (var discoveryPair in mapData.CivDiscoveryPairs)
            {
                var civOne = CivilizationFactory.AllCivilizations.Where(civ => civ.Template.Name.Equals(discoveryPair.Item1)).FirstOrDefault();
                var civTwo = CivilizationFactory.AllCivilizations.Where(civ => civ.Template.Name.Equals(discoveryPair.Item2)).FirstOrDefault();

                if (CivDiscoveryCanon.CanEstablishDiscoveryBetweenCivs(civOne, civTwo))
                {
                    CivDiscoveryCanon.EstablishDiscoveryBetweenCivs(civOne, civTwo);
                }
                else
                {
                    throw new InvalidOperationException(
                              string.Format("Invalid discovery for civs of template names {0} and {1}", discoveryPair.Item1, discoveryPair.Item2)
                              );
                }
            }
        }