大家好,祝你有个愉快的一天。我正在尝试创建一个类似于Asssassin的Creed Syndicate Upgrade系统的系统,如下图所示,我从google中看到。
https://i.stack.imgur.com/30prp.jpg
基本上,您可以进行升级,从上到下进行升级,每次购买新升级时,前者都会被替换或保留。示例3升级可以是以下内容:
当你购买Scavenger II时,它将取代Scavenger I(它将有更多机会掠夺特定物品),但是当你购买Looter的第3升级时,它将不会取代Scavenger。所以基本上你会让Scavenger II + Looter都活跃起来。
我的代码如下:
public static enum Unlock
{
/** Notoriety */
SLEIGHT (1, 30, "Your sleight hands does not let any evidence behind, you get 30% less karma for your kills"),
NOTORIETY (2, true , "Gaurds will make blind eyes and won't hunt you down upon a pk action."),
/** Market */
BARGAIN (3, 7, "You are a good bargain, anything you buy from any NPC will now cost 7% less."),
TRADER (3, 14, "You achieved to be a good trader, market owners make you 14% discount from any NPC."),
MARKETING (3, 25, "You own the market, anything you buy from any NPC will now cost 25% less."),
/** Item */
LOOTER(4, 7, "You became experienced in looting, you have now 7% chance to loot double adena"),
TREASURE_HUNTER(4, 14, "You became advanced adventurer, you have now 14% chance to loot double double"),
ADVENTURER(4, 21, "You became extremely good in looting items, you have now 21% chance to loot double double"),
/** Couple */
LOVER (5, true, "There is a huge bond between you and your partner, upon death your fiance get max healed."),
FAITHFUL (5, true, "Your bond survived over the years. Upon death your fiance will receive beyond imagination support for few seconds."),
/** Death */
TRICKSTER (7, 0, "You can trick the death, you no longer receive death penalty upon deaths."),
TRICKSTER_II (7, 10, "You can trick the death, your items has 10% less chance to drop upon death."),
TRICKSTER_III (7, 25, "You can trick the death, your items has 25% less chance to drop upon death."),
TRICKSTER_IV (7, 50, "You can trick the death, your items has 50% less chance to drop upon death.");
private final int _groupId;
private final Object _value;
private final String _desc;
private Unlock(final int groupId, final Object value, final String desc)
{
_groupId = groupId;
_value = value;
_desc = desc;
}
public int getId()
{
return _groupId;
}
public final Object getValue()
{
return _value;
}
public final String getDescription()
{
return _desc;
}
}
所以我做了一个枚举,我不得不说我是枚举的忠实粉丝因为它使代码可读。我想要的是如何使我的代码像数据报一样的想法。 现在我在我想要应用升级的每种方法中调用我的代码:
itemDropPercent = itemDropPercent - (int) player.getUnlockables().getUnlockable(UnlockAction.DEATH, 0);
如果播放器没有特定升级,则0是默认值。 UnlockAction是我做的另一个枚举:
public static enum UnlockAction
{
MARKET (Unlock.MARKETING, Unlock.TRADER, Unlock.BARGAIN),
COUPLE (Unlock.FAITHFUL, Unlock.LOVER),
DEATH(Unlock.TRICKSTER_IV, Unlock.TRICKSTER_III, Unlock.TRICKSTER_II, Unlock.TRICKSTER),
ITEM(Unlock.LOOTER);
final Unlock[] _values;
private UnlockAction(final Unlock ...values)
{
_values = values;
}
}
就像列表一样,一个接一个地解锁。 那么我怎么能做到这一点才能使动态系统升级呢?
非常感谢你的时间。