Inheritance: StaticObject, IResource
 public override void ExecuteCreateObjectCommand(string[] commandWords)
 {
     switch (commandWords[1])
     {
         case "knight":
             {
                 string name = commandWords[2];
                 Point position = Point.Parse(commandWords[3]);
                 int owner = int.Parse(commandWords[4]);
                 this.AddObject(new Knight(name, position, owner));
                 break;
             }
         case "giant":
             {
                 string name = commandWords[2];
                 Point position = Point.Parse(commandWords[3]);
                 this.AddObject(new Giant(name, position));
                 this.controllables.Add(new Giant(name, position));
                 break;
             }
         case "rock":
             {
                 Point position = Point.Parse(commandWords[3]);
                 int hitPoints = int.Parse(commandWords[2]);
                 Rock rock = new Rock(position, hitPoints);
                 this.AddObject(rock);
                 break;
             }
         case "ninja":
             {
                 string name = commandWords[2];
                 Point position = Point.Parse(commandWords[3]);
                 int owner = int.Parse(commandWords[4]);
                 Ninja ninja = new Ninja(name, position, owner);
                 this.AddObject(ninja);
                 break;
             }
             //TODO case "house"
         default: base.ExecuteCreateObjectCommand(commandWords);
             break;
     }
 }
Beispiel #2
0
 public virtual void ExecuteCreateObjectCommand(string[] commandWords)
 {
     switch (commandWords[1])
     {
         case "lumberjack":
             {
                 string name = commandWords[2];
                 Point position = Point.Parse(commandWords[3]);
                 int owner = int.Parse(commandWords[4]);
                 this.AddObject(new Lumberjack(name, position, owner));
                 break;
             }
         case "guard":
             {
                 string name = commandWords[2];
                 Point position = Point.Parse(commandWords[3]);
                 int owner = int.Parse(commandWords[4]);
                 this.AddObject(new Guard(name, position, owner));
                 break;
             }
         case "tree":
             {
                 int size = int.Parse(commandWords[2]);
                 Point position = Point.Parse(commandWords[3]);
                 this.AddObject(new Tree(size, position));
                 break;
             }
         case "knight":
             {
                 string name = commandWords[2];
                 Point position = Point.Parse(commandWords[3]);
                 int owner = int.Parse(commandWords[4]);
                 this.AddObject(new Knight(name, position, owner));
                 break;
             }
         case "house":
             {
                 Point position = Point.Parse(commandWords[2]);
                 int owner = int.Parse(commandWords[3]);
                 this.AddObject(new House(position, owner));
                 break;
             }
         case "giant":
             {
                 string name = commandWords[2];
                 Point position = Point.Parse(commandWords[3]);
                 this.AddObject(new Giant(name, position));
                 break;
             }
         case "rock":
             {
                 int hitPoints = int.Parse(commandWords[2]);
                 Point position = Point.Parse(commandWords[3]);
                 Rock newRock = new Rock(position);
                 newRock.HitPoints = hitPoints;
                 this.AddObject(newRock);
                 break;
             }
     }
 }