Exemple #1
0
 private void OnTriggerEnter(Collider other)
 {
     UnderfootSurfaceDetector.SurfaceType surfaceType = UnderfootSurfaceDetector.GetSurfaceType(other);
     if (surfaceType != UnderfootSurfaceDetector.SurfaceType.None)
     {
         int i = 0;
         while (i < this.colliders.Count)
         {
             if (this.colliders[i] == null || this.colliders[i] == other)
             {
                 this.colliders.RemoveAt(i);
             }
             else
             {
                 i++;
             }
         }
         this.colliders.Add(other);
         this.Surface = surfaceType;
     }
     if (other.tag == UnderfootSurfaceDetector.GoreTag)
     {
         this.goreColliders.Add(other);
     }
 }
Exemple #2
0
 private void OnTriggerExit(Collider other)
 {
     UnderfootSurfaceDetector.RemoveIfPresent(this.goreColliders, other);
     if (UnderfootSurfaceDetector.RemoveIfPresent(this.colliders, other))
     {
         this.UpdateSurface();
     }
 }
Exemple #3
0
 private void ValidateColliders()
 {
     UnderfootSurfaceDetector.RemoveNonIntersecting(this.goreColliders, this.collider);
     if (UnderfootSurfaceDetector.RemoveNonIntersecting(this.colliders, this.collider))
     {
         this.UpdateSurface();
     }
 }
Exemple #4
0
 private void UpdateSurface()
 {
     if (this.colliders.Count > 0)
     {
         this.Surface = UnderfootSurfaceDetector.GetSurfaceType(this.colliders[this.colliders.Count - 1]);
     }
     else
     {
         this.Surface = UnderfootSurfaceDetector.SurfaceType.None;
     }
 }
 private void Awake()
 {
     this.underFoot  = base.transform.parent.GetComponentInChildren <UnderfootSurfaceDetector>();
     this.headBob    = base.transform.parent.GetComponent <FirstPersonHeadBob>();
     this.animator   = base.gameObject.GetComponent <Animator>();
     this.hitTrigger = base.transform.GetComponentInChildren <treeHitTrigger>();
     if (this.Remote)
     {
         return;
     }
     this.SetUpWeapons();
 }
    private void Start()
    {
        this.preloadFootsteps();
        this.originalLocalPos = this.head.localPosition;
        this.prevPosition     = base.GetComponent <Rigidbody>().position;
        this.surfaceDetector  = base.GetComponentInChildren <UnderfootSurfaceDetector>();
        Terrain activeTerrain = Terrain.activeTerrain;

        if (activeTerrain && activeTerrain.materialTemplate)
        {
            this.snowStartHeight  = activeTerrain.materialTemplate.GetFloat("_SnowStartHeight");
            this.snowFadeLength   = activeTerrain.materialTemplate.GetFloat("_SnowFadeLength");
            this.snowStartHeight += this.snowFadeLength / 4f;
            this.snowFadeLength  /= 2f;
        }
    }
Exemple #7
0
 private void HandleCollision(Collider collider)
 {
     if (this.rigidBody.IsSleeping())
     {
         return;
     }
     if (collider.gameObject.CompareTag("Tree") || collider.gameObject.CompareTag("TerrainMain") || collider.gameObject.layer == 17 || collider.gameObject.layer == 20 || collider.gameObject.layer == 21 || collider.gameObject.layer == 25 || collider.gameObject.layer == 26 || UnderfootSurfaceDetector.GetSurfaceType(collider) != UnderfootSurfaceDetector.SurfaceType.None)
     {
         this.TryPlaySound(this.tree);
     }
 }
Exemple #8
0
 public void OnCollisionEnter(Collision collision)
 {
     if (!this.rigidBody)
     {
         return;
     }
     if (this.flintLock)
     {
         ArrowDamage componentInChildren = base.transform.GetComponentInChildren <ArrowDamage>();
         if (componentInChildren && componentInChildren.Live)
         {
             componentInChildren.CheckHit(collision.transform.position, collision.transform, collision.collider.isTrigger, collision.collider);
         }
     }
     this.calculateDamage(collision.gameObject);
     if ((collision.gameObject.CompareTag("Tree") || collision.gameObject.CompareTag("Stick") || collision.gameObject.layer == 17 || collision.gameObject.layer == 20 || collision.gameObject.layer == 25 || UnderfootSurfaceDetector.GetSurfaceType(collision.collider) != UnderfootSurfaceDetector.SurfaceType.None) && this.rigidBody.velocity.magnitude > this.speedThreshold)
     {
         if (!this.InWater && !this.effectDelay)
         {
             this.PlayEvent(this.rockOnTree);
         }
         if (!this.soundDelay)
         {
             this.enableSound();
             this.soundDelay = true;
         }
     }
     if ((collision.gameObject.CompareTag("TerrainMain") || collision.gameObject.layer == 26) && this.rigidBody.velocity.magnitude > this.speedThreshold)
     {
         if (!this.InWater && !this.effectDelay)
         {
             if (this.rockOnGround.Length > 0)
             {
                 this.PlayEvent(this.rockOnGround);
             }
             else
             {
                 this.PlayEvent(this.rockOnTree);
             }
         }
         if (!this.soundDelay)
         {
             this.enableSound();
             this.soundDelay = true;
         }
     }
     if (collision.gameObject.CompareTag("Float") && this.rigidBody.velocity.magnitude > this.speedThreshold)
     {
         if (!this.InWater && !this.effectDelay)
         {
             if (this.rockOnGround.Length > 0)
             {
                 this.PlayEvent(this.stickHitTree);
             }
             else
             {
                 this.PlayEvent(this.rockOnTree);
             }
         }
         if (!this.soundDelay)
         {
             this.enableSound();
             this.soundDelay = true;
         }
     }
 }
Exemple #9
0
 public void OnCollisionEnter(Collision collision)
 {
     if (!this.rigidBody)
     {
         return;
     }
     if ((collision.gameObject.CompareTag("Tree") || collision.gameObject.CompareTag("Stick") || collision.gameObject.layer == 17 || collision.gameObject.layer == 20 || collision.gameObject.layer == 25 || UnderfootSurfaceDetector.GetSurfaceType(collision.collider) != UnderfootSurfaceDetector.SurfaceType.None) && this.rigidBody.velocity.magnitude > this.speedThreshold)
     {
         if (!this.InWater && !this.effectDelay)
         {
             this.PlayEvent(this.rockOnTree);
         }
         if (!this.soundDelay)
         {
             this.enableSound();
             this.soundDelay = true;
         }
     }
     if ((collision.gameObject.CompareTag("TerrainMain") || collision.gameObject.layer == 26) && this.rigidBody.velocity.magnitude > this.speedThreshold)
     {
         if (!this.InWater && !this.effectDelay)
         {
             if (this.rockOnGround.Length > 0)
             {
                 this.PlayEvent(this.rockOnGround);
             }
             else
             {
                 this.PlayEvent(this.rockOnTree);
             }
         }
         if (!this.soundDelay)
         {
             this.enableSound();
             this.soundDelay = true;
         }
     }
     if (collision.gameObject.CompareTag("Float") && this.rigidBody.velocity.magnitude > this.speedThreshold)
     {
         if (!this.InWater && !this.effectDelay)
         {
             if (this.rockOnGround.Length > 0)
             {
                 this.PlayEvent(this.stickHitTree);
             }
             else
             {
                 this.PlayEvent(this.rockOnTree);
             }
         }
         if (!this.soundDelay)
         {
             this.enableSound();
             this.soundDelay = true;
         }
     }
 }