Esempio n. 1
0
    protected override void LabourResult(int iterations)
    {
        if (iterations < 1)
        {
            return;
        }
        workflow -= iterations;
        int memCount = (int)((workersCount / (float)maxWorkers) * Crew.MAX_MEMBER_COUNT);

        if (workersCount < memCount)
        {
            memCount = workersCount;
        }
        if (memCount > 0)
        {
            Crew c = Crew.CreateNewCrew(colony, memCount);
            workersCount -= memCount;
            workflow      = 0;
            finding       = false;
            AnnouncementCanvasController.MakeAnnouncement(Localization.GetCrewAction(LocalizedCrewAction.Ready, c));
            hireCost = hireCost * (1 + GameConstants.HIRE_COST_INCREASE);
            hireCost = ((int)(hireCost * 100)) / 100f;
            if (showOnGUI)
            {
                rcenterObserver.SelectCrew(c);
            }
        }
    }
Esempio n. 2
0
    public float BuyResource(ResourceType rt, float volume)
    {
        var colony = GameMaster.realMaster.colonyController;

        if (colony.energyCrystalsCount <= 0f)
        {
            return(0f);
        }
        float p = ResourceType.prices[rt.ID], money = 0f;

        if (p != 0)
        {
            money  = colony.GetEnergyCrystals(volume * ResourceType.prices[rt.ID]);
            volume = money / ResourceType.prices[rt.ID];
            if (volume <= 0f)
            {
                return(0f);
            }
            else
            {
                if (volume > 99f)
                {
                    AnnouncementCanvasController.MakeAnnouncement(Localization.GetBuyMsg(rt, volume, money));
                }
            }
        }
        colony.storage.AddResource(rt, volume);
        colony.gears_coefficient -= gearsDamage * volume;
        return(volume);
    }
 override public void LevelUp(bool returnToUI)
 {
     if (!GameMaster.realMaster.weNeedNoResources)
     {
         ResourceContainer[] cost = GetUpgradeCost();
         if (!colony.storage.CheckBuildPossibilityAndCollectIfPossible(cost))
         {
             AnnouncementCanvasController.NotEnoughResourcesAnnounce();
             return;
         }
     }
     if (level > 3)
     {
         SetBlockers();
     }
     level++;
     nextStageConditionMet = CheckUpgradeCondition();
     SetModel();
     buildingObserver.CheckUpgradeAvailability();
     Quest.ResetHousingQuest();
     AnnouncementCanvasController.MakeAnnouncement(Localization.LevelReachedString(level));
     if (GameMaster.soundEnabled)
     {
         GameMaster.audiomaster.Notify(NotificationSound.HQ_Upgraded);
     }
     GameMaster.realMaster.eventTracker?.BuildingUpgraded(this);
 }
 public void Next()
 {
     if (currentStep == FoundationScenarioStep.AnchorStart)
     {
         AnnouncementCanvasController.MakeAnnouncement(localizer.GetAnnounceTitle(currentStep, QUEST_INFO_1));
         scenarioQuest.MakeQuestCompleted();
     }
     currentStep++;
     StartSubscenario();
 }
Esempio n. 5
0
    public void SubmitButton() // for save option only
    {
        int si = listController.selectedButtonIndex;

        if (si < 0 || savenames == null || si >= savenames.Length)
        {
            return;
        }
        string name       = savenames[listController.selectedButtonIndex];
        bool   redrawList = false;

        if (workWithTerrains)
        {// ПЕРЕЗАПИСЬ СОХРАНЕНИЯ ТЕРРЕЙНА
            if (deleteSubmit)
            {
                File.Delete(GetTerrainSaveFullpath(name));
                redrawList = true;
            }
            else
            {
                GameMaster.realMaster.SaveTerrain(name);
                redrawList = true;
            }
        }
        else
        {   // ПЕРЕЗАПИСЬ СОХРАНЕНИЯ ИГРЫ
            if (deleteSubmit)
            {
                File.Delete(GetGameSaveFullpath(name));
                redrawList = true;
            }
            else
            {
                if (GameMaster.realMaster.SaveGame(name))
                {
                    AnnouncementCanvasController.MakeAnnouncement(Localization.GetAnnouncementString(GameAnnouncements.GameSaved));
                    redrawList = true;
                }
                else
                {
                    AnnouncementCanvasController.MakeAnnouncement(Localization.GetAnnouncementString(GameAnnouncements.SavingFailed));
                    if (GameMaster.soundEnabled)
                    {
                        GameMaster.audiomaster.Notify(NotificationSound.SystemError);
                    }
                }
            }
        }
        submitWindow.SetActive(false);
        if (redrawList)
        {
            PrepareSavesList();
        }
    }
