我试图弄清楚这一点,但一直没能做到。无法将类型隐式转换int
为BaseStats.Stat
using UnityEngine;
using System.Collections;
public class BaseStats : MonoBehaviour {
public struct baseStats {
public string name;
public int level;
public Stat hp;
public int ap;
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 exp;
public baseStats(string Name, int Level, int Hp, int Ap, 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 Exp) {
name = Name;
level = Level;
hp = Hp;
ap = Ap;
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;
exp = Exp;
}
}
public class Stat {
int current;
int max;
}
void Start() {
baseStats mainChar = new baseStats(
"Truth",
99,
9999,
999,
255,
255,
255,
255,
255,
255,
255,
255,
255,
100,
255,
255,
100,
7777777);
print(mainChar.level);
}
}
我试图让 HP 达到电流和最大值,这就是教程教我的方式。不幸的是,本教程是在统一脚本中,而我想用 c# 和