예제 #1
0
 //写一个函数 将游戏对象们添加到游戏场景中
 public void AddGameObject(GameObjcte go)
 {
     if (go is Background)
     {
         //如果传进来的是背景的对象,则赋值给SingleObject类中的BG属性
         this.BG = go as Background;
     }
     else if (go is HeroPlane)
     {
         this.HP = go as HeroPlane;
     }
     else if (go is EnemyPlane)
     {
         this.listEnemyPlane.Add(go as EnemyPlane);
     }
     else if (go is HeroZiDan)
     {
         this.listHeroZiDan.Add(go as HeroZiDan);
     }
     else if (go is EnempyZiDan)
     {
         this.listEnempyZiDan.Add(go as EnempyZiDan);
     }
     else if (go is EnemyBoom)
     {
         this.listEnemBoom.Add(go as EnemyBoom);
     }
     else if (go is HeroBoom)
     {
         this.listHeroBoom.Add(go as HeroBoom);
     }
 }
예제 #2
0
 //从游戏中将游戏对象移除
 public void RemoveGameObject(GameObjcte go)
 {
     if (go is EnemyPlane)
     {
         //将当前这架敌人飞机移除
         listEnemyPlane.Remove(go as EnemyPlane);
     }
     else if (go is HeroZiDan)
     {
         listHeroZiDan.Remove(go as HeroZiDan);
     }
     else if (go is EnempyZiDan)
     {
         listEnempyZiDan.Remove(go as EnempyZiDan);
     }
     else if (go is EnemyBoom)
     {
         listEnemBoom.Remove(go as EnemyBoom);
     }
     else if (go is HeroBoom)
     {
         listHeroBoom.Remove(go as HeroBoom);
     }
 }