76 lines
2.3 KiB
C#
76 lines
2.3 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using Game;
|
|
using GameCore;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class FishingPanelDrawAuto : MonoBehaviour
|
|
{
|
|
private Animator _btnAnimator;
|
|
private Animator _sliderAnimator;
|
|
Button _button_draw_auto;
|
|
Tables _tables;
|
|
private void Awake()
|
|
{
|
|
_btnAnimator = GetComponent<Animator>();
|
|
_button_draw_auto = GetComponent<Button>();
|
|
_sliderAnimator = transform.Find("slider").GetComponent<Animator>();
|
|
}
|
|
private void Start()
|
|
{
|
|
_btnAnimator.Play("Normal", -1, 0);
|
|
//_btnAnimator.Play("slider_rotate_2", -1, 0);
|
|
_button_draw_auto.onClick.AddListener(() =>
|
|
{
|
|
_button_draw_auto.enabled = false;
|
|
_btnAnimator.SetTrigger("AutoExit");
|
|
StopAllCoroutines();
|
|
//GContext.container.Resolve<PlayerFishData>().AutomaticFishing = false;
|
|
GContext.container.Resolve<FishingData>().StopAuto();
|
|
});
|
|
}
|
|
public void StartAuto()
|
|
{
|
|
_tables = GContext.container.Resolve<Tables>();
|
|
StartCoroutine(AutoPlay());
|
|
}
|
|
IEnumerator AutoPlay()
|
|
{
|
|
//if (GContext.container.Resolve<PlayerFishData>().AutomaticFishing)
|
|
//{
|
|
// _btnAnimator.Play("Pressed");//, -1, 0);
|
|
//}
|
|
//else
|
|
//{
|
|
// _btnAnimator.Play("pressed2");
|
|
//}
|
|
_sliderAnimator.SetTrigger("Pressed1");
|
|
yield return Awaiters.Seconds(GContext.container.Resolve<FishingData>().HoldThreshold());
|
|
int coung = Random.Range(5, 15);
|
|
while (coung > 0 && enabled)
|
|
{
|
|
coung--;
|
|
yield return Awaiters.Seconds(_tables.TbGlobalConfig.HoldVibrationInterval);
|
|
GContext.Publish(new VibrationData(HapticTypes.LightImpact));
|
|
}
|
|
//if (GContext.container.Resolve<PlayerFishData>().AutomaticFishing)
|
|
//{
|
|
// _btnAnimator.Play("Normal");
|
|
//}
|
|
//else
|
|
//{
|
|
// _btnAnimator.Play("Normal2");
|
|
//}
|
|
_sliderAnimator.SetTrigger("Normal1");
|
|
StartCoroutine(DelayAutoPlay());
|
|
}
|
|
IEnumerator DelayAutoPlay()
|
|
{
|
|
float timer = Random.Range(0.5f, 2f);
|
|
yield return Awaiters.Seconds(timer);
|
|
StartCoroutine(AutoPlay());
|
|
}
|
|
}
|