private static void TellTheStory(AbstractDragon dragon) { string name = dragon.GetName(); int speed = dragon.GetSpeed(); int strength = dragon.GetStrenght(); string element = dragon.GetElement(); Console.WriteLine(name + " the " + element + "dragon was one of them."); Console.WriteLine("Although still being young, he could travel " + speed + " leagues with one swipe of his mighty wings."); Console.WriteLine("He was the chosen one, who was foretold to collect all elements into one...\n"); Console.WriteLine("But for now he has to fight with his hydra brother Ezoeos. \n"); Console.WriteLine("Tail slash!"); if (dragon.GetRole("Air") != null) { Console.Write(((AirElementalDecorator)dragon.GetRole("Air")).WingFling()); } if (dragon.GetRole("Fire") != null) { Console.Write(((FireElementalDecorator)dragon.GetRole("Fire")).FireBreath()); } Console.WriteLine("Dragon bite!"); Console.Write("And Ezoeos has lost " + strength + " of his lives."); }
public override AbstractDragon DeleteRole(string element) { if (m_Element == element) { return(m_BaseDragon); } AbstractDragon role = m_BaseDragon.DeleteRole(element); if (role == null) { return(this); } m_BaseDragon = role; return(this); }
protected Decorator(AbstractDragon baseComponent) { m_BaseDragon = baseComponent; }