void Catch(MTK_Interactable interactable) { if (Time.time > m_lastActivationTime + m_activationCooldown) { if (!interactable.jointType.Used() && !catchedObject && !interactable.isDistanceGrabbed) { m_lastActivationTime = Time.time; if (m_snapToCenter) { interactable.transform.position = transform.position; } interactable.jointType.JoinWith(gameObject); GetComponent <Joint>().breakForce = float.MaxValue; AkSoundEngine.PostEvent("Socle_Activated_Play", gameObject); catchedObject = interactable; interactable.jointType.onJointBreak.AddListener(Release); interactable.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePosition; interactable.isDistanceGrabbable = false; IcoPlanet icoplanet = interactable.GetComponent <IcoPlanet>(); if (icoplanet) { StartCoroutine(AnimatePlanet(icoplanet, 0.12f, 15)); onPlanetCatched.Invoke(true); } m_visual.SetActive(false); m_nbObjectsInTrigger = 0; onObjectCatched.Invoke(true); } } }
public void Release() { if (catchedObject) { catchedObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; m_lastActivationTime = Time.time; onObjectCatched.Invoke(false); catchedObject.jointType.onJointBreak.RemoveListener(Release); catchedObject.isDistanceGrabbable = true; MTK_Interactable tmp = catchedObject; catchedObject = null; IcoPlanet icoplanet = tmp.GetComponent <IcoPlanet>(); if (icoplanet) { StartCoroutine(AnimatePlanet(icoplanet, 0.04f, 4.2f)); onPlanetCatched.Invoke(false); } tmp.jointType.RemoveJoint(); tmp.GetComponent <Rigidbody>().AddForce(m_ejectForce * Vector3.up, ForceMode.Impulse); m_nbObjectsInTrigger = 0; objInTrigger = null; m_button.SetActive(false); } }
protected override void OnWorkshopUpdateState(bool state, MTK_Interactable current) { if (state) { m_scaleEffect = current.GetComponent <ScaleEffect>(); if (!m_scaleEffect) { m_scaleEffect = current.gameObject.AddComponent <ScaleEffect>(); m_scaleEffect.ApplyEffect(); } AkSoundEngine.PostEvent("LFO_Scale_Play", gameObject); } else { if (m_scaleEffect) { m_scaleEffect.RemoveEffect(); } m_scaleEffect = null; AkSoundEngine.PostEvent("LFO_Scale_Stop", gameObject); } }
bool IsLevitating(MTK_Interactable interactable) { Rigidbody rb = interactable.GetComponent <Rigidbody>(); if (rb) { return(!rb.useGravity); } return(false); }
void SetLevitation(MTK_Interactable interactable, bool value) { Rigidbody rb = interactable.GetComponent <Rigidbody>(); if (rb) { if (value) { interactable.GetComponent <Rigidbody>().isKinematic = false; interactable.GetComponent <Rigidbody>().drag = 0; interactable.UseEffects = false; rb.velocity = Vector3.up; rb.angularVelocity = Random.onUnitSphere; m_lastForceApplied = Vector3.zero; } rb.useGravity = !value; // !gravity = levitate } }
public void NotifyGrab(MTK_Interactable grabbed) { m_grabbedList.Add(grabbed); m_scalerDrop.enabled = true; if (grabbed.GetComponent <IcoPlanet>()) { m_tileDrop.enabled = m_placerDrop.enabled = true; } }
private void OnTriggerEnter(Collider other) { if (other.attachedRigidbody) { MTK_Interactable interactable = other.attachedRigidbody.GetComponent <MTK_Interactable>(); if (interactable && interactable.isGrabbable && !interactable.isDistanceGrabbed) { UpdateTPZone(interactable.GetComponent <IcoPlanet>(), true); if (!other.attachedRigidbody.gameObject.GetComponent <PlanetEffect>()) { if (!other.GetComponentInParent <IcoSegment>()) { PlanetEffect eff = other.attachedRigidbody.gameObject.AddComponent <PlanetEffect>(); if (eff) { eff.maxSpeed = m_maxSpeed; eff.accelerationForce = m_accelerationForce; eff.impactForce = impactForce; eff.sunRigidbody = m_rb; m_planetEffectsList.Add(eff); eff.explosionEffect = m_explosionEffect; UpdateState(m_planetEffectsList.Count); if (m_exclusionPlatform.m_objectsInTrigger.Contains(eff.gameObject)) { eff.effectActive = false; eff.GetComponent <Rigidbody>().useGravity = true; } } } } } } }