141 lines
4.0 KiB
C#
141 lines
4.0 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
public class ShowControllerXX : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
public static ShowControllerXX Instance;
|
|||
|
|
|
|||
|
|
List<BaseShow> lstShow;
|
|||
|
|
|
|||
|
|
// Start is called before the first frame update
|
|||
|
|
void Start()
|
|||
|
|
{
|
|||
|
|
Instance = this;
|
|||
|
|
|
|||
|
|
lstShow = new List<BaseShow>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void AddShow(BaseShow bs)
|
|||
|
|
{
|
|||
|
|
lstShow.Add(bs);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void RemoveShow(BaseShow bs)
|
|||
|
|
{
|
|||
|
|
lstShow.Remove(bs);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string GetImageShow(Data info, int index)
|
|||
|
|
{
|
|||
|
|
var result = lstShow.FirstOrDefault(show =>
|
|||
|
|
(show.info.ObjectID == info.ObjectID || show.info.ParentID == info.ParentID)
|
|||
|
|
&& show.info.Type == DataType.MultiImage
|
|||
|
|
&& show.info.Index == index
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
if (result == null)
|
|||
|
|
{
|
|||
|
|
int count = lstShow.Count(show => show.info.ParentID == info.ObjectID);
|
|||
|
|
if (result == null)
|
|||
|
|
{
|
|||
|
|
return info.Title;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ImageShow isResult = (result as ImageShow);
|
|||
|
|
if (isResult == null)
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return isResult.info.Title;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
float distance;
|
|||
|
|
bool canClickNewStatus;
|
|||
|
|
ShowBoxCollider tmpSBC;
|
|||
|
|
|
|||
|
|
// Update is called once per frame
|
|||
|
|
void FixedUpdate()
|
|||
|
|
{
|
|||
|
|
//if (
|
|||
|
|
// BaseController.IsJoyStickOnControl
|
|||
|
|
// || BaseController.IsKeyOnControl
|
|||
|
|
// || BaseController.IsMouseOnControl
|
|||
|
|
// || BaseController.IsNavOnControl
|
|||
|
|
// )
|
|||
|
|
if(BaseController.CanControl &&
|
|||
|
|
!BaseController.IsKeyOnControl &&
|
|||
|
|
!BaseController.IsNavOnControl &&
|
|||
|
|
!BaseController.IsJoyStickOnControl)
|
|||
|
|
{
|
|||
|
|
foreach (BaseShow show in lstShow)
|
|||
|
|
{
|
|||
|
|
if(show.transform.childCount > 0)
|
|||
|
|
{
|
|||
|
|
distance = show.GetComponentsInChildren<Transform>().Min(tran => Vector3.Distance(CommonData.MainCamera.transform.position, tran.position));
|
|||
|
|
// Debug.Log(show.name);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õľ<C3B5><C4BE><EFBFBD>
|
|||
|
|
if (distance == 0)
|
|||
|
|
distance = Vector3.Distance(CommonData.MainCamera.transform.position, show.transform.position);
|
|||
|
|
else
|
|||
|
|
distance = Mathf.Min(
|
|||
|
|
distance,
|
|||
|
|
Vector3.Distance(CommonData.MainCamera.transform.position, show.transform.position)
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
canClickNewStatus = (distance <= CommonData.ClickDistance);
|
|||
|
|
|
|||
|
|
// <20>ɵ<EFBFBD><C9B5><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ı䣨<C4B1><E4A3A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>룩
|
|||
|
|
if (show.CanClick != canClickNewStatus)
|
|||
|
|
{
|
|||
|
|
show.CanClick = canClickNewStatus;
|
|||
|
|
|
|||
|
|
if (show.info.Clickable)
|
|||
|
|
{
|
|||
|
|
if (show.CanClick)
|
|||
|
|
{
|
|||
|
|
tmpSBC = show.gameObject.AddComponent<ShowBoxCollider>();
|
|||
|
|
tmpSBC.showHotTip = show.info.ShowHotTip;
|
|||
|
|
tmpSBC.showBox = show.info.ShowBox;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Destroy(show.gameObject.GetComponent<ShowBoxCollider>());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
show.OnStatusChange();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (show.sbc != null)
|
|||
|
|
{
|
|||
|
|
if (show.CanClick)
|
|||
|
|
{
|
|||
|
|
show.sbc.enabled = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
show.sbc.enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
distance = 0f;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|