Esempio n. 1
0
    public void LoadGame()  //30 переменных
    {
        // SteamAchiments.main.LockAchiv("ACH_TRAVEL_FAR_ACCUM");
        MatchThree.main.LifeDays   = FileBasedPrefs.GetInt("LifeDays");
        MatchThree.main.TimeHour   = FileBasedPrefs.GetInt("TimeHour");
        MatchThree.main.TimeMinute = FileBasedPrefs.GetInt("TimeMinute");
        LastNalogDay = FileBasedPrefs.GetInt("LastNalogDay");

        MatchThree.main.eat     = FileBasedPrefs.GetInt("eat");
        MatchThree.main.energy  = FileBasedPrefs.GetInt("energy");
        MatchThree.main.coffee  = FileBasedPrefs.GetInt("coffee");
        MatchThree.main.hygiene = FileBasedPrefs.GetInt("hygiene");
        MatchThree.main.money   = FileBasedPrefs.GetInt("money");

        MatchThree.main.coffeevarka = FileBasedPrefs.GetBool("coffeevarka");
        MatchThree.main.multvarka   = FileBasedPrefs.GetBool("multvarka");
        MatchThree.main.icebox      = FileBasedPrefs.GetBool("icebox");
        MatchThree.main.shower      = FileBasedPrefs.GetBool("shower");
        MatchThree.main.bed         = FileBasedPrefs.GetBool("bed");
        MatchThree.main.computer    = FileBasedPrefs.GetBool("computer");

        flowchart.SetBooleanVariable("FirstKitchen", FileBasedPrefs.GetBool("FirstKitchen"));
        flowchart.SetBooleanVariable("FirstShower", FileBasedPrefs.GetBool("FirstShower"));
        flowchart.SetBooleanVariable("FirstBed", FileBasedPrefs.GetBool("FirstBed"));
        flowchart.SetBooleanVariable("Firstcabinet", FileBasedPrefs.GetBool("Firstcabinet"));

        flowchart.SetBooleanVariable("HaveCompDialog", FileBasedPrefs.GetBool("HaveCompDialog")); // Показывался ли диалог со сломаным пк

        IncriseMoney = FileBasedPrefs.GetFloat("IncriseMoney");                                   // общее увеличение доходв от компа
        // Налоги
        Nalogi        = FileBasedPrefs.GetFloat("Nalogi");
        NDS           = FileBasedPrefs.GetFloat("NDS");
        Priceincrease = FileBasedPrefs.GetFloat("Priceincrease");
        Rentincrease  = FileBasedPrefs.GetFloat("Rentincrease");
        //продукты
        numproducts = FileBasedPrefs.GetInt("numproducts"); // число продуктов в холодильнике
        numcoffee   = FileBasedPrefs.GetInt("numcoffee");   // число кофе в холодильнике
        //Statistic
        MovesinGame = FileBasedPrefs.GetInt("MovesinGame"); // ходов стелано в последней игре
        GameWins    = FileBasedPrefs.GetInt("GameWins");    // игр выйграно
        MoneyProfit = FileBasedPrefs.GetInt("MoneyProfit"); // денег заработано
        MoneyOutgo  = FileBasedPrefs.GetInt("MoneyOutgo");  // денег потрачено

        ChangeBG.main.UpdateStatusDevice();
    }
    void BoolTests()
    {
        FileBasedPrefs.SetBool("test", true);

        if (!FileBasedPrefs.GetBool("test").Equals(true))
        {
            Debug.LogException(new System.Exception("SetBoolFailed"));
            return;
        }

        FileBasedPrefs.SetBool("test", true);

        if (!FileBasedPrefs.GetBool("test").Equals(true))
        {
            Debug.LogException(new System.Exception("ReplaceBoolFailed"));
            return;
        }

        if (!FileBasedPrefs.HasKeyForBool("test"))
        {
            Debug.LogException(new System.Exception("HasKeyForBoolFailed"));
            return;
        }

        FileBasedPrefs.DeleteBool("test");

        if (!FileBasedPrefs.GetBool("test").Equals(false))
        {
            Debug.LogException(new System.Exception("DeleteBoolFailed"));
            return;
        }

        FileBasedPrefs.SetBool("test", true);

        if (!FileBasedPrefs.GetBool("test").Equals(true))
        {
            Debug.LogException(new System.Exception("ReplaceBoolFailed"));
            return;
        }

        Debug.Log("Bool Tests Passed");
    }
    //! Called once per frame by unity engine.
    public void Update()
    {
        if (addedModBlocks == false)
        {
            if (ReadyToLoadModBlocks())
            {
                BlockDictionary blockDictionary = GetComponent <BuildController>().blockDictionary;
                blockDictionary.AddModBlocks(blockDictionary.blockDictionary);
                blockDictionary.AddModMachines(blockDictionary.machineDictionary);
                blockDictionary.AddModMeshes(blockDictionary.meshDictionary);
                addedModBlocks = true;
            }
        }

        // Get a refrence to the camera.
        if (mCam == null)
        {
            mCam = Camera.main;

            if (PlayerPrefs.GetFloat("FOV") != 0)
            {
                mCam.fieldOfView = PlayerPrefs.GetFloat("FOV");
            }

            if (PlayerPrefs.GetFloat("drawDistance") != 0)
            {
                mCam.farClipPlane = PlayerPrefs.GetFloat("drawDistance");
            }
        }
        else
        {
            // Disable mouse look during main menu sequence.
            gameObject.GetComponent <MSCameraController>().enabled &= gameStarted != false;

            // Get the spawn location, for respawning the player character.
            if (gotPosition == false)
            {
                originalPosition = transform.position;
                gotPosition      = true;
            }

            // The state manager has finished loading the world.
            if (stateManager.worldLoaded == true)
            {
                gameStarted = true;

                if (FileBasedPrefs.GetBool(stateManager.worldName + "oldWorld") == false)
                {
                    OpenTabletOnFirstLoad();
                }
                else if (movedPlayer == false)
                {
                    MovePlayerToSavedLocation();
                }

                if (ShouldShowTabletIntro())
                {
                    ShowTabletIntro();
                }

                if (checkedForCreativeMode == false && stateManager.worldLoaded == true)
                {
                    creativeMode = FileBasedPrefs.GetBool(stateManager.worldName + "creativeMode");
                    if (creativeMode == true)
                    {
                        Debug.Log("World [" + stateManager.worldName + "] running in creative mode.");
                    }
                    else
                    {
                        Debug.Log("World [" + stateManager.worldName + "] running in standard mode.");
                    }
                    checkedForCreativeMode = true;
                }

                // Destruction messages.
                if (destructionMessageActive == true)
                {
                    if (destructionMessageCount > 10)
                    {
                        currentTabletMessage    = "";
                        destructionMessageCount = 0;
                    }
                    if (destructionMessageReceived == false)
                    {
                        tablet.GetComponent <AudioSource>().Play();
                        destructionMessageReceived = true;
                    }
                }
                else
                {
                    destructionMessageCount    = 0;
                    destructionMessageReceived = false;
                }

                // Pirate attack warnings.
                if (pirateAttackWarningActive == true)
                {
                    currentTabletMessage = "Warning! Warning! Warning! Warning! Warning!\n\nIncoming pirate attack!";
                    if (pirateAttackWarningReceived == false)
                    {
                        tablet.GetComponent <AudioSource>().Play();
                        pirateAttackWarningReceived = true;
                    }
                }
                else
                {
                    pirateAttackWarningReceived = false;
                }

                // Meteor shower warnings.
                if (meteorShowerWarningActive == true)
                {
                    currentTabletMessage = "Warning! Warning! Warning! Warning! Warning!\n\nIncoming meteor shower!";
                    if (meteorShowerWarningReceived == false)
                    {
                        tablet.GetComponent <AudioSource>().Play();
                        meteorShowerWarningReceived = true;
                    }
                }
                else
                {
                    meteorShowerWarningReceived = false;
                }

                if (timeToDeliver == true)
                {
                    DisplayDeliveryWarning();
                }
                else
                {
                    timeToDeliverWarningRecieved = false;
                }

                if (destroying == true)
                {
                    ModifyCombinedMeshes();
                }

                if (requestedBuildingStop == true)
                {
                    HandleBuildingStopRequest();
                }

                // The player controller is notified that the game manager finished combining meshes.
                if (stoppingBuildCoRoutine == true && gameManager.working == false)
                {
                    stoppingBuildCoRoutine = false;
                }

                if (requestedChunkLoad == true)
                {
                    HandleChunkLoadRequest();
                }

                // Locking or unlocking the mouse cursor for GUI interaction.
                if (GuiOpen())
                {
                    Cursor.visible   = true;
                    Cursor.lockState = CursorLockMode.None;
                    gameObject.GetComponent <MSCameraController>().enabled = false;
                }
                else
                {
                    Cursor.visible   = false;
                    Cursor.lockState = CursorLockMode.Locked;
                    gameObject.GetComponent <MSCameraController>().enabled = true;
                }

                if (requestedSave == true)
                {
                    HandleSaveRequest();
                }

                if (storageInventory != null && storageGUIopen == true)
                {
                    CheckStorageDistance();
                }

                if (stateManager.saving == false)
                {
                    inputManager.HandleInput();
                    EnforceWorldLimits();
                }

                if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
                {
                    networkController.NetworkFrame();

                    if (networkController.networkWorldUpdateCoroutineBusy == false)
                    {
                        networkWorldUpdateCoroutine = StartCoroutine(networkController.NetWorkWorldUpdate());
                    }
                }
            }
        }
    }
