// Update is called once per frame void Update() { //メインカメラが画面の外を捉える領域に入ったら縮小 //左ループ if (TargetPlayer.transform.position.x - (GetComponent <Camera>().orthographicSize + 1) < 0 - setStage.GetStageSize().x / 2) { set_rectx = (TargetPlayer.transform.position.x + setStage.GetStageSize().x / 2) / (GetComponent <Camera>().orthographicSize + 1); GetComponent <Camera>().rect = new Rect(1 - set_rectx, 0.0f, 1.0f, 1.0f); Debug.Log(GetComponent <Camera>().rect); } //右ループ else if (TargetPlayer.transform.position.x + (GetComponent <Camera>().orthographicSize + 1) > setStage.GetStageSize().x * 3 / 2) { set_rectx = (setStage.GetStageSize().x * 3 / 2 - TargetPlayer.transform.position.x) / (GetComponent <Camera>().orthographicSize + 1); GetComponent <Camera>().rect = new Rect(0.0f, 0.0f, set_rectx, 1.0f); Debug.Log(GetComponent <Camera>().rect); } else { set_rectx = 0.0f; GetComponent <Camera>().rect = new Rect(0.0f, 0.0f, 1.0f, 1.0f); } transform.position = new Vector3(TargetPlayer.transform.position.x, TargetPlayer.transform.position.y, -10); }
// Update is called once per frame void Update() { //メインカメラが画面の外を捉える領域に入ったら変動 //左ループ if (TargetPlayer.transform.position.x - (GetComponent <Camera>().orthographicSize + 1) < 0 - setStage.GetStageSize().x / 2) { transform.position = new Vector3(TargetPlayer.transform.position.x + setStage.GetStageSize().x * 2 - (GetComponent <Camera>().orthographicSize + 1), TargetPlayer.transform.position.y, -10); //set_rectx = (TargetPlayer.transform.position.x + setStage.GetStageSize().x / 2) / GetComponent<Camera>().orthographicSize; set_rectx = player_Camera.GetPlayerCameraRectX(); //GetComponent<Camera>().rect = new Rect(set_rectx, 0.0f, 1.0f, 1.0f); GetComponent <Camera>().rect = new Rect(0.0f, 0.0f, 1 - set_rectx, 1.0f); Debug.Log(GetComponent <Camera>().rect); } //左ループ else if (TargetPlayer.transform.position.x + (GetComponent <Camera>().orthographicSize + 1) > setStage.GetStageSize().x * 3 / 2) { transform.position = new Vector3(TargetPlayer.transform.position.x - setStage.GetStageSize().x * 2 + (GetComponent <Camera>().orthographicSize + 1), TargetPlayer.transform.position.y, -10); set_rectx = player_Camera.GetPlayerCameraRectX(); //GetComponent<Camera>().rect = new Rect(set_rectx, 0.0f, 1.0f, 1.0f); GetComponent <Camera>().rect = new Rect(set_rectx, 0.0f, 1.0f, 1.0f); Debug.Log(GetComponent <Camera>().rect); } else { GetComponent <Camera>().rect = new Rect(0.0f, 0.0f, 1.0f, 1.0f); } }
protected void CharaLoop() { //Debug.Log(transform.position.x); //横ループ if (transform.position.x < -setStage.GetStageSize().x / 2) { //Debug.Log("front " + stagefront_state); //Debug.Log("back " + stageback_state); //Debug.Log("3"); //Debug.Break(); transform.position = new Vector3(transform.position.x + setStage.GetStageSize().x * 2 - 0.5f - LoopAddLength, transform.position.y, transform.position.z); //enter_flag[(int)STAGE_KIND.BACK] = true; //exit_flag[(int)STAGE_KIND.FRONT] = false; stagefront_state = STAGE_STATE.NONE; stageback_state = STAGE_STATE.ENTER; //Debug.Log(setStage.GetStageSize().x * 2); //Debug.Log(transform.position.x); } else if (transform.position.x > setStage.GetStageSize().x * 3 / 2) { //Debug.Log("front " + stagefront_state); //Debug.Log("back " + stageback_state); //Debug.Log("4"); //Debug.Break(); transform.position = new Vector3(transform.position.x - setStage.GetStageSize().x * 2 + 0.5f + LoopAddLength, transform.position.y, transform.position.z); //enter_flag[(int)STAGE_KIND.FRONT] = true; //exit_flag[(int)STAGE_KIND.BACK] = false; stagefront_state = STAGE_STATE.ENTER; stageback_state = STAGE_STATE.NONE; } //縦ループ //表から出たとき else if (stagefront_state == STAGE_STATE.EXIT && stageback_state == STAGE_STATE.NONE) { //Debug.Log("front " + stagefront_state); //Debug.Log("back " + stageback_state); //Debug.Log("1"); //Debug.Break(); //上から出るか下から出るか float set_y = transform.position.y; if (transform.position.y > setStage.GetStageSize().y / 2 - 0.5f) { set_y = transform.position.y - setStage.GetStageSize().y; } else if (transform.position.y < -setStage.GetStageSize().y / 2 + 0.5f) { set_y = transform.position.y + setStage.GetStageSize().y; } transform.position = new Vector3(transform.position.x + setStage.GetStageSize().x, set_y, transform.position.z); } else if (stageback_state == STAGE_STATE.EXIT && stagefront_state == STAGE_STATE.NONE) { //Debug.Log("front " + stagefront_state); //Debug.Log("back " + stageback_state); //Debug.Break(); float set_y = transform.position.y; if (transform.position.y > setStage.GetStageSize().y / 2 - 0.5f) { set_y = transform.position.y - setStage.GetStageSize().y; } else if (transform.position.y < -setStage.GetStageSize().y / 2 + 0.5f) { set_y = transform.position.y + setStage.GetStageSize().y; } transform.position = new Vector3(transform.position.x - setStage.GetStageSize().x, set_y, transform.position.z); //Debug.Log("2"); } if (stagefront_state == STAGE_STATE.EXIT) { stagefront_state = STAGE_STATE.NONE; } if (stageback_state == STAGE_STATE.EXIT) { stageback_state = STAGE_STATE.NONE; } }