示例#1
0
 public void SetupLevel()
 {
     if (firstStart)
     {
         gameObjects.Insert(gameObjects.Count - 4, SnowFlakePool.Create(new Vector2(600, 700), Content));
         gameObjects.Insert(gameObjects.Count - 4, SnowFlakePool.Create(new Vector2(600, 700), Content));
         gameObjects.Insert(gameObjects.Count - 4, SnowFlakePool.Create(new Vector2(600, 700), Content));
     }
     hour       = min = sec = 0;
     firstStart = false;
     engine.StopAllSounds();
     if (playSound)
     {
         engine.Play2D("Content/iceMove.wav", true);
     }
     restartGame   = true;
     playGame      = true;
     batSpownTimer = 0;
     if (currentLevel < previousLevel)
     {
         int i = 0;
         foreach (GameObject go in gameObjects)
         {
             if (go.GetComponent("SnowFlake") is SnowFlake)
             {
                 objectsToRemove.Add(go);
                 i++;
                 if (i == (previousLevel - currentLevel))
                 {
                     break;
                 }
             }
         }
     }
     else if (currentLevel > previousLevel)
     {
         for (int i = 0; i < currentLevel - previousLevel; i++)
         {
             gameObjects.Insert(gameObjects.Count - 4, SnowFlakePool.Create(new Vector2(rnd.Next(450, 700), rnd.Next(650, 1000)), Content));
         }
     }
     UpdateTimer();
 }
示例#2
0
 public void ClearLists()
 {
     if (objectsToRemove.Count > 0)
     {
         foreach (GameObject go in objectsToRemove)
         {
             collidersToRemove.Add(go.GetComponent("Collider") as Collider);
         }
         foreach (GameObject go in objectsToRemove)
         {
             if (go.GetComponent("SnowFlake") is SnowFlake)
             {
                 SnowFlakePool.ReleaseObject(go);
             }
             gameObjects.Remove(go);
         }
         objectsToRemove.Clear();
     }
     if (collidersToRemove.Count > 0)
     {
         foreach (Collider c in collidersToRemove)
         {
             colliders.Remove(c);
         }
         collidersToRemove.Clear();
     }
     if (scores.Count > 0)
     {
         foreach (Score s in scores)
         {
             s.Update();
         }
     }
     if (scoresToRemove.Count > 0)
     {
         foreach (Score s in scoresToRemove)
         {
             scores.Remove(s);
         }
     }
 }