当前位置: 首页>>代码示例>>C#>>正文


C# Collider2D.OverlapPoint方法代码示例

本文整理汇总了C#中UnityEngine.Collider2D.OverlapPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Collider2D.OverlapPoint方法的具体用法?C# Collider2D.OverlapPoint怎么用?C# Collider2D.OverlapPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Collider2D的用法示例。


在下文中一共展示了Collider2D.OverlapPoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnTriggerStay2D

    void OnTriggerStay2D(Collider2D col)
    {
        ///get position of click
        clickPosition.x = Camera.main.ScreenToWorldPoint(Input.mousePosition).x;
        clickPosition.y = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
        ///currently, click must be on player
        if (col.tag == "Player" && ((Input.GetKeyDown(KeyCode.Space)) || (col.OverlapPoint(clickPosition) && Input.GetMouseButtonDown(0))))
        {

            if (exit != null)
            {
                cameraScript.follow = false;
                cameraScript.target = exit.transform;

            }
            else
            {
                Debug.Log("no exit assigned");
            }

            Debug.Log("Teleport Complete!"); // confirm that teleport is complete; this can be taken out
            TeleportToExit2D(col);

        }
        /*
        else
        {
            //cameraScript.follow = true;//allows smooth transition for each teleport
        }
        */
    }
开发者ID:mxz0801,项目名称:DarkDreams,代码行数:31,代码来源:TeleportDoors.cs

示例2: OnTriggerStay2D

    void OnTriggerStay2D( Collider2D col)
    {
        ///get position of click
        clickPosition.x = Camera.main.ScreenToWorldPoint(Input.mousePosition).x;
        clickPosition.y = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
        ///currently, click must be on player
        if (col.tag == "Player" && ((Input.GetKeyDown(KeyCode.Space))||(col.OverlapPoint(clickPosition) && Input.GetMouseButtonDown(0))))
        {

                Debug.Log("Teleport Complete!"); // confirm that teleport is complete; this can be taken out
                TeleportToExit2D(col);

        }
    }
开发者ID:Lazer7,项目名称:DarkDreams,代码行数:14,代码来源:TeleportDoors.cs

示例3: OnTriggerStay2D

    //allows actions when staying within collision area
    void OnTriggerStay2D(Collider2D col)
    {
        // OverlapPoint refers to world space instead of screen space, adjusting accordingly
        clickPosition.x = (Camera.main.ScreenToWorldPoint(Input.mousePosition).x);
        clickPosition.y = (Camera.main.ScreenToWorldPoint(Input.mousePosition).y);

        //Toggle Hide/Unhide
        if ((Input.GetKeyDown(KeyCode.Space) || (Input.GetMouseButtonDown(0) && col.OverlapPoint(clickPosition)))) //if player activates hiding spot
            //|| ((hide && ((Input.GetAxis("Horizontal") > 0.9)||(Input.GetAxis("Horizontal") < -0.9)))  //or if player is hidden and moves using the keyboard
            //|| (hide && Input.GetMouseButton(0)&& (Input.mousePosition.x < edgeLeft.x || Input.mousePosition.x > edgeRight.x)))) //or if player is hidden and moves using the mouse
        {
            if (col.gameObject.tag == "Cover")
            {
                if (!hide)
                {
                    sprite.sortingOrder = hidingOrder;
                    hide = true;
                }
                else if (hide)
                {
                    sprite.sortingOrder = sortingOrder;
                    hide = false;

                    if (slowMo) //Disables slowmotion speed upon hiding
                    {
                        slowMo = false;
                    }
                }
            }
            //if player is trying to hide, and the object is the trap enemy
            else if (col.gameObject.tag == "Enemy")
            {
                //player dies
                isAlive = false;
                //prevents movement
                normalSpeed = 0f;
            }

          }

        //if player colliders with an enemy and is not hidden
        if (col.gameObject.tag == "PatrolEnemy" && hide == false)
        {
            //player is dead
            isAlive = false;
            //prevent player from moving
            normalSpeed = 0f;
        }
           ///gameover for stationary enemies handled in their own code
    }
开发者ID:andrewhe1997,项目名称:DarkDreams,代码行数:51,代码来源:PlayerControl.cs

示例4: OnTriggerStay2D

    //allows actions when staying within collision area
    void OnTriggerStay2D(Collider2D col)
    {
        // OverlapPoint refers to world space instead of screen space, adjusting accordingly
        clickPosition.x = (Camera.main.ScreenToWorldPoint(Input.mousePosition).x);
        clickPosition.y = (Camera.main.ScreenToWorldPoint(Input.mousePosition).y);

        //Toggle Hide/Unhide
        if ((Input.GetKeyDown(KeyCode.Space) || (Input.GetMouseButtonDown(0)&& col.OverlapPoint(clickPosition))))
        {
            if (col.gameObject.tag == "Cover")
            {
                if (!hide)
                {
                    sprite.sortingOrder = hidingOrder;
                    hide = true;
                }
                else if (hide)
                {
                    sprite.sortingOrder = sortingOrder;
                    hide = false;

                    if (slowMo) //Disables slowmotion speed upon hiding
                    {
                        slowMo = false;
                    }
                }
            }

          }

        //if player colliders with an enemy and is not hidden
        if (col.gameObject.tag == "PatrolEnemy" && hide == false)
        {
            //player is dead
            isAlive = false;
            //prevent player from moving
            normalSpeed = 0f;
        }
           ///gameover for stationary enemies handled in their own code
    }
开发者ID:Lazer7,项目名称:DarkDreams,代码行数:41,代码来源:PlayerControl.cs

示例5: IsHeroNearWayout

 private bool IsHeroNearWayout(Collider2D wayout, bool central)
 {
     if (_hero == null)
         return false;
     Vector2 position = _hero.transform.position;
     if (central)
         position.y -= 0.7f;
     Vector3 position2check = new Vector3(position.x, position.y, wayout.transform.position.z);
     return wayout.OverlapPoint(position2check);
 }
开发者ID:Syjgin,项目名称:zerotram,代码行数:10,代码来源:Floor.cs


注:本文中的UnityEngine.Collider2D.OverlapPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。