|
|
|
@ -8,6 +8,7 @@ using static EnemyNode; |
|
|
|
using static UnityEngine.Rendering.DebugUI; |
|
|
|
using System; |
|
|
|
using Unity.VisualScripting; |
|
|
|
using System.Data; |
|
|
|
|
|
|
|
public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler |
|
|
|
{ |
|
|
|
@ -19,7 +20,7 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
public EventSystem eventSystem; |
|
|
|
bool canUse = true;//决定卡牌是否可以释放
|
|
|
|
bool choosed;//标识卡牌是否被选中
|
|
|
|
|
|
|
|
|
|
|
|
[Header("贝塞尔曲线瞄准")] |
|
|
|
public GameObject ainPanle; |
|
|
|
|
|
|
|
@ -52,7 +53,7 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
{ |
|
|
|
Debug.Log("当前费用:" + TurnMaster.Instance.currentCost); |
|
|
|
Debug.Log("总费用:" + Usermanager.Instance.totalCost); |
|
|
|
if (TurnMaster.Instance.currentCost - cardEntity.cardOriginalData.Cost < 0) |
|
|
|
if (GameManager.Instance.playerState.currentCost - cardEntity.cardOriginalData.Cost < 0) |
|
|
|
{ |
|
|
|
Debug.Log("费用不足"); |
|
|
|
cardEntity.costEnough = false; |
|
|
|
@ -102,11 +103,11 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
private void resetComponentPosition() |
|
|
|
{ |
|
|
|
//遍历范围预览池消除影响色
|
|
|
|
for (int i = 0; i < GameManager.Instance.player.influencePreviewPool.Count; i++) |
|
|
|
for (int i = 0; i < MapUnityManager.Instance.castPool.Count; i++) |
|
|
|
{ |
|
|
|
GameManager.Instance.player.influencePreviewPool[i].influenced = false; |
|
|
|
MapUnityManager.Instance.castPool[i].influenced = false; |
|
|
|
} |
|
|
|
GameManager.Instance.player.influencePreviewPool.Clear(); |
|
|
|
MapUnityManager.Instance.castPool.Clear(); |
|
|
|
//遍历影响池变色
|
|
|
|
for (int i = 0; i < cardEntity.influencePreviewPool.Count; i++) |
|
|
|
{ |
|
|
|
@ -128,6 +129,7 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
|
|
|
|
if (choosed && Mouse.current.rightButton.wasPressedThisFrame) |
|
|
|
{ |
|
|
|
GameManager.Instance.onDrag = false; |
|
|
|
Debug.Log("取消释放"); |
|
|
|
canUse = false;//取消释放
|
|
|
|
ainPanle.SetActive(false); |
|
|
|
@ -146,6 +148,7 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
GameManager.Instance.onDrag = true; |
|
|
|
choosed = true; |
|
|
|
|
|
|
|
GetComponent<CanvasGroup>().blocksRaycasts = false; |
|
|
|
@ -190,7 +193,6 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
//重新调用范围预览
|
|
|
|
//GameManager.Instance.player.StepPreviewInfluencedNode(cardEntity.cardOriginalData.CastingRange);
|
|
|
|
setCastingRangePreview(cardEntity.cardOriginalData.EffectRange); |
|
|
|
Debug.Log(cardEntity.cardOriginalData.CastingRange); |
|
|
|
//预览影响范围
|
|
|
|
if (currentNode.influenced) |
|
|
|
{ |
|
|
|
@ -198,7 +200,6 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
|
|
|
|
Vector3 face = currentNode.transform.position - GameManager.Instance.playerOn.transform.position; |
|
|
|
float euler = Vector3.SignedAngle(-GameManager.Instance.playerOn.transform.forward, face, GameManager.Instance.playerOn.transform.up) + 180; |
|
|
|
Debug.Log("角度是:" + euler); |
|
|
|
setEffectRangePreview(cardEntity.cardOriginalData.EffectRange, euler, currentNode); |
|
|
|
//influencePreviewPool.Add(currentNode);
|
|
|
|
|
|
|
|
@ -213,13 +214,20 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
|
|
|
|
private void setCastingRangePreview(string effectRange) |
|
|
|
{ |
|
|
|
for (int i = 0; i < MapUnityManager.Instance.castPool.Count; i++) |
|
|
|
{ |
|
|
|
MapUnityManager.Instance.castPool[i].influenced = false; |
|
|
|
} |
|
|
|
MapUnityManager.Instance.castPool.Clear(); |
|
|
|
if (effectRange == EffectRange.range1) |
|
|
|
{ |
|
|
|
GameManager.Instance.player.StepPreviewInfluencedNode(cardEntity.cardOriginalData.CastingRange); |
|
|
|
MapUnityManager.Instance.getCastPool(cardEntity.cardOriginalData.EffectRange, cardEntity.cardOriginalData.CastingRange); |
|
|
|
//GameManager.Instance.player.StepPreviewInfluencedNode(cardEntity.cardOriginalData.CastingRange);
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
GameManager.Instance.player.StepPreviewInfluencedNode(1); |
|
|
|
MapUnityManager.Instance.getCastPool(cardEntity.cardOriginalData.EffectRange, cardEntity.cardOriginalData.CastingRange); |
|
|
|
//GameManager.Instance.player.StepPreviewInfluencedNode(1);
|
|
|
|
/* MapUnity playerNode = GameManager.Instance.playerOn; |
|
|
|
MapUnity currentNode = GameManager.Instance.playerOn; |
|
|
|
castingPool.Clear(); |
|
|
|
@ -236,7 +244,6 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
} |
|
|
|
private void setEffectRangePreview(string effectRange, float euler, MapUnity currentNode) |
|
|
|
{ |
|
|
|
Debug.Log("作用范围:" + effectRange); |
|
|
|
MapUnity playerOnNode = GameManager.Instance.playerOn.transform.GetComponent<MapUnity>(); |
|
|
|
var handlers = new Dictionary<string, EffectRangeHandler> |
|
|
|
{ |
|
|
|
@ -264,86 +271,9 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
{ |
|
|
|
cardEntity.influencePreviewPool = handler.HandleAngleWithResult(euler); |
|
|
|
} |
|
|
|
cardEntity.influencePreviewPool=MathTool.RemoveDuplicates(cardEntity.influencePreviewPool); |
|
|
|
|
|
|
|
} |
|
|
|
/* private void showEffectRange3_2(float euler) |
|
|
|
{ |
|
|
|
if (euler > 0 && euler < 45) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[0])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[0]); |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[4])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[4]); |
|
|
|
} |
|
|
|
else if (euler > 45 && euler < 135) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[1])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[1]); |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[5])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[5]); |
|
|
|
} |
|
|
|
else if (euler > 135 && euler < 180) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[2])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[2]); |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[0])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[0]); |
|
|
|
} |
|
|
|
else if (euler > 180 && euler < 225) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[1])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[1]); |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[3])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[3]); |
|
|
|
} |
|
|
|
else if (euler > 225 && euler < 315) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[2])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[2]); |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[4])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[4]); |
|
|
|
} |
|
|
|
else if (euler > 315 && euler < 360) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[3])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[3]); |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[5])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[5]); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
/* private void showEffectRange2(float euler) |
|
|
|
{ |
|
|
|
if (euler > 0 && euler <= 45) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[2])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[2]); |
|
|
|
} |
|
|
|
else if (euler > 45 && euler <= 135) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[3])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[3]); |
|
|
|
} |
|
|
|
else if (euler > 135 && euler <= 180) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[4])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[4]); |
|
|
|
} |
|
|
|
else if (euler > 180 && euler <= 225) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[5])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[5]); |
|
|
|
} |
|
|
|
else if (euler > 225 && euler <= 315) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[0])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[0]); |
|
|
|
} |
|
|
|
else if (euler > 315 && euler <= 360) |
|
|
|
{ |
|
|
|
if (checkNodeInfluencedable(currentNode.unitPool[1])) |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode.unitPool[1]); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
private void getInfluencePreviePoll(MapUnity currentNode, string effecctRange) |
|
|
|
@ -359,7 +289,7 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
private void noAinPanleWork(PointerEventData eventData) |
|
|
|
{ |
|
|
|
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|
|
|
/*Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|
|
|
if (eventData.pointerCurrentRaycast.gameObject != null) |
|
|
|
{ |
|
|
|
if (Physics.Raycast(ray, out RaycastHit raycastHit)) |
|
|
|
@ -367,7 +297,8 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
currentNode = raycastHit.collider.transform.GetComponent<MapUnity>(); |
|
|
|
cardEntity.influencePreviewPool.Add(currentNode); |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
setEffectRangePreview(cardEntity.cardOriginalData.EffectRange, 30.0f, currentNode); |
|
|
|
} |
|
|
|
|
|
|
|
public void OnDrag(PointerEventData eventData) |
|
|
|
@ -383,8 +314,7 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//没有范围不需要射线吧,因为不需要指定目标点?
|
|
|
|
// noAinPanleWork(eventData);
|
|
|
|
noAinPanleWork(eventData); |
|
|
|
} |
|
|
|
dyeing(); |
|
|
|
|
|
|
|
@ -403,114 +333,9 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
|
|
|
|
public void OnEndDrag(PointerEventData eventData) |
|
|
|
{ |
|
|
|
StartCoroutine(OnDragIEnumerator(eventData)); |
|
|
|
/* if (!cardEntity.costEnough) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
choosed = false; |
|
|
|
if (canUse) |
|
|
|
{ |
|
|
|
if (eventData.pointerCurrentRaycast.gameObject != null) |
|
|
|
{ |
|
|
|
if (eventData.pointerCurrentRaycast.gameObject.name == "Card") |
|
|
|
{ |
|
|
|
transform.SetParent(eventData.pointerCurrentRaycast.gameObject.transform.parent); |
|
|
|
transform.position = eventData.pointerCurrentRaycast.gameObject.transform.position; |
|
|
|
eventData.pointerCurrentRaycast.gameObject.transform.position = originalParent.position; |
|
|
|
eventData.pointerCurrentRaycast.gameObject.transform.SetParent(originalParent); |
|
|
|
GameManager.Instance.onDrag = false; |
|
|
|
|
|
|
|
GetComponent<CanvasGroup>().blocksRaycasts = true; |
|
|
|
|
|
|
|
ainPanle.SetActive(false);//关闭贝塞尔曲线
|
|
|
|
//遍历范围预览池消除影响色
|
|
|
|
for (int i = 0; i < GameManager.Instance.player.influencePreviewPool.Count; i++) |
|
|
|
{ |
|
|
|
GameManager.Instance.player.influencePreviewPool[i].influenced = false; |
|
|
|
} |
|
|
|
//GameManager.Instance.player.influencePreviewPool.Clear();
|
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
else if (eventData.pointerCurrentRaycast.gameObject.name == "cardSlot") |
|
|
|
{ |
|
|
|
transform.SetParent(eventData.pointerCurrentRaycast.gameObject.transform); |
|
|
|
transform.position = eventData.pointerCurrentRaycast.gameObject.transform.position; |
|
|
|
GetComponent<CanvasGroup>().blocksRaycasts = true; |
|
|
|
|
|
|
|
ainPanle.SetActive(false);//关闭贝塞尔曲线
|
|
|
|
//遍历范围预览池消除影响色
|
|
|
|
for (int i = 0; i < GameManager.Instance.player.influencePreviewPool.Count; i++) |
|
|
|
{ |
|
|
|
GameManager.Instance.player.influencePreviewPool[i].influenced = false; |
|
|
|
} |
|
|
|
//GameManager.Instance.player.influencePreviewPool.Clear();
|
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ainPanle.activeSelf) |
|
|
|
{ |
|
|
|
ainPanle.SetActive(false);//关闭贝塞尔曲线
|
|
|
|
} |
|
|
|
|
|
|
|
//先判断该卡牌的类型是否是需要范围
|
|
|
|
if (cardEntity.cardOriginalData.CastingRange != 0) |
|
|
|
{ |
|
|
|
//检测碰撞的地图节点是否被影响(可释放)
|
|
|
|
if (currentNode == null || currentNode.influenced == false) |
|
|
|
{ |
|
|
|
//遍历范围预览池消除影响色(红色,卡牌的释放范围)
|
|
|
|
for (int i = 0; i < GameManager.Instance.player.influencePreviewPool.Count; i++) |
|
|
|
{ |
|
|
|
GameManager.Instance.player.influencePreviewPool[i].influenced = false; |
|
|
|
} |
|
|
|
//GameManager.Instance.player.influencePreviewPool.Clear();
|
|
|
|
} |
|
|
|
else if (currentNode.influenced) |
|
|
|
{ |
|
|
|
|
|
|
|
//卡牌释放效果
|
|
|
|
Debug.Log("卡牌释放前影响格数:" + cardEntity.influencePreviewPool.Count); |
|
|
|
cardEntity.use(); |
|
|
|
Debug.Log("玩家盾量:" + Usermanager.Instance.Shield); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
//遍历范围预览池消除影响色
|
|
|
|
for (int i = 0; i < GameManager.Instance.player.influencePreviewPool.Count; i++) |
|
|
|
{ |
|
|
|
GameManager.Instance.player.influencePreviewPool[i].influenced = false; |
|
|
|
} |
|
|
|
GameManager.Instance.player.influencePreviewPool.Clear(); |
|
|
|
//遍历影响池变色
|
|
|
|
for (int i = 0; i < cardEntity.influencePreviewPool.Count; i++) |
|
|
|
{ |
|
|
|
cardEntity.influencePreviewPool[i].influenced = false; |
|
|
|
} |
|
|
|
cardEntity.influencePreviewPool.Clear(); |
|
|
|
GetComponent<CanvasGroup>().blocksRaycasts = true; |
|
|
|
|
|
|
|
//其他位置都归位
|
|
|
|
transform.SetParent(originalParent); |
|
|
|
transform.localPosition = originalpoint; |
|
|
|
return; |
|
|
|
}//范围类,需要指定被影响的节点才能释放
|
|
|
|
else |
|
|
|
{ |
|
|
|
//卡牌释放效果
|
|
|
|
cardEntity.use(); |
|
|
|
Debug.Log("玩家盾量:" + Usermanager.Instance.Shield); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
}//无范围类,直接释放
|
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
canUse = true; |
|
|
|
}*/ |
|
|
|
StartCoroutine(OnDragIEnumerator(eventData)); |
|
|
|
} |
|
|
|
|
|
|
|
private IEnumerator OnDragIEnumerator(PointerEventData eventData) |
|
|
|
@ -551,10 +376,16 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
|
|
|
|
ainPanle.SetActive(false);//关闭贝塞尔曲线
|
|
|
|
//遍历范围预览池消除影响色
|
|
|
|
for (int i = 0; i < GameManager.Instance.player.influencePreviewPool.Count; i++) |
|
|
|
for (int i = 0; i < MapUnityManager.Instance.castPool.Count; i++) |
|
|
|
{ |
|
|
|
GameManager.Instance.player.influencePreviewPool[i].influenced = false; |
|
|
|
MapUnityManager.Instance.castPool[i].influenced = false; |
|
|
|
} |
|
|
|
MapUnityManager.Instance.castPool.Clear(); |
|
|
|
for (int i = 0; i < cardEntity.influencePreviewPool.Count; i++) |
|
|
|
{ |
|
|
|
cardEntity.influencePreviewPool[i].influenced = false; |
|
|
|
} |
|
|
|
cardEntity.influencePreviewPool.Clear(); |
|
|
|
//GameManager.Instance.player.influencePreviewPool.Clear();
|
|
|
|
|
|
|
|
yield break; |
|
|
|
@ -572,18 +403,17 @@ public class CardDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag |
|
|
|
if (currentNode == null || currentNode.influenced == false) |
|
|
|
{ |
|
|
|
//遍历范围预览池消除影响色(红色,卡牌的释放范围)
|
|
|
|
for (int i = 0; i < GameManager.Instance.player.influencePreviewPool.Count; i++) |
|
|
|
for (int i = 0; i < MapUnityManager.Instance.castPool.Count; i++) |
|
|
|
{ |
|
|
|
GameManager.Instance.player.influencePreviewPool[i].influenced = false; |
|
|
|
MapUnityManager.Instance.castPool[i].influenced = false; |
|
|
|
} |
|
|
|
//GameManager.Instance.player.influencePreviewPool.Clear();
|
|
|
|
MapUnityManager.Instance.castPool.Clear(); |
|
|
|
} |
|
|
|
else if (currentNode.influenced) |
|
|
|
{ |
|
|
|
|
|
|
|
//卡牌释放效果
|
|
|
|
yield return StartCoroutine(cardEntity.settle(0)); |
|
|
|
Debug.Log("玩家盾量:" + Usermanager.Instance.Shield); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|