尝试使用统一扩展的编辑器窗口创建项目创建器工具。我得到了数千种可能的switch语句检查。而且我几乎可以肯定,我正在努力地做到这一点。编辑:我发现了这个问题,但是我不确定还是可以帮助我(我的英语不太好)。 Multiple cases in switch statement 这些是仅适用于整数还是我可以在我的情况下使用它。如果有人可以解释会很好。谢谢。 这是我的代码示例:
switch (tempItem.damageTypes)
{
case DamageTypes.PHYSICAL:
case DamageTypes.PHYSICAL | DamageTypes.Critical:
case DamageTypes.Magical:
case DamageTypes.True:
switch (tempItem.pasiveType)
{
case PasiveType.PHYSICAL_DAMAGE:
case PasiveType.PHYSICAL_DAMAGE | PasiveType.MOVEMENT_SPEED
PasiveType.ATTACK_SPEED:
case PasiveType.PHYSICAL_DAMAGE | PasiveType.ATTACK_SPEED:
case PasiveType.ATTACK_SPEED:
case PasiveType.ATTACK_SPEED | PasiveType.MOVEMENT_SPEED:
if (itemoPrefabas.GetComponent<Itemspasive>() == null)
itemoPrefabas.AddComponent<Itemspasive>();
if (itemoPrefabas.GetComponent<ItemCoolDown>() == null)
itemoPrefabas.AddComponent<ItemCoolDown>();
break;
}
break;
}
switch (tempItem.pasiveType)
{
case PasiveType.ARMOR_PENETRATION:
case PasiveType.CITICAL_DAMAGE:
case PasiveType.COOLDOWN_REDUCE:
case PasiveType.CRIT_CHANCE:
case PasiveType.DEFENCIVE:
case PasiveType.HEALING:
case PasiveType.INCREASING_HEALTH:
case PasiveType.LIFE_STEAL:
case PasiveType.MAGICAL_DAMAGE:
case PasiveType.MAGIC_PENETRATION:
case PasiveType.MOVEMENT_SPEED:
case PasiveType.PHYSICAL_DAMAGE:
case PasiveType.REDUCE_HEALING:
case PasiveType.TRUE_DAMAGE:
if (itemoPrefabas.GetComponent<Itemspasive>() == null)
itemoPrefabas.AddComponent<Itemspasive>();
break;
}
}
void AddComponentsByChoosenTypeDefensive(GameObject itemoPrefabas)
{
var tempItem = ItemCreator.S_item;
switch (tempItem.defensiveTypes)
{
case DefensiveTypes.ARMORS:
case DefensiveTypes.INCREACED_HEALING:
case DefensiveTypes.MAGIC_RESIST:
case DefensiveTypes.REDUCE_CRIT_DAMAGE:
case DefensiveTypes.SLOW_ATTACKING_SPEED:
case DefensiveTypes.TENACITY:
// cia dar nieko nera!
break;
}
}