示例#1
0
    void Update()
    {
        if (_isFall)
        {
            if (_timer <= 3)
            {
                AudioManager.instance.ChangeVolume((3 - _timer) / 3);
            }
            if (_timer >= 3)
            {
                proCamera2DRooms  = FindObjectOfType <ProCamera2DRooms>();
                numericBoundaries = FindObjectOfType <ProCamera2DNumericBoundaries>();

                proCamera2DRooms.enabled  = false;
                numericBoundaries.enabled = false;
            }

            if (_timer >= 5)
            {
                hero.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
                Vector3 pos = hero.transform.position;
                pos.x += 10;
                pos.y -= 16;
                world3.transform.position = pos;
                _isFall = false;
                _timer  = 0f;
                if (AudioManager.instance.GetVolume() < 1)
                {
                    AudioManager.instance.ChangeVolume(1);
                    AudioManager.instance.Play(AudioManager.AudioType.WINDMILL_IN_GARDEN);
                }
            }
            _timer += Time.deltaTime;
        }
    }
示例#2
0
 void SetBounds()
 {
     ProCamera2DNumericBoundaries boundaries = Camera.main.GetComponent<ProCamera2DNumericBoundaries>();
     boundaries.LeftBoundary = _tileMap.MapBounds.min.x;
     boundaries.RightBoundary = _tileMap.MapBounds.max.x;
     boundaries.TopBoundary = 100;
     boundaries.BottomBoundary = _tileMap.MapBounds.min.y;
 }
示例#3
0
    void Awake()
    {
        Instance = this;

        Application.targetFrameRate = 60;
        ProCam           = ProCamera2D.Instance;
        CamTrans         = ProCam.transform;
        ProBoundariesCam = ProCam.GetComponent <ProCamera2DNumericBoundaries>();
        PlayerTrans      = FindObjectOfType <PlayerController>().transform;
        //Map = GameObject.Find("Map").transform;
    }
示例#4
0
    void Start()
    {
        playerCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
        cameraBounds = playerCamera.GetComponent <ProCamera2DNumericBoundaries>();

        ProCamera2D.Instance.AddCameraTarget(transform, 1f, 1f, 0f);

        wallJumpUp   = new Vector2(wallJumpUpX, wallJumpUpY);
        wallJumpDown = new Vector2(wallJumpDownX, wallJumpDownY);
        wallJumpAway = new Vector2(wallJumpAwayX, wallJumpAwayY);

        gravity = -(2 * maxJumpHeight) / Mathf.Pow(jumpSpeed, 2);                     // calculate gravity
        playerController.myGrav = Controller2D.GravDir.Down;
        maxJumpVelocity         = Mathf.Abs(gravity) * jumpSpeed;                     // calculate jumpVelocity
        minJumpVelocity         = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight); // calculate jumpVelocity

        playerCanMove      = true;
        playerIsDead       = false;
        playerJumping      = false;
        respawnTimerActive = false;
        respawnTimer       = 60;

        knockBack = new Vector2(knockBackX, knockBackY);
    }
示例#5
0
    // checks if player moves to edge of screen then loads next scene
    void CheckRoomPos()
    {
        viewPosition = playerCamera.WorldToViewportPoint(transform.position);

        ProCamera2DNumericBoundaries cameraBounds = playerCamera.GetComponent <ProCamera2DNumericBoundaries>();

        vertExtent      = playerCamera.orthographicSize;
        horzExtent      = vertExtent * Screen.width / Screen.height;
        cameraRightPos  = Mathf.Round(playerCamera.transform.position.x + horzExtent * 10f) / 10f;
        cameraLeftPos   = Mathf.Round(playerCamera.transform.position.x - horzExtent * 10f) / 10f;
        cameraTopPos    = Mathf.Round(playerCamera.transform.position.y + vertExtent * 10f) / 10f;
        cameraBottomPos = Mathf.Round(playerCamera.transform.position.y - vertExtent * 10f) / 10f;

        /*
         * Debug.Log("horzExtent = " + horzExtent);
         * Debug.Log("camera.transform.position(" + playerCamera.transform.position);
         * Debug.Log("cameraBounds.RightBoundary(" + cameraBounds.RightBoundary + ")");
         * Debug.Log("cameraRightPos = " + cameraRightPos);
         * Debug.Log("cameraLeftPos = " + cameraLeftPos);
         * Debug.Log("cameraBottomPos = " + cameraBottomPos);
         * Debug.Log("cameraTopPos = " + cameraTopPos);
         */

        if (viewPosition.x > 1.01f)
        {
            // move right
            // check if camera is at boundary first
            if (cameraRightPos >= cameraBounds.RightBoundary)
            {
                Debug.Log("Bingo");
                // check if there is a scene available
                if (GameController.gameControl.currentRoomControl.moveSceneRightString != "")
                {
                    GameController.gameControl.NextScene(GameController.gameControl.currentRoomControl.moveSceneRightString, 1);
                    GameController.gameControl.prevPlayerVelocity = velocity;
                }
                //  if not kill of the player character
                else
                {
                    Die();
                }
            }
            // kill player if too far off screen (just in case)
            else if (cameraRightPos >= cameraBounds.RightBoundary + 5)
            {
                Die();
            }
        }
        else if (viewPosition.x < -0.01f)
        {
            // move left
            // check if camera is at boundary
            if (cameraLeftPos <= cameraBounds.LeftBoundary)
            {
                if (GameController.gameControl.currentRoomControl.moveSceneLeftString != "")
                {
                    GameController.gameControl.NextScene(GameController.gameControl.currentRoomControl.moveSceneLeftString, 0);
                    GameController.gameControl.prevPlayerVelocity = velocity;
                }
                else
                {
                    Die();
                }
            }
            // kill player if too far off screen (just in case)
            else if (cameraLeftPos <= cameraBounds.LeftBoundary - 5)
            {
                Die();
            }
        }
        else if (viewPosition.y > 1.01f)
        {
            // move up
            // check if camera is at boundary
            if (cameraTopPos >= cameraBounds.TopBoundary)
            {
                if (GameController.gameControl.currentRoomControl.moveSceneUpString != "")
                {
                    GameController.gameControl.NextScene(GameController.gameControl.currentRoomControl.moveSceneUpString, 2);
                    GameController.gameControl.prevPlayerVelocity = velocity;
                }
            }
        }
        else if (viewPosition.y < -0.01f)
        {
            // move down
            if (cameraBottomPos <= cameraBounds.BottomBoundary)
            {
                if (GameController.gameControl.currentRoomControl.moveSceneDownString != "")
                {
                    GameController.gameControl.NextScene(GameController.gameControl.currentRoomControl.moveSceneDownString, 3);
                    GameController.gameControl.prevPlayerVelocity = velocity;
                }
                // if you fall off the screen and there is no attached room then die
                else
                {
                    Die();
                }
            }
            // kill player if too far off the screen (just in case)
            else if (cameraBottomPos <= cameraBounds.BottomBoundary - 10)
            {
                Die();
            }
        }
    }
示例#6
0
 private void OnValidate()
 {
     NumericBoundaries = GetComponent <ProCamera2DNumericBoundaries>();
     prcShake          = GetComponent <ProCamera2DShake>();
     procam            = GetComponent <ProCamera2D>();
 }