Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using PlayFab;
- using PlayFab.ClientModels;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class DaileyManagment : MonoBehaviour
- {
- [SerializeField] public int year, month, day, hours, minutes, seconds;
- private bool daylieRun;
- public GameObject DaileyEncounter;
- public GameObject Dayprice1;
- public GameObject Dayprice2;
- public GameObject Dayprice3;
- public GameObject Dayprice4;
- public GameObject Dayprice5;
- public GameObject Dayprice6;
- public GameObject Dayprice7;
- //public float Timer;
- public Text Daytime;
- public Text Clock;
- public Text Dailey;
- public Text Day1;
- public Text Day2;
- public Text Day3;
- public Text Day4;
- public Text Day5;
- public Text Day6;
- public Text Day7;
- void Awake()
- {
- GetStats();
- }
- // Start is called before the first frame update
- void Start()
- {
- //daylieRun = false;
- Dailey.text = "Tägliche Belohnung fürs einloggen";
- Day1.text = "Tag 1";
- Day2.text = "Tag 2";
- Day3.text = "Tag 3";
- Day4.text = "Tag 4";
- Day5.text = "Tag 5";
- Day6.text = "Tag 6";
- Day7.text = "Tag 7";
- //GetStats();
- }
- // Update is called once per frame
- public void Update()
- {
- DateTime time = DateTime.Now;
- Clock.text = time.ToString("HH:mm:ss");
- if (DateTime.Now.Hour == hours && DateTime.Now.Minute == minutes && DateTime.Now.Second == seconds)
- {
- if (!daylieRun)
- {
- daylieRun = true;
- if (day == 7)
- {
- print("Es ist eine 7 !!!!!");
- day = 1;
- }
- else
- {
- day++;
- }
- Daytime.text = "Day " + day.ToString();
- print(day.ToString());
- SaveDay();
- }
- }
- }
- private void SaveDay()
- {
- var request = new UpdatePlayerStatisticsRequest();
- request.Statistics = new List<StatisticUpdate>();
- var stat = new StatisticUpdate { StatisticName = "Day", Value = day };
- request.Statistics.Add(stat);
- PlayFabClientAPI.UpdatePlayerStatistics(request, OnSendStatsSuccess, OnError);
- }
- private void OnError(PlayFabError obj)
- {
- print("Der Tag konnte nicht gespeichert werden");
- }
- private void OnSendStatsSuccess(UpdatePlayerStatisticsResult obj)
- {
- print("Tag wurde gespeichert");
- }
- public void DaileyClosed()
- {
- DaileyEncounter.SetActive(false);
- }
- public void DayPrice1()
- {
- }
- public void DayPrice2()
- {
- }
- public void DayPrice3()
- {
- }
- public void DayPrice4()
- {
- }
- public void DayPrice5()
- {
- }
- public void DayPrice6()
- {
- }
- public void DayPrice7()
- {
- }
- public void GetStats()
- {
- //Neue Anfrage erstallen
- var request = new GetPlayerStatisticsRequest();
- request.StatisticNames = new List<string>() { "Year", "Month", "Day", "Hour", "Minuts", "Seconds" };
- // request an PlayFabAPI
- PlayFabClientAPI.GetPlayerStatistics(request, GetPlayerStaticsSuccess, OnPlayFabError);
- }
- private void OnPlayFabError(PlayFabError obj)
- {
- print("Es konnte nichts geholt werden");
- }
- public void GetPlayerStaticsSuccess(GetPlayerStatisticsResult result)
- {
- for (int i = 0; i < result.Statistics.Count; i++)
- {
- if (result.Statistics[i].StatisticName == "Day")
- {
- day = result.Statistics[i].Value;
- print("Day wurde geholt");
- }
- }
- Daytime.text ="Day" + day.ToString();
- print(day.ToString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement