Advertisement
StoneHaos

Untitled

Aug 6th, 2021
1,043
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. using DG.Tweening;
  6.  
  7. public class DivideMultiplier : MonoBehaviour
  8. {
  9.     public int Value;
  10.  
  11.     public GameObject textAnim;
  12.     private TextMeshPro tmPro;
  13.  
  14.     public float animDuration;
  15.     Sequence textAnimMultiplier;
  16.  
  17.     public List<GameObject> ballList = new List<GameObject>();
  18.     public int Border = 0;
  19.  
  20.  
  21.     void Start()
  22.     {
  23.         tmPro = textAnim.GetComponent<TextMeshPro>();
  24.     }
  25.  
  26.     public void TextAnimMultiplier()
  27.     {
  28.         textAnimMultiplier.Kill();
  29.         textAnimMultiplier = DOTween.Sequence();
  30.         textAnimMultiplier.Append(textAnim.transform.DOScale(new Vector3(1.35f, 1.35f, 1f), animDuration / 2));
  31.         textAnimMultiplier.Append(textAnim.transform.DOScale(Vector3.one, animDuration / 2));
  32.     }
  33.  
  34.     private void OnTriggerEnter2D(Collider2D collision)
  35.     {
  36.        
  37.         ballList.Add(collision.gameObject);
  38.         Div(ref ballList);
  39.            
  40.  
  41.     }
  42.  
  43.     public void Div(ref List<GameObject> lst) {
  44.         if ((lst.Count - Border) == Value) {
  45.             Border++;
  46.             for (int i = Border; i < lst.Count; ++ i) {
  47.                 GameManager.instance.poolBalls.Despawn(lst[i]);
  48.             }
  49.             lst.RemoveRange(Border, lst.Count - Border);
  50.         }
  51.     }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement