2013-04-15 39 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