I have a Player Attributes class:
import UnityEngine class Stat (): public current as int public max as int class PlayerAttributes ( MonoBehaviour ): public Name as string public level as int public hp as Stat = Stat() public ep as Stat = Stat() public strength as int // How accurate and how much damage with melee attacks public dexterity as int // How accurate and how much damage with ranged attacks public vitality as int // How many hit points he has public power as int // How much damage his energy attacks deal public resistance as int // How much defense he has against energy attacks public agility as int public speed as int // How fast character attacks public meleeAtk as int public rangedAtk as int public defense as int public powerAtk as int public powerDef as int public initiative as single public exp as Stat = Stat() def SetInitialStats ( name as string, strength as int, dexterity as int, vitality as int, power as int, resistance as int, agility as int, speed as int, exp as int ): self.level = 1 self.Name = name self.strength = strength self.dexterity = dexterity self.vitality = vitality self.power = power self.resistance = resistance self.agility = agility self.speed = speed self.exp.max = self.level * (self.level + 1) * 500 AddExp(exp) def AddExp ( experience as int ): exp.current += experience while exp.current >= exp.max and level < 99: exp.current -= exp.max exp.max = level * (level + 1) * 500 level += 1 IncreaseStats() def IncreaseStats (): strength += 1 dexterity += 1 vitality += 1 power += 1 resistance += 1 agility += 1 speed += 1 meleeAtk = (level * 7) + strength rangedAtk = (level * 7) + dexterity defense = (level * 2) + agility powerAtk = (level * 7) + power powerDef = (level * 2) + resistance initiative = 20 + ((speed * level)/1500) hp.max = ((level * 5) + vitality) * 10 hp.current = hp.max ep.max = ((level * 5) + power) ep.current = ep.max
Jut anything simple really. Well I read in the docs to not use constructors with MonoBehaviour, but I try instantiating my variables with the Start() function which is SetInitialStats (...)
So In another script in the Start() function I call it up like this
Player = PlayerAttributes.SetInitialStats('Robo', 20, 21, 19, 20, 18, 22, 22, 57000)
I get the warning: ' An instance of type 'PlayerAttributes' is required to access non static member'
Not sure what else I can do to setup my beginning stats.
I got this to work I Unityscript which worked with a constructor without MonoBehaviour so I don't know where else to go from here. I would like to stay using Boo.