Esempio n. 6
0
    public void SellResource(ResourceType rt, float volume)
    {
        var   colony = GameMaster.realMaster.colonyController;
        float vol    = colony.storage.GetResources(rt, volume);
        float money  = vol * ResourceType.prices[rt.ID] * GameMaster.sellPriceCoefficient;

        colony.AddEnergyCrystals(money);
        colony.gears_coefficient -= gearsDamage * vol;
        if (vol > 99f)
        {
            AnnouncementCanvasController.MakeAnnouncement(Localization.GetSellMsg(rt, vol, money));
        }
    }
Esempio n. 7
0
 public void StartShipService(Ship s)
 {
     if (servicingShip != s)
     {
         servicingShip.Undock();
     }
     servicingShip = s;
     loadingTimer  = LOADING_TIME;
     if (announceNewShips)
     {
         AnnouncementCanvasController.MakeAnnouncement(Localization.GetAnnouncementString(GameAnnouncements.ShipArrived));
     }
 }
Esempio n. 8
0
    public void Dismiss() // экспедиция вернулась домой и распускается
    {
        //зависимость : Disappear()
        if (stage == ExpeditionStage.Disappeared | stage == ExpeditionStage.Dismissed)
        {
            return;
        }
        else
        {
            AnnouncementCanvasController.MakeAnnouncement(Localization.GetCrewAction(LocalizedCrewAction.Returned, crew));
            if (crew != null)
            {
                crew.CountMission(missionCompleted);
                crew.SetCurrentExpedition(null);
                crew = null;
            }
            QuantumTransmitter.StopTransmission(transmissionID);
            Hangar.ReturnShuttle(shuttleID);
            if (destination != null)
            {
                destination.DeassignExpedition(this);
            }
            if (suppliesCount > 0)
            {
                GameMaster.realMaster.colonyController.storage.AddResource(ResourceType.Supplies, suppliesCount);
            }
            if (expeditionsList.Contains(this))
            {
                expeditionsList.Remove(this);
            }
            if (crystalsCollected > 0)
            {
                GameMaster.realMaster.colonyController.AddEnergyCrystals(crystalsCollected);
                crystalsCollected = 0;
            }
            stage = ExpeditionStage.Dismissed;
            if (missionCompleted)
            {
                expeditionsSucceed++;
                Knowledge.GetCurrent()?.ExpeditionsCheck(expeditionsSucceed);
            }

            if (subscribedToUpdate & !GameMaster.sceneClearing)
            {
                GameMaster.realMaster.labourUpdateEvent -= this.LabourUpdate;
                subscribedToUpdate = false;
            }
            changesMarkerValue++;
        }
    }
Esempio n. 9
0
 public void LaunchButton()
 {
     if (observingExpedition == null)
     {
         if (selectedCrew != null && selectedCrew.atHome)
         {
             var  storage  = colony.storage;
             bool TESTMODE = GameMaster.realMaster.weNeedNoResources;
             if (TESTMODE || suppliesSlider.value <= storage.GetResourceCount(ResourceType.Supplies) &&
                 crystalsSlider.value <= colony.energyCrystalsCount &&
                 storage.GetResourceCount(ResourceType.Fuel) >= FUEL_BASE_COST
                 )
             {
                 int shID = Hangar.GetFreeShuttleID();
                 if (shID != Hangar.NO_SHUTTLE_VALUE)
                 {
                     var t = QuantumTransmitter.GetFreeTransmitter();
                     if (t != null)
                     {
                         if (storage.TryGetResources(ResourceType.Fuel, FUEL_BASE_COST))
                         {
                             var e  = new Expedition(selectedDestination, selectedCrew, shID, t, storage.GetResources(ResourceType.Supplies, suppliesSlider.value), colony.GetEnergyCrystals(crystalsSlider.value));
                             var mc = mycanvas.uicontroller;
                             if (mc.currentMode == UIMode.Standart)
                             {
                                 observingExpedition = e;
                             }
                             else
                             {
                                 observingExpedition = e;
                                 RedrawWindow();
                                 mc.ShowExpedition(e);
                             }
                         }
                         else
                         {
                             AnnouncementCanvasController.MakeAnnouncement(Localization.GetExpeditionErrorText(ExpeditionComposingErrors.NotEnoughFuel));
                         }
                         RedrawWindow();
                     }
                 }
             }
         }
     }
     else
     {
         observingExpedition.EndMission();
     }
 }
