Esempio n. 1
0
 public ExplosionInfo(Explosion src, Explodable afflicted, Vector3 explosionOrigination, Vector3 explosionMultiplier)
 {
     source           = src;
     affected         = afflicted;
     affectedPosition = affected.transform.position;
     explosionCenter  = explosionOrigination;
     dist             = Vector3.Distance(explosionCenter, affected.transform.position);
     forceMultipliers = explosionMultiplier;
 }
Esempio n. 2
0
        private void ProcessExplosion(Vector3 blastPoint)
        {
            bool success = false;

            //Debug.DrawLine(transform.position, transform.position + Vector3.up * BlastRadius, Color.red, 5.0f);
            //Debug.DrawLine(transform.position, transform.position + Vector3.down * BlastRadius, Color.red, 5.0f);
            //Debug.DrawLine(transform.position, transform.position + Vector3.right * BlastRadius, Color.red, 5.0f);
            //Debug.DrawLine(transform.position, transform.position + Vector3.left * BlastRadius, Color.red, 5.0f);
            //Debug.DrawLine(transform.position, transform.position + Vector3.forward * BlastRadius, Color.red, 5.0f);
            //Debug.DrawLine(transform.position, transform.position + Vector3.back * BlastRadius, Color.red, 5.0f);

            Collider[] Blast = Physics.OverlapSphere(blastPoint, BlastRadius, BlastableLayers);
            if (Blast != null)
            {
                //Debug.Log("Blast Area: " + Blast.Length + "\n");
                for (int i = 0; i < Blast.Length; i++)
                {
                    Explodable affected = Blast[i].GetComponent <Explodable>();

                    if (affected && BlastRadius > 0)
                    {
                        //Debug.Log("Blast Area: " + Blast.Length + "\n" + affected.gameObject.name + "  " + name, this);
                        if (affected.gameObject != gameObject)
                        {
                            float range = Vector3.Distance(blastPoint, Blast[i].gameObject.transform.position);

                            //A multiplier for objects being knocked around
                            float damage = Mathf.Clamp(1 - ((range - affected.MinSphereRadius) / BlastRadius), .25f, 1);
                            //Debug.Log("Radius [" + BlastRadius + "]  Dist [" + range + "] bonusRadius [" + affected.MinSphereRadius + "]\n");

                            Vector3 startPoint = (alternateExplosionPoint == null) ? transform.position : alternateExplosionPoint.transform.position;

                            ExplosionInfo info = new ExplosionInfo(this, affected, startPoint, new Vector3(1, 1.25f, 1) * damage * BlastForce / 4);
                            info.ClampBlastDamage  = ClampBlastDamage;
                            info.explosionSequence = explosionSequence;
                            //Debug.Log(info.ToString() + "\n");
                            success = affected.RecieveExplosion(info);

                            if (!success)
                            {
                                Debug.Log("Failed to apply explosion\n" + info.ToString() + "\n");
                            }
                        }
                    }
                }
            }

            if (ShockwaveSize > 0)
            {
                ProcessShockwave(blastPoint);
            }
        }
        void Start()
        {
            ThirstQuencher = GetComponentInChildren <ProximityTriggerAction>();
            ThirstQuencher.triggerStayDelegate += CheckDrinkingWhiskey;
            ThirstQuencher.triggerExitDelegate += StopDrinking;

            gulpSource = AudioManager.Inst.MakeSource("Bottle/DrinkingInGulps");
            gulpSource.transform.SetParent(VRMimic.Instance.VRCamera.transform);
            gulpSource.transform.localPosition = Vector3.up * -.4f;
            gulpSource.volume = 0;
            gulpSource.loop   = true;
            gulpSource.Play();

            myDestroyable = GetComponent <Destroyable>();
            myExplodable  = GetComponent <Explodable>();
            myExplosion   = GetComponent <Explosion>();

            //if (swishCalculator != null)
            //{
            //swishCalculator = transform.FindChild("bottle2").FindChild("Whiskey Swish").GetComponent<Swish>();
            //}
            //myExplodable.HitByExplosionDelegate += HitByExplosion;
        }