コード例 #1
0
    void HitSavePoint()
    {
        float   rayLength = collider_box.bounds.size.y;
        Vector2 rayOrigin = raycastOrigins.midBot;

        RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.up, rayLength, collisionMask);

        //Debug.DrawRay(rayOrigin, Vector2.up, Color.red);
        if (hit && !saved)
        {
            player.savePoint = this.transform.position;
            foreach (GameObject b in box)
            {
                pushAble           = b.GetComponent <PushAble>();
                pushAble.savePoint = pushAble.transform.position;
            }
            foreach (GameObject m in movePlatform)
            {
                mpController = m.GetComponent <MovingPlatformController>();
                mpController.SavedPlatformMovement();
            }
            foreach (GameObject u in unStalePlatform)
            {
                usController = u.GetComponent <UnStablePlatformController>();
                usController.SaveIsHide();
            }
            saved = true;
        }
    }
コード例 #2
0
    void CheckHit()
    {
        Bounds bounds    = this.collider_box.bounds;
        float  rayLength = bounds.size.x;

        for (int i = 0; i < horizontalRayCount; i++)
        {
            Vector2 rayOrigin = raycastOrigins.bottomLeft;
            rayOrigin += Vector2.up * (horizontalRaySpacing * i);
            RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.right, rayLength, collisionMask);

            Debug.DrawRay(rayOrigin, Vector2.right, Color.red);

            if (hit)
            {
                audio.PlayOneShot(clip, 0.7F);
                player.GetSavePointPosition();
                player.velocity = Vector2.zero;
                foreach (GameObject b in box)
                {
                    pushAble = b.GetComponent <PushAble>();
                    pushAble.GetSavePointPosition();
                }
                foreach (GameObject m in movingPlatform)
                {
                    mpController = m.GetComponent <MovingPlatformController>();
                    mpController.ResetPlatformMovement();
                    mpController.loadedPlatformMovement();
                }
                foreach (GameObject u in unStalePlatform)
                {
                    usController = u.GetComponent <UnStablePlatformController>();
                    usController.IsThisHide();
                }
            }
        }
    }