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; private TurnEventManagement turnManager; private TurnSingleton turnSingleton; private void Awake() { turnManager = GetComponent(); turnSingleton = TurnSingleton.Instance; } private void Start() { if (mainCamera == null) mainCamera = Camera.main; RectTransformUtility.ScreenPointToWorldPointInRectangle( rect: dropCardPlace, screenPoint: dropCardPlace.position, cam: mainCamera, out drop_card_point_world_position); } public void DropCard(float cardDropDuration) // 系统弃牌 { 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); StartCoroutine(coroutine()); return; IEnumerator coroutine() { if (turnManager.GetHandCardCount() > 0) { for (var i = 0; i < turnManager.GetHandCardCount(); i++) { turnManager.GetHandCard(i).DropCard( new STRUCT_TURN_CARD.LET_CARD_DROP_SELF { METHOD = RequestsMethods.DELETE, ID = i, POSITION = drop_card_point_world_position, DURATION = cardDropDuration, }); yield return new WaitForSeconds(cardDropDuration); } } turnManager.SetActionState(TURN_ACTION_STATE.WAIT); turnManager.FlushHandCard(); turnManager.EnterEnemyTurn(); } } }