Exemplo n.º 1
0
        /// <summary>
        /// Sets up all traits, mentalities, parties, policies etc and starts the game. This happens after map generation for all clients.
        /// </summary>
        /// <param name="seed">Seed is used to synchronize in multiplayer</param>
        public void StartGame(int seed)
        {
            UnityEngine.Random.InitState(seed);

            UI.LoadingScreen.gameObject.SetActive(false);
            Year = 1999;

            Map.InitializeMap(showRegionBorders: true, showShorelineBorders: true, showContinentBorders: false, showWaterConnections: false, MapColorMode.Basic, MapTextureMode.None);
            UI.MapControls.Init(this, MapDisplayMode.NoOverlay);
            VfxManager.Init(this);

            InitGeograhyTraits();
            InitMentalities();
            InitParties();
            InitPolicies();
            UI.SidePanelFooter.Init(this);

            MarkovChainWordGenerator.Init();
            Constitution = new Constitution(this);
            UI.Constitution.Init(Constitution);
            StartNextElectionCycle(); // Start first cycle
            SetAllDistrictsVisible();
            CameraHandler.FocusDistricts(VisibleDistricts.Values.ToList());
            State = GameState.PreparationPhase;

            UI.SelectTab(Tab.Parliament);
            ElectionAnimationHandler = new ElectionAnimationHandler(this);
        }
Exemplo n.º 2
0
    public void StartNewGame(int mapWidth, int mapHeight)
    {
        // Generate map
        MapData data = MapGenerator.GenerateMap(mapWidth, mapHeight, false);

        Map.InitializeMap(this, data);

        // Init values
        InstabilityLevel = 1;

        // Init other elements
        CameraHandler   = new CameraHandler(this);
        InputHandler    = new InputHandler(this);
        EventHandler    = new GameEventHandler(this);
        DisasterHandler = new DisasterHandler(this);
        MarkovChainWordGenerator.Init();

        // Initialize building attributes
        BPC.City.InitAttributes(this);
        BPC.HQ.InitAttributes(this);
        BPC.Radar.InitAttributes(this);

        // Place initial random cities
        PlaceRandomCities();

        // Choose random starting (next to a city) tile to place Headquarters
        List <Tile> startRadarCandidates = Map.TilesList.Where(x => BPC.HQ.CanBuildOn(x) && x.BuildingsInRange(GameSettings.Headquarter_VisibilityRange, typeof(City)).Count == 1).ToList();
        Tile        startingTile         = startRadarCandidates[Random.Range(0, startRadarCandidates.Count)];

        PlaceBuilding(startingTile, BPC.HQ, initializing: true);

        // Init visiblie tiles around starting radar
        foreach (Building b in Buildings)
        {
            b.OnBuild();
        }

        // Set camera position
        CameraHandler.FocusVisibleTiles();

        ResetDailyValues();

        GameUI.Initialize(this);

        GameState = GameState.Idle;
    }
Exemplo n.º 3
0
    void Start()
    {
        MarkovChainWordGenerator.Init();

        GenerateButton.onClick.AddListener(GenerateButton_OnClick);

        foreach (MapType mapType in Enum.GetValues(typeof(MapType)))
        {
            MapTypeDropdown.options.Add(new Dropdown.OptionData(mapType.ToString()));
        }
        MapTypeDropdown.onValueChanged.AddListener(MapTypeDropdown_OnValueChanged);
        MapTypeDropdown.value = 1; MapTypeDropdown.value = 2;
        ContinentSizeSlider.onValueChanged.AddListener(ContinentSizeSlider_OnValueChanged);

        RegionBorderToggle.onValueChanged.AddListener(RegionBorderToggle_OnValueChanged);
        ShorelineBorderToggle.onValueChanged.AddListener(ShorelineBorderToggle_OnValueChanged);
        ContinentBorderToggle.onValueChanged.AddListener(ContinentBorderToggle_OnValueChanged);
        WaterConnectionToggle.onValueChanged.AddListener(WaterConnectionToggle_OnValueChanged);

        foreach (MapColorMode mode in Enum.GetValues(typeof(MapColorMode)))
        {
            ColorModeDropdown.options.Add(new Dropdown.OptionData(mode.ToString()));
        }
        ColorModeDropdown.onValueChanged.AddListener(ColorModeDropdown_OnValueChanged);
        ColorModeDropdown.value = 1; ColorModeDropdown.value = 0;

        foreach (MapTextureMode mode in Enum.GetValues(typeof(MapTextureMode)))
        {
            TextureModeDropdown.options.Add(new Dropdown.OptionData(mode.ToString()));
        }
        TextureModeDropdown.onValueChanged.AddListener(TextureModeDropdown_OnValueChanged);
        TextureModeDropdown.value = 1; TextureModeDropdown.value = 0;

        TurnToLandButton.onClick.AddListener(TurnSelectedToRegionsToLand);
        TurnToWaterButton.onClick.AddListener(TurnSelectedRegionsToWater);
        SplitRegionButton.onClick.AddListener(SplitSelectedRegion);
        MergeRegionsButton.onClick.AddListener(MergeSelectedRegions);
        CreateNationButton.onClick.AddListener(CreateNation);

        MapInfoPanel.SetActive(false);
        RegionInfoPanel.SetActive(false);
        MultRegions_Panel.SetActive(false);
        ClearRegionSelection();
    }