Exemplo n.º 1
0
        private void ThrowCExploderClone()
        {
            if (cExploderClone)
            {
                IsThrowing = false;

                // Throw grenade
                cExploderClone.transform.SetParent(null, true);
                Rigidbody rb = cExploderClone.GetComponent <Rigidbody>();
                if (rb)
                {
                    rb.isKinematic = false;
                    rb.GetComponent <Collider>().enabled = true;
                    rb.velocity = throwDir * Mathf.Lerp(
                        cExploderClone.throwForceMinMax.x, cExploderClone.throwForceMinMax.y,
                        animator.GetFloat(cap_ThrowDistance)) / (cExploderClone.landingFireForceDivisor == 0 ? 1 : cExploderClone.landingFireForceDivisor);
                }

                if (cExploderClone.GetComponent <LineRenderer>())
                {
                    cExploderClone.GetComponent <LineRenderer>().SetVertexCount(2);
                    cExploderClone.GetComponent <LineRenderer>().enabled = false;
                }

                cExploderClone.gameObject.AddComponent <Destroy>();
                cExploderClone.GetComponent <Destroy>().destroyTime = cExploderClone.GetComponent <Exploder>().modelDestroyTime;

                CalculateNextThrowable();
                Events.InvokeOnThrow(cExploderClone);
                Events.InvokeThrowableExit(cExploderClone);
            }
        }
Exemplo n.º 2
0
        public void HandOnBomb()
        {
            if (_mirroredAnimDoubleHandOnCall_IsCalled)
            {
                return;
            }

            _mirroredAnimDoubleHandOnCall_IsCalled = true;
            GameObject newExp = null;

            if (!UseMirrorThrow)
            {
                newExp = Instantiate(player.throwableBag[CurrentThrowableIndex].throwablePrefab.gameObject,
                                     leftHandHold.position, leftHandHold.rotation) as GameObject;
                newExp.transform.SetParent(leftHandHold);
            }
            else
            {
                newExp = Instantiate(player.throwableBag[CurrentThrowableIndex].throwablePrefab.gameObject,
                                     rightHandHold2.position, rightHandHold2.rotation) as GameObject;
                newExp.transform.SetParent(rightHandHold2);
            }
            if (newExp.GetComponent <Rigidbody>())
            {
                newExp.GetComponent <Rigidbody>().isKinematic = true;
            }
            if (newExp.GetComponent <Collider>())
            {
                newExp.GetComponent <Collider>().enabled = false;
            }
            cExploderClone = newExp.GetComponent <Exploder>();
            if (cExploderClone.GetComponent <LineRenderer>())
            {
                cExploderClone.GetComponent <LineRenderer>().enabled = true;
            }

            Events.InvokeOnPullOut(cExploderClone);

            cExploderClone.PlayRandomSoundAsWeaponChild(cExploderPrefab.sounds.pins, transform, true);
        }