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

public class login : MonoBehaviour
{
    public ADokManager adok;

    public InputField txtPhoneNo;

    public InputField txtUserName;
    public InputField txtPass;

    public InputField txtCodeTaied;

    public Text txtResult;

    // Use this for initialization
    void Start()
    {
        adok.OnLoginChange += Adok_OnLoginChange;
        adok.OnResendCodeTaiedChange += Adok_OnResendCodeTaiedChange;
        adok.OnCodeTaiedChange += Adok_OnCodeTaiedChange;
    }

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

    }

    public void LoginPlayerWithSms()
    {
        adok.LoginUser(txtPhoneNo.text);
    }

    public void LoginPlayerPass()
    {
        adok.LoginUserWithPass(txtUserName.text, txtPass.text);
    }


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

    public void CheckCodeTaied()
    {
        adok.CheckCodeTaiedLogin(txtCodeTaied.text.Trim());
    }

    public void CheckIsLogined()
    {
        txtResult.text = adok.CheckLogin().ToString();
    }

    private void Adok_OnLoginChange(ADokManager.LoginResult loginResult)
    {
        txtResult.text = "loginResult:" + loginResult.ToString();
    }

    private void Adok_OnResendCodeTaiedChange(ADokManager.CodeTaiedResult CodeTaiedResult)
    {
        int mustWaitTime = (int)(60 - adok.delayNeeded);
        if (mustWaitTime < 0)
        {
            mustWaitTime = 0;
        }
        txtResult.text = "CodeTaiedResult:" + CodeTaiedResult.ToString() + " --- mustWaitTime:" + mustWaitTime;
    }

    private void Adok_OnCodeTaiedChange(ADokManager.CodeTaiedResult CodeTaiedResult)
    {
        txtResult.text = "CodeTaiedResult:" + CodeTaiedResult.ToString();
    }

   
}
