// Perfoms shooting private void Shoot() { Vector3 position = transform.position; position.y += 1.0F; Bullet newBullet = Instantiate(bullet, position, bullet.transform.rotation); newBullet.Direction = newBullet.transform.up; // PLays sound SoundManagerScript.Play("shot"); // Set cooldown cooldown = shotCooldown; }
void Update() { animator.SetFloat("walkingSpeed", Mathf.Abs(GetComponent <Rigidbody2D>().velocity.x)); if (Input.GetKeyDown(KeyCode.W)) { if (Physics2D.IsTouchingLayers(GetComponent <Collider2D>())) { manager.Play("jump"); GetComponent <Rigidbody2D>().velocity += new Vector2(0, jumpHeight); } } if (Input.GetKey(KeyCode.A)) { // Goes left GetComponent <Rigidbody2D>().AddForce(new Vector2(-maxSpeed / 4, 0), ForceMode2D.Force); GetComponent <Rigidbody2D>().transform.rotation = new Quaternion(0, 180, 0, 9); } if (Input.GetKey(KeyCode.D)) { // Goes right GetComponent <Rigidbody2D>().AddForce(new Vector2(+maxSpeed / 4, 0), ForceMode2D.Force); GetComponent <Rigidbody2D>().transform.rotation = new Quaternion(0, 0, 0, 9); } }
void Update() { // Once Sally's placed, the plane she's stands on will be assigned to mainPlane. Then, Update is bypassed if (mainPlane != null) { return; } // When a plane with a decent size is detected, the cavas UI image and icod is changed for tap action if (!isDecentSizePlaneDetected && planeManager.trackables.count > 0) { foreach (var plane in planeManager.trackables) { // Default mininum width set to 25cm, lenght set to 70% of the width if (plane.extents.x > minExtentOfPlaneForTap && plane.extents.y > minExtentOfPlaneForTap * 0.7f) { StartUI uiScript = startUI.GetComponent <StartUI>(); uiScript.isMainPlaneDetected = true; isDecentSizePlaneDetected = true; } } } // Quit update routine in case of no touch input Touch touch; if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) { return; } // Raycast on the plane and place Sally when Sally is not visible in the beginning if (!isSallyVisible && isDecentSizePlaneDetected && arRaycaster.Raycast(touch.position, s_Hits, TrackableType.PlaneWithinPolygon)) { // Get Camera bearing(rotation without vertical component) and set main plane Pose hitPose = s_Hits[0].pose; Vector3 camForward = Camera.main.transform.forward; Vector3 camBearing = new Vector3(camForward.x, 0, camForward.z); mainPlane = planeManager.GetPlane(s_Hits[0].trackableId); //Play tapplace sound effect// SoundManagerScript.Play("tapplace"); // Make Sally visible on the plane and rotate her toward the Camera GameObject sally = GameObject.Find("skinnysally"); sallyScript s = sally.GetComponent <sallyScript>(); sally.transform.localScale = new Vector3(s.size, s.size, s.size); s.isVisible = true; isSallyVisible = true; sally.transform.position = hitPose.position; sally.transform.rotation = Quaternion.LookRotation(camBearing, mainPlane.normal); sally.transform.Rotate(0, 180, 0, Space.Self); // Match CylinderMask at sally's position and rotation and activate with the moving up direction true GameObject mask = GameObject.Find("CylinderMask"); mask.GetComponent <CylinderMask>().activate(sally, true); // Create AR Reference point(anchor) and parent it to Sally, Zero and Mask and deactivate UI and start the flow ARReferencePoint anchorRefPoint = refPointManager.AddReferencePoint(hitPose); GameObject anchor = anchorRefPoint.gameObject; sally.transform.parent = anchor.transform; GameObject zero = GameObject.Find("zero"); zero.transform.parent = anchor.transform; mask.transform.parent = anchor.transform; startUI.SetActive(false); inActivatePlanes(); Invoke("startFlow", 4.0f); } }
// Base class for player, bonuses, centipede and mushrooms public virtual void ReceiveDamage() { SoundManagerScript.Play("boom"); Die(); }