levelBaseStart有什么问题?

时间:2013-04-15 06:44:25

标签: c# operators unity3d

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。谢谢你提前!!!

1 个答案:

答案 0 :(得分:3)

我从来没有听说[]被用来制作一个整数的数字......

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