diff --git a/ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset b/ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset index f14225ca..c3fd44d6 100644 --- a/ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset +++ b/ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset @@ -13,13 +13,13 @@ MonoBehaviour: m_Name: cardDeckList m_EditorClassIdentifier: cardDeckList: - - 1011 - - 1010 - - 1012 - - 1008 - - 1007 - - 1001 - - 1001 - - 1001 - - 2002 - - 2001 + - 1019 + - 1019 + - 1019 + - 1019 + - 1019 + - 1019 + - 1019 + - 1019 + - 1019 + - 1019 diff --git a/ColorlessWorld-2024-4-2/Assets/Plugins/Microsoft.CSharp.dll.meta b/ColorlessWorld-2024-4-2/Assets/Plugins/Microsoft.CSharp.dll.meta new file mode 100644 index 00000000..17bba4e5 --- /dev/null +++ b/ColorlessWorld-2024-4-2/Assets/Plugins/Microsoft.CSharp.dll.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: a94cf6fef2879da4c91e5ef768aadf4e +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/ColorlessWorld-2024-4-2/Assets/Scenes/SampleScene.unity b/ColorlessWorld-2024-4-2/Assets/Scenes/SampleScene.unity index 4eb20843..2f9c730f 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scenes/SampleScene.unity +++ b/ColorlessWorld-2024-4-2/Assets/Scenes/SampleScene.unity @@ -21079,8 +21079,8 @@ GameObject: - component: {fileID: 457398704} - component: {fileID: 457398707} - component: {fileID: 457398706} - - component: {fileID: 457398705} - component: {fileID: 457398708} + - component: {fileID: 457398709} m_Layer: 5 m_Name: WeaponNode m_TagString: WeaponDragPanel @@ -21107,40 +21107,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: -8, y: -8} m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &457398705 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 457398703} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4012b9f69059ec040b5641a5cfa8eac7, type: 3} - m_Name: - m_EditorClassIdentifier: - score: 0 - scoreMul: 0 - condition: position - result: AcidRain - conditionValue: 0 - resultValue: 1 - nodesMark: - - 0_0 - - 1_0 - - 0_1 - nodesColor: - - white - - red - - blue - extraRedNodeCount: 0 - extraBlueNodeCount: 0 - extraYellowNodeCount: 0 - extraMostNodeCount: 0 - extraLeastNodeCount: 0 - extraAllNodeCount: 0 - isIgnoreCondition: 0 - isDoubleSettle: 0 --- !u!114 &457398706 MonoBehaviour: m_ObjectHideFlags: 0 @@ -21192,6 +21158,37 @@ CanvasGroup: m_Interactable: 1 m_BlocksRaycasts: 1 m_IgnoreParentGroups: 0 +--- !u!114 &457398709 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 457398703} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d6302809f06dc36468787c81c4c492aa, type: 3} + m_Name: + m_EditorClassIdentifier: + score: 0 + scoreMul: 0 + condition: red>5 + result: addScore + conditionValue: + resultValue: 5 + nodesMark: [] + nodesColor: [] + extraRedNodeCount: 0 + extraBlueNodeCount: 0 + extraYellowNodeCount: 0 + extraMostNodeCount: 0 + extraLeastNodeCount: 0 + extraAllNodeCount: 0 + isIgnoreCondition: 0 + isDoubleSettle: 0 + resultDescription: + conditionDescription: + gemImage: {fileID: 0} --- !u!1 &458000797 GameObject: m_ObjectHideFlags: 0 @@ -42460,6 +42457,9 @@ MonoBehaviour: extraAllNodeCount: 0 isIgnoreCondition: 0 isDoubleSettle: 0 + resultDescription: + conditionDescription: + gemImage: {fileID: 0} --- !u!1 &1009332616 GameObject: m_ObjectHideFlags: 0 @@ -74193,8 +74193,8 @@ GameObject: - component: {fileID: 1713025703} - component: {fileID: 1713025706} - component: {fileID: 1713025705} - - component: {fileID: 1713025708} - component: {fileID: 1713025707} + - component: {fileID: 1713025708} m_Layer: 5 m_Name: WeaponNode m_TagString: WeaponDragPanel @@ -74281,15 +74281,15 @@ MonoBehaviour: m_GameObject: {fileID: 1713025702} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f2fbc27b744afba46a8f18f6c09eed3f, type: 3} + m_Script: {fileID: 11500000, guid: d6302809f06dc36468787c81c4c492aa, type: 3} m_Name: m_EditorClassIdentifier: score: 0 scoreMul: 0 - condition: none - result: mulScore + condition: blue<10 + result: addScore conditionValue: - resultValue: 1.0 + resultValue: 10 nodesMark: [] nodesColor: [] extraRedNodeCount: 0 @@ -74300,6 +74300,9 @@ MonoBehaviour: extraAllNodeCount: 0 isIgnoreCondition: 0 isDoubleSettle: 0 + resultDescription: + conditionDescription: + gemImage: {fileID: 0} --- !u!1 &1715971502 GameObject: m_ObjectHideFlags: 0 @@ -78711,9 +78714,7 @@ MonoBehaviour: enemyScore: 0 enemyHp: 60 straightHit: 0 - attackPattern: {fileID: 2135474817} - defenseIcon: {fileID: 21300000, guid: 8fd74ffa775b75741a21abd9250e2767, type: 3} - attackIcon: {fileID: 21300000, guid: 0a1daf24126ecb54e87fbf1dbf3cec7b, type: 3} + hitTypeText: {fileID: 0} scorResults: 0 playerScoreBar: {fileID: 93681350} playerScoreText: {fileID: 1259852126} @@ -80867,8 +80868,8 @@ MonoBehaviour: generatePointTest: {fileID: 668478574} cameraObject: {fileID: 0} mapUnity: {fileID: 887005656701010215, guid: b9233122c0864c84dad5899758cf64f2, type: 3} - line: 9 - column: 6 + line: 15 + column: 9 lineOffSet: {x: 1, y: 0, z: 0} columnOffSet: {x: 0, y: 0, z: 0.865} mapUnityFather: {fileID: 1884246785} @@ -80882,6 +80883,12 @@ MonoBehaviour: - Y: [] - Y: [] - Y: [] + - Y: [] + - Y: [] + - Y: [] + - Y: [] + - Y: [] + - Y: [] --- !u!4 &1884246785 Transform: m_ObjectHideFlags: 0 diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Card/TurnMaster.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/Card/TurnMaster.cs index 82098284..63c5a677 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/Card/TurnMaster.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Card/TurnMaster.cs @@ -104,7 +104,8 @@ public class TurnMaster : Singleton //敌人动作如移动,涂色 //EnemyManager.Instance.EnemyTurn_Observer(); - getNodeTools.RandomPollute(getNodeTools.getAllNotBlackNodes(), 8); + //getNodeTools.RandomPollute(getNodeTools.getAllNotBlackNodes(), 8); + GameManager.Instance.enemy.EnemyTurnSettle(3); turn = Turn.turnStop; turn = Turn.enemyTurnEnd; } diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/Enemy.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/Enemy.cs new file mode 100644 index 00000000..fce17104 --- /dev/null +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/Enemy.cs @@ -0,0 +1,99 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Enemy +{ + public List deck = new List(); // 卡组 + public List hand = new List(); // 手牌 + public List discardPile = new List();// 弃牌堆 + public List inPlay = new List(); // 战场上的牌 + + + public void EnemyTurnSettle(int num) + { + for (int i = 0; i < num; i++) + { + DrawOneCard(); + } + } + public void PlayCard(int num) + { + // 处理无效输入 + if (deck == null || deck.Count == 0) return ; + + // 如果n超过列表长度,则删除全部元素 + if (num >= deck.Count) + { + deck.Clear(); + ReshuffleDiscardIntoDeck(); + return; + } + + // 存储被选中的元素 + var selectedElements = new List(num); + + // 随机选择并删除元素 + for (int i = 0; i < num; i++) + { + int randomIndex = new System.Random().Next(deck.Count); + selectedElements.Add(deck[randomIndex]); + deck.RemoveAt(randomIndex); + } + } + + // 洗牌(将弃牌堆洗入卡组) + public void ReshuffleDiscardIntoDeck() + { + if (discardPile.Count == 0) + { + Debug.Log("弃牌堆为空,无法洗牌"); + return; + } + + // 将弃牌堆加入卡组 + deck.AddRange(discardPile); + discardPile.Clear(); + + // 洗牌算法 + ShuffleDeck(); + + Debug.Log($"已将弃牌堆洗入卡组,当前卡组有 {deck.Count} 张牌"); + } + + // 洗牌算法 + void ShuffleDeck() + { + // Fisher-Yates 洗牌算法 + for (int i = deck.Count - 1; i > 0; i--) + { + int j = Random.Range(0, i + 1); + EnemyCard temp = deck[i]; + deck[i] = deck[j]; + deck[j] = temp; + } + } + public void DrawOneCard() + { + if (deck.Count == 0) + { + Debug.Log("卡组空了,无法抽牌!"); + ReshuffleDiscardIntoDeck(); + if (deck.Count == 0) + { + Debug.Log("洗牌后卡组仍然为空!"); + return; + } + } + EnemyCard drawnCard = deck[0]; + deck.RemoveAt(0); + settleCard(drawnCard); + discardPile.Add(drawnCard); + } + + public void settleCard(EnemyCard card) + { + MapUnity target = getNodeTools.getBestTargetNodeForEnemyCard(card.nodesMark, card.nodesColor); + card.CardSettle(target); + } +} diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/Enemy.cs.meta b/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/Enemy.cs.meta new file mode 100644 index 00000000..f54c5d22 --- /dev/null +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/Enemy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a8bcecd86a4bbbd42b662c5ee02ea8d2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/EnemyCard.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/EnemyCard.cs new file mode 100644 index 00000000..dbe19a46 --- /dev/null +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/EnemyCard.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EnemyCard +{ + public string[] nodesMark; + public string[] nodesColor; + + public void CardSettle(MapUnity targetNode) + { + Debug.Log("打出一张"); + float euler = 90.0f; + //Debug.Log("currentNode的X是" + targetNode.locationX + "currentNode的Y是" + targetNode.locationY); + //Debug.Log("currentNode的Q是" + currentNode.cubeQ + "currentNode的S是" + currentNode.cubeS + "currentNode的R是" + currentNode.cubeR); + List<(int, int, int)> cubeList = new List<(int, int, int)>(); + int intEuler = (int)euler; + //Debug.Log("euler是" + intEuler); + for (int i = 0; i < nodesMark.Length; i++) + { + + try + { + string[] marks = nodesMark[i].Split("_"); + //Debug.Log("AxialToCube的X是" + int.Parse(marks[0]) + "AxialToCube的Y是" + int.Parse(marks[1])); + (int q, int s, int y) = MathTool.AxialToCube(int.Parse(marks[0]), int.Parse(marks[1])); + cubeList.Add((q, s, y)); + } + catch (Exception e) + { } + } + List<(int, int, int)> rotatedCubeList = new List<(int, int, int)>(); + rotatedCubeList = MathTool.RotateCoordinates(cubeList, intEuler); + foreach (var tuple in rotatedCubeList) + { + MapUnity endNode = null; + endNode = getNodeTools.getNodeWithCube(tuple.Item1, tuple.Item2, tuple.Item3); + // Debug.Log("rotatedNode的X是" + endNode.locationX + "rotatedNode的Y是" + endNode.locationY); + //Debug.Log("rotatedNode的Q是" + tuple.Item1 + "rotatedNode的S是" + tuple.Item2 + "rotatedNode的R是" + tuple.Item3); + } + + + List<(int, int, int)> trueCubeList = new List<(int, int, int)>(); + trueCubeList = MathTool.TranslateHexesToNewOrigin(rotatedCubeList, (targetNode.cubeQ, targetNode.cubeS, targetNode.cubeR)); + for (int i = 0; i < trueCubeList.Count; i++) + { + MapUnity endNode = null; + endNode = getNodeTools.getNodeWithCube(trueCubeList[i].Item1, trueCubeList[i].Item2, trueCubeList[i].Item3); + // Debug.Log("endNode的X是" + endNode.locationX + "endNode的Y是" + endNode.locationY); + //Debug.Log("endNode的Q是"+endNode.cubeQ+ "endNode的S是" + endNode.cubeS+ "endNode的R是" + endNode.cubeR); + if (endNode != null) + { + endNode.switchColor(Name.stringColorToint(nodesColor[i])); + } + } + } +} diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/EnemyCard.cs.meta b/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/EnemyCard.cs.meta new file mode 100644 index 00000000..4ef13bad --- /dev/null +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Enemy/EnemyCard.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d8c2b264584fca34c94ae347efe2655b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/GameManager.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/GameManager.cs index ba3ef467..d1adc778 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/GameManager.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/GameManager.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; +using static UnityEngine.EventSystems.EventTrigger; public class GameManager : Singleton { @@ -117,11 +118,21 @@ public class GameManager : Singleton public bool isPlayerMoved = false; + public Enemy enemy; + private void Start() { //生成角色数据 if (PlayerStatsManager.Instance.playerState != null) - playerState = PlayerStatsManager.Instance.playerState; + playerState = PlayerStatsManager.Instance.playerState; + enemy=new Enemy(); + EnemyCard enemyCard = new EnemyCard(); + enemyCard.nodesMark= new string[1] {"0_0" }; + enemyCard.nodesColor = new string[1] { "black" }; + for (int i = 0; i < 6; i++) + { + enemy.deck.Add(enemyCard); + } //生成空地图列表 // GenerateEnmptyMapList(); GenerateEnmptyMapListDefault(); diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/MathTool.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/MathTool.cs index 92d7bfbd..c08c627b 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/MathTool.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/MathTool.cs @@ -43,6 +43,66 @@ public class MathTool return numbers; } + + public static string GetKeyWithMaxValue(Dictionary dict) + { + if (dict == null) + throw new ArgumentNullException(nameof(dict), "字典不能为null"); + + if (dict.Count == 0) + throw new InvalidOperationException("字典不能为空"); + + int maxValue = int.MinValue; + var maxKeys = new List(); + + foreach (var pair in dict) + { + if (pair.Value > maxValue) + { + // 发现更大的值,重置列表 + maxValue = pair.Value; + maxKeys.Clear(); + maxKeys.Add(pair.Key); + } + else if (pair.Value == maxValue) + { + // 发现相同的最大值,添加到列表 + maxKeys.Add(pair.Key); + } + } + + return maxKeys[new System.Random().Next(maxKeys.Count)]; + } + + public static string GetKeyWithMinValue(Dictionary dict) + { + if (dict == null) + throw new ArgumentNullException(nameof(dict), "字典不能为null"); + + if (dict.Count == 0) + throw new InvalidOperationException("字典不能为空"); + + int minValue = int.MaxValue; + var minKeys = new List(); + + foreach (var pair in dict) + { + if (pair.Value < minValue) + { + // 发现更小的值,重置列表 + minValue = pair.Value; + minKeys.Clear(); + minKeys.Add(pair.Key); + } + else if (pair.Value == minValue) + { + // 发现相同的最小值,添加到列表 + minKeys.Add(pair.Key); + } + } + + return minKeys[new System.Random().Next(minKeys.Count)]; + } public static List sortByCubeDistance(List nodeList,MapUnity originNode) { // 使用LINQ的OrderByDescending来按照距离基准点从远到近排序 diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/Name.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/Name.cs index e32bc8f7..712add59 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/Name.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/Name.cs @@ -757,6 +757,8 @@ public static class Name public const int Yellow = 7; public static readonly List PlayerColor = new() { Red, Blue, Yellow , Green }; public static readonly List EnemyColor = new() { Black }; + public static readonly List PlayerAndWhiteColor = new() { Red, Blue, Yellow, Green,White }; + } public static int stringColorToint(string color) diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/getNodeTools.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/getNodeTools.cs index 06e202b6..5256d2af 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/getNodeTools.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/getNodeTools.cs @@ -28,6 +28,22 @@ public class getNodeTools return canPass; } + public static string getMostPlayerNodeName() + { + Dictionary nodes= new Dictionary{ { Name.Color.Blue, MapUnityManager.Instance.blueNodeCount},{ Name.Color.Red,MapUnityManager.Instance.redNodeCount},{ Name.Color.Yellow, MapUnityManager.Instance.yellowNodeCount} + ,{ Name.Color.Green,MapUnityManager.Instance.greenNodeCount} + }; + return MathTool.GetKeyWithMaxValue(nodes); + } + + public static string getLeastPlayerNodeName() + { + Dictionary nodes = new Dictionary{ { Name.Color.Blue, MapUnityManager.Instance.blueNodeCount},{ Name.Color.Red,MapUnityManager.Instance.redNodeCount},{ Name.Color.Yellow, MapUnityManager.Instance.yellowNodeCount} + ,{ Name.Color.Green,MapUnityManager.Instance.greenNodeCount} + }; + return MathTool.GetKeyWithMinValue(nodes); + } + public static int getEnemyToPlayerUnitPoolOffset(MapUnity playerOn, MapUnity targetNode) { int offset = 0; @@ -41,6 +57,7 @@ public class getNodeTools return offset; } + public static void playerMoveToNextNode(MapUnity mapNode) { //角色移动 @@ -1167,4 +1184,80 @@ public class getNodeTools return result; } + + public static int CheckNodeRewardForEnemy(string[] nodesMark, string[] nodesColor, MapUnity targetNode) + { + int canRemovePlayerNodeCount = 0; + float euler = 90.0f; + //Debug.Log("currentNode的X是" + targetNode.locationX + "currentNode的Y是" + targetNode.locationY); + //Debug.Log("currentNode的Q是" + currentNode.cubeQ + "currentNode的S是" + currentNode.cubeS + "currentNode的R是" + currentNode.cubeR); + List<(int, int, int)> cubeList = new List<(int, int, int)>(); + int intEuler = (int)euler; + //Debug.Log("euler是" + intEuler); + for (int i = 0; i < nodesMark.Length; i++) + { + try + { + string[] marks = nodesMark[i].Split("_"); + Debug.Log("AxialToCube的X是" + int.Parse(marks[0]) + "AxialToCube的Y是" + int.Parse(marks[1])); + (int q, int s, int y) = MathTool.AxialToCube(int.Parse(marks[0]), int.Parse(marks[1])); + cubeList.Add((q, s, y)); + } + catch (Exception e) + { } + } + List<(int, int, int)> rotatedCubeList = new List<(int, int, int)>(); + rotatedCubeList = MathTool.RotateCoordinates(cubeList, intEuler); + foreach (var tuple in rotatedCubeList) + { + MapUnity endNode = null; + endNode = getNodeTools.getNodeWithCube(tuple.Item1, tuple.Item2, tuple.Item3); + // Debug.Log("rotatedNode的X是" + endNode.locationX + "rotatedNode的Y是" + endNode.locationY); + //Debug.Log("rotatedNode的Q是" + tuple.Item1 + "rotatedNode的S是" + tuple.Item2 + "rotatedNode的R是" + tuple.Item3); + } + + List<(int, int, int)> trueCubeList = new List<(int, int, int)>(); + trueCubeList = MathTool.TranslateHexesToNewOrigin(rotatedCubeList, (targetNode.cubeQ, targetNode.cubeS, targetNode.cubeR)); + Debug.Log("入口4" + trueCubeList.Count); + for (int i = 0; i < trueCubeList.Count; i++) + { + + MapUnity endNode = null; + endNode = getNodeTools.getNodeWithCube(trueCubeList[i].Item1, trueCubeList[i].Item2, trueCubeList[i].Item3); + // Debug.Log("endNode的X是" + endNode.locationX + "endNode的Y是" + endNode.locationY); + //Debug.Log("endNode的Q是"+endNode.cubeQ+ "endNode的S是" + endNode.cubeS+ "endNode的R是" + endNode.cubeR); + if (endNode != null) + { + Debug.Log("endNode颜色是" + Name.intColorTostring(endNode.whoColour)); + if ( Name.NodeColor.PlayerAndWhiteColor.Contains(endNode.whoColour)) + { + Debug.Log("canRemovePlayerNodeCount++"); + canRemovePlayerNodeCount++; + } + } + } + return canRemovePlayerNodeCount; + } + + public static MapUnity getBestTargetNodeForEnemyCard(string[] nodesMark, string[] nodesColor) + { + int mostCanRemovePlayerNodeCount = 0; + HashSet targetNodes=new HashSet(); + foreach (MapUnity node in getNodeTools.getAllNodes()) + { + int count = CheckNodeRewardForEnemy(nodesMark, nodesColor, node); + if (count > mostCanRemovePlayerNodeCount) + { + targetNodes.Clear(); + targetNodes.Add(node); + mostCanRemovePlayerNodeCount= count; + } + else if(count == mostCanRemovePlayerNodeCount) + { + targetNodes.Add(node); + } + } + Debug.Log("targetNodes大小是" + targetNodes.Count); + return MathTool.GetRandomElements(targetNodes,1).ElementAt(0); + } } diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Weapon/WeaponNode.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/Weapon/WeaponNode.cs index 7f84f1cd..fdeb8f62 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/Weapon/WeaponNode.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Weapon/WeaponNode.cs @@ -181,8 +181,10 @@ public class WeaponNode : MonoBehaviour,IDragHandler, IBeginDragHandler, IEndDra extraYellowNodeCount += int.Parse(resultValue); break; case Name.WeaponNodeFunction.mostNodeCount: + addPlayerMostNodeCount(); break; case Name.WeaponNodeFunction.leastNodeCount: + addPlayerLeastNodeCount(); break; case Name.WeaponNodeFunction.allNodeCount: extraAllNodeCount += int.Parse(resultValue); @@ -217,6 +219,40 @@ public class WeaponNode : MonoBehaviour,IDragHandler, IBeginDragHandler, IEndDra } } + + public void addPlayerMostNodeCount() + { + string mostNode= getNodeTools.getMostPlayerNodeName(); + switch (mostNode) + { + case Name.WeaponNodeFunction.redNodeCount: + extraRedNodeCount += int.Parse(resultValue); + break; + case Name.WeaponNodeFunction.blueNodeCount: + extraBlueNodeCount += int.Parse(resultValue); + break; + case Name.WeaponNodeFunction.yellowNodeCount: + extraYellowNodeCount += int.Parse(resultValue); + break; + } + } + + public void addPlayerLeastNodeCount() + { + string mostNode = getNodeTools.getLeastPlayerNodeName(); + switch (mostNode) + { + case Name.WeaponNodeFunction.redNodeCount: + extraRedNodeCount += int.Parse(resultValue); + break; + case Name.WeaponNodeFunction.blueNodeCount: + extraBlueNodeCount += int.Parse(resultValue); + break; + case Name.WeaponNodeFunction.yellowNodeCount: + extraYellowNodeCount += int.Parse(resultValue); + break; + } + } public bool SingleConditionCheck(string condition,int position) { bool check = false; diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/manager/SettlementManager.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/manager/SettlementManager.cs index 820571a7..9ed24197 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/manager/SettlementManager.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/manager/SettlementManager.cs @@ -51,14 +51,14 @@ public class SettlementManager : Singleton //造成伤害 //染色 - private void dyeingWork(List influencePreviewPool) +/* private void dyeingWork(List influencePreviewPool) { for (int i = 0; i < influencePreviewPool.Count; i++) { influencePreviewPool[i].whoColour = Name.NodeColor.Black; } - } + }*/ private void dyeingWork(CardOriginalData cardOriginalData,MapUnity targetNode) { @@ -284,12 +284,12 @@ public class SettlementManager : Singleton } - private void dyeingAroundWork(List influencePreviewPool) + private void dyeingAroundWork(CardOriginalData cardOriginalData, List influencePreviewPool) { HashSet influencePreviewPoolSet = new HashSet(influencePreviewPool); getNodeTools.getCircleNode(influencePreviewPoolSet, 1); List targetNodes = new List(influencePreviewPoolSet); - dyeingWork(targetNodes); + dyeingWork(cardOriginalData, targetNodes.ElementAt(0)); } private void nodesForCostWork(List influencePreviewPool, int val) @@ -830,7 +830,7 @@ public class SettlementManager : Singleton //repelFromPlayer(influencePreviewPool, targetNode, 100); break; case CardFunction.dyeingAround: - dyeingAroundWork(influencePreviewPool); + dyeingAroundWork(cardOriginalData,influencePreviewPool); break; case CardFunction.consumePlayerNodesForHealth: //consumePlayerNodesForHealthWork(influencePreviewPool);