コード例 #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (ArcadePhysics.SameWorld(this, other))
     {
         // only trigger if this component is on
         if (enabled)
         {
             // and now it's time to stop the level
             FinalizeLevel.CrossFinishLine(clock.GetTime());
         }
     }
 }
コード例 #2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (ArcadePhysics.SameWorld(this, other))
     {
         // only trigger if this component is on
         if (enabled)
         {
             // the timer is stopped when a player touches the line
             // idempotent, so don't worry about calling it more than once
             clock.StopTiming();
         }
     }
 }
コード例 #3
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (ArcadePhysics.SameWorld(this, other))
     {
         if (enabled)
         {
             // the game ends when the player touches the exit portal
             if (other.gameObject.CompareTag(Magic.Tags.PLAYER))
             {
                 FinalizeLevel.FinishGame();
             }
         }
     }
 }
コード例 #4
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (ArcadePhysics.SameWorld(this, other))
     {
         // only trigger if this component is on
         if (enabled)
         {
             if (!started)
             {
                 started = true;
             }
         }
     }
 }
コード例 #5
0
ファイル: StartLine.cs プロジェクト: matomatical/8bIT-Project
        void OnTriggerEnter2D(Collider2D other)
        {
            if (ArcadePhysics.SameWorld(this, other))
            {
                if (enabled)                   // only trigger if this component is on

                // start the clock the first time a player comes through!
                {
                    if (other.gameObject.CompareTag(Magic.Tags.PLAYER))
                    {
                        clock.StartTiming();
                    }
                }
            }
        }
コード例 #6
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (ArcadePhysics.SameWorld(this, other))
            {
                // only trigger if this component is on
                if (enabled)
                {
                    ++isColliding;

                    if (isColliding == 1)                       // first presser!
                    {
                        plate.Press();
                    }
                }
            }
        }
コード例 #7
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (ArcadePhysics.SameWorld(this, other))
     {
         // only trigger if this component is on
         if (enabled)
         {
             // if the key collides with another game object that has a
             // KeyHolder component that isn't already holding a key object,
             KeyHolder holder = other.gameObject.GetComponent <KeyHolder> ();
             if (holder != null && holder.CanPickupKey())
             {
                 // then mark that object as holding a key and deactivate self
                 holder.PickupKey();
                 key.Pickup();
             }
         }
     }
 }
コード例 #8
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (ArcadePhysics.SameWorld(this, other))
            {
                if (enabled)                   // only trigger if this component is on

                // start the clock the first time a player comes through!
                {
                    if (other.gameObject.CompareTag(Magic.Tags.PLAYER))
                    {
                        // Send an update saying the clock has started

                        if (updateManager != null)
                        {
                            updateManager.SendStartClock();
                        }
                    }
                }
            }
        }
コード例 #9
0
        void OnTriggerExit2D(Collider2D other)
        {
            if (ArcadePhysics.SameWorld(this, other))
            {
                // only trigger if this component is on
                if (enabled)
                {
                    --isColliding;

                    if (isColliding < 0)                       // clamp at zero
                    {
                        isColliding = 0;
                    }

                    if (isColliding == 0)                       // last releaser!
                    {
                        plate.Release();
                    }
                }
            }
        }
コード例 #10
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (ArcadePhysics.SameWorld(this, other))
            {
                // only trigger if this component is on and
                // inside the same physics layer
                if (enabled)
                {
                    // if the block collides with another game object that has a
                    // KeyHolder component that is holding a key object,

                    KeyHolder holder = other.gameObject.GetComponent <KeyHolder> ();
                    if (holder != null && holder.IsHoldingKey())
                    {
                        // open (deactivate self) and mark the object as no longer
                        // holding a key
                        block.Open();
                        holder.DropKey();
                    }
                }
            }
        }