2013-04-15 4 views
0
using UnityEngine; 
using System.Collections; 

public class BaseStats : MonoBehaviour { 
[System.Serializable] 
public class baseStats { 
    public string name; 
    public int currentLevel; 
    public int targetLevel; 
    Stat currentHp = new Stat(); 
    public int maxHp; 
    public int currentAp; 
    public int maxAp; 

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

    public int attack; 
    public int hitPercentage; 
    public int defence; 
    public int evasionPercentage; 
    public int abilityAttack; 
    public int abilityDefence; 
    public int abilityDefencePercentage; 

    public int currentExp; 
    public int targetExp; 

     public baseStats(string Name, int CurrentLevel, int TargetLevel, Stat 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  EvasionPercentage, int AbilityAttack, int AbilityDefence, int  AbilityDefencePercentage, int  CurrentExp, int TargetExp) {  

     name = Name; 
     currentLevel = CurrentLevel; 
     targetLevel = TargetLevel; 
     currentHp = CurrentHp; 
     maxHp = MaxHp; 
     currentAp = CurrentAp; 
     maxAp = MaxAp; 

     strength = Strength; 
     toughness = Toughness; 
     agility = Agility; 
     intelligence = Intelligence; 
     willPower = WillPower; 
     luck = Luck; 

     attack = Attack; 
     hitPercentage = HitPercentage; 
     defence = Defence; 
     evasionPercentage = EvasionPercentage; 
     abilityAttack = AbilityAttack; 
     abilityDefence = AbilityDefence; 
     abilityDefencePercentage = AbilityDefencePercentage; 

     currentExp = CurrentExp; 
     targetExp = TargetExp; 

    } 
public class Stat{ 
    public int current; 
    public int max;} 
} 

public baseStats mainChar; 
void Start() { 

    mainChar = new baseStats(
     "Truth", 
     98, 
     99, 
     , 
     9999, 
     754, 
     999, 
     255, 
     255, 
     255, 
     255, 
     255, 
     255, 
     255, 
     255, 
     255, 
     100, 
     255, 
     255, 
     100, 
     7773473, 
     7777777); 

    print(mainChar.currentHp); 

} 

    } 

Это мой код, который пытался получить его там, где hp имеет выпадение в инспекторе тока и макс. Я слежу за rpg tut от повстанцев, если вы знаете об этом, проблема заключается в том, что он делает это в unitscript, и мне нужен мой в C#. Любая помощь будет оценена!Хотите, чтобы hp наследовал Stat и имеет ток и max вместо того, чтобы вручную создавать currenthp и maxhp?

+0

Что вы предполагаете делать с классом Stat? Кажется бесполезным в любом случае, вы можете поставить max и current в basestat –

ответ

0

Вы ищете что-то в этом роде?

Stat hp = new Stat() { current = currentHP, max = maxHP };

Ваш вопрос очень запутанный. Вы хотите, чтобы inherit Stat, но у вас нет класса HP, который может наследовать что-либо. Трудно понять, чего именно вы пытаетесь достичь.

+0

Извините, я пытался сделать это вместо того, чтобы делать currentHp и maxHp, что я мог бы просто сделать hp и получить максимальный и текущий из Stat. Я видел, как парень в tut делал это с помощью unitscript и пытался сделать это в C#. Спасибо, что ответили: D – user2279258