Esempio n. 10
0
    public void Next()
    {
        switch (currentStep)
        {
        case FoundationScenarioStep.AnchorBuilding:
            scenarioQuest?.MakeQuestCompleted();
            break;

        case FoundationScenarioStep.AnchorStart:
            AnnouncementCanvasController.MakeAnnouncement(localizer.GetAnnounceTitle(currentStep, QUEST_INFO_1));
            scenarioQuest.MakeQuestCompleted();
            break;
        }
        currentStep++;
        StartSubscenario();
    }
    public void Prepare()
    {
        if (prepared)
        {
            return;
        }
        else
        {
            prepared = true;
        }
        vegetationShaderWindPropertyID = Shader.PropertyToID("_Windpower");
        if (!GameMaster.loading)
        {
            windVector    = Random.insideUnitCircle;
            newWindVector = windVector;
        }

        Shader.SetGlobalFloat(vegetationShaderWindPropertyID, 1);
        sun = FindObjectOfType <Light>();
        if (sun == null)
        {
            sun      = new GameObject("sun").AddComponent <Light>();
            sun.type = LightType.Directional;
        }
        sunTransform = sun.transform;
        decorations  = new List <Transform>();

        skyboxMaterial = RenderSettings.skybox;
        gm             = GameMaster.realMaster;
        globalMap      = gm.globalMap;
        SetEnvironment(Environment.defaultEnvironment);
        if (gm.gameMode != GameMode.Editor)
        {
            RefreshVisual();
            RecalculateCelestialDecorations();
        }
        else
        {
        }
        islandStability = DEFAULT_ISLAND_STABILITY;
        globalMap?.LinkEnvironmentMaster(this);
        if (GameMaster.realMaster.IsInTestMode)
        {
            AnnouncementCanvasController.MakeAnnouncement("environment master loaded");
        }
    }
Esempio n. 12
0
    private void Update()
    {
        if (loading | gameSpeed == 0)
        {
            return;
        }

        autosaveTimer -= Time.deltaTime;
        if (autosaveTimer <= 0f)
        {
            SetPause(true);
            AnnouncementCanvasController.MakeAnnouncement("autosaving!");
            SaveGame("autosave_time");
            SetPause(false);
            autosaveTimer = AUTOSAVE_TIME;
        }
        gameSpeed = _gameSpeed;
    }
Esempio n. 13
0
    /// ===============================
    public Expedition(PointOfInterest i_destination, Crew c, int i_shuttleID, QuantumTransmitter transmitter, float i_supplies, float i_crystals)
    {
        // СДЕЛАТЬ: проверка компонентов и вывод ошибок
        ID    = nextID++;
        stage = ExpeditionStage.WayIn;

        destination = i_destination; destination.AssignExpedition(this);
        crew        = c; c.SetCurrentExpedition(this);

        if (Hangar.OccupyShuttle(i_shuttleID))
        {
            shuttleID = i_shuttleID;
        }
        else
        {
            AnnouncementCanvasController.MakeAnnouncement(Localization.GetExpeditionErrorText(ExpeditionComposingErrors.ShuttleUnavailable));
            Dismiss();
        }

        if (transmitter != null)
        {
            transmissionID = transmitter.StartTransmission();
            hasConnection  = true;
        }
        else
        {
            transmissionID = QuantumTransmitter.NO_TRANSMISSION_VALUE;
            hasConnection  = false;
        }
        suppliesCount     = (byte)i_supplies;
        crystalsCollected = (ushort)i_crystals;

        //#creating map marker
        GlobalMap gmap = GameMaster.realMaster.globalMap;

        mapMarker = new FlyingExpedition(this, gmap.cityPoint, destination, FLY_SPEED);
        gmap.AddPoint(mapMarker, true);
        //

        expeditionsList.Add(this);
        listChangesMarker++;
    }
Esempio n. 14
0
 override protected void LabourResult(int iterations)
 {
     if (iterations < 1)
     {
         return;
     }
     shuttleID = nextShuttleID++;
     status    = HangarStatus.ShuttleInside;
     if (workersCount > 0)
     {
         FreeWorkers();
     }
     workflow = 0f;
     listChangesMarkerValue++;
     if (showOnGUI)
     {
         hangarObserver.PrepareHangarWindow();
     }
     AnnouncementCanvasController.MakeAnnouncement(Localization.GetPhrase(LocalizedPhrase.ShuttleConstructed));
 }
