コード例 #1
0
ファイル: Main_Manager.cs プロジェクト: safe27698/PetStory
    public void CallbackReward()
    {
        int coin = (indexReward + 1) * 10;

        Popup.Ins.PopupOne("You received " + coin + " coins from this gift.", "OK", GetReward);
        SaveSystem.A_AddCoin(coin);
    }
コード例 #2
0
    public void ResultRoll()
    {
        int    coin = 0;
        Sprite s    = null;
        float  f    = roll.transform.eulerAngles.z;

        if (f < 22 || f >= 337)
        {
            s    = point10;
            coin = 10;
        }
        else if (f < 66)
        {
            s    = point50;
            coin = 50;
        }
        else if (f < 111)
        {
            s    = point500;
            coin = 500;
        }
        else if (f < 156)
        {
            s    = point10;
            coin = 10;
        }
        else if (f < 201)
        {
            s    = point100;
            coin = 100;
        }
        else if (f < 246)
        {
            s    = point20;
            coin = 20;
        }
        else if (f < 291)
        {
            s    = point50;
            coin = 50;
        }
        else if (f < 337)
        {
            s    = point20;
            coin = 20;
        }
        SaveSystem.A_AddCoin(coin);
        Popup.Ins.PopupReward("", s, Finish);
        rollBo    = !rollBo;
        speed     = 500;
        speedDown = 0;
    }
コード例 #3
0
    public void Finish()
    {
        Player player = SaveSystem.A_LoadSaveGame();

        if (player.pets != null && player.pets.Count > 0)
        {
            for (int i = 0; i < player.pets.Count; i++)
            {
                if (player.pets[i].selected && player.pets[i].status >= 0)
                {
                    StartCoroutine(LoadYourAsyncScene("Main"));
                    return;
                }
            }
        }
        if (player.coin == 0 && (player.pets == null || player.pets.Count <= 0))
        {
            SaveSystem.A_AddCoin(2500);
        }


        StartCoroutine(LoadYourAsyncScene("Edit"));
    }
コード例 #4
0
 public void OnEndDrag(PointerEventData eventData)
 {
     SaveSystem.A_AddCoin(5000);
 }
コード例 #5
0
ファイル: Main_Manager.cs プロジェクト: safe27698/PetStory
    public IEnumerator StatusAndRewardCalculator()
    {
        DateTime oldTime;
        int      totalMin = 0;

        if (p.lastTimeInGame != null && p.lastTimeInGame.Length > 0)
        {
            oldTime  = DateTime.Parse(p.lastTimeInGame);
            totalMin = (int)DateTime.Now.Subtract(oldTime).TotalMinutes;
            string datett = DateTime.Now.Year + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00") + DateTime.Now.Hour.ToString("00") + DateTime.Now.Minute.ToString("00");
            string formm  = "yyyyMMddHHmm";
        }

        p.lastTimeInGame = DateTime.Now.ToString();

        SaveSystem.A_SaveGame(p);

        for (int i = 0; i < petList.Count; i++)
        {
            m_Data = SaveSystem.A_LoadPet(petList[i].id);

//            Debug.LogError(m_Data.UUID.Length + "**" + m_Data.UUID);
            if (m_Data.UUID.Length != 10)
            {
                m_Data.UUID = "2019010112";
            }

            string   formm   = "yyyyMMddHH";
            DateTime oldDate = DateTime.ParseExact(m_Data.UUID, formm, null);
            oldTime  = oldDate;
            totalMin = (int)DateTime.Now.Subtract(oldTime).TotalMinutes;
            string newTime = DateTime.Now.Year + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00") + DateTime.Now.Hour.ToString("00") /*+ DateTime.Now.Minute.ToString("00")*/;
//            Debug.LogError(newTime);
            m_Data.UUID = newTime;

            if (!m_Data.selected)
            {
                continue;
            }

            float happy      = petList[i].Happiness;
            float hungy      = petList[i].Hunger;
            float unitPerMin = 0.000115740741f;
            // float unitPerMin = 5f;


            if (Mathf.Abs(((unitPerMin * totalMin) - hungy)) < 40)
            {
                if (hungy > 40f)
                {
                    float earlierMin = (hungy - 40) / unitPerMin;
                    float afterMin   = totalMin - earlierMin;

                    petList[i].Hunger -= unitPerMin * totalMin;

                    petList[i].Happiness -= (unitPerMin / 2) * earlierMin;
                    petList[i].Happiness -= ((unitPerMin / 2) * afterMin) * 2;
                }
                else
                {
                    petList[i].Hunger    -= unitPerMin * totalMin;
                    petList[i].Happiness -= unitPerMin * totalMin;
                }
            }
            else
            {
                petList[i].Hunger    -= unitPerMin * totalMin;
                petList[i].Happiness -= (unitPerMin / 2) * totalMin;
            }
            m_Data.happiness = (int)petList[i].Happiness;
            m_Data.hunger    = (int)petList[i].Hunger;


            //Reward
            getReward = false;
            if (m_Data.lastTimeReward.Length > 0 && petList[i].Happiness >= 50)
            {
                DateTime petDate = DateTime.Parse(m_Data.lastTimeReward);
                if (petDate.Day != DateTime.Now.Day)
                {
                    m_Data.lastTimeReward = DateTime.Now.ToString("yyyy-MM-dd");
                    RandomReward();
                    yield return(null);

                    SoundManager.Ins.PlaySound(SoundManager.Ins._Reward);
                    Popup.Ins.PopupReward(m_Data.namePet + " has a gift for you.", Atlas.Ins.GetSprites(Atlas.Ins.reward.reward)[indexReward], CallbackReward);

                    yield return(new WaitUntil(() => getReward == true));
                }
            }
            if (m_Data.lastTimeReward.Length <= 0)
            {
                Debug.LogError("zxc");
                m_Data.lastTimeReward = DateTime.Now.ToString("yyyy-MM-dd");
                RandomReward();
                yield return(null);

                SoundManager.Ins.PlaySound(SoundManager.Ins._Reward);
                Popup.Ins.PopupReward(m_Data.namePet + " has a gift for you.", Atlas.Ins.GetSprites(Atlas.Ins.reward.reward)[indexReward], CallbackReward);

                yield return(new WaitUntil(() => getReward == true));
            }
            getReward = false;
            SaveSystem.A_EditPet(m_Data, true);

            yield return(null);
        }

        //Daily Reward
        if (PlayerPrefs.HasKey("DailyReward"))
        {
            DateTime dailyTime = DateTime.Parse(PlayerPrefs.GetString("DailyReward"));
            if (dailyTime.Day != DateTime.Now.Day)
            {
                SaveSystem.A_AddCoin(500);
                Popup.Ins.PopupReward("", lottery.point500, null);
                PlayerPrefs.SetString("DailyReward", DateTime.Now.ToString());
            }
        }
        else
        {
            SaveSystem.A_AddCoin(500);
            Popup.Ins.PopupReward("", lottery.point500, null);
            PlayerPrefs.SetString("DailyReward", DateTime.Now.ToString());
        }
    }