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;
|
|
|
|
|
|
|
|
|
|
// ======== private ========
|
|
|
|
|
private Vector3 drop_card_point_world_position;
|
2025-11-18 19:22:47 +08:00
|
|
|
private TurnEventManagement turnManager;
|
2025-11-18 22:26:13 +08:00
|
|
|
private TurnSingleton turnSingleton;
|
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 22:26:13 +08:00
|
|
|
turnSingleton = TurnSingleton.Instance;
|
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 22:26:13 +08:00
|
|
|
public void DropCard(float cardDropDuration) // 系统弃牌
|
2025-11-18 19:22:47 +08:00
|
|
|
{
|
2025-11-18 22:26:13 +08:00
|
|
|
if (!turnSingleton.VerificationSystemStatus(turnManager.GetState(), TURN_OS_STATE.EXIT_SELF_TURN)) return;
|
|
|
|
|
if (!turnSingleton.VerificationActionStatus(turnManager.GetActionState(), TURN_ACTION_STATE.DROP_REQUEST)) return;
|
|
|
|
|
turnManager.SetActionState(TURN_ACTION_STATE.DROP_RUNNING);
|
2025-11-18 19:22:47 +08:00
|
|
|
StartCoroutine(coroutine());
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator coroutine()
|
|
|
|
|
{
|
|
|
|
|
if (turnManager.GetHandCardCount() > 0)
|
|
|
|
|
{
|
|
|
|
|
for (var i = 0; i < turnManager.GetHandCardCount(); i++)
|
|
|
|
|
{
|
2025-11-18 22:26:13 +08:00
|
|
|
turnManager.GetHandCard(i).DropCard(
|
|
|
|
|
new STRUCT_TURN_CARD.LET_CARD_DROP_SELF
|
2025-11-18 19:22:47 +08:00
|
|
|
{
|
2025-11-20 14:43:50 +08:00
|
|
|
METHOD = RequestsMethods.DELETE,
|
2025-11-18 19:22:47 +08:00
|
|
|
ID = i,
|
|
|
|
|
POSITION = drop_card_point_world_position,
|
|
|
|
|
DURATION = cardDropDuration,
|
|
|
|
|
});
|
|
|
|
|
yield return new WaitForSeconds(cardDropDuration);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-18 22:26:13 +08:00
|
|
|
turnManager.SetActionState(TURN_ACTION_STATE.WAIT);
|
|
|
|
|
turnManager.FlushHandCard();
|
|
|
|
|
turnManager.EnterEnemyTurn();
|
2025-11-18 19:22:47 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-11-18 12:56:16 +08:00
|
|
|
}
|