예제 #1
0
    public static void DoImpact(GameObject go, SurfaceInfoObject.ImpactType type, Vector3 worldPos, Quaternion rotation)
    {
        SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(go, worldPos);

        UnityEngine.Object obj = UnityEngine.Object.Instantiate(surfaceInfoFor.GetImpactEffect(type), worldPos, rotation);
        UnityEngine.Object.Destroy(obj, 1f);
    }
예제 #2
0
    private void Update()
    {
        bool flag;

        if (this.terraincheck)
        {
            int textureIndex = TerrainTextureHelper.GetTextureIndex(base.origin);
        }
        if ((base.stateFlags.grounded && (!(flag = this.trait.timeLimited) || (this.nextAllowTime <= Time.time))) && ((base.masterControllable == null) || (base.masterControllable.idMain == base.idMain)))
        {
            bool    crouch = base.stateFlags.crouch;
            Vector3 origin = base.origin;
            this.movedAmount    += Vector3.Distance(this.lastFootstepPos, origin);
            this.lastFootstepPos = origin;
            if (this.movedAmount >= this.trait.sqrStrideDist)
            {
                this.movedAmount = 0f;
                AudioClip clip = null;
                if ((footsteps.quality >= 2) || ((footsteps.quality == 1) && base.character.localControlled))
                {
                    Collider belowObj = this.GetBelowObj();
                    if (belowObj != null)
                    {
                        SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(belowObj, origin);
                        if (surfaceInfoFor != null)
                        {
                            clip            = !this.trait.animal ? surfaceInfoFor.GetFootstepBiped(this.lastPlayed) : surfaceInfoFor.GetFootstepAnimal();
                            this.lastPlayed = clip;
                        }
                    }
                }
                if (clip == null)
                {
                    clip = this.trait.defaultFootsteps[UnityEngine.Random.Range(0, this.trait.defaultFootsteps.Length)];
                    if (clip == null)
                    {
                        return;
                    }
                }
                float minAudioDist = this.trait.minAudioDist;
                float maxAudioDist = this.trait.maxAudioDist;
                if (crouch)
                {
                    clip.Play(origin, 0.2f, UnityEngine.Random.Range((float)0.95f, (float)1.05f), minAudioDist * 0.333f, maxAudioDist * 0.333f, 30);
                }
                else
                {
                    clip.Play(origin, 0.65f, UnityEngine.Random.Range((float)0.95f, (float)1.05f), minAudioDist, maxAudioDist, 30);
                }
                if (flag)
                {
                    this.nextAllowTime = Time.time + this.trait.minInterval;
                }
            }
        }
    }
예제 #3
0
 public GameObject GetImpactEffect(SurfaceInfoObject.ImpactType type)
 {
     if (type == SurfaceInfoObject.ImpactType.Bullet)
     {
         return this.bulletEffects[UnityEngine.Random.Range(0, (int)this.bulletEffects.Length)];
     }
     if (type != SurfaceInfoObject.ImpactType.Melee)
     {
         return null;
     }
     return this.meleeEffects[UnityEngine.Random.Range(0, (int)this.meleeEffects.Length)];
 }
예제 #4
0
    public static SurfaceInfoObject GetSurfaceInfoFor(GameObject obj, Vector3 worldPos)
    {
        SurfaceInfo component = obj.GetComponent <SurfaceInfo>();

        if (component != null)
        {
            return(component.SurfaceObj(worldPos));
        }
        IDBase base2 = obj.GetComponent <IDBase>();

        if (base2 != null)
        {
            SurfaceInfo info2 = base2.idMain.GetComponent <SurfaceInfo>();
            if (info2 != null)
            {
                return(info2.SurfaceObj(worldPos));
            }
        }
        return(SurfaceInfoObject.GetDefault());
    }
예제 #5
0
    public static SurfaceInfoObject GetSurfaceInfoFor(GameObject obj, Vector3 worldPos)
    {
        SurfaceInfo component = obj.GetComponent <SurfaceInfo>();

        if (component)
        {
            return(component.SurfaceObj(worldPos));
        }
        IDBase dBase = obj.GetComponent <IDBase>();

        if (dBase)
        {
            SurfaceInfo surfaceInfo = dBase.idMain.GetComponent <SurfaceInfo>();
            if (surfaceInfo)
            {
                return(surfaceInfo.SurfaceObj(worldPos));
            }
        }
        return(SurfaceInfoObject.GetDefault());
    }