Esempio n. 15
0
    public void SaveLoadButton()
    {
        int sid = listController.selectedButtonIndex;

        if (sid == -1)
        {
            return;
        }
        if (saveMode)
        {
            submitWindow.SetActive(true);
            submitQuestionText.text = Localization.GetWord(LocalizedWord.Rewrite) + '?';
            submitButtonText.text   = Localization.GetWord(LocalizedWord.Yes);
            rejectButtonText.text   = Localization.GetWord(LocalizedWord.Cancel);
            deleteSubmit            = false;
        }
        else
        {
            bool   ingame = GameMaster.realMaster != null;
            string name   = savenames[sid];
            if (workWithTerrains)
            {// ЗАГРУЗКА  УРОВНЕЙ  ДЛЯ  РЕДАКТОРА
                string fullPath = GetTerrainSaveFullpath(name);
                if (ingame)
                {
                    if (GameMaster.realMaster.LoadTerrain(fullPath))
                    {
                        gameObject.SetActive(false);
                    }
                }
                else
                {
                    // теоретический сценарий, не должен использоваться
                    if (File.Exists(fullPath))
                    {
                        GameMaster.StartNewGame(
                            GameStartSettings.GetEditorStartSettings(name)
                            );
                    }
                    else
                    {
                        PrepareSavesList();
                    }
                }
            }
            else
            {// ЗАГРУЗКА  УРОВНЕЙ  ДЛЯ  ИГРЫ
                string fullPath = GetGameSaveFullpath(name);
                if (ingame)
                {
                    if (GameMaster.realMaster.LoadGame(fullPath))
                    {
                        gameObject.SetActive(false);
                        UIController.GetCurrent().GetMainCanvasController().ChangeActiveWindow(ActiveWindowMode.NoWindow);
                        AnnouncementCanvasController.MakeAnnouncement(Localization.GetAnnouncementString(GameAnnouncements.GameLoaded));
                    }
                }
                else
                {
                    if (File.Exists(fullPath))
                    {
                        GameMaster.StartNewGame(
                            GameStartSettings.GetLoadingSettings(GameMode.Survival, name)
                            );
                    }
                    else
                    {
                        PrepareSavesList();
                    }
                }
            }
        }
    }
Esempio n. 16
0
    void PrepareSession()
    {
        if (sessionPrepared)
        {
            return;
        }
        bool activateEventTracker = false;

        switch (gameMode)
        {
        case GameMode.Survival:
        {
            uicontroller.ChangeUIMode(UIMode.Standart, true);
            difficulty = startSettings.DefineDifficulty();
            SetDefaultValues();
            var cgs         = startSettings.GetChunkGenerationSettings();
            var chunkAction = cgs.preparingActionMode;
            if (chunkAction != ChunkPreparingAction.NoAction)
            {
                if (chunkAction == ChunkPreparingAction.Load)
                {
                    LoadTerrain(SaveSystemUI.GetTerrainsPath() + '/' + cgs.GetTerrainName() + '.' + SaveSystemUI.TERRAIN_FNAME_EXTENSION);
                }
                else
                {
                    mainChunk = Constructor.ConstructChunk(cgs);
                    var slist = mainChunk.GetSurfaces();
                    if (slist != null)
                    {
                        geologyModule.SpreadMinerals(slist);
                    }
                    mainChunk.InitializeNature().FirstLifeformGeneration(Chunk.chunkSize * Chunk.chunkSize * 500f);
                }
            }
            //
            var fcm = FollowingCamera.main;
            fcm.CameraToStartPosition();
            fcm.ResetTouchRightBorder();
            fcm.CameraRotationBlock(false);
            warProximity   = 0.01f;
            layerCutHeight = Chunk.chunkSize; prevCutHeight = layerCutHeight;
            //
            switch (startSettings.DefineFoundingType())
            {
            case StartFoundingType.Zeppelin:
            {
                Zeppelin.CreateNew();
                AnnouncementCanvasController.MakeAnnouncement(Localization.GetAnnouncementString(GameAnnouncements.SetLandingPoint));
                break;
            }

            case StartFoundingType.Headquarters:
            {
                Plane sb   = mainChunk.GetRandomSurface();
                int   xpos = sb.pos.x;
                int   zpos = sb.pos.z;

                Structure s;
                if (testMode)
                {
                    s = HeadQuarters.GetHQ(6);
                    weNeedNoResources = true;
                }
                else
                {
                    weNeedNoResources = false;
                    s = HeadQuarters.GetHQ(1);
                }

                Plane b = mainChunk.GetHighestSurfacePlane(xpos, zpos);
                s.SetBasement(b, PixelPosByte.zero);


                sb = mainChunk.GetNearestUnoccupiedSurface(b.pos);
                StorageHouse firstStorage = Structure.GetStructureByID(Structure.STORAGE_0_ID) as StorageHouse;
                firstStorage.SetBasement(sb, PixelPosByte.zero);
                SetStartResources();
                break;
            }
            }
            fcm.WeNeedUpdate();
            activateEventTracker = true;
            break;
        }

        case GameMode.Editor:
        {
            uicontroller.ChangeUIMode(UIMode.Editor, true);
            mainChunk = new GameObject("chunk").AddComponent <Chunk>();
            int size = Chunk.chunkSize;
            int[,,] blocksArray = new int[size, size, size];
            size /= 2;
            blocksArray[size, size, size] = ResourceType.STONE_ID;
            mainChunk.Rebuild(blocksArray);
            FollowingCamera.main.CameraToStartPosition();
            break;
        }

        case GameMode.Scenario:
        {
            uicontroller.ChangeUIMode(UIMode.Standart, true);
            switch (startSettings.GetScenarioType())
            {
            case ScenarioType.Embedded:
            {
                switch ((EmbeddedScenarioType)startSettings.GetSecondSubIndex())
                {
                case EmbeddedScenarioType.Tutorial:
                {
                    gameRules = GameRules.GetTutorialRules();
                    LoadTerrainFromAssets(TutorialScenarioNS.TutorialScenario.tutorialTerrainName);
                    TutorialScenarioNS.TutorialUI.Initialize();
                    break;
                }
                }
                break;
            }
            }
            activateEventTracker = true;
            FollowingCamera.main.CameraToStartPosition();
            break;
        }
        }
        if (activateEventTracker)
        {
            eventTracker = new EventChecker();
        }

        startSettings   = null;
        sessionPrepared = true;
        if (testMode)
        {
            AnnouncementCanvasController.MakeAnnouncement("game master loaded");
        }
        autosaveTimer = AUTOSAVE_TIME;
    }
