コード例 #1
0
    public void ChangedScene()
    {
        BinaryFormatter       bf   = new BinaryFormatter();
        FileStream            file = File.Create(Application.persistentDataPath + "/playerInfoStoneQuarry.dat");
        PlayerDataStoneQuarry data = new PlayerDataStoneQuarry();
        FileStream            gold = File.Create(Application.persistentDataPath + "/Gold.dat");
        Gold goldData = new Gold();

        data.Seconds = System.DateTime.Now.Second;
        data.Minutes = System.DateTime.Now.Minute;
        data.Hours   = System.DateTime.Now.Hour;
        data.Day     = System.DateTime.Now.DayOfYear;
        data.Total   = data.Seconds + data.Minutes * 60 + data.Hours * 60 * 60;

        data.goldPerSecond = GPS.goldPerSecond;

        Debug.Log("Saved" + click.gold + "Gold");
        goldData.gold     = click.gold;
        goldData.Map2     = Map2;
        goldData.Map3     = Map3;
        goldData.Map4     = Map4;
        goldData.Map5     = Map5;
        goldData.Map6     = Map6;
        goldData.Map7     = Map7;
        goldData.Map8     = Map8;
        goldData.Map9     = Map9;
        goldData.Map10    = Map10;
        data.goldPerClick = click.goldPerClick;

        for (int i = 0; i < 10; i++)
        {
            data.itemsArrayCount [i] = Items [i].count;
        }

        for (int i = 0; i < 10; i++)
        {
            data.itemsArrayCost [i] = Items [i].cost;
        }

        for (int i = 0; i < 10; i++)
        {
            data.upgradesArrayCount [i] = Upgrades [i].count;
        }

        for (int i = 0; i < 10; i++)
        {
            data.upgradesArrayCost [i] = Upgrades [i].cost;
        }

        goldData.gems           = Gems.gems;
        data.AwayGoldMultiplier = Bank.AwayGoldMultiplier;


        bf.Serialize(file, data);
        bf.Serialize(gold, goldData);
        file.Close();
        gold.Close();
    }
コード例 #2
0
    public void WhenClicked()
    {
        BinaryFormatter       bf   = new BinaryFormatter();
        FileStream            file = File.Create(Application.persistentDataPath + "/ResearchTimeStoneQuarry.dat");
        PlayerDataStoneQuarry data = new PlayerDataStoneQuarry();

        Debug.Log("data.researchCount0" + data.researchCount0);
        data.researchCount0 = Researches [0].count;
        data.researchCount1 = Researches [1].count;
        data.researchCount2 = Researches [2].count;
        data.researchCount3 = Researches [3].count;
        data.researchCount4 = Researches [4].count;
        data.researchCount5 = Researches [5].count;
        data.researchCount6 = Researches [6].count;
        data.researchCount7 = Researches [7].count;
        data.researchCount8 = Researches [8].count;
        data.researchCount9 = Researches [9].count;

        Debug.Log("data.researchTime0 " + data.researchTime0);
        Debug.Log("Researches [0].startTime" + Researches [0].startTime);
        if (Researches [0].startTime > 0)
        {
            data.researchTime0 = Researches [0].startTime;
        }
        if (Researches [1].startTime > 0)
        {
            data.researchTime1 = Researches [1].startTime;
        }
        if (Researches [2].startTime > 0)
        {
            data.researchTime2 = Researches [2].startTime;
        }
        if (Researches [3].startTime > 0)
        {
            data.researchTime3 = Researches [3].startTime;
        }
        if (Researches [4].startTime > 0)
        {
            data.researchTime4 = Researches [4].startTime;
        }
        if (Researches [5].startTime > 0)
        {
            data.researchTime5 = Researches [5].startTime;
        }
        if (Researches [6].startTime > 0)
        {
            data.researchTime6 = Researches [6].startTime;
        }
        if (Researches [7].startTime > 0)
        {
            data.researchTime7 = Researches [7].startTime;
        }
        if (Researches [8].startTime > 0)
        {
            data.researchTime8 = Researches [8].startTime;
        }
        if (Researches [9].startTime > 0)
        {
            data.researchTime9 = Researches [9].startTime;
        }
        bf.Serialize(file, data);
        file.Close();
    }
