diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/Name.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/Name.cs index c9fbbd77..2cc2fd4a 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/Name.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Tool/Name.cs @@ -995,8 +995,22 @@ public static class Name public static readonly HashSet PlayerConditionSet= new HashSet { cardConditionPattern,position, positionUnused, positionUsed, diffSettle ,usedCard,node,threeColorCountMoreThan,everyNumNodeConvert}; + public static readonly HashSet PlayerBasicConditionSet = new HashSet { cardConditionPattern, + node,position}; + + public static readonly HashSet PlayerElementaryConditionSet = new HashSet { cardConditionPattern,position, positionUsed, diffSettle + ,usedCard,node,everyNumNodeConvert}; + + public static readonly HashSet PlayerIntermediateConditionSet = new HashSet { cardConditionPattern,position, positionUsed, diffSettle + ,usedCard,node,everyNumNodeConvert}; + + public static readonly HashSet PlayerAdvancedConditionSet = new HashSet { cardConditionPattern, positionUnused + ,node,threeColorCountMoreThan}; + } + + public static class NodeItem { public const string itemPrefabPath = "ItemPrefab/"; @@ -1064,6 +1078,26 @@ public static class Name public static readonly HashSet PlayerResultSet = new HashSet { addScore,mulScore, repetWeaponNode, redNodeCount, blueNodeCount ,yellowNodeCount,mostNodeCount,leastNodeCount,allNodeCount,drawCard,isIgnoreCondition,everyRedNodeAddScore,everyYellowNodeAddScore,everyBlueNodeAddScore}; + public static readonly HashSet PlayerBasicResultSet = new HashSet { addScore, redNodeCount, blueNodeCount + ,yellowNodeCount,everyRedNodeAddScore,everyYellowNodeAddScore,everyBlueNodeAddScore}; + + public static readonly HashSet PlayerElementaryResultSet = new HashSet { addScore, redNodeCount, blueNodeCount + ,yellowNodeCount,mostNodeCount,leastNodeCount,drawCard,everyRedNodeAddScore,everyYellowNodeAddScore,everyBlueNodeAddScore}; + + public static readonly HashSet PlayerIntermediateResultSet = new HashSet { addScore,mulScore, repetWeaponNode, redNodeCount, blueNodeCount + ,yellowNodeCount,mostNodeCount,leastNodeCount,allNodeCount,drawCard,everyRedNodeAddScore,everyYellowNodeAddScore,everyBlueNodeAddScore}; + + public static readonly HashSet PlayerAdvancedResultSet = new HashSet { addScore,mulScore, repetWeaponNode + ,mostNodeCount,allNodeCount,isIgnoreCondition,everyRedNodeAddScore,everyYellowNodeAddScore,everyBlueNodeAddScore}; + + } + + public static class WeaponNodeLevel + { + public const string Basic = "Basic"; + public const string Elementary = "Elementary"; + public const string Intermediate = "Intermediate"; + public const string Advanced = "Advanced"; } public static class DomainFunction diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/Weapon/WeaponManager.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/Weapon/WeaponManager.cs index e0197b19..b3654553 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/Weapon/WeaponManager.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/Weapon/WeaponManager.cs @@ -260,6 +260,307 @@ public class WeaponManager : Singleton return gem; } + public GameObject getRandomWeaponNodeForPlayerWithLevel(string level) + { + GameObject gem = Instantiate(Resources.Load(Name.WeaponNode.PrefabPath + Name.WeaponNode.PrefabName)); + string condition = ""; + switch (level) + { + case Name.WeaponNodeLevel.Basic: + condition= MathTool.GetRandomElements(Name.WeaponNodeCondition.PlayerBasicConditionSet, 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Elementary: + condition = MathTool.GetRandomElements(Name.WeaponNodeCondition.PlayerElementaryConditionSet, 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + condition = MathTool.GetRandomElements(Name.WeaponNodeCondition.PlayerIntermediateConditionSet, 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + condition = MathTool.GetRandomElements(Name.WeaponNodeCondition.PlayerAdvancedConditionSet, 1).ElementAt(0); + break; + } + + string conditionValue = ""; + List nodesMark =new List(); + List nodesColor = new List(); + string result = ""; + switch (level) + { + case Name.WeaponNodeLevel.Basic: + result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Elementary: + result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); + break; + } + + string resultValue = ""; + conditionValue = getConditionValueWithLevel(level, condition, ref nodesMark, ref nodesMark); + resultValue = getResultValueWithLevel(level, result, condition, conditionValue); + WeaponNode weaponNode = gem.GetComponent(); + weaponNode.result = result; + weaponNode.resultValue = resultValue; + weaponNode.condition = condition; + weaponNode.conditionValue = conditionValue; + weaponNode.nodesMark = nodesMark.ToArray(); + weaponNode.nodesColor = nodesColor.ToArray(); + return gem; + } + + + public string getConditionValueWithLevel(string level,string condition,ref List nodesMark, ref List nodesColor) + { + string conditionValue = ""; + switch (condition) + { + case Name.WeaponNodeCondition.position: + conditionValue = MathTool.GetRandomElements(new HashSet { "0", "1", "2", "3", "4" }, 1).ElementAt(0); + break; + case Name.WeaponNodeCondition.positionUnused: + conditionValue = MathTool.GetRandomElements(new HashSet { "0", "1", "2", "3", "4" }, 1).ElementAt(0); + break; + case Name.WeaponNodeCondition.positionUsed: + conditionValue = MathTool.GetRandomElements(new HashSet { "0", "1", "2", "3", "4" }, 1).ElementAt(0); + break; + case Name.WeaponNodeCondition.diffSettle: + conditionValue = Name.none; + break; + case Name.WeaponNodeCondition.usedCard: + switch (level) + { + case Name.WeaponNodeLevel.Basic: + conditionValue = MathTool.GetRandomElements(new HashSet { "1", "2", }, 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Elementary: + conditionValue = MathTool.GetRandomElements(new HashSet { "2", "3", }, 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + conditionValue = MathTool.GetRandomElements(new HashSet { "3", "4", "5" }, 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + conditionValue = MathTool.GetRandomElements(new HashSet { "4", "5" }, 1).ElementAt(0); + break; + } + break; + case Name.WeaponNodeCondition.threeColorDiffMoreThan: + conditionValue = MathTool.GetRandomElements(new HashSet { "3", "4", "5" }, 1).ElementAt(0); + break; + case Name.WeaponNodeCondition.everyNumNodeConvert: + conditionValue = MathTool.GetRandomElements(new HashSet { "7", "8", "9" }, 1).ElementAt(0); + switch (level) + { + case Name.WeaponNodeLevel.Basic: + conditionValue = MathTool.GetRandomElements(MathTool.GetTargetRange(3,5), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Elementary: + conditionValue = MathTool.GetRandomElements(MathTool.GetTargetRange(4, 6), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + conditionValue = MathTool.GetRandomElements(MathTool.GetTargetRange(5, 7), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + conditionValue = MathTool.GetRandomElements(MathTool.GetTargetRange(6, 8), 1).ElementAt(0); + break; + } + break; + case Name.WeaponNodeCondition.bombbomb: + conditionValue = Name.none; + break; + case Name.WeaponNodeCondition.node: + conditionValue = Name.none; + HashSet nodesA = new HashSet(); + switch (level) + { + case Name.WeaponNodeLevel.Basic: + nodesA= MathTool.GetRandomElements(new HashSet { "1_0", "-1_0", "0_1", "0_-1", "-1_1", "-1_-1" }, 2); + break; + case Name.WeaponNodeLevel.Elementary: + nodesA = MathTool.GetRandomElements(new HashSet { "1_0", "-1_0", "0_1", "0_-1", "-1_1", "-1_-1" }, 3); + break; + case Name.WeaponNodeLevel.Intermediate: + nodesA = MathTool.GetRandomElements(new HashSet { "1_0", "-1_0", "0_1", "0_-1", "-1_1", "-1_-1" }, 4); + break; + case Name.WeaponNodeLevel.Advanced: + nodesA = MathTool.GetRandomElements(new HashSet { "1_0", "-1_0", "0_1", "0_-1", "-1_1", "-1_-1" }, 5); + break; + } + nodesA.Add("0_0"); + nodesMark = nodesA.ToList(); + for (int i = 0; i < nodesA.Count; i++) + { + nodesColor.Add(MathTool.GetRandomElements(new HashSet { 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 { Name.Color.Red, Name.Color.Blue, Name.Color.Yellow }, 1).ElementAt(0)) + .Append(MathTool.GetRandomElements(new HashSet { "<", ">" }, 1).ElementAt(0)); + string part3 = ""; + switch (level) + { + case Name.WeaponNodeLevel.Basic: + part3 = MathTool.GetRandomElements(MathTool.GetTargetRange(3, 5), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Elementary: + part3 = MathTool.GetRandomElements(MathTool.GetTargetRange(5, 8), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + part3 = MathTool.GetRandomElements(MathTool.GetTargetRange(9, 12), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + part3 = MathTool.GetRandomElements(MathTool.GetTargetRange(14, 18), 1).ElementAt(0); + break; + } + sb.Append(part3); + condition = sb.ToString(); + break; + } + return conditionValue; + } + + public string getResultValueWithLevel(string level, string result,string condition,string conditionValue) + { + string resultValue = ""; + switch (result) + { + case Name.WeaponNodeFunction.addScore: + switch (level) + { + case Name.WeaponNodeLevel.Basic: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(5, 7), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Elementary: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(8, 12), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(13, 18), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(23, 30), 1).ElementAt(0); + break; + } + break; + case Name.WeaponNodeFunction.mulScore: + switch (level) + { + case Name.WeaponNodeLevel.Intermediate: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(1, 3), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(4, 6), 1).ElementAt(0); + break; + } + break; + case Name.WeaponNodeFunction.repetWeaponNode: + resultValue = MathTool.GetRandomElements(new HashSet { "0", "1", "2", "3", "4" }, 1).ElementAt(0); + break; + case Name.WeaponNodeFunction.redNodeCount: + case Name.WeaponNodeFunction.blueNodeCount: + case Name.WeaponNodeFunction.yellowNodeCount: + case Name.WeaponNodeFunction.mostNodeCount: + case Name.WeaponNodeFunction.leastNodeCount: + switch (level) + { + case Name.WeaponNodeLevel.Basic: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(3, 7), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Elementary: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(6, 12), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(14, 18), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(20, 25), 1).ElementAt(0); + break; + } + break; + case Name.WeaponNodeFunction.allNodeCount: + switch (level) + { + case Name.WeaponNodeLevel.Basic: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(2, 3), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Elementary: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(4, 6), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(7, 9), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(10, 12), 1).ElementAt(0); + break; + } + break; + case Name.WeaponNodeFunction.drawCard: + switch (level) + { + case Name.WeaponNodeLevel.Elementary: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(1, 2), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(2, 3), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(4, 5), 1).ElementAt(0); + break; + } + break; + 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; + } + break; + case Name.NodeItem.Volcano: + 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, 2), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Intermediate: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(3, 3), 1).ElementAt(0); + break; + case Name.WeaponNodeLevel.Advanced: + resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(4, 4), 1).ElementAt(0); + break; + } + break; + case Name.WeaponNodeFunction.isIgnoreCondition: + HashSet targets= MathTool.GenerateIntegerSet(0, 4); + if(condition.Equals(Name.WeaponNodeCondition.positionUnused)|| condition.Equals(Name.WeaponNodeCondition.positionUsed)) + { + targets.Remove(conditionValue); + } + resultValue = MathTool.GetRandomElements(targets, 1).ElementAt(0); + break; + } + return resultValue; + } + public void loadEnemyWeaponNode(int position,GameObject weaponNode) {