Esempio n. 1
0
    void FloorCollision(Player player, int layerMask, string tag)//顶部碰撞检测
    {
        RaycastHit2D hit = CheckCollision.CheckUpCollison(player.rig, layerMask, Mathf.Abs(player.speed.y * Time.deltaTime));

        if (hit.collider != null)
        {
            if (hit.collider.tag == tag)
            {
                player.speed.y = 0;
            }
        }
    }
Esempio n. 2
0
    public void OnLiftPlat(Player player)//检测与玩家的碰撞
    {
        RaycastHit2D hit = CheckCollision.CheckUpCollison(rig, player.Layer, 0.1f);

        if (hit.collider != null)
        {
            player.speed.y  = curSpeed + (hit.point.y - player.rig.GetComponent <Collider2D>().bounds.center.y + player.Collider2DExtents.y) / Time.deltaTime;
            player.IsOnPlat = true;
            player.IsFloat  = false;
        }
        else
        {
            player.IsOnPlat = false;
        }
    }
Esempio n. 3
0
    void Open()
    {
        RaycastHit2D hit = CheckCollision.CheckUpCollison(rig, relayLayer, 0.1f);//与继电器的碰撞检测

        if (hit.collider != null)
        {
            if (isControlDoor)
            {
                door.isOpen = true;
            }
            else if (isControlFloor)
            {
                for (int i = 0; i < tropFloors.Length; i++)
                {
                    tropFloors[i].canBroken = true;
                    tropFloors[i].liveTime  = i * 0.4f + 0.4f;//设置玻璃的剩余时常
                }
            }
            GameObject.Instantiate(keyOpen, transform.position, Quaternion.identity, transform.parent);//建造开关—开
            GameObject.Destroy(gameObject);
        }
    }