Esempio n. 4
0
    //! Called once per frame by unity engine.
    public void Update()
    {
        if (FileBasedPrefs.initialized == true)
        {
            if (FileBasedPrefs.GetBool(GetComponent <StateManager>().worldName + "Initialized") == false)
            {
                if (lander.GetComponent <InventoryManager>().initialized == true)
                {
                    lander.GetComponent <InventoryManager>().AddItem("Solar Panel", 9);
                    lander.GetComponent <InventoryManager>().AddItem("Universal Conduit", 8);
                    lander.GetComponent <InventoryManager>().AddItem("Storage Container", 4);
                    lander.GetComponent <InventoryManager>().AddItem("Smelter", 3);
                    lander.GetComponent <InventoryManager>().AddItem("Universal Extractor", 2);
                    lander.GetComponent <InventoryManager>().AddItem("Dark Matter Conduit", 1);
                    lander.GetComponent <InventoryManager>().AddItem("Dark Matter Collector", 1);
                    FileBasedPrefs.SetBool(GetComponent <StateManager>().worldName + "Initialized", true);
                }
            }
            else
            {
                if (loadedBlockPhysics == false)
                {
                    if (PlayerPrefsX.GetPersistentBool("multiplayer") == false)
                    {
                        blockPhysics = PlayerPrefsX.GetPersistentBool("blockPhysics");
                    }
                    else
                    {
                        blockPhysics = false;
                    }
                    loadedBlockPhysics = true;
                }
                if (loadedHazardsEnabled == false)
                {
                    hazardsEnabled       = PlayerPrefsX.GetPersistentBool("hazardsEnabled");
                    loadedHazardsEnabled = true;
                }
                if (loadedMeteorTimer == false)
                {
                    meteorShowerTimer = FileBasedPrefs.GetFloat(GetComponent <StateManager>().worldName + "meteorShowerTimer");
                    loadedMeteorTimer = true;
                }
                if (loadedPirateTimer == false)
                {
                    pirateAttackTimer = FileBasedPrefs.GetFloat(GetComponent <StateManager>().worldName + "pirateAttackTimer");
                    loadedPirateTimer = true;
                }
            }

            // A save game request is pending.
            if (dataSaveRequested == true)
            {
                if (GetComponent <StateManager>().saving == false && GetComponent <StateManager>().AddressManagerBusy() == false)
                {
                    UnityEngine.Debug.Log("Saving world...");
                    GetComponent <StateManager>().SaveData();
                    dataSaveRequested = false;
                }
                else if (GetComponent <StateManager>().AddressManagerBusy() == true)
                {
                    if (GetComponent <GameManager>().simulationSpeed < 0.1f)
                    {
                        userSimSpeed  = GetComponent <GameManager>().simulationSpeed;
                        resetSimSpeed = true;
                    }
                    GetComponent <GameManager>().simulationSpeed = 0.1f;
                }
            }
            else if (resetSimSpeed == true)
            {
                GetComponent <GameManager>().simulationSpeed = userSimSpeed;
                resetSimSpeed = false;
            }

            // Used to ensure components are removed before combining meshes.
            if (replacingMeshFilters == true)
            {
                mfDelay += 1 * Time.deltaTime;
                if (mfDelay > 1)
                {
                    meshManager.CombineMeshes();
                    mfDelay = 0;
                    replacingMeshFilters = false;
                }
            }

            if (GetComponent <StateManager>().worldLoaded == true)
            {
                hazardManager.UpdateHazards();
            }

            if (memoryCoroutineBusy == false)
            {
                memoryCoroutine = StartCoroutine(ManageMemory());
            }
        }
    }
