等级计算

发布于 2025-01-12 00:12:00 字数 584 浏览 0 评论 0原文

不知怎的,我想不出一个实际上很简单的问题的解决方案。 这是一个关卡系统,我需要一种非常简单的公式,但我想不出来。

我根据经验点计算等级,例如,1级需要1.000 EXP,2级需要3.000 EXP,3级需要6.000 EXP,依此类推。

希望这是可以理解的。

唯一的问题是它不会持续上升。 例如,对于第 2 级,3,000 EXP 是由于您在第 1 级已有 1,000 EXP,然后添加 2,000 EXP(第 2 级)。在第 3 级,它是 6,000,因为第 1 级有 1,000 个,第 2 级有 2,000 个,然后第 3 级还有 3,000 个。

如果你更进一步,例如,第 5 级需要 5,000 EXP,才能从第 1 级获得4到5,在此之前你还有其他级别的经验。这意味着您总共需要 15,000 EXP 才能达到第 5 级。

以下是各个级别及其所需 EXP 的列表:

Level 2 -> 3.000
Level 3 -> 6.000
Level 4 -> 10.000
Level 5 -> 15.000
Level 6 -> 21.000
...
Level 10 -> 55.000

somehow I can't think of a solution to a problem that is actually quite easy.
It's about a level system where I need a kind of formula that is very simple but I can't think of it.

I calculate the level from the experience points and there you need e.g. for level 1 1.000 EXP, for level 2 3.000 EXP, level 3 6.000 EXP and so on.

Hopefully it is understandable.

The only problem is that it doesn't go up consistently.
So for level 2, for example, the 3,000 EXP result from the fact that you already have 1,000 for level 1 and then 2,000 EXP are added (level 2). And at level 3 it is 6,000 because of the 1,000 from level 1, the 2,000 from level 2 and then another 3,000 for level 3.

If you take it further, you need 5,000 EXP for level 5, for example, just to get from level 4 to 5, and before that you still have the other EXP of the other levels. This means that you need a total of 15,000 EXP for level 5.

Here is a list with the levels and the EXP required for them:

Level 2 -> 3.000
Level 3 -> 6.000
Level 4 -> 10.000
Level 5 -> 15.000
Level 6 -> 21.000
...
Level 10 -> 55.000

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹿! 2025-01-19 00:12:00
int xp=500;

//list of xp land marks to level up[adjust them to your needs]
int[] checkPoints=
{
  0,2000,3000,6000
 ,10000,15000,21000,
 ,25000,30000,35000
 ,40000,45000,50000
 ,55000
};

int level=0;
for(int i=0;i<checkPoints.length-1;i++)
{
 /*
  if xp lies with this range then level=i
  example xp=11000 lies between 10000[i=4] && 15000[i=5]
  so level=4
 */
 if(xp>=checkPoints[i] && xp<=checkPoints[i+1])
 {
   level=i;
 }
}

System.out.println("You are level="+level);
int xp=500;

//list of xp land marks to level up[adjust them to your needs]
int[] checkPoints=
{
  0,2000,3000,6000
 ,10000,15000,21000,
 ,25000,30000,35000
 ,40000,45000,50000
 ,55000
};

int level=0;
for(int i=0;i<checkPoints.length-1;i++)
{
 /*
  if xp lies with this range then level=i
  example xp=11000 lies between 10000[i=4] && 15000[i=5]
  so level=4
 */
 if(xp>=checkPoints[i] && xp<=checkPoints[i+1])
 {
   level=i;
 }
}

System.out.println("You are level="+level);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文