Esempio n. 17
0
    private void Update()
    {
        if (!prepared)
        {
            return;
        }

        float t = Time.deltaTime * GameMaster.gameSpeed;
        float f = 0, a;

        float[] thisCycleRotations = new float[RINGS_COUNT];
        for (int i = 0; i < RINGS_COUNT; i++)
        {
            a = rotationSpeed[i] * t;
            thisCycleRotations[i] = a;
            f  = ringsRotation[i];
            f -= thisCycleRotations[i];
            if (f > 360)
            {
                f = f % 360f;
            }
            else
            {
                if (f < 0)
                {
                    f = 360f - Mathf.Abs(f % 360f);
                }
            }
            ringsRotation[i] = f;
        }

        var prefAsc = ascension;

        updateTimer -= t;
        if (updateTimer <= 0f)
        {
            updateTimer = ASCENSION_UPDATE_TIME;

            ascensionTarget = ProgressionMaster.DefineAscension(colonyController);
            a = GetGlobalMapAscension(); if (ascensionTarget > a)
            {
                ascensionTarget = a;
            }
            a = Knowledge.GetCurrent()?.GetCompleteness() ?? 0f; if (ascensionTarget > a)
            {
                ascensionTarget = a;
            }
        }
        if (ascension != ascensionTarget)
        {
            ascension = Mathf.MoveTowards(ascension, ascensionTarget, GameConstants.ASCENSION_CHANGE_SPEED * t * (1.5f - GameMaster.stability));
        }
        float ascensionChange = prefAsc - ascension;
        //
        float prevX = cityPoint.angle, prevY = cityPoint.height;

        if (mapPoints.Count > 0)
        {
            if (GameMaster.realMaster.colonyController != null && cityPoint.ringIndex != 2)
            {
                float speed = RING_RESIST_CF;
                if (cityPoint.ringIndex == 0 || cityPoint.ringIndex == 4)
                {
                    speed *= speed;
                }
                a = Mathf.MoveTowards(cityPoint.height, 0.5f, speed * t);
                ChangeCityPointHeight(a - cityPoint.height);
                // Использование stability?
            }
            int i = 0;
            while (i < mapPoints.Count)
            {
                MapPoint mp = mapPoints[i];
                mp.angle += thisCycleRotations[mp.ringIndex];
                if (mp.type == MapPointType.FlyingExpedition)
                {
                    FlyingExpedition fe = (mp as FlyingExpedition);
                    MapPoint         d  = fe.destination;
                    if (d != null)
                    {
                        if (mp.height != d.height)
                        {
                            mp.height = Mathf.MoveTowards(mp.height, d.height, fe.speed * t * 0.01f);
                        }
                        else
                        {
                            if (mp.angle != d.angle)
                            {
                                mp.angle = Mathf.MoveTowardsAngle(mp.angle, d.angle, fe.speed * t);
                            }
                            else
                            {
                                mapPoints.RemoveAt(i);
                                fe.expedition.DropMapMarker();
                                pointsExploringEvent?.Invoke(d);
                                if (fe.expedition.stage == Expedition.ExpeditionStage.WayIn)
                                {
                                    fe.expedition.StartMission();
                                }
                                else
                                {
                                    fe.expedition.Dismiss();
                                }
                                actionsHash++;
                                continue;
                            }
                        }
                    }
                    else
                    {
                        AnnouncementCanvasController.MakeAnnouncement(Localization.GetCrewAction(LocalizedCrewAction.CannotReachDestination, fe.expedition.crew));
                        fe.expedition.EndMission();
                    }
                }
                i++;
            }
        }
        //
        cityLookVector   = Quaternion.AngleAxis(cityPoint.angle, Vector3.up) * Vector3.forward;
        cityFlyDirection = new Vector3(cityPoint.angle - prevX + rotationSpeed[cityPoint.ringIndex], ascensionChange, cityPoint.height - prevY);
        SYSTEM_envWasCalculatedThisTick = false;
    }
