public void ResetTarget() { target = null; hitInfo = new RaycastHit(); reticle.ResetTargetBodyScale(); focusOnTargetWithoutInterruptionSec = 0; }
IEnumerator SummonHeartCo(InteractiveThing thing) { if (this.name == "skull1") { LeanTween.move(this.gameObject, new Vector3(ring1.transform.position.x, ring1.transform.position.y + 0.3f, ring1.transform.position.z), 2f).setEase(LeanTweenType.easeOutSine); LeanTween.rotate(this.gameObject, new Vector3(0, 0, 0), 2f).setEase(LeanTweenType.easeOutSine); skullCount++; } else if (this.name == "skull2") { LeanTween.move(this.gameObject, new Vector3(ring2.transform.position.x, ring2.transform.position.y + 0.3f, ring2.transform.position.z), 2f).setEase(LeanTweenType.easeOutSine); LeanTween.rotate(this.gameObject, new Vector3(0, 0, 0), 2f).setEase(LeanTweenType.easeOutSine); skullCount++; } else if (this.name == "skull3") { LeanTween.move(this.gameObject, new Vector3(ring3.transform.position.x, ring3.transform.position.y + 0.3f, ring3.transform.position.z), 2f).setEase(LeanTweenType.easeOutSine); LeanTween.rotate(this.gameObject, new Vector3(0, 0, 0), 2f).setEase(LeanTweenType.easeOutSine); skullCount++; } if (skullCount >= 3) { darkhole.SetActive(true); LeanTween.scale(darkhole.gameObject, darkhole_scale, 2f).setEase(LeanTweenType.easeOutSine); yield return(new WaitForSeconds(1.5f)); LeanTween.move(heart.gameObject, heart_pos, 2f).setEase(LeanTweenType.easeOutSine); } yield return(new WaitForSeconds(0.2f)); //gameObject.SetActive(false); }
public void Add(InteractiveThing thing) { if (!(thing is ObtainableItem)) return; items.Add(thing as ObtainableItem); }
public override void InteractWith(InteractiveThing thing) { if (!IsAbleToInteractWith(thing)) return; StartCoroutine(OpenLockCo(thing)); }
void Start() { interactiveThing = GetComponent<InteractiveThing>(); interactiveThing.isAbleToInteract = false; King.visitor.sight.enabled = false; StartCoroutine(ActivateAfterSec(activateAfterSec)); }
void Start() { interactiveThing = GetComponent <InteractiveThing>(); interactiveThing.isAbleToInteract = false; King.visitor.sight.enabled = false; StartCoroutine(ActivateAfterSec(activateAfterSec)); }
public void Add(InteractiveThing thing) { if (!(thing is ObtainableItem)) { return; } items.Add(thing as ObtainableItem); }
public override void InteractWith(InteractiveThing thing) { if (!IsAbleToInteractWith(thing)) { return; } StartCoroutine(OpenLockCo(thing)); }
public override void InteractWith(InteractiveThing thing) { if (!IsAbleToInteractWith(thing)) { Debug.Log(this+" can't interact with "+thing); return; } thing.isAbleToInteract = false; StartCoroutine(OpenKeyhole(thing)); }
public override void InteractWith(InteractiveThing thing) { if (!IsAbleToInteractWith(thing)) { Debug.Log(this + " can't interact with " + thing); return; } thing.isAbleToInteract = false; StartCoroutine(OpenKeyhole(thing)); }
public bool IsAbleToInteractWith(InteractiveThing thing) { if (!thing.isAbleToInteract) return false; foreach (Interaction interaction in interactions) { if (interaction.IsAbleToInteractWith(thing)) { return true; } } return false; }
public bool Interact(InteractiveThing thing) { Debug.Log("Visitor tries to use "+this+" with "+thing); // Use interaction script to determin if this thing can interact with an object. foreach (Interaction interaction in interactions) { if (interaction.IsAbleToInteractWith(thing)) { interaction.InteractWith(thing); isAbleToInteract = false; } } return true; }
public override bool IsAbleToInteractWith(InteractiveThing thing) { //if (HName.GetPure(thing.name) != "lock") if (thing.name != "Lock") return false; var targetLock = thing.interactions.Find(it => it is TempLock) as TempLock; if (targetLock != null && targetLock.lockID == lockID) return true; else return false; //return HName.GetPure(thing.name) == "lock" && (thing as ObtainableItem).; }
IEnumerator KnifeThrowCo(InteractiveThing thing) { LeanTween.rotate(this.gameObject, new Vector3(90, 0, -30), 2f).setEase(LeanTweenType.easeOutSine); yield return(new WaitForSeconds(3f)); LeanTween.move(this.gameObject, thing.transform.position, 1.5f).setEase(LeanTweenType.easeOutSine); yield return(new WaitForSeconds(1.2f)); webstring.SetActive(false); spider.GetComponent <ObtainableItem>().isAbleToInteract = true; spider.GetComponent <Rigidbody>().isKinematic = false; spider.GetComponent <Rigidbody>().useGravity = true; LeanTween.rotate(spider.gameObject, new Vector3(0, 0, 0), 1f).setEase(LeanTweenType.easeOutSine); yield return(null); }
public bool Interact(InteractiveThing thing) { Debug.Log("Visitor tries to use " + this + " with " + thing); // Use interaction script to determin if this thing can interact with an object. foreach (Interaction interaction in interactions) { if (interaction.IsAbleToInteractWith(thing)) { interaction.InteractWith(thing); isAbleToInteract = false; } } return(true); }
public bool IsAbleToInteractWith(InteractiveThing thing) { if (!thing.isAbleToInteract) { return(false); } foreach (Interaction interaction in interactions) { if (interaction.IsAbleToInteractWith(thing)) { return(true); } } return(false); }
public override void InteractWith(InteractiveThing thing) { var _rigidbody = GetComponent<Rigidbody>(); _rigidbody.isKinematic = false; _rigidbody.useGravity = true; var force = throwForce; if (thing.GetComponent<ForceOverrider> ()) { force = thing.GetComponent<ForceOverrider>().newForce; } _rigidbody.AddForce((King.visitor.sight.facingVector + Vector3.up * 1.5f) * force, ForceMode.Impulse); StartCoroutine(UnblockCo()); }
IEnumerator OpenKeyhole(InteractiveThing thing) { var options = new Hashtable (); options.Add ("ease", "easeOutCubic"); LeanTween.move(gameObject, thing.transform.position, 2f).setEase(LeanTweenType.easeOutSine); LeanTween.rotate(gameObject, thing.transform.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeOutSine); yield return new WaitForSeconds(2f); if (target != null) { target.SendMessage("OnKeyUse"); } else { Debug.LogError(this+" doesn't have a target door"); } //transform.parent.SendMessage("OnPointCollect", SendMessageOptions.DontRequireReceiver); }
public override void InteractWith(InteractiveThing thing) { var _rigidbody = GetComponent <Rigidbody>(); _rigidbody.isKinematic = false; _rigidbody.useGravity = true; var force = throwForce; if (thing.GetComponent <ForceOverrider> ()) { force = thing.GetComponent <ForceOverrider>().newForce; } _rigidbody.AddForce((King.visitor.sight.facingVector + Vector3.up * 1.5f) * force, ForceMode.Impulse); StartCoroutine(UnblockCo()); }
IEnumerator MakePopcornCo(InteractiveThing thing) { LeanTween.move(gameObject, thing.transform.position, 2f).setEase(LeanTweenType.easeOutSine); yield return(new WaitForSeconds(3f)); var currentScale = initScale; for (int i = 0; i < popcorn.Length; i++) { var pop = popcorn[i]; pop.gameObject.SetActive(true); var prevScale = currentScale; currentScale = currentScale * 0.9f; soundPlayer.PlayOneShot(i); LeanTween.scale(cornBody, currentScale, 0.1f).setEase(LeanTweenType.easeInCirc); yield return(new WaitForSeconds(0.1f)); var randomForce = Random.Range(0.1f, 0.2f); pop.GetComponent <Rigidbody>().useGravity = true; pop.GetComponent <Rigidbody>().isKinematic = false; pop.GetComponent <Rigidbody>().AddForce(Vector3.back * randomForce, ForceMode.Impulse); LeanTween.scale(cornBody, prevScale, 0.1f).setEase(LeanTweenType.easeInOutCirc); yield return(new WaitForSeconds(0.25f)); } /* * popcorn.gameObject.SetActive(true); * * popcorn.GetComponent<Rigidbody>().useGravity = true; * popcorn.GetComponent<Rigidbody>().isKinematic = false; * popcorn.GetComponent<Rigidbody>().AddForce(Vector3.back * 0.25f, ForceMode.Impulse); */ LeanTween.scale(cornBody, Vector3.zero, 0.2f).setEase(LeanTweenType.easeInCirc); yield return(new WaitForSeconds(0.2f)); gameObject.SetActive(false); }
IEnumerator OpenLockCo(InteractiveThing thing) { var tempLock = thing.GetComponent <TempLock>(); // Rotate the lock toward the key. var lockLookRotation = Quaternion.LookRotation(transform.position - tempLock.transform.position); LeanTween.rotate(tempLock.gameObject, lockLookRotation.eulerAngles, 0.5f); yield return(new WaitForSeconds(0.5f)); // Move the key towards the lock. LeanTween.move(gameObject, tempLock.keyOutsidePoint.position, 2f).setEase(LeanTweenType.easeOutSine); LeanTween.rotate(gameObject, tempLock.keyOutsidePoint.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeOutSine); yield return(new WaitForSeconds(2f + 0.25f)); // Move the key inside the lock. LeanTween.move(gameObject, tempLock.keyInsidePoint.position, 0.25f).setEase(LeanTweenType.easeOutSine); if (_audioSource != null) { _audioSource.Play(); } yield return(new WaitForSeconds(0.25f)); // Rotate the key in the lock. LeanTween.rotate(gameObject, tempLock.keyInsidePoint.eulerAngles, 0.5f); yield return(new WaitForSeconds(0.5f)); tempLock.receiver.Interact(); transform.parent = tempLock.transform; LeanTween.move(tempLock.gameObject, tempLock.transform.position + tempLock.transform.forward * 0.25f, 1f).setEase(LeanTweenType.easeOutSine); yield return(new WaitForSeconds(1f)); GetComponent <Rigidbody>().detectCollisions = false; tempLock.GetComponent <Rigidbody>().isKinematic = false; tempLock.GetComponent <InteractiveThing>().isAbleToInteract = false; }
IEnumerator MakePopcornCo(InteractiveThing thing) { LeanTween.move(gameObject, thing.transform.position, 2f).setEase(LeanTweenType.easeOutSine); yield return new WaitForSeconds(3f); var currentScale = initScale; for (int i = 0; i < popcorn.Length; i++) { var pop = popcorn[i]; pop.gameObject.SetActive(true); var prevScale = currentScale; currentScale = currentScale * 0.9f; soundPlayer.PlayOneShot(i); LeanTween.scale(cornBody, currentScale, 0.1f).setEase(LeanTweenType.easeInCirc); yield return new WaitForSeconds (0.1f); var randomForce = Random.Range(0.1f, 0.2f); pop.GetComponent<Rigidbody>().useGravity = true; pop.GetComponent<Rigidbody>().isKinematic = false; pop.GetComponent<Rigidbody>().AddForce(Vector3.back * randomForce, ForceMode.Impulse); LeanTween.scale(cornBody, prevScale, 0.1f).setEase(LeanTweenType.easeInOutCirc); yield return new WaitForSeconds (0.25f); } /* popcorn.gameObject.SetActive(true); popcorn.GetComponent<Rigidbody>().useGravity = true; popcorn.GetComponent<Rigidbody>().isKinematic = false; popcorn.GetComponent<Rigidbody>().AddForce(Vector3.back * 0.25f, ForceMode.Impulse); */ LeanTween.scale(cornBody, Vector3.zero, 0.2f).setEase(LeanTweenType.easeInCirc); yield return new WaitForSeconds (0.2f); gameObject.SetActive(false); }
IEnumerator OpenLockCo(InteractiveThing thing) { var tempLock = thing.GetComponent<TempLock>(); // Rotate the lock toward the key. var lockLookRotation = Quaternion.LookRotation(transform.position - tempLock.transform.position); LeanTween.rotate(tempLock.gameObject, lockLookRotation.eulerAngles, 0.5f); yield return new WaitForSeconds(0.5f); // Move the key towards the lock. LeanTween.move(gameObject, tempLock.keyOutsidePoint.position, 2f).setEase(LeanTweenType.easeOutSine); LeanTween.rotate(gameObject, tempLock.keyOutsidePoint.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeOutSine); yield return new WaitForSeconds(2f + 0.25f); // Move the key inside the lock. LeanTween.move(gameObject, tempLock.keyInsidePoint.position, 0.25f).setEase(LeanTweenType.easeOutSine); if (_audioSource != null) _audioSource.Play(); yield return new WaitForSeconds(0.25f); // Rotate the key in the lock. LeanTween.rotate(gameObject, tempLock.keyInsidePoint.eulerAngles, 0.5f); yield return new WaitForSeconds(0.5f); tempLock.receiver.Interact(); transform.parent = tempLock.transform; LeanTween.move(tempLock.gameObject, tempLock.transform.position + tempLock.transform.forward * 0.25f, 1f).setEase(LeanTweenType.easeOutSine); yield return new WaitForSeconds(1f); GetComponent<Rigidbody>().detectCollisions = false; tempLock.GetComponent<Rigidbody>().isKinematic = false; tempLock.GetComponent<InteractiveThing>().isAbleToInteract = false; }
public override bool IsAbleToInteractWith(InteractiveThing thing) { //if (HName.GetPure(thing.name) != "lock") if (thing.name != "Lock") { return(false); } var targetLock = thing.interactions.Find(it => it is TempLock) as TempLock; if (targetLock != null && targetLock.lockID == lockID) { return(true); } else { return(false); } //return HName.GetPure(thing.name) == "lock" && (thing as ObtainableItem).; }
IEnumerator OpenKeyhole(InteractiveThing thing) { var options = new Hashtable(); options.Add("ease", "easeOutCubic"); LeanTween.move(gameObject, thing.transform.position, 2f).setEase(LeanTweenType.easeOutSine); LeanTween.rotate(gameObject, thing.transform.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeOutSine); yield return(new WaitForSeconds(2f)); if (target != null) { target.SendMessage("OnKeyUse"); } else { Debug.LogError(this + " doesn't have a target door"); } //transform.parent.SendMessage("OnPointCollect", SendMessageOptions.DontRequireReceiver); }
public virtual bool IsAbleToInteractWith(InteractiveThing thing) { return(false); }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return(thing.name == ("heartRing")); }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return false; }
public virtual bool IsAbleToInteractWith(InteractiveThing thing) { return false; }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return thing.name == "ThrowingSurface"; }
public override void InteractWith(InteractiveThing thing) { StartCoroutine(KnifeThrowCo(thing)); }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return(false); }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return(thing is SurfaceForItems); }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return(thing.name == "Keyhole"); }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return thing.name == "Fireplace"; }
void Start() { target = target == null?GetComponent <InteractiveThing>() : target; StartCoroutine(ActivateAfterSecCo()); }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return thing.name == "Keyhole"; }
public override void InteractWith(InteractiveThing thing) { var cauldron = thing as Cauldron; cauldron.Add(GetComponent<ObtainableItem>()); }
public override void InteractWith(InteractiveThing thing) { var surface = thing as SurfaceForItems; surface.AddItem(GetComponent <ObtainableItem>()); }
public override void InteractWith(InteractiveThing thing) { }
public override void InteractWith(InteractiveThing thing) { StartCoroutine(MakePopcornCo(thing)); }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return(thing.name == "ThrowingSurface"); }
void UpdateInteractions() { if (!sight.enabled || sight.target == null || !sight.target.isAbleToInteract) { return; } InteractiveThing target = sight.target; var focusTimeSec = target.hasItsOwnFocusTime ? target.focusTimeSec : defaultFocusTimeSec; if (itemInHand != null && itemInHand.isAbleToInteract) { if (target != null && target != itemInHand && sight.focusOnTargetWithoutInterruptionSec > focusTimeSec) { if (itemInHand.IsAbleToInteractWith(target)) { itemInHand.Interact(target); /* * itemInHand = null; * sight.reticle.SetBody(0); * sight.ResetTarget(); */ Drop(itemInHand); } if (target is InventorySpot) { var inventorySpot = target as InventorySpot; if (inventorySpot.item == null) { inventorySpot.Add(itemInHand); /* * itemInHand = null; * sight.reticle.SetBody(0); * sight.ResetTarget(); */ Drop(itemInHand); } } } } else if (itemInHand == null) { if (target != null && sight.focusOnTargetWithoutInterruptionSec > focusTimeSec) { if (target is ObtainableItem) { Take(target as ObtainableItem); } else if (target is InteractiveObject) { var interactiveObject = target as InteractiveObject; if (interactiveObject.isAbleToBeActivatedOnItsOwn) { //Debug.Log("Visitor activates "+target); interactiveObject.Activate(); } } } } }
void UpdateTarget() { if (hitInfo.collider == null) { target = null; return; } var thing = GetInteractiveThing(hitInfo.collider); if (thing == null && hitInfo.rigidbody != null) { thing = GetInteractiveThing(hitInfo.rigidbody); } target = thing; }
public virtual void InteractWith(InteractiveThing thing) { }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return(thing is Cauldron); }
public override void InteractWith(InteractiveThing thing) { var cauldron = thing as Cauldron; cauldron.Add(GetComponent <ObtainableItem>()); }
InteractiveThing GetInteractiveThing(Component component) { var thing = component.GetComponent<InteractiveThing>(); if (thing != null) { target = thing; } else { var link = component.GetComponent<LinkToInteractiveThing>(); thing = link != null ? link.target : null; } return thing; }
public override bool IsAbleToInteractWith(InteractiveThing thing) { return (thing is Cauldron); }
public override void InteractWith(InteractiveThing thing) { StartCoroutine(SummonHeartCo(thing)); }