public void BubbleTiming() { if (bubbleSystem.IsAbleProduce) { lastBubbleTime++; if (IsCompleteTimer(lastBubbleTime, bubbleSystem.BubbleEndTime)) { BubbleSystem.SetActive(PoolObject, false); if (IsReward) { Reward(); pushGameObjectInPool(vehicles, PoolObject); } } if (IsCompleteTimer(lastBubbleTime, bubbleSystem.BubbleTables[(int)vehicles].bubbleUpTime)) { PoolObject = popGameObjectInPool(vehicles); PoolObject.transform.position = BubbleSystem.ConvertWorldToScreenPoint(transform.position); PoolObject.GetComponent <UnityEngine.UI.Button>().onClick.RemoveAllListeners(); PoolObject.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(() => { Reward(); pushGameObjectInPool(vehicles, PoolObject); }); BubbleSystem.SetActive(PoolObject, true); lastBubbleTime = 0; IsReward = true; SoundManager.Instance.PlayOneShot("BubbleUp"); } } }
IEnumerator EUpdate() { while (true) { PoolObject.transform.position = BubbleSystem.ConvertWorldToScreenPoint(transform.position); yield return(null); } }
IEnumerator EUpdate(GameObject poolObject, GameObject bubble) { while (poolObject.activeInHierarchy) { poolObject.transform.position = BubbleSystem.ConvertWorldToScreenPoint(bubble.transform.position); yield return(null); } }
IEnumerator EInit() { if (this.vehicles == Vehicles.STORAGE) { yield break; } yield return(new WaitForSeconds(bubbleSystem.BubbleTables[(int)vehicles].bubbleUpTime)); PoolObject = popGameObjectInPool(vehicles); PoolObject.transform.position = BubbleSystem.ConvertWorldToScreenPoint(transform.position); PoolObject.GetComponent <UnityEngine.UI.Button>().onClick.RemoveAllListeners(); PoolObject.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(() => { Reward(); pushGameObjectInPool(vehicles, PoolObject); }); StartCoroutine(EUpdate()); GameEvent.Instance.SubscribeBubbleEvent(() => { BubbleTiming(); }); }
private void Start() { bubbleSystem = BubbleSystem.Instance; StartCoroutine(EInit()); }