コード例 #1
0
ファイル: Game1.cs プロジェクト: kaoabi/GP3_CourseworkGame
 //Collision function for the UFO
 public bool UFOCollisionDetection(CollisionSkin owner, CollisionSkin collidee)
 {
     //If the UFO collides with the bottom of the box
     if (collidee.Equals(m_UFOCatcherBox.m_skin) && m_ufoState == e_UFOStates.e_grabbing)
     {
         m_ufoState = e_UFOStates.e_moveBackUp;
         return true;
     }
     //If the UFO collides with a prize
     foreach( Prize ob in m_prizesList)
     {
         if( collidee.Equals(ob.m_skin))
         {
             //Move the ufo back and
             m_ufoState = e_UFOStates.e_moveBackUp;
             ob.m_UFOBody = m_UFO.m_body;
             ob.moveToTarget = true;
             return true;
         }
     }
     // all other collisions will be handled by physicengine
     return true;
 }
コード例 #2
0
ファイル: Game1.cs プロジェクト: kaoabi/GP3_CourseworkGame
 public bool PrizeCollisionDetection(CollisionSkin owner, CollisionSkin collidee)
 {
     //If the UFO collides with the bottom of the box
     if (collidee.Equals(m_UFO.m_skin) && m_ufoState == e_UFOStates.e_grabbing)
     {
         m_ufoState = e_UFOStates.e_moveBackUp;
         return true;
     }
     // here is handled what happens if your Object collides with another special Object (= OtherObject)
     foreach (Prize ob in m_prizesList)
     {
         if (collidee.Equals(ob.m_skin))
         {
             ob.m_body = null;
             ob.m_skin = null;
             m_GameObjects.Remove(ob);
             m_prizesList.Remove(ob);
             Components.Remove(ob);
             m_prizesObtained++;
             return true;
         }
     }
     // all other collisions will be handled by physicengine
     return true;
 }