| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using DG.Tweening;
- using UnityEngine.SceneManagement;
- public class GameAssistUI : MonoBehaviour
- {
- [SerializeField] Material outlight;
- [SerializeField] Text text1;
- [SerializeField] Text text2;
- public static GameAssistUI ins;
- void Start()
- {
- ins = this;
- this.transform.Find("Button0").GetComponent<Button>().onClick.AddListener(delegate(){
- AudioMgr.ins.PlayBtn();
- // SceneManager.LoadScene("Home", LoadSceneMode.Single);
- Application.Quit();
- });
- this.transform.Find("Button1").GetComponent<Button>().onClick.AddListener(delegate(){
- AudioMgr.ins.PlayBtn();
- GameRuleView.Create();
- });
- Button btnScaleAim = this.transform.Find("Button2").GetComponent<Button>();
- btnScaleAim.onClick.AddListener(delegate(){
- AudioMgr.ins.PlayBtn();
- if (btnScaleAim.GetComponentInChildren<Image>().material == outlight) {
- btnScaleAim.GetComponentInChildren<Image>().material = null;
- closeScaleAim();
- } else {
- if (openScaleAim()) {
- btnScaleAim.GetComponentInChildren<Image>().material = outlight;
- }
- }
- });
- Button btnScaleShoot = this.transform.Find("Button3").GetComponent<Button>();
- btnScaleShoot.onClick.AddListener(delegate(){
- AudioMgr.ins.PlayBtn();
- if (btnScaleShoot.GetComponentInChildren<Image>().material == outlight) {
- btnScaleShoot.GetComponentInChildren<Image>().material = null;
- closeScaleShoot();
- } else {
- if (openScaleShoot()) {
- btnScaleShoot.GetComponentInChildren<Image>().material = outlight;
- }
- }
- });
- Button btnIdentity = this.transform.Find("Button4").GetComponent<Button>();
- btnIdentity.onClick.AddListener(delegate(){
- AudioMgr.ins.PlayBtn();
- AimHandler.ins.DoIdentity();
- });
- // ------ 查看靶子 ------
- Transform targetView = this.transform.Find("TargetView");
- Button btnViewTarget = this.transform.Find("Button10").GetComponent<Button>();
- btnViewTarget.onClick.AddListener(delegate(){
- AudioMgr.ins.PlayBtn();
- Transform icon1 = btnViewTarget.transform.Find("Icon1");
- Transform icon2 = btnViewTarget.transform.Find("Icon2");
- bool isOpen = icon2.gameObject.activeSelf;
- if (isOpen) {
- icon1.gameObject.SetActive(true);
- icon2.gameObject.SetActive(false);
- targetView.gameObject.SetActive(false);
- btnViewTarget.GetComponentInChildren<TextAutoLanguage>().SetText(204);
- } else {
- icon1.gameObject.SetActive(false);
- icon2.gameObject.SetActive(true);
- targetView.gameObject.SetActive(true);
- btnViewTarget.GetComponentInChildren<TextAutoLanguage>().SetText(205);
- }
- });
- targetView.gameObject.SetActive(false);
- if (GameMgr.gameType == 2) {
- targetView.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(45, 30);
- btnViewTarget.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(45, 195);
- }
- }
- // ------ 开镜瞄准功能 ------
- Transform scope = null;
- float[] scaleAimFieldOfViews = {30, 20, 12, 6, 3};
- float[] scaleAimArmBowZs = {-0.813f, -0.799f, -0.77f, -0.695f, -0.55f};
- float[] scaleAimScopeScales = {150, 98, 58, 29, 14.5f};
- Sequence seq1 = null;
- bool openScaleAim()
- {
- int scaleValue = GetPropScaleAimValue();
- if (scaleValue > 0)
- {
- BowCamera bowCamera = GameObject.FindObjectOfType<BowCamera>();
- bowCamera.banCameraFieldOfView = true;
- CrossHair.ins.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(500, 500);
- bowCamera.SetCameraFieldOfView(scaleAimFieldOfViews[scaleValue - 1]);
- Vector3 localPosition = ArmBow.ins.transform.localPosition;
- localPosition.z = -2;
- ArmBow.ins.transform.localPosition = localPosition;
- scope = bowCamera.transform.Find("Scope");
- float scopeScale = scaleAimScopeScales[scaleValue - 1];
- scope.localScale = new Vector3(scopeScale, scopeScale, scopeScale);
- return true;
- }
- if (seq1 != null && !seq1.IsComplete()) {
- seq1.Complete();
- }
- seq1 = DOTween.Sequence();
- seq1.Append(text1.DOFade(1, 0.5f));
- seq1.AppendInterval(2);
- seq1.Append(text1.DOFade(0, 0.5f));
- return false;
- }
- void closeScaleAim()
- {
- BowCamera bowCamera = GameObject.FindObjectOfType<BowCamera>();
- bowCamera.banCameraFieldOfView = false;
- CrossHair.ins.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(260, 260);
- Vector3 localPosition = ArmBow.ins.transform.localPosition;
- localPosition.z = -0.1f;
- ArmBow.ins.transform.localPosition = localPosition;
- scope.localScale = new Vector3(0, 0, 0);
- scope = null;
- }
- int GetPropScaleAimValue()
- {
- List<PropInfo> props = PropMgr.ins.ListForEquipped();
- foreach (var prop in props)
- {
- if (prop.config.type == 1) {
- PropScaleAim config = prop.config as PropScaleAim;
- return config.scaleValue;
- }
- }
- return 0;
- }
- // ------ 发射加速功能 ------
- public int shootScaleValue = 0;
- Sequence seq2 = null;
- bool openScaleShoot()
- {
- List<PropInfo> props = PropMgr.ins.ListForEquipped();
- foreach (var prop in props)
- {
- if (prop.config.type == 2) {
- PropScaleShoot config = prop.config as PropScaleShoot;
- shootScaleValue = config.scaleValue;
- return true;
- }
- }
- if (seq2 != null && !seq2.IsComplete()) {
- seq2.Complete();
- }
- seq2 = DOTween.Sequence();
- seq2.Append(text2.DOFade(1, 0.5f));
- seq2.AppendInterval(2);
- seq2.Append(text2.DOFade(0, 0.5f));
- return false;
- }
- void closeScaleShoot()
- {
- shootScaleValue = 0;
- }
- }
|