예제 #6
0
 public static void DoImpact(GameObject go, SurfaceInfoObject.ImpactType type, Vector3 worldPos, Quaternion rotation)
 {
     SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(go, worldPos);
     UnityEngine.Object obj = UnityEngine.Object.Instantiate(surfaceInfoFor.GetImpactEffect(type), worldPos, rotation);
     UnityEngine.Object.Destroy(obj, 1f);
 }
예제 #7
0
 private void Update()
 {
     if (this.terraincheck)
     {
         TerrainTextureHelper.GetTextureIndex(base.origin);
     }
     if (base.stateFlags.grounded)
     {
         bool flag  = this.trait.timeLimited;
         bool flag1 = flag;
         if ((!flag || this.nextAllowTime <= Time.time) && (!base.masterControllable || !(base.masterControllable.idMain != base.idMain)))
         {
             bool            flag2           = base.stateFlags.crouch;
             Vector3         vector3         = base.origin;
             FootstepEmitter footstepEmitter = this;
             footstepEmitter.movedAmount = footstepEmitter.movedAmount + Vector3.Distance(this.lastFootstepPos, vector3);
             this.lastFootstepPos        = vector3;
             if (this.movedAmount >= this.trait.sqrStrideDist)
             {
                 this.movedAmount = 0f;
                 AudioClip item = null;
                 if (footsteps.quality >= 2 || footsteps.quality == 1 && base.character.localControlled)
                 {
                     Collider belowObj = this.GetBelowObj();
                     if (belowObj)
                     {
                         SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(belowObj, vector3);
                         if (surfaceInfoFor)
                         {
                             item            = (!this.trait.animal ? surfaceInfoFor.GetFootstepBiped(this.lastPlayed) : surfaceInfoFor.GetFootstepAnimal());
                             this.lastPlayed = item;
                         }
                     }
                 }
                 if (!item)
                 {
                     item = this.trait.defaultFootsteps[UnityEngine.Random.Range(0, this.trait.defaultFootsteps.Length)];
                     if (!item)
                     {
                         return;
                     }
                 }
                 float single  = this.trait.minAudioDist;
                 float single1 = this.trait.maxAudioDist;
                 if (!flag2)
                 {
                     item.Play(vector3, 0.65f, UnityEngine.Random.Range(0.95f, 1.05f), single, single1, 30);
                 }
                 else
                 {
                     item.Play(vector3, 0.2f, UnityEngine.Random.Range(0.95f, 1.05f), single * 0.333f, single1 * 0.333f, 30);
                 }
                 if (flag1)
                 {
                     this.nextAllowTime = Time.time + this.trait.minInterval;
                 }
             }
             return;
         }
     }
 }
예제 #8
0
    private void Update()
    {
        if (!this.impacted)
        {
            float num = Time.time - this.lastUpdateTime;
            this.lastUpdateTime = Time.time;
            RaycastHit  hit     = new RaycastHit();
            RaycastHit2 invalid = RaycastHit2.invalid;
            base.transform.Rotate(Vector3.right, (float)(this.dropDegreesPerSec * num));
            Ray   ray  = new Ray(base.transform.position, base.transform.forward);
            float num2 = this.speedPerSec * num;
            bool  flag = true;
            if (!Physics2.Raycast2(ray, out invalid, this.speedPerSec * num, this.layerMask))
            {
                Transform transform = base.transform;
                transform.position += (Vector3)((base.transform.forward * this.speedPerSec) * num);
                this.distance      += this.speedPerSec * num;
            }
            else
            {
                Vector3    point;
                Vector3    normal;
                GameObject gameObject;
                Rigidbody  rigidbody;
                if (flag)
                {
                    normal     = invalid.normal;
                    point      = invalid.point;
                    gameObject = invalid.gameObject;
                    rigidbody  = invalid.rigidbody;
                }
                else
                {
                    normal     = hit.normal;
                    point      = hit.point;
                    gameObject = hit.collider.gameObject;
                    rigidbody  = hit.rigidbody;
                }
                Quaternion rotation = Quaternion.LookRotation(normal);
                Vector3    zero     = Vector3.zero;
                int        layer    = gameObject.layer;
                bool       flag2    = true;
                if (((rigidbody != null) && !rigidbody.isKinematic) && !rigidbody.CompareTag("Door"))
                {
                    rigidbody.AddForceAtPosition((Vector3)(Vector3.up * 200f), point);
                    rigidbody.AddForceAtPosition((Vector3)(ray.direction * 1000f), point);
                }
                switch (layer)
                {
                case 0x11:
                case 0x12:
                case 0x1b:
                case 0x15:
                    flag2 = false;
                    break;

                default:
                    zero = point + ((Vector3)(normal * 0.01f));
                    break;
                }
                this.impacted           = true;
                base.transform.position = point;
                this.TryReportHit(gameObject);
                base.transform.parent = gameObject.transform;
                TrailRenderer component = base.GetComponent <TrailRenderer>();
                if (component != null)
                {
                    component.enabled = false;
                }
                base.audio.enabled = false;
                if (gameObject != null)
                {
                    SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(gameObject, point);
                    surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet);
                    Object.Destroy(Object.Instantiate(surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet), point, rotation), 1.5f);
                    this.TryReportMiss();
                }
                Object.Destroy(base.gameObject, 20f);
            }
            if ((this.distance > this.maxRange) || ((Time.time - this.spawnTime) > this.maxLifeTime))
            {
                Object.Destroy(base.gameObject);
            }
        }
    }
