2021-12-28 11:25:09 +08:00
|
|
|
|
using Assets.Scripts;
|
|
|
|
|
|
using Assets.Scripts.UI.Control;
|
2021-12-27 09:39:07 +08:00
|
|
|
|
using DG.Tweening;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using UnityEngine;
|
2021-12-28 18:25:48 +08:00
|
|
|
|
using UnityEngine.Events;
|
2021-12-27 09:39:07 +08:00
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public class NewMainNav : MonoBehaviour
|
|
|
|
|
|
{
|
2021-12-28 18:25:48 +08:00
|
|
|
|
public class CustomButton
|
|
|
|
|
|
{
|
|
|
|
|
|
public Sprite image;
|
|
|
|
|
|
public UnityAction action;
|
2022-03-10 18:10:34 +08:00
|
|
|
|
public bool isAlways;
|
2021-12-28 18:25:48 +08:00
|
|
|
|
public CustomButton(Sprite image, UnityAction action)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.image = image;
|
|
|
|
|
|
this.action = action;
|
2022-03-10 18:10:34 +08:00
|
|
|
|
isAlways = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CustomButton(Sprite image, UnityAction action,bool isAlways)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.image = image;
|
|
|
|
|
|
this.action = action;
|
|
|
|
|
|
isAlways = false;
|
2021-12-28 18:25:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
private GameObject exit;
|
|
|
|
|
|
private GameObject home;
|
|
|
|
|
|
private GameObject back;
|
|
|
|
|
|
float delayTime = 0;
|
|
|
|
|
|
private List<string> typeArray = new List<string>()
|
|
|
|
|
|
{
|
2022-03-10 18:10:34 +08:00
|
|
|
|
"Back","Exit","Home","Device","Delay","Setting","Support","Avatar","Custom","Custom2","Mail","Custom3"
|
2021-12-27 09:39:07 +08:00
|
|
|
|
};
|
|
|
|
|
|
private List<int> indexs = new List<int>();
|
2021-12-28 11:25:09 +08:00
|
|
|
|
private int? shrinkIndex = null;
|
2022-03-10 18:10:34 +08:00
|
|
|
|
private CustomButton custom = null,custom2 = null, custom3 = null;
|
2021-12-27 09:39:07 +08:00
|
|
|
|
/// <summary>
|
2021-12-28 11:25:09 +08:00
|
|
|
|
///
|
2021-12-27 09:39:07 +08:00
|
|
|
|
/// </summary>
|
2021-12-28 18:25:48 +08:00
|
|
|
|
/// <param name="indexs">仅展开显示的按钮:1:"Exit",3:"Device",4:"Delay",5:"Setting",6:"Support",7:"Avatar"</param>
|
|
|
|
|
|
/// <param name="shrinkIndex">合上后仍显示的按钮:0:"Back",2:"Home",null:仅PF</param>
|
2022-03-10 18:10:34 +08:00
|
|
|
|
/// <param name="custom">自定义按钮 8:c1 9:c2 11:c3</param>
|
2022-03-28 17:42:23 +08:00
|
|
|
|
public void SetButtonActive(List<int> indexs,int? shrinkIndex = null, CustomButton custom = null, CustomButton custom2 = null,CustomButton custom3 = null,bool ShowMail = true)
|
2021-12-27 09:39:07 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.indexs = indexs;
|
2022-03-28 17:42:23 +08:00
|
|
|
|
|
|
|
|
|
|
if (ShowMail)
|
|
|
|
|
|
{
|
|
|
|
|
|
//邮箱常驻(除划船机)
|
|
|
|
|
|
this.indexs.Add(10);
|
|
|
|
|
|
}
|
2021-12-28 11:25:09 +08:00
|
|
|
|
this.shrinkIndex = shrinkIndex;
|
2021-12-28 18:25:48 +08:00
|
|
|
|
this.custom = custom;
|
2021-12-29 14:23:37 +08:00
|
|
|
|
this.custom2 = custom2;
|
2022-03-10 18:10:34 +08:00
|
|
|
|
this.custom3 = custom3;
|
2021-12-28 18:25:48 +08:00
|
|
|
|
if (custom != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("Custom").GetComponent<Button>().onClick.RemoveAllListeners();
|
|
|
|
|
|
transform.Find("Custom").GetComponent<Button>().onClick.AddListener(custom.action);
|
|
|
|
|
|
transform.Find("Custom").GetComponent<Image>().sprite = custom.image;
|
2021-12-29 14:23:37 +08:00
|
|
|
|
indexs.Add(8);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (custom2 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("Custom2").GetComponent<Button>().onClick.RemoveAllListeners();
|
|
|
|
|
|
transform.Find("Custom2").GetComponent<Button>().onClick.AddListener(custom2.action);
|
|
|
|
|
|
transform.Find("Custom2").GetComponent<Image>().sprite = custom2.image;
|
|
|
|
|
|
indexs.Add(9);
|
2021-12-28 18:25:48 +08:00
|
|
|
|
}
|
2022-03-10 18:10:34 +08:00
|
|
|
|
if (custom3 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("Custom3").GetComponent<Button>().onClick.RemoveAllListeners();
|
|
|
|
|
|
transform.Find("Custom3").GetComponent<Button>().onClick.AddListener(custom3.action);
|
|
|
|
|
|
transform.Find("Custom3").GetComponent<Image>().sprite = custom3.image;
|
|
|
|
|
|
indexs.Add(11);
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
SetExpand(false);
|
|
|
|
|
|
}
|
2021-12-29 14:23:37 +08:00
|
|
|
|
|
2022-02-10 12:57:43 +08:00
|
|
|
|
|
2021-12-27 09:39:07 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// true:展开 false:关闭
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="flag"></param>
|
2021-12-29 14:23:37 +08:00
|
|
|
|
public void SetExpand(bool flag)
|
2021-12-27 09:39:07 +08:00
|
|
|
|
{
|
|
|
|
|
|
List<string> types = new List<string>();
|
|
|
|
|
|
if (indexs != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
types = typeArray.Where((x, i) => indexs.Contains(i)).ToList();
|
|
|
|
|
|
}
|
2021-12-28 11:25:09 +08:00
|
|
|
|
string shrinkName = null;
|
2022-02-10 12:57:43 +08:00
|
|
|
|
if (shrinkIndex.HasValue && isShrinkIndex(shrinkIndex.Value))
|
2021-12-28 11:25:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
shrinkName = typeArray[shrinkIndex.Value];
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
foreach (Transform item in transform)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.name == "Down")
|
|
|
|
|
|
{
|
|
|
|
|
|
item.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (item.name == "PF")
|
|
|
|
|
|
{
|
|
|
|
|
|
item.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
item.gameObject.SetActive(types.Contains(item.name));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-03-10 18:10:34 +08:00
|
|
|
|
else
|
2021-12-27 09:39:07 +08:00
|
|
|
|
{
|
2022-03-10 18:10:34 +08:00
|
|
|
|
item.gameObject.SetActive(item.name == "PF" || item.name == shrinkName);
|
2021-12-27 09:39:07 +08:00
|
|
|
|
}
|
2022-03-10 18:10:34 +08:00
|
|
|
|
if (item.name == "Custom" || item.name == "Custom2" || item.name == "Custom3")
|
2022-01-05 17:40:12 +08:00
|
|
|
|
{
|
2022-03-10 18:10:34 +08:00
|
|
|
|
//自定义按钮出来
|
|
|
|
|
|
CustomButton c = null;
|
|
|
|
|
|
if (item.name == "Custom")
|
|
|
|
|
|
{
|
|
|
|
|
|
c = custom;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (item.name == "Custom2")
|
|
|
|
|
|
{
|
|
|
|
|
|
c = custom2;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (item.name == "Custom3")
|
|
|
|
|
|
{
|
|
|
|
|
|
c = custom3;
|
|
|
|
|
|
}
|
|
|
|
|
|
item.gameObject.SetActive(c != null && types.Contains(item.name) && (flag || !flag && c.isAlways));
|
2022-01-05 17:40:12 +08:00
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-12-29 14:23:37 +08:00
|
|
|
|
|
|
|
|
|
|
public void ShowButton(string v)
|
|
|
|
|
|
{
|
|
|
|
|
|
var i = typeArray.FindIndex((x)=>x == v);
|
2022-02-10 12:57:43 +08:00
|
|
|
|
if (i == -1 || isShrinkIndex(i))
|
2021-12-29 14:23:37 +08:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
indexs.Add(i);
|
|
|
|
|
|
SetExpand(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void HideButton(string v)
|
|
|
|
|
|
{
|
|
|
|
|
|
var i = typeArray.FindIndex((x) => x == v);
|
2022-02-10 12:57:43 +08:00
|
|
|
|
if (i == -1 || isShrinkIndex(i))
|
2021-12-29 14:23:37 +08:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Debug.Log(i);
|
|
|
|
|
|
indexs.RemoveAll(x => x == i);
|
|
|
|
|
|
SetExpand(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-27 09:39:07 +08:00
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
2021-12-28 11:25:09 +08:00
|
|
|
|
Utils.DisplayHead(transform.Find("Avatar").GetComponent<Image>(), App.CurrentUser.WxHeadImg);
|
|
|
|
|
|
UIManager.AddEvent(transform.Find("Avatar").gameObject, EventTriggerType.PointerClick, b =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowUserInfoPanel();
|
|
|
|
|
|
});
|
2021-12-27 09:39:07 +08:00
|
|
|
|
UIManager.AddEvent(transform.Find("PF").gameObject, EventTriggerType.PointerClick, b =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SetExpand(true);
|
|
|
|
|
|
});
|
|
|
|
|
|
UIManager.AddEvent(transform.Find("Down").gameObject, EventTriggerType.PointerClick, b =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SetExpand(false);
|
|
|
|
|
|
});
|
|
|
|
|
|
//var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
|
|
|
|
|
|
|
|
|
|
|
//var rect = ((RectTransform)this.transform).rect;
|
|
|
|
|
|
//material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
|
|
|
|
|
//this.GetComponent<Image>().material = material;
|
|
|
|
|
|
|
|
|
|
|
|
var device = this.transform.Find("Device");
|
|
|
|
|
|
UIManager.AddEvent(device.gameObject, EventTriggerType.PointerClick, x =>
|
|
|
|
|
|
{
|
|
|
|
|
|
//Debug.Log("click device");
|
2022-03-10 18:10:34 +08:00
|
|
|
|
if (App.IsRowerMode.HasValue && App.IsRowerMode.Value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (UIManager.Instance.RowerHomeScript.checkRowing()) return;
|
|
|
|
|
|
UIManager.ShowRowerDevicePanel();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowDevicePanel();
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
home = this.transform.Find("Home").gameObject;
|
|
|
|
|
|
UIManager.AddEvent(home, EventTriggerType.PointerClick, x =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowHomePanel();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
exit = this.transform.Find("Exit").gameObject;
|
|
|
|
|
|
exit.SetActive(false);
|
|
|
|
|
|
back = transform.Find("Back").gameObject;
|
|
|
|
|
|
back.SetActive(false);
|
|
|
|
|
|
#if UNITY_ANDROID || UNITY_IOS
|
|
|
|
|
|
UIManager.AddEvent(transform.Find("Delay").gameObject, EventTriggerType.PointerClick, b =>
|
|
|
|
|
|
{
|
2021-12-30 16:51:04 +08:00
|
|
|
|
if (delayTime <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
delayTime = 3;
|
|
|
|
|
|
transform.Find("Delay/Tooltips").gameObject.SetActive(true);
|
|
|
|
|
|
transform.Find("Delay/Tooltips").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
delayTime = 0;
|
|
|
|
|
|
transform.Find("Delay/Tooltips").GetComponent<CanvasGroup>().DOFade(0, 0.5f).onComplete = () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("Delay/Tooltips").gameObject.SetActive(false);
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
});
|
|
|
|
|
|
#endif
|
|
|
|
|
|
//transform.Find("Delay").GetComponent<PfUIButton>().showTooltip = true;
|
|
|
|
|
|
UIManager.AddEvent(exit, EventTriggerType.PointerClick, (e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", ()=> {
|
|
|
|
|
|
Application.Quit();
|
|
|
|
|
|
},2);
|
|
|
|
|
|
});
|
|
|
|
|
|
UIManager.AddEvent(back, EventTriggerType.PointerClick, (e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowPrePanel();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
UIManager.AddEvent(transform.Find("Setting").gameObject, EventTriggerType.PointerClick, x =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowSettingModal();
|
|
|
|
|
|
});
|
|
|
|
|
|
UIManager.AddEvent(transform.Find("Support").gameObject, EventTriggerType.PointerClick, x =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowFeedBackModal();
|
|
|
|
|
|
});
|
2022-03-03 14:38:51 +08:00
|
|
|
|
UIManager.AddEvent(transform.Find("Mail").gameObject, EventTriggerType.PointerClick, x =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowMailListPanel();
|
|
|
|
|
|
});
|
|
|
|
|
|
App.HasNotReadChanged -= ShowMailDot;
|
|
|
|
|
|
App.HasNotReadChanged += ShowMailDot;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void ShowMailDot(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (transform)
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("Mail/Dot").gameObject.SetActive((bool)sender);
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-03 14:38:51 +08:00
|
|
|
|
|
2021-12-27 09:39:07 +08:00
|
|
|
|
public void ShowRowerTab()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (transform.Find("Device"))
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("Device").gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (transform.Find("Exit"))
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("Exit").gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (transform.Find("Home"))
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("Home").gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-02-10 12:57:43 +08:00
|
|
|
|
private bool isShrinkIndex(int ind)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ind == 0 || ind == 2;
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-12-29 17:05:58 +08:00
|
|
|
|
bool isTouch = false;
|
|
|
|
|
|
float hideTime = 5;
|
2021-12-27 09:39:07 +08:00
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
2021-12-29 17:05:58 +08:00
|
|
|
|
if (Input.touchCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
isTouch = true;
|
|
|
|
|
|
GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
|
|
|
|
|
}
|
|
|
|
|
|
hideTime -= Time.deltaTime;
|
|
|
|
|
|
if (hideTime < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!isTouch)
|
|
|
|
|
|
{
|
|
|
|
|
|
GetComponent<CanvasGroup>().DOFade(0.4f, 0.5f);
|
|
|
|
|
|
}
|
|
|
|
|
|
isTouch = false;
|
|
|
|
|
|
hideTime += 5;
|
|
|
|
|
|
}
|
2021-12-30 16:51:04 +08:00
|
|
|
|
//Debug.Log(Input.touchCount);
|
2021-12-27 09:39:07 +08:00
|
|
|
|
if (delayTime < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("小时");
|
|
|
|
|
|
delayTime = 0;
|
|
|
|
|
|
transform.Find("Delay/Tooltips").GetComponent<CanvasGroup>().DOFade(0, 0.5f).onComplete = ()=>
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("Delay/Tooltips").gameObject.SetActive(false);
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(delayTime > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log(delayTime);
|
|
|
|
|
|
delayTime -= Time.deltaTime;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|