Exemple #1
0
 private void ExplodeObject(GameObject gameObject)
 {
     ExploderUtils.SetActive(ExploderObjectInstance.gameObject, true);
     ExploderObjectInstance.transform.position = ExploderUtils.GetCentroid(gameObject);
     ExploderObjectInstance.Radius             = 1.0f;
     ExploderObjectInstance.Explode();
 }
    public void Explode(bool bPlayWetSounds = false)
    {
        if (!_destroyed)
        {
            _destroyed = true;

            if (bPlayWetSounds)
            {
                PlayRandomSound(eggImpactSoundsWet, true);
            }
            else
            {
                PlayRandomSound(eggImpactSoundsDry, true);
            }

            this.tag = "Exploder";
            _exploder.Explode();

            if (eggLeftoversGO != null && Random.value < chanceForEggLeftovers)
            {
                Vector3 pos = this.transform.position + new Vector3(0f, 0.5f, 0f);
                Instantiate(eggLeftoversGO, pos, Quaternion.identity);
            }
        }
    }
Exemple #3
0
        private void OnGUI()
        {
            if (GUI.Button(new Rect(10, 10, 100, 30), "Explode!"))
            {
                if (Exploder)
                {
                    Exploder.Explode();
                }
            }

            if (GUI.Button(new Rect(130, 10, 100, 30), "Reset"))
            {
                // activate exploder
                ExploderUtils.SetActive(Exploder.gameObject, true);

                if (!Exploder.DestroyOriginalObject)
                {
                    foreach (var destroyableObject in DestroyableObjects)
                    {
                        ExploderUtils.SetActiveRecursively(destroyableObject, true);
                    }
                    ExploderUtils.SetActive(Exploder.gameObject, true);
                }
            }
        }
Exemple #4
0
 private void Phase5()
 {
     _rigidbody.velocity = Vector3.zero;
     _animator.SetBool("Walking", false);
     transform.eulerAngles = new Vector3(-85f, 180f, 0);
     _exploder.Explode();
 }
Exemple #5
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         ExploderObject exploder = GameObject.Find("exploder").GetComponent <ExploderObject>();
         exploder.gameObject.SetActive(true);
         exploder.transform.position = transform.position;
         exploder.Explode();
     }
 }
Exemple #6
0
        void ExplodeObject(GameObject obj)
        {
            // activate exploder
            ExploderUtils.SetActive(Exploder.gameObject, true);

            // move exploder object to the same position
            Exploder.transform.position = ExploderUtils.GetCentroid(obj);

            // decrease the radius so the exploder is not interfering other objects
            Exploder.Radius = 0.1f;

            // DONE!
#if ENABLE_CRACK_AND_EXPLODE
            Exploder.Crack(OnCracked);
#else
            Exploder.Explode(OnExplosion);
#endif
        }
    public void Explode()
    {
        if (explosionInProgress)
        {
            return;
        }

        explosionInProgress = true;
        throwing            = false;

        if (!Impact)
        {
            // grenade is still in the air
            explodeTimeoutMax = 5.0f;
        }
        else
        {
            exploder.transform.position = transform.position;

            // dont destroy exploder game object
            exploder.ExplodeSelf = false;

            // dont use force vector, default is explosion in every direction
            exploder.UseForceVector = false;

            // set explosion radius to 5 meters
            exploder.Radius = 5.0f;

            // fragment pieces
            exploder.TargetFragments = 200;

            // adjust force
            exploder.Force = 20;

            // run explosion
            exploder.Explode(OnExplode);

            ExploderUtils.Log("Explode(OnExplode)");

            ExplodeFinished = false;
        }
    }
    void OnRocketHit(Vector3 position)
    {
        nextShotTimeout = 0.6f;

        // place the exploder object to centroid position
        exploder.transform.position = position;
        exploder.ExplodeSelf        = false;

        exploder.Force = 20;

        // fragment pieces
        exploder.TargetFragments = 100;

        // set explosion radius to 10 meters
        exploder.Radius = 10.0f;

        exploder.UseForceVector = false;

        // run explosion
        exploder.Explode();

        // reset rocket position
        Rocket.Reset();
    }
        public override void Use()
        {
            base.Use();

            Exploder.transform.position = ChairBomb.transform.position;

            // dont destroy exploder game object
            Exploder.ExplodeSelf = false;

            // dont use force vector, default is explosion in every direction
            Exploder.UseForceVector = false;

            // set explosion radius to 5 meters
            Exploder.Radius = 10.0f;

            // fragment pieces
            Exploder.TargetFragments = 300;

            // adjust force
            Exploder.Force = 30;

            // run explosion
            Exploder.Explode(OnExplode);
        }
 /// <summary>
 /// call this to explode your object
 /// </summary>
 public void ExplodeObject(GameObject obj)
 {
     // pass callback to get results when explosion is finished
     Exploder.Explode(OnExplosion);
 }
