bool ThrowContent(Transform t) { bool flag = false; InteractControl i = t.GetComponent <InteractControl>(); if (filled && i.IsHuman) { filled = false; flag = true; Vector3 throwingAngle = i.throwingAngle; float throwPower = i.throwPower; float throwForce = i.throwForce; Vector3 v = new Vector3(throwingAngle.z, throwingAngle.y, throwingAngle.x); GameObject g = GameObject.Instantiate(liquidPrefab, transform.position, Quaternion.LookRotation(v)); //g.transform.parent = transform; //g.transform.rotation = Quaternion.LookRotation(v); ParticleSystem ps = g.GetComponentInChildren <ParticleSystem>(); if (ps) { var sh = ps.shape; sh.rotation = Quaternion.LookRotation(throwingAngle).eulerAngles; Debug.DrawRay(transform.position, throwingAngle, Color.blue, 3f); //sh.rotation = new Vector3(0 , sh.rotation.y, 0); ps.Play(); } g.GetComponent <Rigidbody>().AddForce(throwingAngle * throwPower * throwForce, ForceMode.Impulse); Destroy(g, 3.5f); liquidName = null; SetContent(null); liquidPrefab = null; } return(flag); }
protected override void Start() { base.Start(); movement = GetComponent <FPSMovementControl>(); movement?.setValues(playerCamera, characterInput); interactControl = GetComponent <InteractControl>(); interactControl?.setValues(playerCamera, characterInput); }
void OnTriggerExit(Collider collider) { if (this.isActiveAndEnabled && collider.gameObject.layer == LayerMask.NameToLayer("ObjectSafeArea") && !IsOnHand(collider.transform)) { InteractControl i = collider.GetComponentInParent <InteractControl>(); if (!i) { SetLayer(collider.transform.parent.transform, "Default"); } } }
void OnThrow(MessageArgs msg) { msg.received = true; InteractControl i = msg.sender.GetComponent <InteractControl>(); if (i) { if (i.IsHuman) { i.ReleaseHand(true, false, true); rig.AddForce(i.throwingAngle * i.throwPower * i.throwForce, ForceMode.Impulse); rig.maxAngularVelocity = maxAngVel; flyingWithSpin = true; } } //rig.AddTorque(spinForce * transform.right, ForceMode.Acceleration); }
bool TestRabbitHole(Transform t) { bool flag = false; user = t; if (user) { InteractControl interactControl = user.GetComponent <InteractControl>(); if (interactControl) { if (!interactControl.IsHuman) { flag = true; UseRabbitHole(); } } } return(flag); }
void OnInteract(MessageArgs msg) { //grab msg.received = true; interactControl = msg.sender.GetComponentInChildren <InteractControl>(); inventory = msg.sender.GetComponentInChildren <Inventory>(); inventory.SaveToInventory(transform, 0, true, false); gameObject.layer = LayerMask.NameToLayer("IgnorePlayer"); //GetComponent<Collider>().isTrigger = true; Debug.Log("girl inventory"); /* * if (interactControl.rightGrab != null && inventory.slots[0] != null){ * * } * else { * * } */ }
bool GetOnLadder(Transform t) { bool success = false; RaycastHit[] hits = Physics.RaycastAll(t.position, t.forward, 2); for (int i = 0; i < hits.Length; i++) { if (hits[i].transform == transform) { success = true; InteractControl interactControl = t.GetComponent <InteractControl>(); if (interactControl) { interactControl.ReleaseHand(); interactControl.rightGrab = transform; interactControl.leftGrab = transform; interactControl.rightHandGrabbing = true; interactControl.leftHandGrabbing = true; interactControl.rigidbodyConstraints[0] = GetComponent <Rigidbody>().constraints; } ladderPoint.position = new Vector3(hits[i].point.x + ladderPoint.localPosition.z, hits[i].point.y, ladderPoint.position.z); onLadder = true; user = t; if (t.GetComponent <PlayerMovement>()) { t.GetComponent <PlayerMovement>().enabled = false; } gameObject.layer = LayerMask.NameToLayer("IgnorePlayer"); t.rotation = Quaternion.LookRotation(transform.forward); Debug.Log("GettingOnLadder"); Debug.DrawRay(transform.position, transform.forward, Color.black, 3f); } } return(success); }
bool GetLiquid(Transform t) { bool flag = false; InteractControl i = t.GetComponent <InteractControl>(); if (i) { if (i.IsHuman) { if (i.rightGrab) { Bucket b = i.rightGrab.GetComponentInChildren <Bucket>(); if (b) { flag = true; b.FillBucketWith(liquidName, contentPrefab[0], liquidPrefab[0]); } } } } return(flag); }
void OnTriggerStay(Collider other) { if (this.enabled) { if ((TagMatch(other.tag) && LayerMatch(LayerMask.LayerToName(other.gameObject.layer))) && OnArray(other.transform) == -1) { //small test (if on other playable cahracter then get only if is on the right hand) if (!other.GetComponentInParent <InteractControl>()) { possibleinteracts.Add(other.transform); } else { InteractControl i = other.GetComponentInParent <InteractControl>(); if (i.rightGrab == other.transform || (i.leftGrab == other.transform && !i.rightGrab)) { possibleinteracts.Add(other.transform); } } } } }
/*void DropItem(){ * //Debug.Log("posItem: "+possibleItem); * //Debug.Log(previousAnchorPivot); * item.SetParent(previousAnchorPivot); * foreach (Collider c in item.GetComponents<Collider>()) * { * if (!c.isTrigger) c.enabled = true; * } * if (item.GetComponent<Rigidbody>()) item.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezePositionZ; * //Destroy(AnchorPivot.Find("itemPivot").gameObject); * // myObjList.Where(x => x.name == yourname).SingleOrDefault(); * //if (previousAnchorPivot) item.SetParent(previousAnchorPivot); * //else item.DetachChildren(); * grabbing=false; * Debug.Log("Not grabbing"); * } */ public void GrabItem(Transform obj, bool OnRight) { //test if obj is hand of other playable cahracter if (obj.GetComponentInParent <InteractControl>()) { InteractControl i = obj.GetComponentInParent <InteractControl>(); if (i.rightGrab == obj) { i.SendMessageReleaseHand(true, false); } else if (i.leftGrab == obj) { i.SendMessageReleaseHand(false, true); } } int hand = 0; if (OnRight) { rightHandGrabbing = true; rightGrab = obj; hand = 0; } else { leftHandGrabbing = true; leftGrab = obj; hand = 1; } //Debug.Log("Grab"); ItemParent[hand] = obj.parent; //GameObject g = new GameObject(); //g.name = "itemPivot"; //g.transform.parent = AnchorPivot.transform; //item.transform.parent = g.transform; obj.parent = HandPivot[hand]; /* * obj.localPosition = Vector3.zero; * obj.localRotation = Quaternion.identity; */ rightGrab.SendMessage("OnGrab", new MessageArgs(transform), SendMessageOptions.DontRequireReceiver); StopCoroutine("GrabOverTime"); StartCoroutine(GrabOverTime(obj, HandPivot[hand], 10f, hand)); if (obj.GetComponent <Rigidbody>()) { rigidbodyConstraints[hand] = obj.GetComponent <Rigidbody>().constraints; obj.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; } /*foreach (Collider c in obj.GetComponents<Collider>()) * { * //if (!c.isTrigger) c.enabled = false; //test * if (!c.isTrigger) c.isTrigger = true; * }*/ SetLayer(obj, "IgnorePlayer"); //SetIgnoreCollision(obj.GetComponentInChildren<Collider>(), true); }
void Start() { interactControl = GetComponent <InteractControl>(); }
// Start is called before the first frame update void Start() { spellDisplay = GetComponent <TextMeshProUGUI>(); ic = playerGameObject.GetComponent <InteractControl>(); }