|
|
|
@ -8,6 +8,8 @@ using Unity.VisualScripting; |
|
|
|
using UnityEngine; |
|
|
|
using static Cinemachine.DocumentationSortingAttribute; |
|
|
|
using static Name; |
|
|
|
using static UnityEngine.InputSystem.InputControlScheme.MatchResult; |
|
|
|
using Match = System.Text.RegularExpressions.Match; |
|
|
|
|
|
|
|
public class WeaponManager : Singleton<WeaponManager> |
|
|
|
{ |
|
|
|
@ -162,117 +164,15 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
|
|
|
|
public GameObject getRandomWeaponNodeForPlayer() |
|
|
|
{ |
|
|
|
GameObject gem = Instantiate(Resources.Load<GameObject>(Name.WeaponNode.PrefabPath + Name.WeaponNode.PrefabName)); |
|
|
|
string condition = MathTool.GetRandomElements(Name.WeaponNodeCondition.PlayerConditionSet, 1).ElementAt(0); |
|
|
|
string conditionValue = ""; |
|
|
|
string[] nodesMark = new string[4]; |
|
|
|
string[] nodesColor = new string[4]; |
|
|
|
string result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerResultSet, 1).ElementAt(0); |
|
|
|
string resultValue = ""; |
|
|
|
switch (condition) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeCondition.position: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "0", "1", "2", "3", "4" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.positionUnused: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "0", "1", "2", "3", "4" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.positionUsed: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "0", "1", "2", "3", "4" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.diffSettle: |
|
|
|
conditionValue = Name.none; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.usedCard: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "1", "2", "3", "4", "5" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.threeColorDiffMoreThan: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "3", "4", "5" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.everyNumNodeConvert: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "7", "8", "9" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.bombbomb: |
|
|
|
conditionValue = Name.none; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.node: |
|
|
|
conditionValue = Name.none; |
|
|
|
HashSet<string> nodesA = MathTool.GetRandomElements(new HashSet<string> { "1_0", "-1_0", "0_1", "0_-1", "-1_1", "-1_-1" }, 3); |
|
|
|
nodesA.Add("0_0"); |
|
|
|
nodesMark = nodesA.ToArray(); |
|
|
|
nodesColor = new string[4] { MathTool.GetRandomElements(new HashSet<string> { Name.Color.Red, Name.Color.Blue, Name.Color.Yellow }, 1).ElementAt(0) |
|
|
|
,MathTool.GetRandomElements(new HashSet<string> { Name.Color.Red, Name.Color.Blue, Name.Color.Yellow }, 1).ElementAt(0) |
|
|
|
,MathTool.GetRandomElements(new HashSet<string> { Name.Color.Red, Name.Color.Blue, Name.Color.Yellow }, 1).ElementAt(0) |
|
|
|
,MathTool.GetRandomElements(new HashSet<string> { Name.Color.Red, Name.Color.Blue, Name.Color.Yellow }, 1).ElementAt(0)}; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.cardConditionPattern: |
|
|
|
conditionValue = Name.none; |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
sb.Append(MathTool.GetRandomElements(new HashSet<string> { Name.Color.Red, Name.Color.Blue, Name.Color.Yellow }, 1).ElementAt(0)) |
|
|
|
.Append(MathTool.GetRandomElements(new HashSet<string> { "<", ">" }, 1).ElementAt(0)) |
|
|
|
.Append(MathTool.GetRandomElements(new HashSet<string> { "5", "6", "7", "8", "9" }, 1).ElementAt(0)); |
|
|
|
condition = sb.ToString(); |
|
|
|
break; |
|
|
|
} |
|
|
|
switch (result) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeFunction.addScore: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(7, 12), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.mulScore: |
|
|
|
resultValue = MathTool.GetRandomElements(new HashSet<string> { "1", "2" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.repetWeaponNode: |
|
|
|
resultValue = MathTool.GetRandomElements(new HashSet<string> { "0", "1", "2", "3", "4" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.redNodeCount: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(3, 8), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.blueNodeCount: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(3, 8), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.yellowNodeCount: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(3, 8), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.mostNodeCount: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(3, 8), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.leastNodeCount: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(3, 8), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.allNodeCount: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(2, 4), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.drawCard: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(1, 4), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.everyRedNodeAddScore: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(1, 3), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.everyYellowNodeAddScore: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(1, 3), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.everyBlueNodeAddScore: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(1, 3), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.NodeItem.Volcano: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(1, 2), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
WeaponNode weaponNode = gem.GetComponent<WeaponNode>(); |
|
|
|
weaponNode.result = result; |
|
|
|
weaponNode.resultValue = resultValue; |
|
|
|
weaponNode.condition = condition; |
|
|
|
weaponNode.conditionValue = conditionValue; |
|
|
|
weaponNode.nodesMark = nodesMark; |
|
|
|
weaponNode.nodesColor = nodesColor; |
|
|
|
return gem; |
|
|
|
string level= MathTool.GetRandomElements(Name.WeaponNodeLevel.WeaponNodeLevelSet,1).ElementAt(0); |
|
|
|
return getRandomWeaponNodeForPlayerWithLevel(level); |
|
|
|
} |
|
|
|
|
|
|
|
public GameObject getRandomWeaponNodeForPlayerWithLevel(string level) |
|
|
|
{ |
|
|
|
GameObject gem = Instantiate(Resources.Load<GameObject>(Name.WeaponNode.PrefabPath + Name.WeaponNode.PrefabName)); |
|
|
|
string condition = ""; |
|
|
|
HashSet<string> resultSet = new HashSet<string>(); |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
@ -296,21 +196,23 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); |
|
|
|
resultSet = Name.WeaponNodeFunction.PlayerBasicResultSet; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Elementary: |
|
|
|
result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
resultSet = Name.WeaponNodeFunction.PlayerElementaryResultSet; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Intermediate: |
|
|
|
result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
resultSet = Name.WeaponNodeFunction.PlayerIntermediateResultSet; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Advanced: |
|
|
|
result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
resultSet = Name.WeaponNodeFunction.PlayerAdvancedResultSet; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
string resultValue = ""; |
|
|
|
conditionValue = getConditionValueWithLevel(level,ref condition, ref nodesMark, ref nodesColor); |
|
|
|
checkResultSetRationality(ref resultSet, condition); |
|
|
|
result = MathTool.GetRandomElements(resultSet, 1).ElementAt(0); |
|
|
|
resultValue = getResultValueWithLevel(level,ref result, condition, conditionValue); |
|
|
|
WeaponNode weaponNode = gem.GetComponent<WeaponNode>(); |
|
|
|
weaponNode.result = result; |
|
|
|
@ -322,6 +224,85 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
return gem; |
|
|
|
} |
|
|
|
|
|
|
|
public string getEveryNodeAddScoreValue(string level,string condition) |
|
|
|
{ |
|
|
|
string resultValue = ""; |
|
|
|
HashSet<string> resultSet = new HashSet<string>(); |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
resultSet = Name.EveryNodeAddScoreResultSet.BasiclSet; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Elementary: |
|
|
|
resultSet = Name.EveryNodeAddScoreResultSet.ElementarySet; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Intermediate: |
|
|
|
resultSet = Name.EveryNodeAddScoreResultSet.IntermediateSet; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Advanced: |
|
|
|
resultSet = Name.EveryNodeAddScoreResultSet.AdvancedSet; |
|
|
|
break; |
|
|
|
} |
|
|
|
//checkResultSetRationality(ref resultSet, condition);
|
|
|
|
resultValue = MathTool.GetRandomElements(resultSet, 1).ElementAt(0); |
|
|
|
return resultValue; |
|
|
|
} |
|
|
|
public void checkResultSetRationality(ref HashSet<string> set,string condition) |
|
|
|
{ |
|
|
|
Match match = System.Text.RegularExpressions.Regex.Match(condition, Name.Regex.cardConditionPattern); |
|
|
|
if (match.Success) |
|
|
|
{ |
|
|
|
//Debug.Log("checkResultSetRationality成功2");
|
|
|
|
string firstPart = match.Groups[1].Value; // 第一部分
|
|
|
|
string op = match.Groups[2].Value; // 运算符部分
|
|
|
|
string secondPart = match.Groups[3].Value; // 第二部分
|
|
|
|
if (op.Equals("<")) |
|
|
|
{ |
|
|
|
//Debug.Log("checkResultSetRationality成功1");
|
|
|
|
resultBlockingPolicy(firstPart,ref set); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//屏蔽策略
|
|
|
|
public void resultBlockingPolicy(string firstPart, ref HashSet<string> set) |
|
|
|
{ |
|
|
|
switch (firstPart) |
|
|
|
{ |
|
|
|
case Name.Color.Red: |
|
|
|
set.Remove(Name.WeaponNodeFunction.everyRedNodeAddScore); |
|
|
|
set.Remove(Name.WeaponNodeFunction.redNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.leastNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.mostNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.allNodeCount); |
|
|
|
break; |
|
|
|
case Name.Color.Blue: |
|
|
|
set.Remove(Name.WeaponNodeFunction.everyBlueNodeAddScore); |
|
|
|
set.Remove(Name.WeaponNodeFunction.blueNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.leastNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.mostNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.allNodeCount); |
|
|
|
break; |
|
|
|
case Name.Color.Yellow: |
|
|
|
set.Remove(Name.WeaponNodeFunction.everyYellowNodeAddScore); |
|
|
|
set.Remove(Name.WeaponNodeFunction.yellowNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.leastNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.mostNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.allNodeCount); |
|
|
|
break; |
|
|
|
case Name.Color.Black: |
|
|
|
set.Remove(Name.WeaponNodeFunction.everyBlackNodeAddScore); |
|
|
|
set.Remove(Name.WeaponNodeFunction.leastNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.mostNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.allNodeCount); |
|
|
|
break; |
|
|
|
case Name.Color.White: |
|
|
|
set.Remove(Name.WeaponNodeFunction.everyWhiteNodeAddScore); |
|
|
|
set.Remove(Name.WeaponNodeFunction.leastNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.mostNodeCount); |
|
|
|
set.Remove(Name.WeaponNodeFunction.allNodeCount); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
public WeaponNodeDataPair getRandomConditionWithLevel(string level) |
|
|
|
{ |
|
|
|
string condition = ""; |
|
|
|
@ -384,6 +365,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
{ |
|
|
|
GameObject gem = Instantiate(Resources.Load<GameObject>(Name.WeaponNode.PrefabPath + Name.WeaponNode.PrefabName)); |
|
|
|
string condition = ""; |
|
|
|
HashSet<string> resultSet= new HashSet<string>(); |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
@ -407,21 +389,22 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicAddScoreResultSet, 1).ElementAt(0); |
|
|
|
resultSet = Name.WeaponNodeFunction.PlayerBasicResultSet; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Elementary: |
|
|
|
result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
resultSet = Name.WeaponNodeFunction.PlayerElementaryResultSet; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Intermediate: |
|
|
|
result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
resultSet = Name.WeaponNodeFunction.PlayerIntermediateResultSet; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Advanced: |
|
|
|
result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
resultSet = Name.WeaponNodeFunction.PlayerAdvancedResultSet; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
string resultValue = ""; |
|
|
|
conditionValue = getConditionValueWithLevel(level, ref condition, ref nodesMark, ref nodesColor); |
|
|
|
checkResultSetRationality(ref resultSet, condition); |
|
|
|
result = MathTool.GetRandomElements(resultSet, 1).ElementAt(0); |
|
|
|
resultValue = getResultValueWithLevel(level, ref result, condition, conditionValue); |
|
|
|
WeaponNode weaponNode = gem.GetComponent<WeaponNode>(); |
|
|
|
weaponNode.result = result; |
|
|
|
@ -833,6 +816,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
public string getResultValueWithLevel(string level,ref string result, string condition, string conditionValue) |
|
|
|
{ |
|
|
|
string resultValue = ""; |
|
|
|
HashSet<string> resultSet = new HashSet<string>(); |
|
|
|
switch (result) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeFunction.addScore: |
|
|
|
@ -921,21 +905,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
case Name.WeaponNodeFunction.everyRedNodeAddScore: |
|
|
|
case Name.WeaponNodeFunction.everyYellowNodeAddScore: |
|
|
|
case Name.WeaponNodeFunction.everyBlueNodeAddScore: |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(1, 1), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Elementary: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(2, 3), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Intermediate: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(4, 5), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Advanced: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(6, 8), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
resultValue = getEveryNodeAddScoreValue(level, condition); |
|
|
|
break; |
|
|
|
case Name.NodeItem.Volcano: |
|
|
|
switch (level) |
|
|
|
@ -1012,10 +982,10 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
{ Name.WeaponNodeLevel.Elementary, MathTool.GenerateIntegerSet(3, 3) }, |
|
|
|
{ Name.WeaponNodeLevel.Intermediate, MathTool.GenerateIntegerSet(4, 5) }}; |
|
|
|
Dictionary<string, HashSet<string>> everyNodeAddScoreDict = new Dictionary<string, HashSet<string>>{ |
|
|
|
{ Name.WeaponNodeLevel.Basic, MathTool.GenerateIntegerSet(1, 1) }, |
|
|
|
{ Name.WeaponNodeLevel.Elementary, MathTool.GenerateIntegerSet(2, 3) }, |
|
|
|
{ Name.WeaponNodeLevel.Intermediate, MathTool.GenerateIntegerSet(4, 5) }, |
|
|
|
{ Name.WeaponNodeLevel.Advanced, MathTool.GenerateIntegerSet(6, 8) }}; |
|
|
|
{ Name.WeaponNodeLevel.Basic, Name.EveryNodeAddScoreResultSet.BasiclSet }, |
|
|
|
{ Name.WeaponNodeLevel.Elementary, Name.EveryNodeAddScoreResultSet.ElementarySet }, |
|
|
|
{ Name.WeaponNodeLevel.Intermediate, Name.EveryNodeAddScoreResultSet.IntermediateSet }, |
|
|
|
{ Name.WeaponNodeLevel.Advanced, Name.EveryNodeAddScoreResultSet.AdvancedSet }}; |
|
|
|
Dictionary<string, HashSet<string>> isIgnoreConditionDict = new Dictionary<string, HashSet<string>>(); |
|
|
|
Dictionary<string, HashSet<string>> VolcanoDict = new Dictionary<string, HashSet<string>>{ |
|
|
|
{ Name.WeaponNodeLevel.Basic, MathTool.GenerateIntegerSet(1, 1) }, |
|
|
|
|