Exemple #11
0
    void Update()
    {
        GameObject hitObject  = null;
        var        targetType = ExplodeTargetManager.Instance.TargetType;

        if (HideGunWhileZooming && Camera.main.enabled)
        {
//			GameScene.Instance.player.GetComponent<Equips> ().HideWeapons (Zooming);
        }
        // dont shoot when targeting use object
        if (targetType == TargetType.UseObject)
        {
            if (lastTarget != TargetType.UseObject)
            {
//                animation["shotgunHide"].speed = 1;
//                animation.Play("shotgunHide");
            }

            lastTarget = TargetType.UseObject;
        }

        if (lastTarget == TargetType.UseObject)
        {
//            animation["shotgunHide"].speed = -1;
//
//            if (animation["shotgunHide"].time < 0.01f)
//            {
//                animation["shotgunHide"].time = animation["shotgunHide"].length;
//            }
//
//            animation.Play("shotgunHide", AnimationPlayMode.Mix);
        }

        lastTarget = targetType;

        // run raycast against objects in the scene
        var mouseRay = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f));

        UnityEngine.Debug.DrawRay(mouseRay.origin, mouseRay.direction * 10, Color.red, 0);

        if (targetType == TargetType.DestroyableObject)
        {
            hitObject = ExplodeTargetManager.Instance.TargetObject;
        }
                #if UNITY_EDITOR
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetMouseButtonDown(1))
                #else
        if (Input.touchCount > 2 && Input.touches[0].phase == TouchPhase.Began && Input.touches[1].phase == TouchPhase.Began)
                #endif
        {
            ZoomThermal();
        }
                #if UNITY_EDITOR
        else if (Input.GetMouseButtonDown(1))
                #else
        else if (Input.touchCount > 1 && Input.touches[0].phase == TouchPhase.Began)
                #endif
        {
            ZoomGreen();
        }
        if (Input.GetAxis("Mouse ScrollWheel") < 0)
        {
            ZoomAdjust(-1);
        }
        if (Input.GetAxis("Mouse ScrollWheel") > 0)
        {
            ZoomAdjust(1);
        }
        if (Zooming)
        {
            if (ZoomFOVLists.Length > 0)
            {
                //MouseSensitiveZoom = ((MouseSensitive * 0.16f) / 10) * ZoomFOVLists [IndexZoom];
                camera.fieldOfView += (ZoomFOVLists [IndexZoom] - camera.fieldOfView) / 10;
            }
        }
        else
        {
            camera.fieldOfView += (fovTemp - camera.fieldOfView) / 10;
        }
                #if UNITY_EDITOR
        if (Input.GetMouseButtonDown(0) && nextShotTimeout < 0 && CursorLocking.IsLocked)
                #else
        if (Input.touchCount == 1 && Input.touches[0].phase == TouchPhase.Stationary && nextShotTimeout < 0)
                #endif
        {
            if (targetType != TargetType.UseObject)
            {
                Source.PlayOneShot(GunShot);
                //MouseLookCamera.Kick();//no kick

                // play reload sound after this timeout
                reloadTimeout = 0.3f;

                // turn on flash light for 5 frames
                flashing = 5;
            }

            if (hitObject)
            {
                // get centroid of the hitting object
                var centroid = ExploderUtils.GetCentroid(hitObject);

                // place the exploder object to centroid position
                exploder.transform.position = centroid;
                exploder.ExplodeSelf        = false;

                // adjust force vector to be in direction from shotgun
                exploder.ForceVector = mouseRay.direction.normalized;
//                Utils.Log("ForceVec: " + exploder.ForceVector);
                exploder.Force          = 10;
                exploder.UseForceVector = true;

                // fragment pieces
                exploder.TargetFragments = 30;

                // set explosion radius to 5 meters
                exploder.Radius = 1.0f;

                // run explosion
                exploder.Explode();
            }

            nextShotTimeout = 0.6f;
        }

        nextShotTimeout -= Time.deltaTime;

        if (flashing > 0)
        {
            Flash.intensity = 1.0f;
            ExploderUtils.SetActive(MuzzleFlash, true);
            flashing--;
        }
        else
        {
            Flash.intensity = 0.0f;
            ExploderUtils.SetActive(MuzzleFlash, false);
        }

        reloadTimeout -= Time.deltaTime;

        if (reloadTimeout < 0.0f)
        {
            reloadTimeout = float.MaxValue;

            // play reload sound
            Source.PlayOneShot(Reload);

            // play reload animation
            ReloadAnim.Play();
        }
    }
        private void Update()
        {
            GameObject hitObject  = null;
            var        targetType = TargetManager.Instance.TargetType;

            // dont shoot when targeting use object
            if (targetType == TargetType.UseObject)
            {
                if (lastTarget != TargetType.UseObject)
                {
                    //                animation["shotgunHide"].speed = 1;
                    //                animation.Play("shotgunHide");
                }

                lastTarget = TargetType.UseObject;
            }

            if (lastTarget == TargetType.UseObject)
            {
                //            animation["shotgunHide"].speed = -1;
                //
                //            if (animation["shotgunHide"].time < 0.01f)
                //            {
                //                animation["shotgunHide"].time = animation["shotgunHide"].length;
                //            }
                //
                //            animation.Play("shotgunHide", AnimationPlayMode.Mix);
            }

            lastTarget = targetType;

            // run raycast against objects in the scene
            var mouseRay = MouseLookCamera.mainCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f));

            UnityEngine.Debug.DrawRay(mouseRay.origin, mouseRay.direction * 10, Color.red, 0);

            if (targetType == TargetType.DestroyableObject)
            {
                hitObject = TargetManager.Instance.TargetObject;
            }

            if (Input.GetMouseButtonDown(0) && nextShotTimeout < 0 && CursorLocking.IsLocked)
            {
                if (targetType != TargetType.UseObject)
                {
                    Source.PlayOneShot(GunShot);
                    MouseLookCamera.Kick();

                    // play reload sound after this timeout
                    reloadTimeout = 0.3f;

                    // turn on flash light for 5 frames
                    flashing = 5;
                }

                if (hitObject)
                {
                    // get centroid of the hitting object
                    var centroid = ExploderUtils.GetCentroid(hitObject);

                    // place the exploder object to centroid position
                    exploder.transform.position = centroid;
                    exploder.ExplodeSelf        = false;

                    // adjust force vector to be in direction from shotgun
                    exploder.ForceVector = mouseRay.direction.normalized;
                    //                Utils.Log("ForceVec: " + exploder.ForceVector);
                    exploder.Force          = 10;
                    exploder.UseForceVector = true;

                    // fragment pieces
                    exploder.TargetFragments = 30;

                    // set explosion radius to 5 meters
                    exploder.Radius = 1.0f;

                    // run explosion
                    exploder.Explode();
                }

                nextShotTimeout = 0.6f;
            }

            nextShotTimeout -= Time.deltaTime;

            if (flashing > 0)
            {
                Flash.intensity = 1.0f;
                ExploderUtils.SetActive(MuzzleFlash, true);
                flashing--;
            }
            else
            {
                Flash.intensity = 0.0f;
                ExploderUtils.SetActive(MuzzleFlash, false);
            }

            reloadTimeout -= Time.deltaTime;

            if (reloadTimeout < 0.0f)
            {
                reloadTimeout = float.MaxValue;

                // play reload sound
                Source.PlayOneShot(Reload);

                // play reload animation
                ReloadAnim.Play();
            }
        }