Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.35 KB | None | 0 0
  1. using PlayFab;
  2. using PlayFab.ClientModels;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8.  
  9. public class DaileyManagment : MonoBehaviour
  10. {
  11.     [SerializeField] private int year, month, day, hours, minutes, seconds;
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.     private bool daylieRun;
  20.  
  21.  
  22.     public GameObject DaileyEncounter;
  23.  
  24.     public GameObject Dayprice1;
  25.     public GameObject Dayprice2;
  26.     public GameObject Dayprice3;
  27.     public GameObject Dayprice4;
  28.     public GameObject Dayprice5;
  29.     public GameObject Dayprice6;
  30.     public GameObject Dayprice7;
  31.  
  32.     //public float Timer;
  33.  
  34.  
  35.     public Text Daytime;
  36.     public Text Clock;
  37.     public Text Dailey;
  38.     public Text Day1;
  39.     public Text Day2;
  40.     public Text Day3;
  41.     public Text Day4;
  42.     public Text Day5;
  43.     public Text Day6;
  44.     public Text Day7;
  45.     private int dayVariable;
  46.  
  47.     void Awake()
  48.     {
  49.         GetStats();  
  50.     }
  51.  
  52.    
  53.  
  54.     // Start is called before the first frame update
  55.     void Start()
  56.     {
  57.         daylieRun = false;
  58.         Dailey.text = "Tägliche Belohnung fürs einloggen";
  59.         Day1.text = "Tag 1";
  60.         Day2.text = "Tag 2";
  61.         Day3.text = "Tag 3";
  62.         Day4.text = "Tag 4";
  63.         Day5.text = "Tag 5";
  64.         Day6.text = "Tag 6";
  65.         Day7.text = "Tag 7";
  66.         //GetStats();
  67.     }
  68.  
  69.     // Update is called once per frame
  70.     void Update()
  71.     {
  72.  
  73.  
  74.  
  75.  
  76.         DateTime time = DateTime.Now;
  77.  
  78.         Clock.text = time.ToString("HH:mm:ss");
  79.  
  80.         if (!daylieRun)
  81.         {
  82.             daylieRun = true;
  83.  
  84.             if (DateTime.Now.Hour == hours && DateTime.Now.Minute == minutes && DateTime.Now.Second == seconds)
  85.             {
  86.                 if (day == 7)
  87.                 {
  88.                     day = 1;
  89.                 }
  90.                 else
  91.                 {
  92.                     day++;
  93.                 }
  94.  
  95.                 Daytime.text = day.ToString();
  96.                 print("Tag hat gewechselt");
  97.  
  98.  
  99.  
  100.             }
  101.         }
  102.     }
  103.  
  104.     public void DaileyClosed()
  105.     {
  106.         DaileyEncounter.SetActive(false);
  107.     }
  108.  
  109.  
  110.  
  111.     public void DayPrice1()
  112.     {
  113.  
  114.     }
  115.  
  116.     public void DayPrice2()
  117.     {
  118.  
  119.     }
  120.  
  121.     public void DayPrice3()
  122.     {
  123.  
  124.     }
  125.  
  126.     public void DayPrice4()
  127.     {
  128.  
  129.     }
  130.  
  131.     public void DayPrice5()
  132.     {
  133.  
  134.     }
  135.  
  136.     public void DayPrice6()
  137.     {
  138.  
  139.     }
  140.  
  141.     public void DayPrice7()
  142.     {
  143.  
  144.     }
  145.  
  146.     public void GetStats()
  147.     {
  148.         //Neue Anfrage erstallen
  149.         var request = new GetPlayerStatisticsRequest();
  150.         request.StatisticNames = new List<string>() { "Year", "Month", "Day", "Hour", "Minuts", "Seconds" };
  151.  
  152.  
  153.         // request an PlayFabAPI
  154.         PlayFabClientAPI.GetPlayerStatistics(request, GetPlayerStaticsSuccess, OnPlayFabError);
  155.  
  156.     }
  157.  
  158.     private void OnPlayFabError(PlayFabError obj)
  159.     {
  160.         print("Es konnte nichts geholt werden");
  161.     }
  162.  
  163.     private void GetPlayerStaticsSuccess(GetPlayerStatisticsResult result)
  164.     {
  165.         for (int i = 0; i < result.Statistics.Count; i++)
  166.         {
  167.             if (result.Statistics[i].StatisticName == "Day")
  168.             {
  169.                 dayVariable = result.Statistics[i].Value;
  170.                 print("Day wurde geholt");
  171.             }
  172.         }
  173.         Daytime.text ="Day" + dayVariable.ToString();
  174.  
  175.     }
  176.  
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement