|
|
|
@ -7,20 +7,20 @@ using UnityEngine; |
|
|
|
|
|
|
|
public class WeaponManager : Singleton<WeaponManager> |
|
|
|
{ |
|
|
|
[Header("控制是否进行武器结算")] |
|
|
|
[Header("�����Ƿ������������")] |
|
|
|
public bool isWeaponSettle; |
|
|
|
|
|
|
|
[Header ("武器数据组件")] |
|
|
|
//玩家武器节点
|
|
|
|
[Header("�����������")] |
|
|
|
//��������ڵ�
|
|
|
|
/*public List<WeaponNode> playerWeaponNodeList = new List<WeaponNode>(); |
|
|
|
//怪物武器节点
|
|
|
|
//���������ڵ�
|
|
|
|
public List<WeaponNode> enemyWeaponNodeList = new List<WeaponNode>();*/ |
|
|
|
|
|
|
|
public Weapon playerUsingWeapon; |
|
|
|
|
|
|
|
public EnemyWeapon enemyUsingWeapon; |
|
|
|
|
|
|
|
public bool isMapChange=true; |
|
|
|
public bool isMapChange = true; |
|
|
|
|
|
|
|
public bool isWeaponNodeChange = true; |
|
|
|
|
|
|
|
@ -32,13 +32,13 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
private void Start() |
|
|
|
{ |
|
|
|
DontDestroyOnLoad(this.gameObject); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void Update() |
|
|
|
{ |
|
|
|
if (isWeaponSettle == true ) |
|
|
|
if (isWeaponSettle == true) |
|
|
|
{ |
|
|
|
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); |
|
|
|
stopwatch.Start(); |
|
|
|
@ -48,24 +48,24 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
stopwatch.Stop(); |
|
|
|
enemyUsingWeapon.SettleEnemyWeapon(enemyWeaponNodeList); |
|
|
|
isMapChange = false; |
|
|
|
isWeaponNodeChange =false; |
|
|
|
isWeaponNodeChange = false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (stopwatch.ElapsedMilliseconds>100) |
|
|
|
|
|
|
|
if (stopwatch.ElapsedMilliseconds > 100) |
|
|
|
{ |
|
|
|
Debug.LogWarning($"性能警告!耗时 {stopwatch.ElapsedMilliseconds}ms"); |
|
|
|
Debug.LogWarning($"���ܾ��棡��ʱ {stopwatch.ElapsedMilliseconds}ms"); |
|
|
|
} |
|
|
|
|
|
|
|
if(stopwatch.ElapsedMilliseconds>10) |
|
|
|
if (stopwatch.ElapsedMilliseconds > 10) |
|
|
|
{ |
|
|
|
Debug.LogWarning($"性能警告!耗时 {stopwatch.ElapsedMilliseconds}ms"); |
|
|
|
Debug.LogWarning($"���ܾ��棡��ʱ {stopwatch.ElapsedMilliseconds}ms"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//SettleWeaponNode();
|
|
|
|
//SettleEnemyWeaponNode();
|
|
|
|
} |
|
|
|
@ -114,30 +114,30 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
FadeMode(); |
|
|
|
} |
|
|
|
} |
|
|
|
public void ShowMode()//展示隐藏的功能
|
|
|
|
public void ShowMode()//չʾ���صĹ���
|
|
|
|
{ |
|
|
|
isWeaponSettle= true; |
|
|
|
isWeaponSettle = true; |
|
|
|
|
|
|
|
enemyWeaponNodeList.gameObject.SetActive (true); |
|
|
|
enemyWeaponNodeList.gameObject.SetActive(true); |
|
|
|
|
|
|
|
playerUsingWeapon = new Weapon(); |
|
|
|
enemyUsingWeapon = new EnemyWeapon(); |
|
|
|
} |
|
|
|
public void FadeMode()//非战斗界面隐藏功能
|
|
|
|
public void FadeMode()//��ս���������ع���
|
|
|
|
{ |
|
|
|
isWeaponSettle = false; |
|
|
|
|
|
|
|
enemyWeaponNodeList .gameObject .SetActive(false); |
|
|
|
enemyWeaponNodeList.gameObject.SetActive(false); |
|
|
|
|
|
|
|
foreach (Transform transform in playerWeaponNodeList) |
|
|
|
{ |
|
|
|
if(transform .childCount >0) |
|
|
|
if (transform.childCount > 0) |
|
|
|
{ |
|
|
|
WeaponNode weaponNode = transform.GetChild(0).GetComponent<WeaponNode>(); |
|
|
|
if (weaponNode.enableVFX != null) |
|
|
|
weaponNode.enableVFX.SetActive(false); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
foreach (Transform transform in enemyWeaponNodeList) |
|
|
|
{ |
|
|
|
@ -147,7 +147,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
if (weaponNode.enableVFX != null) |
|
|
|
weaponNode.enableVFX.SetActive(false); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -155,15 +155,15 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
{ |
|
|
|
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 conditionValue = ""; |
|
|
|
string[] nodesMark = new string[4]; |
|
|
|
string[] nodesColor = new string[4]; |
|
|
|
string result = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerResultSet, 1).ElementAt(0); |
|
|
|
string resultValue=""; |
|
|
|
string resultValue = ""; |
|
|
|
switch (condition) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeCondition.position: |
|
|
|
conditionValue= MathTool.GetRandomElements(new HashSet<string> {"0","1","2","3","4" }, 1).ElementAt(0); |
|
|
|
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); |
|
|
|
@ -172,13 +172,13 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "0", "1", "2", "3", "4" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.diffSettle: |
|
|
|
conditionValue=Name.none; |
|
|
|
conditionValue = Name.none; |
|
|
|
break; |
|
|
|
case Name.WeaponNodeCondition.usedCard: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "1", "2", "3", "4", "5" }, 1).ElementAt(0); |
|
|
|
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); |
|
|
|
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); |
|
|
|
@ -190,7 +190,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
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(); |
|
|
|
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) |
|
|
|
@ -202,16 +202,16 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
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(); |
|
|
|
condition = sb.ToString(); |
|
|
|
break; |
|
|
|
} |
|
|
|
switch (result) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeFunction.addScore: |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(7, 12), 1).ElementAt(0); |
|
|
|
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); |
|
|
|
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); |
|
|
|
@ -250,7 +250,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
resultValue = MathTool.GetRandomElements(MathTool.GenerateIntegerSet(1, 2), 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
WeaponNode weaponNode=gem.GetComponent<WeaponNode>(); |
|
|
|
WeaponNode weaponNode = gem.GetComponent<WeaponNode>(); |
|
|
|
weaponNode.result = result; |
|
|
|
weaponNode.resultValue = resultValue; |
|
|
|
weaponNode.condition = condition; |
|
|
|
@ -267,7 +267,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
condition= MathTool.GetRandomElements(Name.WeaponNodeCondition.PlayerBasicConditionSet, 1).ElementAt(0); |
|
|
|
condition = MathTool.GetRandomElements(Name.WeaponNodeCondition.PlayerBasicConditionSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Elementary: |
|
|
|
condition = MathTool.GetRandomElements(Name.WeaponNodeCondition.PlayerElementaryConditionSet, 1).ElementAt(0); |
|
|
|
@ -279,9 +279,9 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
condition = MathTool.GetRandomElements(Name.WeaponNodeCondition.PlayerAdvancedConditionSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string conditionValue = ""; |
|
|
|
List<string> nodesMark =new List<string>(); |
|
|
|
List<string> nodesMark = new List<string>(); |
|
|
|
List<string> nodesColor = new List<string>(); |
|
|
|
string result = ""; |
|
|
|
switch (level) |
|
|
|
@ -299,7 +299,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
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); |
|
|
|
@ -313,8 +313,294 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
return gem; |
|
|
|
} |
|
|
|
|
|
|
|
public GameObject getRandomWeaponNodeForPlayerWithLevelDiff(int levelDiff) |
|
|
|
{ |
|
|
|
GameObject gem = Instantiate(Resources.Load<GameObject>(Name.WeaponNode.PrefabPath + Name.WeaponNode.PrefabName)); |
|
|
|
string condition = ""; |
|
|
|
HashSet<string> resultSet = new HashSet<string>(); |
|
|
|
HashSet<string> conditiontSet = new HashSet<string>(); |
|
|
|
string conditionLevel = ""; |
|
|
|
string resultLevel = ""; |
|
|
|
switch (levelDiff) |
|
|
|
{ |
|
|
|
case -2: |
|
|
|
case -1: |
|
|
|
case 0: |
|
|
|
conditionLevel = MathTool.GetRandomElements(Name.WeaponNodeLevel.WeaponNodeLevelSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
conditionLevel = MathTool.GetRandomElements(new HashSet<string> { Name.WeaponNodeLevel.Elementary, Name.WeaponNodeLevel.Basic, Name.WeaponNodeLevel.Intermediate }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
conditionLevel = MathTool.GetRandomElements(new HashSet<string> { Name.WeaponNodeLevel.Elementary, Name.WeaponNodeLevel.Basic }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
conditionLevel = Name.WeaponNodeLevel.Basic; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
switch (conditionLevel) |
|
|
|
{ |
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
switch (conditionLevel) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
switch (levelDiff) |
|
|
|
{ |
|
|
|
case 0: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Elementary: |
|
|
|
switch (levelDiff) |
|
|
|
{ |
|
|
|
case -1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 0: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Intermediate: |
|
|
|
switch (levelDiff) |
|
|
|
{ |
|
|
|
case -2: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case -1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 0: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Advanced: |
|
|
|
switch (levelDiff) |
|
|
|
{ |
|
|
|
case -3: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case -2: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case -1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 0: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string conditionValue = ""; |
|
|
|
List<string> nodesMark = new List<string>(); |
|
|
|
List<string> nodesColor = new List<string>(); |
|
|
|
string result = ""; |
|
|
|
switch (resultLevel) |
|
|
|
{ |
|
|
|
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; |
|
|
|
|
|
|
|
public string getConditionValueWithLevel(string level,string condition,ref List<string> nodesMark, ref List<string> nodesColor) |
|
|
|
} |
|
|
|
|
|
|
|
string resultValue = ""; |
|
|
|
conditionValue = getConditionValueWithLevel(conditionLevel, condition, ref nodesMark, ref nodesMark); |
|
|
|
resultValue = getResultValueWithLevel(resultLevel, result, condition, conditionValue); |
|
|
|
WeaponNode weaponNode = gem.GetComponent<WeaponNode>(); |
|
|
|
weaponNode.result = result; |
|
|
|
weaponNode.resultValue = resultValue; |
|
|
|
weaponNode.condition = condition; |
|
|
|
weaponNode.conditionValue = conditionValue; |
|
|
|
weaponNode.nodesMark = nodesMark.ToArray(); |
|
|
|
weaponNode.nodesColor = nodesColor.ToArray(); |
|
|
|
return gem; |
|
|
|
} |
|
|
|
|
|
|
|
public GameObject getRandomWeaponNodeForPlayerWithLevelDiffAndConditionlevel(int levelDiff,string conditionLevel) |
|
|
|
{ |
|
|
|
GameObject gem = Instantiate(Resources.Load<GameObject>(Name.WeaponNode.PrefabPath + Name.WeaponNode.PrefabName)); |
|
|
|
string condition = ""; |
|
|
|
HashSet<string> resultSet = new HashSet<string>(); |
|
|
|
HashSet<string> conditiontSet = new HashSet<string>(); |
|
|
|
string resultLevel = ""; |
|
|
|
switch (conditionLevel) |
|
|
|
{ |
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
switch (conditionLevel) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
switch (levelDiff) |
|
|
|
{ |
|
|
|
case 0: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Elementary: |
|
|
|
switch (levelDiff) |
|
|
|
{ |
|
|
|
case -1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 0: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Intermediate: |
|
|
|
switch (levelDiff) |
|
|
|
{ |
|
|
|
case -2: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case -1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 0: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Advanced: |
|
|
|
switch (levelDiff) |
|
|
|
{ |
|
|
|
case -3: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerBasicResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case -2: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerElementaryResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case -1: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerIntermediateResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case 0: |
|
|
|
resultLevel = MathTool.GetRandomElements(Name.WeaponNodeFunction.PlayerAdvancedResultSet, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string conditionValue = ""; |
|
|
|
List<string> nodesMark = new List<string>(); |
|
|
|
List<string> nodesColor = new List<string>(); |
|
|
|
string result = ""; |
|
|
|
switch (resultLevel) |
|
|
|
{ |
|
|
|
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(conditionLevel, condition, ref nodesMark, ref nodesMark); |
|
|
|
resultValue = getResultValueWithLevel(resultLevel, result, condition, conditionValue); |
|
|
|
WeaponNode weaponNode = gem.GetComponent<WeaponNode>(); |
|
|
|
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<string> nodesMark, ref List<string> nodesColor) |
|
|
|
{ |
|
|
|
string conditionValue = ""; |
|
|
|
switch (condition) |
|
|
|
@ -335,16 +621,16 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "1", "2", }, 1).ElementAt(0); |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "1", "2", }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Elementary: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "2", "3", }, 1).ElementAt(0); |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "2", "3", }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Intermediate: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "3", "4", "5" }, 1).ElementAt(0); |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "3", "4", "5" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Advanced: |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "4", "5" }, 1).ElementAt(0); |
|
|
|
conditionValue = MathTool.GetRandomElements(new HashSet<string> { "4", "5" }, 1).ElementAt(0); |
|
|
|
break; |
|
|
|
} |
|
|
|
break; |
|
|
|
@ -356,7 +642,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
conditionValue = MathTool.GetRandomElements(MathTool.GetTargetRange(3,5), 1).ElementAt(0); |
|
|
|
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); |
|
|
|
@ -378,7 +664,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
switch (level) |
|
|
|
{ |
|
|
|
case Name.WeaponNodeLevel.Basic: |
|
|
|
nodesA= MathTool.GetRandomElements(new HashSet<string> { "1_0", "-1_0", "0_1", "0_-1", "-1_1", "-1_-1" }, 2); |
|
|
|
nodesA = MathTool.GetRandomElements(new HashSet<string> { "1_0", "-1_0", "0_1", "0_-1", "-1_1", "-1_-1" }, 2); |
|
|
|
break; |
|
|
|
case Name.WeaponNodeLevel.Elementary: |
|
|
|
nodesA = MathTool.GetRandomElements(new HashSet<string> { "1_0", "-1_0", "0_1", "0_-1", "-1_1", "-1_-1" }, 3); |
|
|
|
@ -425,7 +711,7 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
return conditionValue; |
|
|
|
} |
|
|
|
|
|
|
|
public string getResultValueWithLevel(string level, string result,string condition,string conditionValue) |
|
|
|
public string getResultValueWithLevel(string level, string result, string condition, string conditionValue) |
|
|
|
{ |
|
|
|
string resultValue = ""; |
|
|
|
switch (result) |
|
|
|
@ -550,8 +836,8 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
} |
|
|
|
break; |
|
|
|
case Name.WeaponNodeFunction.isIgnoreCondition: |
|
|
|
HashSet<string> targets= MathTool.GenerateIntegerSet(0, 4); |
|
|
|
if(condition.Equals(Name.WeaponNodeCondition.positionUnused)|| condition.Equals(Name.WeaponNodeCondition.positionUsed)) |
|
|
|
HashSet<string> targets = MathTool.GenerateIntegerSet(0, 4); |
|
|
|
if (condition.Equals(Name.WeaponNodeCondition.positionUnused) || condition.Equals(Name.WeaponNodeCondition.positionUsed)) |
|
|
|
{ |
|
|
|
targets.Remove(conditionValue); |
|
|
|
} |
|
|
|
@ -562,9 +848,9 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void loadEnemyWeaponNode(int position,GameObject weaponNode) |
|
|
|
public void loadEnemyWeaponNode(int position, GameObject weaponNode) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
Transform weaponSlot = enemyWeaponNodeList.GetChild(position); |
|
|
|
if (weaponSlot != null) |
|
|
|
{ |
|
|
|
@ -574,29 +860,29 @@ public class WeaponManager : Singleton<WeaponManager> |
|
|
|
weaponNode.transform.localEulerAngles = Vector3.zero; |
|
|
|
weaponNode.transform.localScale = Vector3.one; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void ClearAllChildren(Transform parent) |
|
|
|
{ |
|
|
|
// 创建临时列表存储子物体(避免在循环中修改集合)
|
|
|
|
// ������ʱ�б��洢�����壨������ѭ�����ļ��ϣ�
|
|
|
|
List<GameObject> children = new List<GameObject>(); |
|
|
|
|
|
|
|
// 收集所有子物体
|
|
|
|
// �ռ�����������
|
|
|
|
foreach (Transform child in parent) |
|
|
|
{ |
|
|
|
children.Add(child.gameObject); |
|
|
|
} |
|
|
|
|
|
|
|
// 删除所有子物体
|
|
|
|
// ɾ������������
|
|
|
|
foreach (GameObject child in children) |
|
|
|
{ |
|
|
|
// 根据环境选择销毁方式
|
|
|
|
// ���ݻ���ѡ�����ٷ�ʽ
|
|
|
|
if (Application.isPlaying) |
|
|
|
{ |
|
|
|
Destroy(child); |
|
|
|
} |
|
|
|
else // 编辑器模式下
|
|
|
|
else // �༭��ģʽ��
|
|
|
|
{ |
|
|
|
DestroyImmediate(child); |
|
|
|
} |
|
|
|
|