// Update is called once per frame void Update() { if (!gameOver && !UIManager.firstLoad) { //left flipper if (Input.GetMouseButtonDown(0) || Input.GetButtonDown("LeftFlipper")) { SoundManager.Instance.PlaySound(SoundManager.Instance.flipping); foreach (GameObject lightGroup in lightGroups) { LightGroupController controller = lightGroup.GetComponent <LightGroupController>(); controller.ShiftLightsLeft(); } leftFlipperRigid.MoveRotation((leftFlipper.GetComponent <HingeJoint2D>().limits.max + 10000) * Time.deltaTime); } else if (Input.GetMouseButtonUp(0) || Input.GetButtonUp("LeftFlipper")) { leftFlipperRigid.MoveRotation(leftFlipper.GetComponent <HingeJoint2D>().limits.min * 10); } else if (Input.GetMouseButton(0) || Input.GetButton("LeftFlipper")) { leftFlipperRigid.MoveRotation(leftFlipper.GetComponent <HingeJoint2D>().limits.max *(Time.deltaTime + 50)); } //right flipper if (Input.GetMouseButtonUp(1) || Input.GetButtonUp("RightFlipper")) { rightFlipperRigid.MoveRotation(rightFlipper.GetComponent <HingeJoint2D>().limits.max * 10); } else if (Input.GetMouseButtonDown(1) || Input.GetButtonDown("RightFlipper")) { SoundManager.Instance.PlaySound(SoundManager.Instance.flipping); //Vector3 mouseHolding = Input.mousePosition; foreach (GameObject lightGroup in lightGroups) { LightGroupController controller = lightGroup.GetComponent <LightGroupController>(); controller.ShiftLightsRight(); } rightFlipperRigid.MoveRotation((rightFlipper.GetComponent <HingeJoint2D>().limits.min + 10000) * -Time.deltaTime); } else if (Input.GetMouseButton(1) || Input.GetButton("RightFlipper")) { rightFlipperRigid.MoveRotation(rightFlipper.GetComponent <HingeJoint2D>().limits.min *(-Time.deltaTime + 50)); } } }
// Use this for initialization void Start() { sprite = GetComponentInChildren <SpriteRenderer>(); groupController = GetComponentInParent <LightGroupController>(); if (On) { turnLightOn(); } else { turnLightOff(); } }