62 lines
2.0 KiB
C#
Raw Normal View History

2025-11-18 12:56:16 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurnHandlerDropCard : MonoBehaviour
{
// ======== serializeField ========
[SerializeField] private RectTransform dropCardPlace;
[SerializeField] private Camera mainCamera;
[SerializeField] private float cardDropDuration = 0.2f;
// ======== private ========
private Vector3 drop_card_point_world_position;
2025-11-18 19:22:47 +08:00
private TurnEventManagement turnManager;
2025-11-18 12:56:16 +08:00
private void Awake()
{
2025-11-18 19:22:47 +08:00
turnManager = GetComponent<TurnEventManagement>();
2025-11-18 12:56:16 +08:00
}
private void Start()
{
2025-11-18 17:11:25 +08:00
if (mainCamera == null) mainCamera = Camera.main;
2025-11-18 12:56:16 +08:00
RectTransformUtility.ScreenPointToWorldPointInRectangle(
rect: dropCardPlace,
screenPoint: dropCardPlace.position,
cam: mainCamera,
out drop_card_point_world_position);
}
2025-11-18 19:22:47 +08:00
private void DropCard() // 系统弃牌
{
if (turnManager.GetState() != EVENT_OS_STATE.WAIT) return; // 系统正在处理其他事务
StartCoroutine(coroutine());
return;
IEnumerator coroutine()
{
turnManager.SetState(EVENT_OS_STATE.DROP_RUNNING);
if (turnManager.GetHandCardCount() > 0)
{
for (var i = 0; i < turnManager.GetHandCardCount(); i++)
{
turnManager.GetHandCard(i).;
EventOS.EVENT_TRIGGER(EventData.EVENT_REGISTER_EVENT_ENUM.EVENT_LET_CARD_DROP_SELF,
new EventStruct.STRUCT_EVENT_DROP_CARD
{
ID = i,
POSITION = drop_card_point_world_position,
DURATION = cardDropDuration,
});
yield return new WaitForSeconds(cardDropDuration);
}
}
handCardList.Clear(); // 清空
turnManager.SetState(EVENT_OS_STATE.WAIT);
}
}
2025-11-18 12:56:16 +08:00
}