void Start() { //创建种类,生命值填0表示从父类继承。 Breed troll = new Breed(null, 25, "The troll hits you!"); Breed trollArcher = new Breed(troll, 0, "The troll archer fires an arrow!"); Breed trollWizard = new Breed(troll, 0, "The troll wizard casts a spell on you!"); //通过种类创建monster对象 Monster trollMonster = troll.NewMonster(); trollMonster.ShowAttack(); Monster trollArcherMonster = trollArcher.NewMonster(); trollArcherMonster.ShowAttack(); Monster trollWizardMonster = trollWizard.NewMonster(); trollWizardMonster.ShowAttack(); }
void Start() { //Create a category, fill with a life value of 0 to indicate inheritance from the parent category. Breed troll = new Breed(null, 25, "The troll hits you!"); Breed trollArcher = new Breed(troll, 0, "The troll archer fires an arrow!"); Breed trollWizard = new Breed(troll, 0, "The troll wizard casts a spell on you!"); //Create monster objects by category Monster trollMonster = troll.NewMonster(); trollMonster.ShowAttack(); Monster trollArcherMonster = trollArcher.NewMonster(); trollArcherMonster.ShowAttack(); Monster trollWizardMonster = trollWizard.NewMonster(); trollWizardMonster.ShowAttack(); }