예제 #1
0
 public DoodadView(IDoodad doodad)
 {
     this.doodad = doodad;
     this.position = new Vector2(
         Constants.TileSize * doodad.Column + Constants.TileHalfSize,
         Constants.TileSize * doodad.Row + Constants.TileHalfSize);
 }
        public IRetainedControl CreateViewFor(IDoodad doodad)
        {
            if (doodad is Wall || doodad is TileDoodad || doodad is Pit)
            {
                return new StaticDoodadView((IStaticDoodad)doodad, level);
            }
            else if (doodad is PlayerControlledTank)
            {
                return new PlayerControlledTankView((PlayerControlledTank)doodad, this.input, this.keyInput, this.random);
            }
            else if (doodad is Tank)
            {
                return new TankView((Tank)doodad, this.random);
            }
            else if (doodad is Missile)
            {
                return new MissileView((Missile)doodad);
            }
            else if (doodad is Waypoint)
            {
                return new WaypointView((Waypoint)doodad);
            }
            else if (doodad is BlastMark)
            {
                return new BlastMarkView((BlastMark)doodad, this.random);
            }
            else if (doodad is TreadMark)
            {
                return new TreadMarkView((TreadMark)doodad);
            }
            else if (doodad is PowerUp)
            {
                return new PowerUpView((PowerUp)doodad);
            }

            throw new ArgumentException("No view found for doodad");
        }