| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- /* 限时模式的靶子距离选择界面 */
- public class TimeLimitGameDistanceSelectView : MonoBehaviour
- {
- public static TimeLimitGameDistanceSelectView ins;
- public Action action_OnClickSelectDistance;
- void Awake()
- {
- SimulateMouseController.ins?.AddOpenLocker(this);
- }
- void Start()
- {
- ins = this;
- GameMgr.ins.addLockerForGamePause(this);
- Transform layout = this.transform.Find("Layout");
- GameObject itemPrefab = layout.Find("Item").gameObject;
- for (int i = 1; i < TimeLimitGameMode.distanceCanSelected.Length; i++) {
- Instantiate(
- itemPrefab, Vector3.zero, Quaternion.identity, this.transform.Find("Layout")
- );
- }
- for (int i = 0; i < TimeLimitGameMode.distanceCanSelected.Length; i++) {
- int distance = TimeLimitGameMode.distanceCanSelected[i];
- Transform item = layout.GetChild(i);
- var tal = item.transform.Find("Text").GetComponent<TextAutoLanguage2>();
- tal.textFormatArgs = new object[]{distance};
- tal.ApplyToText();
- Button btn = item.gameObject.GetComponent<Button>();
- GetComponentInParent<KeyBoardNavigation>()?.buttons.Add(btn);
- btn.onClick.AddListener(delegate() {
- AudioMgr.ins.PlayBtn();
- TimeLimitGameMode.distance = distance;
- ((TimeLimitGameMode) GameMgr.ins.gameMode).ConfirmSelectedTargetDistance();
- Destroy(this.gameObject);
- action_OnClickSelectDistance?.Invoke();
- //增加b端入场音效
- AudioMgr.ins.PlayLetgo();
- });
- }
- }
- void OnDestroy()
- {
- if (ins == this) ins = null;
- if (GameMgr.ins) GameMgr.ins.removeLockerForGamePause(this);
- SimulateMouseController.ins?.RemoveOpenLocker(this);
- }
- public void OnClick_Back()
- {
- GameAssistUI.ins.onBtnBack();
- }
- }
|