示例#1
0
文件: Level.cs 项目: endy/OgmoXNA
 public Level(OgmoLevel level)
 {
     // Get the loaded grid data and use it for a collision layer.
     collisionGrid = level.GetLayer<OgmoGridLayer>("floors").RawData;
     // Create tiles from some tile layer data.
     foreach (OgmoTile tile in level.GetLayer<OgmoTileLayer>("tiles_bg").Tiles)
         tiles.Add(new Tile(tile, false));
     // Create more tiles from some more tile layer data.
     foreach (OgmoTile tile in level.GetLayer<OgmoTileLayer>("tiles_floors").Tiles)
         tiles.Add(new Tile(tile, true));
     // Create our objects from the object layer data.
     foreach (OgmoObject obj in level.GetLayer<OgmoObjectLayer>("objects").Objects)
     {
         if (obj.Name.Equals("ogmo"))
         {
             Ogmo ogmo = new Ogmo(obj, this);
             ogmo.Destroy += new EventHandler(ogmo_Destroy);
             allObjects.Add(ogmo);
             this.ogmo = ogmo;
         }
         if (obj.Name.Equals("chest"))
         {
             Chest chest = new Chest(obj, this);
             chest.Destroy += new EventHandler(DoDestroy);
             allObjects.Add(chest);
         }
         if (obj.Name.Equals("moving_platform"))
             allObjects.Add(new MovingPlatform(obj, this));
         if (obj.Name.StartsWith("spike"))
             allObjects.Add(new Spike(obj, this));
     }
 }
示例#2
0
 void Spike_Collision(object sender, CollisionEventArgs e)
 {
     if (e.Collider is Ogmo)
     {
         Ogmo ogmo = e.Collider as Ogmo;
         ogmo.DoDie();
         ogmo.OnDestroy();
     }
 }
示例#3
0
 void Chest_Collision(object sender, CollisionEventArgs e)
 {
     if (e.Collider != null && e.Collider.Name.Equals("ogmo"))
     {
         Ogmo ogmo = e.Collider as Ogmo;
         ogmo.Coins += this.Coins;
         this.OnDestroy();
     }
 }