123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- using UnityEngine;
- using System.Collections;
- using System;
- public class NotificationCodeEnterNoConnect : MonoBehaviour {
- ScreenBase screen;
- UILabel label;
- void Awake()
- {
- screen = GetComponent<ScreenBase>();
- screen.Hide();
- NotificationCenter.AddListener(OnShowInternetWrong, NotificationType.ShowInternetWrong);
-
- }
- public void EnterDoneCaptcha()
- {
- transform.position = new Vector3(transform.position.x,0,transform.position.z);
- }
- public void EnterCaptcha()
- {
- transform.position = new Vector3(transform.position.x, 77, transform.position.z);
- }
- void OnDestroy()
- {
- NotificationCenter.RemoveListener(OnShowInternetWrong, NotificationType.ShowInternetWrong);
- }
- public void OnShowInternetWrong(Notification note)
- {
- screen.Show();
- }
- public UIInput Captcha;
- public UIInput CodeEnter;
- void OnEnable()
- {
- CodeEnter.text = "Fyll i kod...";
- Captcha.text = "";
- StartCoroutine(AlphaActive());
- }
- public UIButton Ok;
- public UIButton Close;
- private PlayerFrontColliderScriptCS hPlayerFrontColliderScriptCS;
- private PlayerSidesColliderScriptCS hPlayerSidesColliderScriptCS;
- private bool DoneCaptcha;
- private bool DoneCode;
- public CapchaCheck Check;
- void Start()
- {
- Ok.onClick.Add(new EventDelegate(ClickOk));
- hPlayerSidesColliderScriptCS = (PlayerSidesColliderScriptCS)GameObject.Find("PlayerSidesCollider").GetComponent(typeof(PlayerSidesColliderScriptCS));
- hPlayerFrontColliderScriptCS = (PlayerFrontColliderScriptCS)GameObject.Find("PlayerFrontCollider").GetComponent(typeof(PlayerFrontColliderScriptCS));
- StartCoroutine(AlphaActive());
- }
- private IEnumerator AlphaActive()
- {
- yield return new WaitForSeconds(0.5f);
- GetComponent<UIPanel>().alpha = 1;
- Check.GetComponent<UIPanel>().alpha = 1;
- }
- private void ClickOk()
- {
- if (!ConnectivityPollManager.HasInternet)
- {
- screen.Hide();
- LoginManager.Instance.WrongConnectMessages.Show();
- return;
- }
- if (Check.Check(Captcha.value))
- {
- Debug.LogWarning("capcha ok");
- }
- else
- {
- Debug.LogWarning("capcha fail");
- }
- if (CodeColaCaptchaManager.Instance.CheckingCode(CodeEnter.text.ToUpper()) && CodeColaCaptchaManager.Instance.CheckingCaptcha(Captcha.text) && Check.Check(Captcha.value))
- {
- if (ConnectivityPollManager.HasInternet) //register code
- {
- RegisterCodeMIX.Instance.Activate(CodeEnter.text, (state, s) =>
- {
- switch (state)
- {
- case RegisterCodeMIX.ActivateStates.OtherError:
- // screen.Hide();
- // NotificationCenter.Post(NotificationType.ShowEnterWrong);
- CodeEnter.text = "Fyll i kod...";
- Captcha.text = "";
- //todo: handle error
- break;
- case RegisterCodeMIX.ActivateStates.RequestOrNetworkError:
- NotificationCenter.Post(NotificationType.ShowInternetWrong);
- screen.Hide();
- //todo: handle error
- break;
- case RegisterCodeMIX.ActivateStates.CouponAlreadyReedemed:
- CodeEnter.text = "Fyll i kod...";
- Captcha.text = "";
- //todo: handle error
- break;
- case RegisterCodeMIX.ActivateStates.BadInput:
- CodeEnter.text = "Fyll i kod...";
- Captcha.text = "";
- // screen.Hide();
- // NotificationCenter.Post(NotificationType.ShowEnterWrong);
- //todo: handle error
- break;
- case RegisterCodeMIX.ActivateStates.Done:
- Debug.Log(RegisterCodeMIX.ActivateStates.Done);
- OnDone();
- //todo: EVERYTHING GOES WELL
- break;
- }
- });
- }
- else
- {
- screen.Hide();
- }
- }
- }
- void OnDone()
- {
- LifeManager.BottleCap();
- UIEnergy.Instance.Restore();
- PlayerController.Instance.Alive();
- InGameScriptCS.Instance.InvokeResurrection();
- InGameScriptCS.Instance.EnergyAdd(100);
- hPlayerSidesColliderScriptCS.InvokeResurrection();
- hPlayerFrontColliderScriptCS.InvokeResurrection();
- ControllerScriptCS.Instance.bControlsEnabled = true;
- InGameScriptCS.Instance.Resurected = false;
- screen.Hide();
- }
- }
|