Example #1
0
        private void ChangeFootstepType(Collider other)
        {
            Footstep footstep = other.gameObject.GetComponent <Footstep>();

            if (footstep)
            {
                currentFootStepType = footstep.GetFootstepType();
            }
        }
Example #2
0
        private void OnTriggerExit(Collider other)
        {
            Footstep footstep = other.gameObject.GetComponent <Footstep>();

            if (footstep)
            {
                currentFootStepType = FootstepType.defaultFootstep;
            }
        }
    void UpdateGroundType()
    {
        if (Physics.Raycast(thisTransform.position, Vector3.down, out hit, 2, ~(1 << 9)))
        {
            if (hit.collider != terrainCollider)
            {
                switch (hit.collider.material.name)
                {
                    case "Grass (Instance)":
                        type = FootstepType.Grass;
                        break;
                    case "Stone (Instance)":
                        type = FootstepType.Stone;
                        break;
                    case "Dirt (Instance)":
                        type = FootstepType.Dirt;
                        break;
                    case "Wood (Instance)":
                        type = FootstepType.Wood;
                        break;
                    default:
                        type = FootstepType.Stone;
                        break;
                }
            }

            else
            {
                var mainTex = TerrainSurface.GetMainTexture(thisTransform.position);
                switch (mainTex)
                {
                    case 0:
                        type = FootstepType.Grass;
                        break;
                    case 1:
                    case 6:
                    case 2:
                        type = FootstepType.Stone;
                        break;
                    case 3:
                    case 4:
                    case 5:
                    case 7:
                    case 8:
                    case 9:
                        type = FootstepType.Dirt;
                        break;
                    default:
                        type = FootstepType.Stone;
                        break;
                }

            }
        }
    }
Example #4
0
 private void PlayFootStep(AudioSource footstepSource)
 {
     // if(footstepSource.isPlaying) return;
     if (!footstepTable.ContainsKey(currentFootStepType))
     {
         currentFootStepType = FootstepType.defaultFootstep;
     }
     AudioClip[]   sources = footstepTable[currentFootStepType];
     System.Random rnd     = new System.Random();
     footstepSource.PlayOneShot(sources[rnd.Next(0, sources.Length - 1)]);
 }
 public Footstep(Vector3 pos, FootstepType footstep, float ttl)
 {
     this.pos      = pos;
     this.footstep = footstep;
     this.ttl      = ttl;
 }
Example #6
0
 /// <summary>
 ///   Sets the footstep type of the creature specified.
 ///   Changing a creature's footstep type will change the sound that
 ///   its feet make when ever the creature makes takes a step.
 ///   By default a creature's footsteps are detemined by the appearance
 ///   type of the creature. SetFootstepType() allows you to make a
 ///   creature use a difference footstep type than it would use by default
 ///   for its given appearance.
 ///   - nFootstepType (FOOTSTEP_TYPE_*):
 ///   FOOTSTEP_TYPE_NORMAL
 ///   FOOTSTEP_TYPE_LARGE
 ///   FOOTSTEP_TYPE_DRAGON
 ///   FOOTSTEP_TYPE_SoFT
 ///   FOOTSTEP_TYPE_HOOF
 ///   FOOTSTEP_TYPE_HOOF_LARGE
 ///   FOOTSTEP_TYPE_BEETLE
 ///   FOOTSTEP_TYPE_SPIDER
 ///   FOOTSTEP_TYPE_SKELETON
 ///   FOOTSTEP_TYPE_LEATHER_WING
 ///   FOOTSTEP_TYPE_FEATHER_WING
 ///   FOOTSTEP_TYPE_DEFAULT - Makes the creature use its original default footstep sounds.
 ///   FOOTSTEP_TYPE_NONE
 ///   - oCreature: the creature to change the footstep sound for.
 /// </summary>
 public static void SetFootstepType(FootstepType nFootstepType, uint oCreature = OBJECT_INVALID)
 {
     Internal.NativeFunctions.StackPushObject(oCreature);
     Internal.NativeFunctions.StackPushInteger(nFootstepType.InternalValue);
     Internal.NativeFunctions.CallBuiltIn(789);
 }
Example #7
0
 /// <summary>
 ///   Sets the footstep type of the creature specified.
 ///   Changing a creature's footstep type will change the sound that
 ///   its feet make when ever the creature makes takes a step.
 ///   By default a creature's footsteps are detemined by the appearance
 ///   type of the creature. SetFootstepType() allows you to make a
 ///   creature use a difference footstep type than it would use by default
 ///   for its given appearance.
 ///   - nFootstepType (FOOTSTEP_TYPE_*):
 ///   FOOTSTEP_TYPE_NORMAL
 ///   FOOTSTEP_TYPE_LARGE
 ///   FOOTSTEP_TYPE_DRAGON
 ///   FOOTSTEP_TYPE_SoFT
 ///   FOOTSTEP_TYPE_HOOF
 ///   FOOTSTEP_TYPE_HOOF_LARGE
 ///   FOOTSTEP_TYPE_BEETLE
 ///   FOOTSTEP_TYPE_SPIDER
 ///   FOOTSTEP_TYPE_SKELETON
 ///   FOOTSTEP_TYPE_LEATHER_WING
 ///   FOOTSTEP_TYPE_FEATHER_WING
 ///   FOOTSTEP_TYPE_DEFAULT - Makes the creature use its original default footstep sounds.
 ///   FOOTSTEP_TYPE_NONE
 ///   - oCreature: the creature to change the footstep sound for.
 /// </summary>
 public static void SetFootstepType(FootstepType nFootstepType, uint oCreature = Core.NWScript.NWScript.OBJECT_INVALID)
 {
     Internal.NativeFunctions.StackPushObject(oCreature);
     Internal.NativeFunctions.StackPushInteger((int)nFootstepType);
     Internal.NativeFunctions.CallBuiltIn(789);
 }
 /// <summary>
 /// Gets a random footstep clip from the list of clips for the given ground type
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 private AudioClip GetFootstepClip(FootstepType type)
 {
     List<AudioClip> clips = allClips[type];
     var rand = Random.Range(0, clips.Count);
     return clips[rand];
 }