public void BuyClicked() { if (SaveManager.save == null) { return; } if (SaveManager.save.picolinium < price || SaveManager.save.unlocks.Contains(gameObject.name)) { return; } SaveManager.save.picolinium -= price; SaveManager.save.unlocks.Add(gameObject.name); SaveManager.save.Write(); foreach (Unlockable unlockable in FindObjectsOfType <Unlockable>()) { unlockable.UpdateState(); } if (unlockUnlocker == null) { unlockUnlocker = AchievementUnlocker.MakeUnlocker("allunlocks"); if (SaveManager.save.unlocks.Count == 13) { unlockUnlocker.UnlockAchievement(); } } }
private void OnCollisionEnter(Collision collision) { if (!triedUnlock && collision.gameObject.name == "Player" && !AchievementRockChecker.HasTouchedRock()) { AchievementUnlocker.MakeUnlocker("world4_3").UnlockAchievement(); triedUnlock = true; } }
private void OnCollisionEnter(Collision collision) { if (!triedUnlock && collision.gameObject.name == "Player" && AchievementGrateChecker.GetCount() == 0) { AchievementUnlocker.MakeUnlocker("world5_3").UnlockAchievement(); triedUnlock = true; } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.name != "Player") { return; } if (!triedUnlock && AchievementDashChecker.GetCount() == 0) { AchievementUnlocker.MakeUnlocker("world3_2").UnlockAchievement(); triedUnlock = true; } }
private void CheckRegrapple(GameObject collided) { if (collided == null) { return; } if (regrappleUnlocker == null) { regrappleUnlocker = AchievementUnlocker.MakeUnlocker("doublegrapple"); } int grappled = collided.GetInstanceID(); if (lastGrappled == grappled) { regrappleUnlocker.UnlockAchievement(); } lastGrappled = grappled; }
public void EquipClicked() { if (SaveManager.save == null) { return; } if (UnlockType == Type.Upgrade) { SaveManager.save.currentUpgrade = gameObject.name; } else if (UnlockType == Type.Hat) { SaveManager.save.currentHats.Add(gameObject.name); } SaveManager.save.Write(); if (SaveManager.save.currentHats.Count > 1) { if (hatStackUnlocker == null) { hatStackUnlocker = AchievementUnlocker.MakeUnlocker("deckedout"); } if (!triedHatStack) { hatStackUnlocker.UnlockAchievement(); triedHatStack = true; } } foreach (Unlockable unlockable in FindObjectsOfType <Unlockable>()) { unlockable.UpdateState(); } }
public void ShowUnlocks() { if (unlockUnlocker == null) { unlockUnlocker = AchievementUnlocker.MakeUnlocker("allunlocks"); if (SaveManager.save.unlocks.Count == 13) { unlockUnlocker.UnlockAchievement(); } } if (modalBlocker.raycastTarget) { return; } if (menuState == MainMenuState.WorldSelect) { menuState = MainMenuState.Between; StartCoroutine(PlayAnimation(animation, "LevelSelectToUnlocks", false, () => { menuState = MainMenuState.Unlocks; })); } }
void Update() { if (!triedUnlock && Speed > 300 && GetComponent <GrapplingHook>().IsGrappled) { AchievementUnlocker.MakeUnlocker("topspeed").UnlockAchievement(); triedUnlock = true; } if (LevelStart.started && !LevelState.Dead) { float moment; #if UNITY_ANDROID || UNITY_IPHONE foreach (Touch touch in Input.touches) { moment = touch.deltaPosition.x * 60.0f / Screen.dpi; if (touch.phase == TouchPhase.Moved && Time.timeScale > 0.0f) { #else if (InputManager.dragging && Time.timeScale > 0.0f) { { moment = InputManager.frameDifference.x * 0.25f * (1024.0f / (float)Screen.width); #endif angle = moment * sensitivityX; angleChange += angle; Quaternion a = Quaternion.Euler(0, angle, 0); Vector3 outvec = a * GetComponent <Rigidbody>().velocity; outvec.y = GetComponent <Rigidbody>().velocity.y; GetComponent <Rigidbody>().velocity = outvec; transform.rotation *= a; } } } } void FixedUpdate() { if (!LevelState.Dead && !LevelState.HasFinished && !GetComponent <Rigidbody>().isKinematic) { float speedloss = Mathf.Clamp01(((90.0f - Mathf.Abs(angleChange)) / 90.0f) + (SPEEDLOSS_THRERSHHERLD * Time.deltaTime)); speedloss = 1.0f - (0.5f * (1.0f - speedloss)); angleChange = 0.0f; Vector3 vel = GetComponent <Rigidbody>().velocity; vel *= speedloss; vel.y = GetComponent <Rigidbody>().velocity.y; GetComponent <Rigidbody>().velocity = vel; float speed = vel.magnitude; if (SaveManager.save != null && speed > SaveManager.save.highestSpeed) { SaveManager.save.highestSpeed = speed; } } }
public void Update() { GameObject targetedObjectPrev = targetedObject; if (IsGrappled) { hangTime += Time.deltaTime; if (hangTime > 30 && !triedHangUnlock) { hangUnlocker = AchievementUnlocker.MakeUnlocker("hanginout"); hangUnlocker.UnlockAchievement(); triedHangUnlock = true; } } else { hangTime = 0; } // Do gamepad input // Detarget if (!Input.GetButton("Target")) { targetedObject = null; } // Target if (Input.GetButton("Target")) { Vector3 position = new Vector3(Input.GetAxis("Horizontal2"), Input.GetAxis("Vertical2"), 0); // Confirm axis to viewport space (-1..1 to 0..1) position += new Vector3(1.0f, 1.0f, 0); position /= 2.0f; // Find nearest object float distance = float.MaxValue; GameObject nearest = null; Vector3 viewPoint = Vector3.zero; foreach (GameObject gameObject in grappleable) { Vector3 inputViewportPoint = position; inputViewportPoint.z = 0; Vector3 objectViewportPoint = theCamera.WorldToViewportPoint(gameObject.transform.position); objectViewportPoint.z = 0; float gObjDistance = (inputViewportPoint - objectViewportPoint).magnitude; if (gObjDistance < distance) { distance = gObjDistance; nearest = gameObject; viewPoint = objectViewportPoint; } } if (nearest != null) { targetedObject = nearest; GrappleGuide grappleGuide = targetedObject.GetComponent <GrappleGuide>(); if (grappleGuide != null) { targetedObject = grappleGuide.grappleTo.gameObject; } } } // Update targeted object if (targetedObject != targetedObjectPrev) { string targetName = (targetedObject == null ? "null" : targetedObject.name); string oldTargetName = (targetedObjectPrev == null ? "null" : targetedObjectPrev.name); Debug.Log("New target: " + targetName + ", Old target: " + oldTargetName); if (targetedObject != null) { GameObject realObject = targetedObject; realObject.GetComponent <Renderer>().material.SetColor("_OutlineColor", Color.red); } if (targetedObjectPrev != null) { GameObject realObject = targetedObjectPrev; realObject.GetComponent <Renderer>().material.SetColor("_OutlineColor", Color.white); } } if (!enabled) { return; } // Detatch if (LevelStart.started && Input.GetButtonUp("Grapple")) { Detach(); } // Attach if (LevelStart.started && Input.GetButtonDown("Grapple") && targetedObject != null) { Vector3 viewPoint = theCamera.WorldToViewportPoint(targetedObject.transform.position); Ray ray = theCamera.ViewportPointToRay(viewPoint); RaycastHit hit; if (Physics.Raycast(ray, out hit)) // && (enableRegrapple || rope.enabled == false)) { if (hit.collider.gameObject != gameObject && hit.collider.gameObject.tag != "Ungrappleable") { if (rope.enabled == true) { Detach(); } Attach(hit, (transform.position - hit.point).magnitude, true); SoundManager.Play("attach"); } } } // Point the shield at the grapple point. if (rope.enabled) { // Point. shield.GetComponent <Renderer>().enabled = true; // Get the last point on the grapple. shield.transform.LookAt(grapples[grapples.Count - 1].gameObject.transform.position); shield.transform.Rotate(Vector3.right, 90); // // Widen the grapple the closer we are to our target. // // // Get the distance between the . // float actualDistance = (transform.position - grapples[grapples.Count - 1].gameObject.transform.position).magnitude; // float distanceFration = actualDistance / grapples[grapples.Count - 1].maxDistance; // // if(distanceFration < TRANSPARENCY_THRESHOLD) // { // ropeWidth = Mathf.Lerp(ropeWidth, ENABLED_THICKNESS, TRANSITION_RATE * Time.deltaTime); // } // else // { // ropeWidth = Mathf.Lerp(ropeWidth, DISABLED_THICKNESS, TRANSITION_RATE * Time.deltaTime); // } // // rope.SetWidth(ropeWidth, ropeWidth); } else { shield.GetComponent <Renderer>().enabled = false; } if (!ControlManager.MouseOnGUI) { if (!TutorialCamera.Enabled() && !EndFlagScript.hasFinished && !PauseButton.paused) { #if UNITY_ANDROID || UNITY_IPHONE Vector3 pos; foreach (Touch touch in Input.touches) { if (touch.phase == TouchPhase.Began) { // Register touch TouchData touchData = new TouchData(); touchData.fingerId = touch.fingerId; touchData.startTime = Time.time; localTouches.Add(touchData); } if (touch.phase == TouchPhase.Ended) { TouchData touchData = null; foreach (TouchData td in localTouches) { if (td.fingerId == touch.fingerId) { touchData = td; break; } } if (touchData != null) { pos = touch.position; localTouches.Remove(touchData); float startTime = touchData.startTime; float endTime = Time.time; float touchTime = endTime - startTime; // If the drag was less than the minimum time for grapple/ungrapple if (touchTime < CLICK_TIMER) { if (!IsGrappling()) { TryGrapple(pos); } else { Detach(); } } } } } #else if (InputManager.pressed) { pressTime = Time.time; } if (InputManager.released) { float touchTime = Time.time - pressTime; if (touchTime < CLICK_TIMER) { if (!IsGrappling()) { TryGrapple(Input.mousePosition); } else { Detach(); } } } #endif } } if (IsGrappling()) { // Shrink rope for "easy mode" float dist = (grapple.transform.position - transform.position).magnitude; if (dist < springJoint.maxDistance) { springJoint.maxDistance = dist; } } }