Esempio n. 5
0
    //! Adds server to master server database.
    public IEnumerator Announce()
    {
        if (modNames == null)
        {
            modNames = "Mods > ";

            try
            {
                int[] modIds = ModIO.ModManager.GetEnabledModIds().ToArray();
                for (int i = 0; i < modIds.Length; i++)
                {
                    using (WebClient client = new WebClient())
                    {
                        Uri    uri       = new Uri("https://api.mod.io/v1/games/943/mods/" + modIds[i] + "?api_key=" + "8832bfdcf22c63648e4a2f96284159ed");
                        string result    = client.DownloadString(uri);
                        string modName   = result.Split(':')[37].Split(',')[0].Split('"')[1].Split('"')[0];
                        string separator = modIds.Length > 1 && i < modIds.Length - 1 ? " & " : "";
                        modNames += modName + separator;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
            }

            if (modNames == "Mods > ")
            {
                try
                {
                    string modPath = Path.Combine(Application.persistentDataPath, "Mods");
                    Directory.CreateDirectory(modPath);
                    string[] modDirs = Directory.GetDirectories(modPath);
                    for (int i = 0; i < modDirs.Length; i++)
                    {
                        string[] path = modDirs[i].Split('/');
                        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                        {
                            path = modDirs[i].Split('\\');
                        }
                        string mod       = path[path.Length - 1];
                        string separator = modDirs.Length > 1 && i < modDirs.Length - 1 ? " & " : "";
                        modNames += mod + separator;
                    }
                }
                catch (Exception e)
                {
                    Debug.Log(e.Message);
                }
            }

            if (modNames == "Mods > ")
            {
                modNames = "Mods > None";
            }
        }

        yield return(new WaitForSeconds(30));

        using (WebClient client = new WebClient())
        {
            string ip       = PlayerPrefs.GetString("ip");
            string creative = FileBasedPrefs.GetBool(ip + "creativeMode").ToString();

            int      sceneIndex = SceneManager.GetActiveScene().buildIndex;
            string[] scenes     = { "Kepler-1625", "Gliese 876", "Mods Menu", "Kepler-452b" };
            string   worldName  = scenes[sceneIndex];

            NetworkPlayer[] allPlayers         = UnityEngine.Object.FindObjectsOfType <NetworkPlayer>();
            int             playerCount        = allPlayers.Length;
            string[]        commandLineOptions = Environment.GetCommandLineArgs();
            if (!commandLineOptions.Contains("-batchmode"))
            {
                playerCount += 1;
            }

            Uri uri = new Uri("http://45.77.158.179:48000/servers");
            client.UploadStringAsync(uri, "POST", "@" + PlayerPrefs.GetString("ip") + ":" + worldName + "," + creative + "," + modNames + "," + playerCount);

            Debug.Log("Announce >> address: " +
                      PlayerPrefs.GetString("ip") + ", scene: " + worldName + ", creative: " +
                      creative + ", " + modNames + ", players: " + playerCount);
        }
        networkController.announceCoroutineBusy = false;
    }
Esempio n. 6
0
    //! Called by unity engine on start up to initialize variables.
    public void Start()
    {
        string worldName    = FindObjectOfType <StateManager>().worldName;
        bool   paintedIron  = false;
        bool   paintedGlass = false;
        bool   paintedBrick = false;
        bool   paintedSteel = false;

        if (gameObject.name.Equals("ironHolder(Clone)"))
        {
            if (FileBasedPrefs.GetBool(worldName + "ironHolder" + ID + "painted") == true)
            {
                float r = FileBasedPrefs.GetFloat(worldName + "ironHolder" + ID + "Red");
                float g = FileBasedPrefs.GetFloat(worldName + "ironHolder" + ID + "Green");
                float b = FileBasedPrefs.GetFloat(worldName + "ironHolder" + ID + "Blue");
                GetComponent <Renderer>().material.color = new Color(r, g, b);
                if (paintedIron == false)
                {
                    Transform[] allBuiltObjects = FindObjectOfType <GameManager>().builtObjects.GetComponentsInChildren <Transform>(true);
                    foreach (Transform block in allBuiltObjects)
                    {
                        if (block.GetComponent <IronBlock>() != null)
                        {
                            block.GetComponent <Renderer>().material.color = new Color(r, g, b);
                        }
                    }
                }
            }
        }
        if (gameObject.name.Equals("steelHolder(Clone)"))
        {
            if (FileBasedPrefs.GetBool(worldName + "steelHolder" + ID + "painted") == true)
            {
                float r = FileBasedPrefs.GetFloat(worldName + "steelHolder" + ID + "Red");
                float g = FileBasedPrefs.GetFloat(worldName + "steelHolder" + ID + "Green");
                float b = FileBasedPrefs.GetFloat(worldName + "steelHolder" + ID + "Blue");
                GetComponent <Renderer>().material.color = new Color(r, g, b);
                if (paintedSteel == false)
                {
                    Transform[] allBuiltObjects = FindObjectOfType <GameManager>().builtObjects.GetComponentsInChildren <Transform>(true);
                    foreach (Transform block in allBuiltObjects)
                    {
                        if (block.GetComponent <Steel>() != null)
                        {
                            block.GetComponent <Renderer>().material.color = new Color(r, g, b);
                        }
                    }
                }
            }
        }
        if (gameObject.name.Equals("brickHolder(Clone)"))
        {
            if (FileBasedPrefs.GetBool(worldName + "brickHolder" + ID + "painted") == true)
            {
                float r = FileBasedPrefs.GetFloat(worldName + "brickHolder" + ID + "Red");
                float g = FileBasedPrefs.GetFloat(worldName + "brickHolder" + ID + "Green");
                float b = FileBasedPrefs.GetFloat(worldName + "brickHolder" + ID + "Blue");
                GetComponent <Renderer>().material.color = new Color(r, g, b);
                if (paintedBrick == false)
                {
                    Transform[] allBuiltObjects = FindObjectOfType <GameManager>().builtObjects.GetComponentsInChildren <Transform>(true);
                    foreach (Transform block in allBuiltObjects)
                    {
                        if (block.GetComponent <Brick>() != null)
                        {
                            block.GetComponent <Renderer>().material.color = new Color(r, g, b);
                        }
                    }
                }
            }
        }
        if (gameObject.name.Equals("glassHolder(Clone)"))
        {
            if (FileBasedPrefs.GetBool(worldName + "glassHolder" + ID + "painted") == true)
            {
                float r = FileBasedPrefs.GetFloat(worldName + "glassHolder" + ID + "Red");
                float g = FileBasedPrefs.GetFloat(worldName + "glassHolder" + ID + "Green");
                float b = FileBasedPrefs.GetFloat(worldName + "glassHolder" + ID + "Blue");
                GetComponent <Renderer>().material.color = new Color(r, g, b);
                if (paintedGlass == false)
                {
                    Transform[] allBuiltObjects = FindObjectOfType <GameManager>().builtObjects.GetComponentsInChildren <Transform>(true);
                    foreach (Transform block in allBuiltObjects)
                    {
                        if (block.GetComponent <Glass>() != null)
                        {
                            block.GetComponent <Renderer>().material.color = new Color(r, g, b);
                        }
                    }
                }
            }
        }
    }
Esempio n. 7
0
    //! Saves the color of painted objects.
    private IEnumerator SaveDataCoRoutine()
    {
        string worldName = GameObject.Find("GameManager").GetComponent <StateManager>().worldName;

        if (gameObject.name.Equals("ironHolder(Clone)") && FileBasedPrefs.GetBool(worldName + "ironHolder" + ID + "painted") == true)
        {
            float r = GetComponent <Renderer>().material.color.r;
            float g = GetComponent <Renderer>().material.color.g;
            float b = GetComponent <Renderer>().material.color.b;
            FileBasedPrefs.SetFloat(worldName + "ironHolder" + ID + "Red", r);
            FileBasedPrefs.SetFloat(worldName + "ironHolder" + ID + "Green", g);
            FileBasedPrefs.SetFloat(worldName + "ironHolder" + ID + "Blue", b);
            Transform[] blocks        = gameObject.GetComponentsInChildren <Transform>(true);
            int         paintInterval = 0;
            foreach (Transform T in blocks)
            {
                if (T != null)
                {
                    T.gameObject.GetComponent <Renderer>().material.color = new Color(r, g, b);
                }
                paintInterval++;
                if (paintInterval >= 10)
                {
                    yield return(null);

                    paintInterval = 0;
                }
            }
        }
        if (gameObject.name.Equals("steelHolder(Clone)") && FileBasedPrefs.GetBool(worldName + "steelHolder" + ID + "painted") == true)
        {
            float r = GetComponent <Renderer>().material.color.r;
            float g = GetComponent <Renderer>().material.color.g;
            float b = GetComponent <Renderer>().material.color.b;
            FileBasedPrefs.SetFloat(worldName + "steelHolder" + ID + "Red", r);
            FileBasedPrefs.SetFloat(worldName + "steelHolder" + ID + "Green", g);
            FileBasedPrefs.SetFloat(worldName + "steelHolder" + ID + "Blue", b);
            Transform[] blocks        = gameObject.GetComponentsInChildren <Transform>(true);
            int         paintInterval = 0;
            foreach (Transform T in blocks)
            {
                if (T != null)
                {
                    T.gameObject.GetComponent <Renderer>().material.color = new Color(r, g, b);
                }
                paintInterval++;
                if (paintInterval >= 10)
                {
                    yield return(null);

                    paintInterval = 0;
                }
            }
        }
        if (gameObject.name.Equals("brickHolder(Clone)") && FileBasedPrefs.GetBool(worldName + "brickHolder" + ID + "painted") == true)
        {
            float r = GetComponent <Renderer>().material.color.r;
            float g = GetComponent <Renderer>().material.color.g;
            float b = GetComponent <Renderer>().material.color.b;
            FileBasedPrefs.SetFloat(worldName + "brickHolder" + ID + "Red", r);
            FileBasedPrefs.SetFloat(worldName + "brickHolder" + ID + "Green", g);
            FileBasedPrefs.SetFloat(worldName + "brickHolder" + ID + "Blue", b);
            Transform[] blocks        = gameObject.GetComponentsInChildren <Transform>(true);
            int         paintInterval = 0;
            foreach (Transform T in blocks)
            {
                if (T != null)
                {
                    T.gameObject.GetComponent <Renderer>().material.color = new Color(r, g, b);
                }
                paintInterval++;
                if (paintInterval >= 10)
                {
                    yield return(null);

                    paintInterval = 0;
                }
            }
        }
        if (gameObject.name.Equals("glassHolder(Clone)") && FileBasedPrefs.GetBool(worldName + "glassHolder" + ID + "painted") == true)
        {
            float r = GetComponent <Renderer>().material.color.r;
            float g = GetComponent <Renderer>().material.color.g;
            float b = GetComponent <Renderer>().material.color.b;
            FileBasedPrefs.SetFloat(worldName + "glassHolder" + ID + "Red", r);
            FileBasedPrefs.SetFloat(worldName + "glassHolder" + ID + "Green", g);
            FileBasedPrefs.SetFloat(worldName + "glassHolder" + ID + "Blue", b);
            Transform[] blocks        = gameObject.GetComponentsInChildren <Transform>(true);
            int         paintInterval = 0;
            foreach (Transform T in blocks)
            {
                if (T != null)
                {
                    T.gameObject.GetComponent <Renderer>().material.color = new Color(r, g, b);
                }
                paintInterval++;
                if (paintInterval >= 10)
                {
                    yield return(null);

                    paintInterval = 0;
                }
            }
        }
    }