예제 #1
0
    private void GenerateBorders()
    {
        GameObject bottomBorder = _factory.GetBorder(BorderType.Bottom);

        bottomBorder.transform.position = _camera.transform.position;
        Vector2[] bottomPoints = new Vector2[] { new Vector2(-_lvlWidth / 2.0f, -_lvlHeight / 2.0f), new Vector2(_lvlWidth / 2.0f, -_lvlHeight / 2.0f) };
        bottomBorder.GetComponent <EdgeCollider2D>().points = bottomPoints;

        GameObject upperBorder = _factory.GetBorder(BorderType.Upper);

        upperBorder.transform.position = _camera.transform.position;
        Vector2[] upperPoints = new Vector2[] { new Vector2(-_lvlWidth / 2.0f, _lvlHeight / 2.0f), new Vector2(_lvlWidth / 2.0f, _lvlHeight / 2.0f) };
        upperBorder.GetComponent <EdgeCollider2D>().points = upperPoints;

        GameObject rightSideBorder = _factory.GetBorder(BorderType.Side);;

        rightSideBorder.transform.position = _camera.transform.position;
        Vector2[] rightPoints = new Vector2[] { new Vector2(-_lvlWidth / 2.0f, -_lvlHeight / 2.0f), new Vector2(-_lvlWidth / 2.0f, _lvlHeight / 2.0f) };
        rightSideBorder.GetComponent <EdgeCollider2D>().points = rightPoints;

        GameObject leftSideBorder = _factory.GetBorder(BorderType.Side);;

        leftSideBorder.transform.position = _camera.transform.position;
        Vector2[] leftPoints = new Vector2[] { new Vector2(_lvlWidth / 2.0f, -_lvlHeight / 2.0f), new Vector2(_lvlWidth / 2.0f, _lvlHeight / 2.0f) };
        leftSideBorder.GetComponent <EdgeCollider2D>().points = leftPoints;

        GameObject endLevelBorder = _factory.GetBorder(BorderType.EndLevel);

        endLevelBorder.transform.position = new Vector3(_camera.transform.position.x, _platforms[_platforms.Count - 1].transform.position.y + _deltaPlatformEnd);
        Vector2[] endPoints = new Vector2[] { new Vector2(-_lvlWidth / 2.0f, 0.0f), new Vector2(_lvlWidth / 2.0f, 0.0f) };
        endLevelBorder.GetComponent <EdgeCollider2D>().points = endPoints;
    }