| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using DG.Tweening;
- /* 击中靶子时显示的分数 */
- public class HitTargetNumberNew : MonoBehaviour
- {
- void Start()
- {
- DoText();
- }
- void DoText()
- {
- RectTransform rtf = this.transform.GetComponentInChildren<Text>().rectTransform;
- Sequence seq = DOTween.Sequence();
- float scale1 = rtf.localScale.x * 3.3f;
- float scale2 = rtf.localScale.x;
- rtf.localScale = Vector3.zero;
- seq.Append(rtf.DOScale(new Vector3(scale1, scale1, 0), 0.1f));
- seq.Append(rtf.DOScale(new Vector3(scale2, scale2, 0), 0.1f));
- seq.AppendInterval(1f);
- seq.Append(rtf.GetComponent<Text>().DOFade(0, 0.23f));
- seq.AppendCallback(delegate () {
- Destroy(gameObject);
- });
- }
- public static void Create(float number, int pid)
- {
- if (number <= 0) return;
- string oName = "HitTargetNumber" + pid;
- var exist = GameObject.Find(oName);
- if (exist && exist.gameObject) {
- //Destroy(exist);
- exist.SetActive(false);
- }
- GameObject o = Instantiate(
- Resources.Load<GameObject>("Effects/" + oName),
- Vector3.zero,
- Quaternion.identity,
- GameObject.Find("GameCanvas").transform
- );
- o.name = oName;
- o.transform.localPosition = new Vector3(-320, 80, 0);
- if (pid == 1) o.transform.localPosition = new Vector3(320, 80, 0);
- o.GetComponentInChildren<Text>().text = number.ToString($"f{CommonConfig.ringsPrecision}");
- }
- }
|