【问题标题】:Whats wrong with levelBaseStart?levelBaseStart 有什么问题?
【发布时间】:2013-04-07 05:07:31
【问题描述】:
using UnityEngine;
using System.Collections;

public class PlayerStats : MonoBehaviour {
[System.Serializable]
public class BaseStats {

    string name;
    int currentLevel;
    int targetLevel = currentLevel + 1;
    int currentHp;
    int maxHp;
    int currentAp;
    int maxAp;

    int strength;
    int toughness;
    int agility;
    int intelligence;
    int willPower;
    int luck;

    int attack;
    int hitPercentage;
    int defence;
    int defPercentage;
    int powerAttack;
    int powerDefence;
    int powerDefPercentage;

    int totalExp;
    int totalExpNeeded;
    int expTilLevel;
    int expMod;
    int expBase;
    int levelBaseStart = [(targetLevel- 2 ) / 10] * 10 + 2;

}

void AddExp(int experience){


// Update is called once per frame
void Update () {

}
}

我认为 [ ] 将数字取为整数,如果不是这样,我该怎么做?我正在制作 exp 变量以在我的方程式中使用来计算达到某个水平所需的总 exp。提前致谢!!!

【问题讨论】:

标签: c# operators unity3d


【解决方案1】:

我从来没有听说过 [] 被用于将数字变成整数...

您可以使用Math.Floor((targetLevel- 2 ) / 10) 获得整数 http://msdn.microsoft.com/en-GB/library/e0b5f0xb.aspx

【讨论】:

  • 我要写完这篇文章,然后用错误重新发布,Math.Floor 是我需要的,不过谢谢!!
猜你喜欢
  • 2021-06-09
  • 2014-08-12
  • 2010-12-23
  • 2010-10-24
  • 2011-10-04
  • 2011-10-08
  • 2011-03-20
相关资源
最近更新 更多