// Update is called once per frame void Update() { //player movement //line movement if (begin == null) { lineRend.enabled = false; //backGroundScrollRect.horizontal=true; //backGroundScrollRect.vertical=true; } else { //backGroundScrollRect.horizontal=false; //backGroundScrollRect.vertical=false; //makes scroll rect movable if player is next to the edge /* if(worldCorners[1].x- (worldCorners[1].x/10) > this.transform.position.x){ * backGroundScrollRect.horizontalNormalizedPosition = backGroundScrollRect.horizontalNormalizedPosition-(backGroundScrollRect.horizontalNormalizedPosition/1000); * } * if(worldCorners[3].x- (worldCorners[3].x/10) < this.transform.position.x){ * backGroundScrollRect.horizontalNormalizedPosition = backGroundScrollRect.horizontalNormalizedPosition+(backGroundScrollRect.horizontalNormalizedPosition/1000); * } * if(worldCorners[1].y- (worldCorners[1].y/10) > this.transform.position.y){ * backGroundScrollRect.verticalNormalizedPosition = backGroundScrollRect.verticalNormalizedPosition-(backGroundScrollRect.verticalNormalizedPosition/1000); * } * if(worldCorners[3].y- (worldCorners[3].y/10) < this.transform.position.y){ * backGroundScrollRect.verticalNormalizedPosition = backGroundScrollRect.verticalNormalizedPosition+(backGroundScrollRect.verticalNormalizedPosition/1000); * }*/ lineRend.enabled = true; lineRend.SetPosition(0, begin.transform.position); if (over == null) { lineRend.SetPosition(1, new Vector3(this.transform.position.x, this.transform.position.y, 90)); } else { lineRend.SetPosition(1, over.transform.position); } } //star logic if (Input.GetMouseButtonDown(0) == true) { begin = over; } if (Input.GetMouseButtonUp(0) == true) { if (begin != null) { if (over == null) { begin = null; } else { if (over.checkMainConstalation(begin, over) == false) { if (begin.getIsHardMode() == true) { begin.clearMainConstalation(); } playFailSound(); } else { playChainSound(); } begin = null; } } } }
// Update is called once per frame void Update() { //player movement mousePosition = Input.mousePosition; mousePosition = Camera.main.ScreenToWorldPoint(mousePosition); transform.position = Vector3.Lerp(new Vector3(transform.position.x, transform.position.y, 5), mousePosition, moveSpeed); //line movement if (begin == null) { lineRend.enabled = false; backGroundScrollRect.horizontal = true; backGroundScrollRect.vertical = true; } else { backGroundScrollRect.horizontal = false; backGroundScrollRect.vertical = false; //makes scroll rect movable if player is next to the edge if (worldCorners[1].x - (worldCorners[1].x / 10) > this.transform.position.x) { backGroundScrollRect.horizontalNormalizedPosition = backGroundScrollRect.horizontalNormalizedPosition - (backGroundScrollRect.horizontalNormalizedPosition / 1000); } if (worldCorners[3].x - (worldCorners[3].x / 10) < this.transform.position.x) { backGroundScrollRect.horizontalNormalizedPosition = backGroundScrollRect.horizontalNormalizedPosition + (backGroundScrollRect.horizontalNormalizedPosition / 1000); } if (worldCorners[1].y - (worldCorners[1].y / 10) > this.transform.position.y) { backGroundScrollRect.verticalNormalizedPosition = backGroundScrollRect.verticalNormalizedPosition - (backGroundScrollRect.verticalNormalizedPosition / 1000); } if (worldCorners[3].y - (worldCorners[3].y / 10) < this.transform.position.y) { backGroundScrollRect.verticalNormalizedPosition = backGroundScrollRect.verticalNormalizedPosition + (backGroundScrollRect.verticalNormalizedPosition / 1000); } lineRend.enabled = true; lineRend.SetPosition(0, begin.transform.position); if (over == null) { lineRend.SetPosition(1, new Vector3(mousePosition.x, mousePosition.y, 90)); } else { lineRend.SetPosition(1, over.transform.position); } } //star logic if (Input.GetMouseButtonDown(0) == true) { begin = over; } if (Input.GetMouseButtonUp(0) == true) { if (begin != null) { if (over == null) { begin = null; } else { over.checkMainConstalation(begin, over); begin = null; } } } }