YiHe_AllVersion/YHWeb/Assets/YHElectric/Scripts/UIPanel/IndexPanel.cs

174 lines
11 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using XFrame.Core.UI;
using XFrame.Core.Tool;
using UnityEngine.EventSystems;
using DG.Tweening;
using System;
namespace YHElectric
{
public class IndexPanel : XUIPanel
{
static Transform monitor;
static Transform function;
static Transform strategy;
private static float monitorTransX;
private static float functionTransY;
private static float strategyTransX;
public static Text tempTxt;
public static GameObject introduction;
public IndexPanel() : base(UIType.Fixed, UIMode.None, UICollider.None)
{
uiPath = "UI/UIPanelPrefab/IndexPanel";
}
public override void Awake(GameObject go)
{
tempTxt = transform.Find("Bg/temp").GetComponent<Text>();
introduction = transform.Find("Bg/introduction").gameObject;
monitor = transform.Find("Bg/monitor");
function = transform.Find("Bg/function");
strategy = transform.Find("Bg/strategy");
monitorTransX = monitor.GetChild(0).GetChild(0).GetComponent<RectTransform>().position.x;
strategyTransX = strategy.GetChild(0).GetChild(0).GetComponent<RectTransform>().position.x;
functionTransY = function.GetComponent<RectTransform>().position.y;
//transform.Find("Bg/fhyc").GetComponent<Button>().onClick.AddListener(()=> { WebCommunication.Hello("top_fhyc"); });
//transform.Find("Bg/gg").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("top_gg"); });
//transform.Find("Bg/yj").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("top_yj"); });
//transform.Find("Bg/monitor/bg/qj").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_qj"); });
//transform.Find("Bg/monitor/bg/pd").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_pd"); });
//transform.Find("Bg/monitor/bg/cn").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_cn"); });
//transform.Find("Bg/monitor/bg/gf").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_gf"); });
//transform.Find("Bg/monitor/bg/sc").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_sc"); });
//transform.Find("Bg/monitor/bg/kt").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_kt"); });
//transform.Find("Bg/monitor/bg/cd").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_cd"); });
//transform.Find("Bg/monitor/bg/zm").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_zm"); });
//transform.Find("Bg/strategy/bg/yn").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("strategy_yn"); });
//transform.Find("Bg/strategy/bg/kt").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("strategy_kt"); });
//transform.Find("Bg/strategy/bg/scx").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("strategy_scx"); });
//transform.Find("Bg/function/bg/ny").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("function_ny"); });
//transform.Find("Bg/function/bg/gf").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("function_gf"); });
//transform.Find("Bg/function/bg/cn").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("function_cn"); });
//transform.Find("Bg/function/bg/zn").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("function_zn"); });
//transform.Find("Bg/function/bg/xq").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("function_xq"); });
//transform.Find("Bg/function/bg/xh").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.Hello("function_xh"); });
transform.Find("Bg/fhyc").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("top_fhyc"); });
transform.Find("Bg/gg").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("top_gg"); });
transform.Find("Bg/yj").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("top_yj"); });
transform.Find("Bg/monitor/bg/sy").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("display"); });
transform.Find("Bg/monitor/bg/qj").GetComponent<Button>().onClick.AddListener(() => { /*CameraControl.instance.LocationModel("monitor_qj");*/Camera.main.GetComponent<Animator>().enabled = !Camera.main.GetComponent<Animator>().enabled; WebCommunication.CallWGL("monitor_qj"); });
transform.Find("Bg/monitor/bg/pd").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_pd"); });
transform.Find("Bg/monitor/bg/cn").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_cn"); });
transform.Find("Bg/monitor/bg/gf").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_gf"); });
transform.Find("Bg/monitor/bg/sc").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_sc"); });
transform.Find("Bg/monitor/bg/kt").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_kt"); });
transform.Find("Bg/monitor/bg/1#").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("1#"); });
transform.Find("Bg/monitor/bg/zm").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("monitor_zm"); });
transform.Find("Bg/strategy/bg/yn").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("strategy_yn"); });
transform.Find("Bg/strategy/bg/kt").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("strategy_kt"); });
transform.Find("Bg/strategy/bg/scx").GetComponent<Button>().onClick.AddListener(() => { CameraControl.instance.LocationModel("strategy_scx"); });
transform.Find("Bg/function/bg/ny").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("function_ny"); });
transform.Find("Bg/function/bg/gf").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("function_gf"); });
transform.Find("Bg/function/bg/cn").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("function_cn"); });
transform.Find("Bg/function/bg/zn").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("function_zn"); });
transform.Find("Bg/function/bg/xq").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("function_xq"); });
transform.Find("Bg/function/bg/xh").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("function_xh"); });
transform.Find("Bg/monitor/bg/board").GetComponent<Button>().onClick.AddListener(() => { WebCommunication.CallWGL("display"); });
//transform.Find("Bg/monitor/bg/uav").GetComponent<Button>().onClick.AddListener(() => { GameManager.instance.UAV(""); });
//transform.Find("Bg/monitor/bg/uav").GetComponent<Button>().onClick.AddListener(() => { Application.ExternalCall("OpenUAV"); });
}
public static void MonitorShow(bool isShow)
{
if (isShow)
{
Sequence mySequence = DOTween.Sequence();
for (int i = 0; i < monitor.GetChild(0).childCount; i++)
{
mySequence.Append(DoMoveTransX(monitor.GetChild(0).GetChild(i), 5, 0.1f));
}
}
else
{
Sequence mySequence = DOTween.Sequence();
for (int i = 0; i < monitor.GetChild(0).childCount; i++)
{
mySequence.Append(DoMoveTransX(monitor.GetChild(0).GetChild(i), (int)monitorTransX, 0.1f));
}
}
}
public static void FunctionShow(bool isShow)
{
if (isShow)
{
Sequence mySequence = DOTween.Sequence();
for (int i = 0; i < function.GetChild(0).childCount; i++)
{
mySequence.Append(DoMoveTransY(function.GetChild(0).GetChild(i), 131));
}
}
else
{
Sequence mySequence = DOTween.Sequence();
for (int i = 0; i < function.GetChild(0).childCount; i++)
{
mySequence.Append(DoMoveTransY(function.GetChild(0).GetChild(i), (int)functionTransY));
}
}
}
public static void StrategyShow(bool isShow)
{
if (isShow)
{
Sequence mySequence = DOTween.Sequence();
for (int i = 0; i < strategy.GetChild(0).childCount; i++)
{
mySequence.Append(DoMoveTransX(strategy.GetChild(0).GetChild(i), Screen.width - 5, 0.1f));
}
}
else
{
Sequence mySequence = DOTween.Sequence();
for (int i = 0; i < strategy.GetChild(0).childCount; i++)
{
mySequence.Append(DoMoveTransX(strategy.GetChild(0).GetChild(i), (int)strategyTransX, 0.1f));
}
}
}
static bool isShow;
public static void SideBarShow()
{
isShow = !isShow;
MonitorShow(isShow);
FunctionShow(isShow);
StrategyShow(isShow);
}
public static void SideBarHide()
{
isShow = false;
MonitorShow(isShow);
FunctionShow(isShow);
StrategyShow(isShow);
}
static Tween DoMoveTransX(Transform trans, int x, float speed)
{
return trans.DOMoveX(x, speed).SetEase(Ease.InOutQuad);
}
static Tween DoMoveTransY(Transform trans, int y)
{
return trans.DOMoveY(y, 0.1f).SetEase(Ease.InOutBack);
}
}
}