备份CatanBuilding瘦身独立工程
This commit is contained in:
61
Assets/Scripts/SupplyDrop/Lucky3choose1Panel.cs
Normal file
61
Assets/Scripts/SupplyDrop/Lucky3choose1Panel.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
|
||||
public class Lucky3choose1Panel : MonoBehaviour
|
||||
{
|
||||
SupplyDropGameplayLureCtrl supplyDropGameCtrl;
|
||||
CanvasGroup canvasGroup;
|
||||
GameObject text_info;
|
||||
|
||||
int layerMask;
|
||||
Camera ui3d;
|
||||
bool notClick = true;
|
||||
private void Awake()
|
||||
{
|
||||
layerMask = 1 << LayerMask.NameToLayer("UI3D");
|
||||
ui3d = UIManager.Instance.UI3DCamera;
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
text_info = transform.Find("root/text_info").gameObject;
|
||||
canvasGroup.alpha = 0f; // Start with the panel invisible
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
ShowPanel();
|
||||
}
|
||||
public void Init(SupplyDropGameplayLureCtrl supplyDropGameCtrl)
|
||||
{
|
||||
this.supplyDropGameCtrl = supplyDropGameCtrl;
|
||||
}
|
||||
|
||||
void ShowPanel()
|
||||
{
|
||||
notClick = false;
|
||||
canvasGroup.DOFadeAlpha(1f, 0.5f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (notClick)
|
||||
return;
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
var ray = ui3d.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out var hit, 100, layerMask))
|
||||
{
|
||||
Debug.Log($"<color=#e94242>hit: {hit.collider.gameObject.layer}</color>");
|
||||
LurecardItem lurecardItem = hit.collider.transform.GetComponentInParent<LurecardItem>();
|
||||
if (lurecardItem != null)
|
||||
{
|
||||
supplyDropGameCtrl.AddPlayerItem(lurecardItem.data);
|
||||
supplyDropGameCtrl.ShowAllItem(lurecardItem.index);
|
||||
notClick = true;
|
||||
text_info.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Clicked on an invalid item.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user