//checa se o inimigo agarrado esta morto, pra largar. void CheckIsEnemyDie() { if (PickedCollider.GetComponent <FSMMosquito> () != null) { if (PickedCollider.GetComponent <FSMMosquito> ().state == FSMMosquito.FSMStates.Die) { PickedCollider.transform.SetParent(null); PickedCollider.GetComponent <Rigidbody> ().isKinematic = false; PickedCollider.transform.eulerAngles = new Vector3(0, 0, 0); PickedCollider.GetComponent <Rigidbody> ().AddForce(transform.forward * Force); PickedCollider.GetComponent <Collider>().isTrigger = false; PickedObj = null; PickedCollider = null; CanPick = true; transform.parent.GetComponent <Movimentacao3D> ().CanMove = true; transform.parent.GetComponent <Movimentacao3D> ().SetGrabbedAnim(false); } } }
// Update is called once per frame void Update() { LocateObject(); if (PickedCollider != null) { if (PickedCollider.GetComponent <FSMMosquito> () != null) { CheckIsEnemyDie(); } } if (PlayerNum != 0) { if (KeyboardCanControl) { if (Input.GetButtonDown("B P" + PlayerNum) && !Grabbing || Input.GetKeyDown(KeyCode.L) && !Grabbing) { if (CanPick) { transform.parent.GetComponent <Movimentacao3D> ().SetGrabAnim(); } else { transform.parent.GetComponent <Movimentacao3D> ().SetGrabAnim(); } } } else { if (Input.GetButtonDown("B P" + PlayerNum) && !Grabbing) { if (CanPick) { transform.parent.GetComponent <Movimentacao3D> ().SetGrabAnim(); } else { transform.parent.GetComponent <Movimentacao3D> ().SetGrabAnim(); } } } } }
public void ThrowEnemy() { if (PickedCollider.GetComponent <FSMMosquito> () != null) { PickedCollider.GetComponent <FSMMosquito> ().state = FSMMosquito.FSMStates.Thrown; } PickedCollider.transform.SetParent(null); PickedCollider.GetComponent <Rigidbody> ().isKinematic = false; PickedCollider.transform.eulerAngles = new Vector3(0, 0, 0); if (PickedCollider.CompareTag("Box")) { PickedCollider.GetComponent <Rigidbody> ().AddForce(transform.parent.forward * Force * 2); PickedCollider.GetComponent <DestruirObjeto> ().Throwed = true; transform.parent.GetComponent <ApplyCombo> ().enabled = true; } else { PickedCollider.GetComponent <Rigidbody> ().AddForce(transform.parent.forward * Force); } PickedCollider.GetComponent <Collider>().isTrigger = false; PickedObj = null; PickedCollider = null; CanPick = true; }
void PickObject() { if (ColliderInRange == null) { return; } if (ColliderInRange.CompareTag("Box")) { CanPick = false; transform.parent.GetComponent <Movimentacao3D> ().SetGrabbedAnim(true); PickedObj = ColliderInRange.gameObject; PickedCollider = ColliderInRange.gameObject; PickedObj.transform.SetParent(FixPoint2); PickedObj.transform.position = FixPoint2.position; PickedObj.transform.rotation = FixPoint2.rotation; PickedObj.GetComponent <Collider>().isTrigger = true; PickedObj.GetComponent <Rigidbody> ().isKinematic = true; transform.parent.GetComponent <ApplyCombo> ().enabled = false; } else if (ColliderInRange.CompareTag("Enemy")) { transform.parent.GetComponent <Movimentacao3D> ().SetGrabbedAnim(true); CanPick = false; PickedCollider = ColliderInRange.gameObject; //PickedObj = ColliderInRange.gameObject.GetComponentInChildren<PointOfGrab>().gameObject; PickedCollider.transform.SetParent(FixPoint2); PickedCollider.transform.position = FixPoint2.position + PickedCollider.GetComponentInChildren <PointOfGrab>().Offset; PickedCollider.GetComponent <Collider>().isTrigger = true; PickedCollider.GetComponent <Rigidbody> ().isKinematic = true; if (PickedCollider.GetComponent <FSMMosquito> () != null) { PickedCollider.GetComponent <FSMMosquito> ().state = FSMMosquito.FSMStates.Grappled; } } }