コード例 #3
0
    void Start()
    {
        if (File.Exists(Application.persistentDataPath + "/Gold.dat"))
        {
            BinaryFormatter bf       = new BinaryFormatter();
            FileStream      goldf    = File.Open(Application.persistentDataPath + "/Gold.dat", FileMode.Open);
            Gold            goldData = (Gold)bf.Deserialize(goldf);
            goldf.Close();
            Map2  = goldData.Map2;
            Map3  = goldData.Map3;
            Map4  = goldData.Map4;
            Map5  = goldData.Map5;
            Map6  = goldData.Map6;
            Map7  = goldData.Map7;
            Map8  = goldData.Map8;
            Map9  = goldData.Map9;
            Map10 = goldData.Map10;
            Debug.Log(goldData.gold);
            click.gold = goldData.gold;
            Gems.gems  = goldData.gems;
        }
        if (File.Exists(Application.persistentDataPath + "/playerInfoStoneQuarry.dat"))
        {
            BinaryFormatter       bf             = new BinaryFormatter();
            FileStream            playerInfo     = File.Open(Application.persistentDataPath + "/playerInfoStoneQuarry.dat", FileMode.Open);
            PlayerDataStoneQuarry playerInfoData = (PlayerDataStoneQuarry)bf.Deserialize(playerInfo);
            playerInfo.Close();
            Seconds           = System.DateTime.Now.Second;
            Minutes           = System.DateTime.Now.Minute;
            Hours             = System.DateTime.Now.Hour;
            Day               = System.DateTime.Now.DayOfYear;
            Total             = Seconds + Minutes * 60 + Hours * 60 * 60;
            differenceSeconds = Total - playerInfoData.Total;

            for (int i = 0; i < 10; i++)
            {
                Items [i].count = playerInfoData.itemsArrayCount [i];
            }

            for (int i = 0; i < 10; i++)
            {
                Items [i].cost = playerInfoData.itemsArrayCost [i];
            }

            for (int i = 0; i < 10; i++)
            {
                Upgrades [i].count = playerInfoData.upgradesArrayCount [i];
            }

            for (int i = 0; i < 10; i++)
            {
                Upgrades [i].cost = playerInfoData.upgradesArrayCost [i];
            }

            Bank.AwayGoldMultiplier = playerInfoData.AwayGoldMultiplier;

            click.goldPerClick = playerInfoData.goldPerClick;
            GPS.goldPerSecond  = playerInfoData.goldPerSecond;

            if (playerInfoData.Day < Day)
            {
                differenceDays = Day - playerInfoData.Day;
                click.gold     = click.gold + ((playerInfoData.goldPerSecond * ((24 - playerInfoData.Hours + Hours) * 60 * 60) * differenceDays) + ((playerInfoData.goldPerSecond * ((24 - playerInfoData.Hours + Hours) * 60 * 60) * differenceDays) * (Bank.AwayGoldMultiplier) / 100));
                awayGold.text  = CurrencyConverter.Instance.GetCurrencyIntoString(((playerInfoData.goldPerSecond * ((24 - playerInfoData.Hours + Hours) * 60 * 60) * differenceDays) + ((playerInfoData.goldPerSecond * ((24 - playerInfoData.Hours + Hours) * 60 * 60) * differenceDays) * (Bank.AwayGoldMultiplier) / 100)), true) + " gold";
            }
            else
            {
                click.gold    = (click.gold + (playerInfoData.goldPerSecond * differenceSeconds) + ((playerInfoData.goldPerSecond * differenceSeconds) * (Bank.AwayGoldMultiplier) / 100));
                awayGold.text = CurrencyConverter.Instance.GetCurrencyIntoString(((playerInfoData.goldPerSecond * differenceSeconds) + ((playerInfoData.goldPerSecond * differenceSeconds) * (Bank.AwayGoldMultiplier) / 100)), true) + " gold";
            }
        }
        if (click.gold == 0)
        {
            AwayGold.gameObject.SetActive(false);
            Continue.gameObject.SetActive(false);
        }
        else
        {
            AwayGold.gameObject.SetActive(true);
            Continue.gameObject.SetActive(true);
        }
        if (File.Exists(Application.persistentDataPath + "/ResearchTimeStoneQuarry.dat"))
        {
            BinaryFormatter       bf               = new BinaryFormatter();
            FileStream            researchTime     = File.Open(Application.persistentDataPath + "/ResearchTimeStoneQuarry.dat", FileMode.Open);
            PlayerDataStoneQuarry researchTimeData = (PlayerDataStoneQuarry)bf.Deserialize(researchTime);
            researchTime.Close();

            Debug.Log("Researches [0].count" + Researches [0].count);
            Debug.Log("Researches [1].count" + Researches [1].count);
            Researches [0].count = researchTimeData.researchCount0;
            Researches [1].count = researchTimeData.researchCount1;
            Researches [2].count = researchTimeData.researchCount2;
            Researches [3].count = researchTimeData.researchCount3;
            Researches [4].count = researchTimeData.researchCount4;
            Researches [5].count = researchTimeData.researchCount5;
            Researches [6].count = researchTimeData.researchCount6;
            Researches [7].count = researchTimeData.researchCount7;
            Researches [8].count = researchTimeData.researchCount8;
            Researches [9].count = researchTimeData.researchCount9;
            Debug.Log("Researches [0].startTime" + Researches [0].startTime);
            Debug.Log("Researches [1].startTime" + Researches [1].startTime);
            Researches [0].startTime = researchTimeData.researchTime0;
            Researches [1].startTime = researchTimeData.researchTime1;
            Researches [2].startTime = researchTimeData.researchTime2;
            Researches [3].startTime = researchTimeData.researchTime3;
            Researches [4].startTime = researchTimeData.researchTime4;
            Researches [5].startTime = researchTimeData.researchTime5;
            Researches [6].startTime = researchTimeData.researchTime6;
            Researches [7].startTime = researchTimeData.researchTime7;
            Researches [8].startTime = researchTimeData.researchTime8;
            Researches [9].startTime = researchTimeData.researchTime9;
            if (researchTimeData.researchTime0 > 0)
            {
                if (Total - researchTimeData.researchTime0 >= 600 && Researches [0].done == false)
                {
                    GPS.goldPerSecond   = GPS.goldPerSecond * 2;
                    Researches [0].done = true;
                }
            }
            if (researchTimeData.researchTime1 > 0)
            {
                if (Total - researchTimeData.researchTime1 >= 900 && Researches [1].done == false)
                {
                    click.goldPerClick  = click.goldPerClick * 2;
                    Researches [1].done = true;
                }
            }
            if (researchTimeData.researchTime2 > 0)
            {
                if (Total - researchTimeData.researchTime2 >= 900 && Researches [2].done == false)
                {
                    click.goldPerClick  = click.goldPerClick * 3;
                    Researches [2].done = true;
                }
            }
            if (researchTimeData.researchTime3 > 0)
            {
                if (Total - researchTimeData.researchTime3 >= 1200 && Researches [3].done == false)
                {
                    GPS.goldPerSecond   = GPS.goldPerSecond * 2;
                    click.goldPerClick  = click.goldPerClick * 2;
                    Researches [3].done = true;
                }
            }
            if (researchTimeData.researchTime4 > 0)
            {
                if (Total - researchTimeData.researchTime4 >= 3600 && Researches [4].done == false)
                {
                    GPS.goldPerSecond   = GPS.goldPerSecond * 10;
                    Researches [4].done = true;
                }
            }
            if (researchTimeData.researchTime5 > 0)
            {
                if (Total - researchTimeData.researchTime5 >= 9000 && Researches [5].done == false)
                {
                    Upgrades [0].cost   = Upgrades [0].cost - (Upgrades [0].cost * 0.1f);
                    Upgrades [1].cost   = Upgrades [1].cost - (Upgrades [1].cost * 0.1f);
                    Upgrades [2].cost   = Upgrades [2].cost - (Upgrades [2].cost * 0.1f);
                    Upgrades [3].cost   = Upgrades [3].cost - (Upgrades [3].cost * 0.1f);
                    Upgrades [4].cost   = Upgrades [4].cost - (Upgrades [4].cost * 0.1f);
                    Upgrades [5].cost   = Upgrades [5].cost - (Upgrades [5].cost * 0.1f);
                    Upgrades [6].cost   = Upgrades [6].cost - (Upgrades [6].cost * 0.1f);
                    Upgrades [7].cost   = Upgrades [7].cost - (Upgrades [7].cost * 0.1f);
                    Upgrades [8].cost   = Upgrades [8].cost - (Upgrades [8].cost * 0.1f);
                    Upgrades [9].cost   = Upgrades [9].cost - (Upgrades [9].cost * 0.1f);
                    Researches [5].done = true;
                }
            }
            if (researchTimeData.researchTime6 > 0)
            {
                if (Total - researchTimeData.researchTime6 >= 18000 && Researches [6].done == false)
                {
                    GPS.goldPerSecond   = GPS.goldPerSecond * 4;
                    click.goldPerClick  = click.goldPerClick * 4;
                    Researches [6].done = true;
                }
            }
            if (researchTimeData.researchTime7 > 0)
            {
                if (Total - researchTimeData.researchTime7 >= 21000 && Researches [7].done == false)
                {
                    click.goldPerClick  = click.goldPerClick * 50;
                    Researches [7].done = true;
                }
            }
            if (researchTimeData.researchTime8 > 0)
            {
                if (Total - researchTimeData.researchTime8 >= 30000 && Researches [8].done == false)
                {
                    Upgrades [0].cost   = Upgrades [0].cost - (Upgrades [0].cost * 0.5f);
                    Upgrades [1].cost   = Upgrades [1].cost - (Upgrades [1].cost * 0.5f);
                    Upgrades [2].cost   = Upgrades [2].cost - (Upgrades [2].cost * 0.5f);
                    Upgrades [3].cost   = Upgrades [3].cost - (Upgrades [3].cost * 0.5f);
                    Upgrades [4].cost   = Upgrades [4].cost - (Upgrades [4].cost * 0.5f);
                    Upgrades [5].cost   = Upgrades [5].cost - (Upgrades [5].cost * 0.5f);
                    Upgrades [6].cost   = Upgrades [6].cost - (Upgrades [6].cost * 0.5f);
                    Upgrades [7].cost   = Upgrades [7].cost - (Upgrades [7].cost * 0.5f);
                    Upgrades [8].cost   = Upgrades [8].cost - (Upgrades [8].cost * 0.5f);
                    Upgrades [9].cost   = Upgrades [9].cost - (Upgrades [9].cost * 0.5f);
                    Researches [8].done = true;
                }
            }
            if (researchTimeData.researchTime9 > 0)
            {
                if (Total - researchTimeData.researchTime9 >= 36000 && Researches [9].done == false)
                {
                    GPS.goldPerSecond   = GPS.goldPerSecond * 4;
                    Researches [9].done = true;
                }
            }
        }
    }