Esempio n. 18
0
    public void HandleShip(Dock d, Ship s, ColonyController colony)
    {
        int   peopleBefore = immigrationPlan;
        float efficientcy  = (float)d.workersCount / (float)d.maxWorkers;
        float tradeVolume  = s.volume * (0.05f + 0.95f * efficientcy);
        float rewardValue  = 1f;
        var   storage      = colony.storage;

        switch (s.type)
        {
        case ShipType.Passenger:
        {
            float vol = s.volume * (Random.value * 0.5f * colony.happinessCoefficient + 0.5f);
            if (immigrationEnabled && immigrationPlan > 0)
            {
                if (vol > immigrationPlan)
                {
                    colony.AddCitizens(immigrationPlan, true);
                    immigrationPlan = 0;
                    vol            -= immigrationPlan;
                }
                else
                {
                    int x = (int)vol;
                    colony.AddCitizens(x, true); immigrationPlan -= x;
                    vol = 0;
                }
            }
            else
            {
                vol = 0f;
                if (Random.value < colony.happinessCoefficient * 0.25f)
                {
                    int x = (int)(Random.value * colony.hq.level);
                    if (x != 0)
                    {
                        colony.AddCitizens(x, true);
                    }
                }
            }

            if (vol > 0)
            {
                vol *= colony.happinessCoefficient;
                if (vol > 1f)
                {
                    Hotel.DistributeLodgers((int)vol);
                }
                rewardValue += 0.5f;
            }

            if (isForSale[ResourceType.FOOD_ID] != null)
            {
                if (isForSale[ResourceType.FOOD_ID] == true)
                {
                    d.SellResource(ResourceType.Food, s.volume * 0.1f);
                }
                else
                {
                    d.BuyResource(ResourceType.Food, s.volume * 0.1f);
                }
                rewardValue += 0.3f * Random.value;
            }
            break;
        }

        case ShipType.Cargo:
        {
            int        totalPositions = 0;
            List <int> buyPositions = new List <int>(), sellPositions = new List <int>();
            for (int i = 0; i < ResourceType.TYPES_COUNT; i++)
            {
                if (isForSale[i] == null)
                {
                    continue;
                }
                if (isForSale[i] == true)         // продаваемый островом ресурс
                {
                    if (storage.GetResourceCount(i) > minValueForTrading[i])
                    {
                        sellPositions.Add(i);
                        totalPositions++;
                    }
                }
                else         // покупаемый островом ресурс
                {
                    if (storage.GetResourceCount(i) <= minValueForTrading[i])
                    {
                        buyPositions.Add(i);
                        totalPositions++;
                    }
                }
            }

            float pc = tradeVolume * 1f / (float)totalPositions;
            float v, a;
            if (buyPositions.Count > 0)
            {
                foreach (int id in buyPositions)
                {
                    v = pc * (0.9f + 0.2f * Random.value);
                    a = storage.GetResourceCount(id);
                    if (a + v > minValueForTrading[id])
                    {
                        v = minValueForTrading[id] - a;
                    }
                    if (v > 0)
                    {
                        d.BuyResource(ResourceType.GetResourceTypeById(id), v);
                        rewardValue += 0.2f;
                    }
                }
            }
            else
            {
                rewardValue += 0.1f;
            }

            if (sellPositions.Count > 0)
            {
                foreach (int id in sellPositions)
                {
                    v = pc * (0.9f + 0.2f * Random.value);
                    a = storage.GetResourceCount(id);
                    if (a - v <= minValueForTrading[id])
                    {
                        v = a - minValueForTrading[id];
                    }
                    if (v > 0)
                    {
                        d.SellResource(ResourceType.GetResourceTypeById(id), v);
                        rewardValue += 0.2f;
                    }
                }
            }
            else
            {
                rewardValue += 0.1f;
            }

            if (d.ID != Structure.DOCK_ID)
            {
                if (d.ID == Structure.DOCK_2_ID)
                {
                    rewardValue *= 2f;
                }
                else
                {
                    if (d.ID == Structure.DOCK_3_ID)
                    {
                        rewardValue *= 3f;
                    }
                }
            }
            break;
        }

        case ShipType.Military:
        {
            rewardValue += 1f;
            if (GameMaster.realMaster.warProximity < 0.5f && Random.value < 0.1f && immigrationPlan > 0)
            {
                int veterans = (int)(s.volume * 0.02f);
                if (veterans > immigrationPlan)
                {
                    veterans = immigrationPlan;
                }
                colony.AddCitizens(veterans, true);
            }
            if (isForSale[ResourceType.FUEL_ID] == true)
            {
                float tv = (float)(tradeVolume * 0.5f * (Random.value * 0.5f + 0.5f));
                if (tv != 0)
                {
                    d.SellResource(ResourceType.Fuel, tv);
                }
            }
            ;
            if (GameMaster.realMaster.warProximity > 0.5f)
            {
                if (isForSale[ResourceType.METAL_S_ID] == true)
                {
                    d.SellResource(ResourceType.metal_S, s.volume * 0.1f);
                }
                if (isForSale[ResourceType.METAL_K_ID] == true)
                {
                    d.SellResource(ResourceType.metal_K, s.volume * 0.05f);
                }
                if (isForSale[ResourceType.METAL_M_ID] == true)
                {
                    d.SellResource(ResourceType.metal_M, s.volume * 0.1f);
                }
            }
            break;
        }

        case ShipType.Private:
            rewardValue += 0.1f;
            if (isForSale[ResourceType.FUEL_ID] == true)
            {
                d.SellResource(ResourceType.Fuel, (float)(tradeVolume * 0.8f));
            }
            if (isForSale[ResourceType.FOOD_ID] == true)
            {
                d.SellResource(ResourceType.Fuel, (float)(tradeVolume * 0.15f));
            }
            break;
        }

        int newPeople = peopleBefore - immigrationPlan;

        if (newPeople != 0)
        {
            if (newPeople > 0)
            {
                AnnouncementCanvasController.MakeAnnouncement(Localization.GetPhrase(LocalizedPhrase.ColonistsArrived) + " (" + newPeople.ToString() + ')');
                immigrantsArrived += (uint)newPeople;
                Knowledge.GetCurrent()?.ImmigrantsCheck(immigrantsArrived);
            }
            else
            {
                emigrantsGone += (uint)(newPeople * (-1));
            }
        }

        rewardValue += d.workersCount * 0.1f;
        colony.AddEnergyCrystals(rewardValue * GameConstants.PER_DOCKED_SHIP_BASIC_REWARD * GameMaster.realMaster.GetDifficultyCoefficient());
    }
