/* * void OnMouseDrag() * { * Vector3 temp = transform.position; * temp.x = raycaster.currentPosition.x; * transform.position = temp; * raycaster.isDrag = true; * } * * void OnMouseUp() * { * instruction.DestroyHandInstruction(0); * raycaster.isDrag = false; * isDragOver = true; * Destroy(this.gameObject.GetComponent<BoxCollider>()); * gameController.Step1Event(); * } */ public override void OnTap() { instruction.DestroyHandInstruction(0); isDragOver = true; Destroy(this.gameObject.GetComponent <BoxCollider>()); this.gameObject.GetComponent <AudioSource>().PlayOneShot(packTear); gameController.Step1Event(); }
public override void OnTap() { if (gameController.isBalloonSelected == false) { instruction.DestroyHandInstruction(1); isSelected = true; gameController.isBalloonSelected = true; gameController.selectedBalloonNumber = balloonNumber; startTime = Time.time; Destroy(this.gameObject.GetComponent <Collider>()); } else { if (gameController.selectedBalloonNumber != -1) { if (gameController.balloons[gameController.selectedBalloonNumber] != this.gameObject) { print("change color"); print("exchange select number in gamecontroller"); /* * this.gameObject.GetComponent<SpriteRenderer>().material.color = balloonColor[gameController.selectedBalloonNumber]; * gameController.balloons[gameController.selectedBalloonNumber].GetComponent<SpriteRenderer>().material.color = balloonColor[balloonNumber]; */ } } } }
public override void OnTap() { if (gameController.isEdited == true) { gameController.isLanuched = true; gameController.startTime = Time.time; gameController.startCamPosition = Camera.main.transform.position; gameController.startBalloonPosition = gameController.balloons[gameController.selectedBalloonNumber].transform.position; instruction.DestroyHandInstruction(4); this.gameObject.GetComponent <BoxCollider>().enabled = false; } }
void Update() { Vector3 temp = this.transform.localPosition; temp.x = 4.57f; this.transform.localPosition = temp; if (gameController.isStep2Finished && !isColliderOn) { this.gameObject.GetComponent <BoxCollider>().enabled = true; isColliderOn = true; startPosition = this.transform.localPosition; } if (isColliderOn) { distance = this.transform.localPosition.y - startPosition.y; if (distance < 0.001f) { this.transform.localPosition = startPosition; distance = 0f; } else if (distance > dragRange) { this.transform.localPosition = startPosition + new Vector3(0f, dragRange, 0f); distance = dragRange; } if (this.transform.localPosition.y - lastPoint < 0) { volume += lastPoint - this.transform.localPosition.y; } lastPoint = this.transform.localPosition.y; if (volume - current_volume >= max_volume / 12) { if (animationNumber < 10) { current_volume += max_volume / 12; if (animationNumber == 1) { source.PlayOneShot(handlePump); source.PlayOneShot(balloonInflat); } if (animationNumber == 4) { source.PlayOneShot(handlePump); source.PlayOneShot(balloonInflat); } if (animationNumber == 7) { source.PlayOneShot(handlePump); source.PlayOneShot(balloonInflat); } switch (gameController.selectedBalloonNumber) { case 0: gameController.balloons[0].GetComponent <SpriteRenderer>().sprite = YellowBalloonAnimation[animationNumber]; startPipe[0].transform.localPosition = YellowPipePosition[animationNumber]; animationNumber += 1; break; case 1: gameController.balloons[1].GetComponent <SpriteRenderer>().sprite = GreenBalloonAnimation[animationNumber]; startPipe[1].transform.localPosition = GreenPipePosition[animationNumber]; animationNumber += 1; break; case 2: gameController.balloons[2].GetComponent <SpriteRenderer>().sprite = BlueBalloonAnimation[animationNumber]; startPipe[2].transform.localPosition = BluePipePosition[animationNumber]; animationNumber += 1; break; default: gameController.balloons[3].GetComponent <SpriteRenderer>().sprite = RedBalloonAnimation[animationNumber]; startPipe[3].transform.localPosition = RedPipePosition[animationNumber]; animationNumber += 1; break; } } } if (volume >= max_volume && !balloonChangeFlag) { source.PlayOneShot(handlePump); source.PlayOneShot(balloonInflat); gameController.balloons[gameController.selectedBalloonNumber].GetComponent <SpriteRenderer>().sprite = inflatBalloon[gameController.selectedBalloonNumber]; startPipe[gameController.selectedBalloonNumber].SetActive(false); EndPipe[gameController.selectedBalloonNumber].SetActive(true); gameController.balloons[gameController.selectedBalloonNumber].transform.localScale = new Vector3(1.1f, 1.1f, 0f); balloonChangeFlag = true; instruction.DestroyHandInstruction(2); Destroy(this.gameObject.GetComponent <TouchScript.Gestures.TransformGestures.TransformGesture>()); OnDragEnd(); } } }