2013-04-15 40 views
0
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。感谢高级!!!levelBaseStart有什么问题?

+0

Math.Floor或Math.Ceiling? - http://msdn.microsoft.com/en-GB/library/e0b5f0xb.aspx – Sayse

+0

根据需要使用Math.Ceiling(value)或Math.Floor(value)。 –

回答

3

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

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

+0

你也许希望将这种事情也移到构造函数中.. – Sayse

+0

即时完成写这个位然后重新发布它的错误,Math.Floor是我需要的,虽然谢谢! – user2279258