Esempio n. 19
0
    public void SetNewQuest(byte i)
    {
        if (questAccessMap[i] == false)
        {
            activeQuests[i] = Quest.NoQuest;
            return;
        }
        // поиск подходящих среди отложенных
        Quest q = Quest.NoQuest;

        switch ((QuestSection)i)
        {
        case QuestSection.Zero: q = Quest.GetProgressQuest(); break;

        case QuestSection.Endgame:
            break;
            uint mask = Quest.questsCompletenessMask[(int)QuestType.Endgame];
            if (mask == 0)
            {
                q = new Quest(QuestType.Endgame, 0);
            }
            else
            {
                if (mask == 3)
                {
                    q = new Quest(QuestType.Endgame, 2);
                }
                else
                {
                    if (mask == 1)
                    {
                        q = new Quest(QuestType.Endgame, 1);
                    }
                }
            }
            break;

        default:
            q = Knowledge.GetCurrent().GetHelpingQuest();
            break;
        }

        if (q == Quest.NoQuest)
        {
            StartNewQuestAwaiting(i);
            return;
        }
        else
        {
            activeQuests[i] = q;
            if (openedQuest == -1)
            {
                newQuestMarker.enabled = true;
            }
        }

        if (openedQuest == -1 & GetComponent <Image>().enabled)
        {
            PrepareBasicQuestWindow();
        }
        AnnouncementCanvasController.MakeAnnouncement(Localization.GetAnnouncementString(GameAnnouncements.NewQuestAvailable));
        if (GameMaster.soundEnabled)
        {
            GameMaster.audiomaster.Notify(NotificationSound.newQuestAvailable);
        }
    }