예제 #9
0
    private void Update()
    {
        Vector3    vector3;
        Vector3    vector31;
        GameObject gameObject;
        Rigidbody  rigidbody;

        if (this.impacted)
        {
            return;
        }
        float single = Time.time - this.lastUpdateTime;

        this.lastUpdateTime = Time.time;
        RaycastHit  raycastHit  = new RaycastHit();
        RaycastHit2 raycastHit2 = RaycastHit2.invalid;

        base.transform.Rotate(Vector3.right, this.dropDegreesPerSec * single);
        Ray  ray  = new Ray(base.transform.position, base.transform.forward);
        bool flag = true;

        if (!Physics2.Raycast2(ray, out raycastHit2, this.speedPerSec * single, this.layerMask))
        {
            Transform transforms = base.transform;
            transforms.position = transforms.position + ((base.transform.forward * this.speedPerSec) * single);
            ArrowMovement arrowMovement = this;
            arrowMovement.distance = arrowMovement.distance + this.speedPerSec * single;
        }
        else
        {
            if (!flag)
            {
                vector31   = raycastHit.normal;
                vector3    = raycastHit.point;
                gameObject = raycastHit.collider.gameObject;
                rigidbody  = raycastHit.rigidbody;
            }
            else
            {
                vector31   = raycastHit2.normal;
                vector3    = raycastHit2.point;
                gameObject = raycastHit2.gameObject;
                rigidbody  = raycastHit2.rigidbody;
            }
            Quaternion quaternion = Quaternion.LookRotation(vector31);
            Vector3    vector32   = Vector3.zero;
            int        num        = gameObject.layer;
            bool       flag1      = true;
            if (rigidbody && !rigidbody.isKinematic && !rigidbody.CompareTag("Door"))
            {
                rigidbody.AddForceAtPosition(Vector3.up * 200f, vector3);
                rigidbody.AddForceAtPosition(ray.direction * 1000f, vector3);
            }
            if (num == 17 || num == 18 || num == 27 || num == 21)
            {
                flag1 = false;
            }
            else
            {
                vector32 = vector3 + (vector31 * 0.01f);
            }
            this.impacted           = true;
            base.transform.position = vector3;
            this.TryReportHit(gameObject);
            base.transform.parent = gameObject.transform;
            TrailRenderer component = base.GetComponent <TrailRenderer>();
            if (component)
            {
                component.enabled = false;
            }
            base.audio.enabled = false;
            if (gameObject)
            {
                SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(gameObject, vector3);
                surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet);
                UnityEngine.Object obj = UnityEngine.Object.Instantiate(surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet), vector3, quaternion);
                UnityEngine.Object.Destroy(obj, 1.5f);
                this.TryReportMiss();
            }
            UnityEngine.Object.Destroy(base.gameObject, 20f);
        }
        if (this.distance > this.maxRange || Time.time - this.spawnTime > this.maxLifeTime)
        {
            UnityEngine.Object.Destroy(base.gameObject);
        }
    }