﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class RegFuncs : MonoBehaviour
{
    public ADokManager adok;
    public InputField inpCodeMoaref;
    public Text txtResult;

    // Use this for initialization
    void Start()
    {
        adok.OnCodeMoarefEvent += Adok_OnCodeMoarefEvent;
        adok.OnMoarefiCountEvent += Adok_OnMoarefiCountEvent;
        adok.OnMoarefiCountAllEvent += Adok_OnMoarefiCountAllEvent;
        adok.OnMoarefiSetRewardEvent += Adok_OnMoarefiSetRewardEvent;
        adok.OnLogOutEvent += Adok_OnLogOutEvent;

    }

    // Update is called once per frame
    void Update()
    {

    }

    public void SetCodeMoaref()
    {
        adok.SetCodeMoaref(inpCodeMoaref.text);
    }

    public void GetMoarefiCount()
    {
        adok.GetMoarefiCount();
    }

    public void GetMoarefiCountAll()
    {
        adok.GetMoarefiCountAll();
    }

    public void SetMoarefiReward()
    {
        adok.GetMoarefiSetReward();
    }

    public void GetCodeMoaref()
    {
        txtResult.text = "CodeMoaref: " + adok.GetCodeMoaref();
    }

    public void LogOut()
    {
        adok.LogOut();
    }

    private void Adok_OnLogOutEvent(ADokManager.LogOutResult LogOutResult)
    {
        txtResult.text = "LogOutResult: " + LogOutResult.ToString()+" --- "+ "playerId: " + adok.GetUserId() + " nickName:" + adok.GetNickName() + " userName:" + adok.GetUserName();
    }

    private void Adok_OnCodeMoarefEvent(ADokManager.CodeMoarefResult cmResult)
    {
        txtResult.text = "CodeMoarefResult: " + cmResult.ToString();
    }

    public void getUserInfoRegister()
    {
        txtResult.text = "playerId: " + adok.GetUserId() + " nickName:" + adok.GetNickName() + " userName:" + adok.GetUserName();
    }

    private void Adok_OnMoarefiCountEvent(ADokManager.MoarefiCountResult cmResult)
    {
        txtResult.text = "MoarefiCountResult: " + cmResult.ToString() + " count:" + adok.GetMoarefiCountVal() ;

        adok.GetMoarefiCountVal();
        adok.GetMoarefiCountAppShareVal();
        adok.GetMoarefiCountVideoShareVal();
    }

    private void Adok_OnMoarefiCountAllEvent(ADokManager.MoarefiCountResult cmResult)
    {
        txtResult.text = "MoarefiCountAllResult: " + cmResult.ToString() + " count:" + adok.GetMoarefiCountValAll();
        adok.GetMoarefiCountValAll();
        adok.GetMoarefiCountValAllAppShare();
        adok.GetMoarefiCountValAllVideoShare();
    }

    private void Adok_OnMoarefiSetRewardEvent(ADokManager.MoarefiCountResult cmResult)
    {
        txtResult.text = "MoarefiSetRewardResult: " + cmResult.ToString() + " count:" + adok.GetMoarefiSetRewardCount();

        adok.GetMoarefiSetRewardCount();
        adok.GetMoarefiSetRewardCountAppShare();
        adok.GetMoarefiSetRewardCountVideoShare();
    }
}