Esempio n. 20
0
    public void Load()
    {
        if (current != null)
        {
            return;
        }
        current = this;
        DefineMaterialPack();
        LoadMaterials();
        useIlluminationSystem = !shadowCasting;
        if (qualityLevel != 0) // dependency : change quality level()
        {
            buildEmitter     = Instantiate(Resources.Load <ParticleSystem>("buildEmitter"));
            lifepowerEmitter = Instantiate(Resources.Load <ParticleSystem>("lifepowerEmitter"));
        }
        inactiveShips = new List <Ship>();

        lr_red_material   = Resources.Load <Material>("Materials/GUI_Red");
        lr_green_material = Resources.Load <Material>("Materials/GUI_Green");

        zoneCube = Instantiate(Resources.Load <Transform>("Prefs/zoneCube"), transform);
        zoneCube.gameObject.SetActive(false);

        default_material                = Resources.Load <Material>("Materials/Default");
        darkness_material               = Resources.Load <Material>("Materials/Darkness");
        energyMaterial_disabled         = Resources.Load <Material>("Materials/UnchargedMaterial");
        verticalBillboardMaterial       = Resources.Load <Material>("Materials/VerticalBillboard");
        verticalWavingBillboardMaterial = Resources.Load <Material>("Materials/VerticalWavingBillboard");

        billboardShadedMaterial = Resources.Load <Material>("Materials/Advanced/shadedBillboard");
        billboardMaterial       = Resources.Load <Material>("Materials/BillboardMaterial");
        // android errors here:
        // celestialBillboardMaterial = new Material(Shader.Find("Custom/CelestialBillboard"));
        // celestialBillboardMaterial.SetColor("_MainColor", Color.white);
        starsBillboardMaterial     = Resources.Load <Material>("Materials/StarsBillboardMaterial");
        celestialBillboardMaterial = new Material(starsBillboardMaterial);
        celestialBillboardMaterial.SetFloat("_Tick", 1);

        //mineElevator_pref = Resources.Load<GameObject>("Structures/MineElevator");
        gui_overridingSprite = LoadOverridingSprite();
        starsSprites         = Resources.LoadAll <Sprite>("Textures/stars");

        GameMaster.realMaster.labourUpdateEvent += LabourUpdate;
        energyMaterial = Resources.Load <Material>("Materials/ChargedMaterial");

        if (GameMaster.realMaster?.mainChunk != null)
        {
            GameMaster.realMaster.mainChunk.SetShadowCastingMode(shadowCasting);
        }
        if (useIlluminationSystem)
        {
            lightPoolMaterials           = new Dictionary <LightPoolInfo, Material>();
            MAX_MATERIAL_LIGHT_DIVISIONS = QualitySettings.GetQualityLevel() == 0 ? (byte)8 : (byte)16;
        }

        var rrs = Component.FindObjectsOfType <Renderer>();

        //if (rrs != null && rrs.Length != 0) ReplaceMaterials(rrs, useAdvancedMaterials);
        if (GameMaster.realMaster?.IsInTestMode ?? false)
        {
            AnnouncementCanvasController.MakeAnnouncement("Pool master loaded");
        }

        KnowledgeTabUI.PreparePartsTexture();
    }
Esempio n. 21
0
    private void Overloading()
    {
        if (GameMaster.loading)
        {
            return;
        }
        if (announcementTimer <= 0)
        {
            AnnouncementCanvasController.MakeAnnouncement(Localization.GetAnnouncementString(GameAnnouncements.StorageOverloaded));
            if (GameMaster.soundEnabled)
            {
                GameMaster.audiomaster.Notify(NotificationSound.StorageOverload);
            }
            announcementTimer = 10f;
        }
        else
        {
            // storage dumping
            var      chunk = GameMaster.realMaster.mainChunk;
            ChunkPos cpos;
            bool     secondTry = false;
            if (warehouses.Count > 0)
            {
                cpos = warehouses[Random.Range(0, warehouses.Count)].GetBlockPosition();
            }
            else
            {
                cpos = GameMaster.realMaster.colonyController.hq.GetBlockPosition();
            }
            var sblock = chunk.GetNearestUnoccupiedSurface(cpos);
SECOND_TRY:
            if (sblock != null)
            {
                int   maxIndex = 0, sid = 0;
                float maxValue   = 0;
                var   bmaterials = ResourceType.blockMaterials;
                for (int j = 0; j < bmaterials.Length; j++)
                {
                    sid = bmaterials[j].ID;
                    if (standartResources[sid] > maxValue)
                    {
                        maxValue = standartResources[sid];
                        maxIndex = sid;
                    }
                }
                int dumpingVal = 1000;
                if (dumpingVal > maxValue)
                {
                    dumpingVal = (int)maxValue;
                }

                dumpingVal -= sblock.FORCED_GetExtension().ScatterResources(SurfaceRect.full, ResourceType.GetResourceTypeById(maxIndex), dumpingVal);

                if (dumpingVal != 0)
                {
                    standartResources[maxIndex] -= dumpingVal;
                    totalVolume -= dumpingVal;
                }
                else
                {
                    if (!secondTry)
                    {
                        secondTry = true;
                        sblock    = chunk.GetRandomSurface();
                        goto SECOND_TRY;
                    }
                }
            }
        }
    }