예제 #1
0
    public static float GetDamageSelfMul(EObjectMaterial mat)
    {
        switch (mat)
        {
        case EObjectMaterial.Wood:
        case EObjectMaterial.WoodTree:
            return(0.7f);

        case EObjectMaterial.Bush:
            return(0.2f);

        case EObjectMaterial.Stone:
            return(1f);

        case EObjectMaterial.DryLeaves:
        case EObjectMaterial.Grass:
        case EObjectMaterial.Mud:
        case EObjectMaterial.Sand:
            return(0.1f);

        case EObjectMaterial.Flesh:
            return(0.4f);
        }
        return(1f);
    }
    public void FootstepEvent(string obj_name)
    {
        EObjectMaterial mat = (!this.m_Being.IsInWater()) ? this.m_Being.GetMaterial() : EObjectMaterial.Water;

        if (this.m_FootstepAudioSource && !this.m_FootstepAudioSource.isPlaying)
        {
            this.m_FootstepAudioSource.PlayOneShot(AIManager.Get().GetFootstepSound(mat));
        }
    }
예제 #3
0
        public string GetFootstepFX(EObjectMaterial mat)
        {
            List <string> fxnames = this.m_FootstepDatas[(int)mat].m_FXNames;

            if (fxnames.Count == 0)
            {
                return(string.Empty);
            }
            return(fxnames[UnityEngine.Random.Range(0, fxnames.Count)]);
        }
예제 #4
0
        public AudioClip GetFootstepSound(EObjectMaterial mat)
        {
            List <AudioClip> sounds = this.m_FootstepDatas[(int)mat].m_Sounds;

            if (sounds.Count == 0)
            {
                return(null);
            }
            return(sounds[UnityEngine.Random.Range(0, sounds.Count)]);
        }
예제 #5
0
 private void PlayFootstep(AudioSource source, EObjectMaterial mat)
 {
     if (source.rolloffMode != AudioRolloffMode.Custom)
     {
         source.rolloffMode = AudioRolloffMode.Custom;
         source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, MainLevel.Instance.m_SoundRolloffCurve);
     }
     source.volume = (this.m_HumanAI ? 1f : 0.5f);
     source.PlayOneShot(AIManager.Get().GetFootstepSound(mat, this.m_Animator.velocity.magnitude < 4f));
 }
예제 #6
0
        private void InitFootstepsData()
        {
            for (int i = 0; i < 16; i++)
            {
                this.m_FootstepDatas.Add(i, new AIFootstepData());
            }
            TextAssetParser textAssetParser = new TextAssetParser(this.m_FootstepDataScript);

            for (int j = 0; j < textAssetParser.GetKeysCount(); j++)
            {
                Key             key  = textAssetParser.GetKey(j);
                EObjectMaterial key2 = (EObjectMaterial)Enum.Parse(typeof(EObjectMaterial), key.GetName());
                for (int k = 0; k < key.GetKeysCount(); k++)
                {
                    AIFootstepData aifootstepData = this.m_FootstepDatas[(int)key2];
                    Key            key3           = key.GetKey(k);
                    if (key3.GetName() == "FX")
                    {
                        string[] array = key3.GetVariable(0).SValue.Split(new char[]
                        {
                            ';'
                        });
                        for (int l = 0; l < array.Length; l++)
                        {
                            aifootstepData.m_FXNames.Add(array[l]);
                        }
                    }
                    else if (key3.GetName() == "Sound")
                    {
                        string   svalue = key3.GetVariable(0).SValue;
                        string[] array2 = key3.GetVariable(1).SValue.Split(new char[]
                        {
                            ';'
                        });
                        for (int m = 0; m < array2.Length; m++)
                        {
                            aifootstepData.m_WalkSounds.Add(Resources.Load <AudioClip>(svalue + array2[m]));
                        }
                        if (key3.GetVariablesCount() > 2)
                        {
                            array2 = key3.GetVariable(2).SValue.Split(new char[]
                            {
                                ';'
                            });
                            for (int n = 0; n < array2.Length; n++)
                            {
                                aifootstepData.m_RunSounds.Add(Resources.Load <AudioClip>(svalue + array2[n]));
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        public AudioClip GetFootstepSound(EObjectMaterial mat, bool walk)
        {
            List <AudioClip> list = walk ? this.m_FootstepDatas[(int)mat].m_WalkSounds : this.m_FootstepDatas[(int)mat].m_RunSounds;

            if (list.Count != 0)
            {
                return(list[UnityEngine.Random.Range(0, list.Count)]);
            }
            if (mat != EObjectMaterial.Unknown)
            {
                return(this.GetFootstepSound(EObjectMaterial.Unknown, walk));
            }
            return(null);
        }
예제 #8
0
    private AudioClip GetSpecificSound(ItemID item_id, EObjectMaterial material)
    {
        Dictionary <int, List <AudioClip> > dictionary;

        if (!this.m_HitSpecificSounds.TryGetValue((int)item_id, out dictionary))
        {
            return(null);
        }
        List <AudioClip> list;

        if (!dictionary.TryGetValue((int)material, out list))
        {
            return(null);
        }
        if (list.Count == 0)
        {
            return(null);
        }
        return(list[UnityEngine.Random.Range(0, list.Count)]);
    }
예제 #9
0
 public void FootstepEvent(AnimationEvent anim_event)
 {
     if (anim_event.animatorClipInfo.weight >= 0.5f && this.m_LastFootstepEventTime < Time.time - AnimationEventsReceiver.STEP_INTERVAL)
     {
         this.m_LastFootstepEventTime = Time.time;
         EObjectMaterial mat = this.m_Being.IsInWater() ? EObjectMaterial.Water : this.m_Being.GetMaterial();
         foreach (AudioSource audioSource in this.m_FootstepAudioSources)
         {
             if (!audioSource.isPlaying)
             {
                 this.PlayFootstep(audioSource, mat);
                 return;
             }
         }
         if (this.m_FootstepAudioSources.Count < 4)
         {
             this.PlayFootstep(this.AddFootstepAudioSource(), mat);
         }
     }
 }
예제 #10
0
 public static bool IsMaterialHard(EObjectMaterial mat)
 {
     return(mat == EObjectMaterial.Wood || mat == EObjectMaterial.Stone || mat - EObjectMaterial.TurtleShell <= 2);
 }
예제 #11
0
    private void Hit(CJObject cj_object, Collider coll, Vector3 hit_pos, Vector3 hit_dir)
    {
        Item currentItem = this.m_Player.GetCurrentItem(Hand.Right);

        if (cj_object)
        {
            HumanAI component = cj_object.GetComponent <HumanAI>();
            if (component)
            {
                if (component.m_Hallucination && component.m_HallucinationDisappearing)
                {
                    return;
                }
                this.HitHumanAI(component, hit_pos, hit_dir);
                this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
                this.m_AlreadyHit = true;
                return;
            }
            else
            {
                this.HitObject(cj_object, hit_pos, hit_dir);
            }
        }
        else
        {
            RagdollBone component2 = coll.gameObject.GetComponent <RagdollBone>();
            if (component2 && component2.m_Parent)
            {
                DeadBody component3 = component2.m_Parent.GetComponent <DeadBody>();
                if (component3)
                {
                    component3.OnTakeDamage(new DamageInfo
                    {
                        m_DamageItem = currentItem,
                        m_Damager    = base.gameObject,
                        m_Position   = hit_pos,
                        m_HitDir     = hit_dir,
                        m_Normal     = -hit_dir
                    });
                    return;
                }
            }
        }
        DamageInfo     damageInfo = new DamageInfo();
        ObjectMaterial component4;

        if (cj_object != null)
        {
            component4 = cj_object.gameObject.GetComponent <ObjectMaterial>();
        }
        else
        {
            component4 = coll.gameObject.GetComponent <ObjectMaterial>();
        }
        EObjectMaterial mat = (!(component4 == null)) ? component4.m_ObjectMaterial : EObjectMaterial.Unknown;

        damageInfo.m_Damage     = currentItem.m_Info.m_DamageSelf * ObjectMaterial.GetDamageSelfMul(mat);
        damageInfo.m_DamageItem = currentItem;
        this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
        currentItem.TakeDamage(damageInfo);
        this.OnHit();
    }
예제 #12
0
    public void PlayFootstepSound()
    {
        if ((Player.Get().GetFPPController().m_LastCollisionFlags & CollisionFlags.Below) == CollisionFlags.None)
        {
            return;
        }
        Vector3 wantedSpeed = this.m_FPPController.m_WantedSpeed;

        wantedSpeed.y = 0f;
        if (wantedSpeed.magnitude < 0.1f)
        {
            return;
        }
        if (Time.time - this.m_LastFootstepSound < 0.1f)
        {
            return;
        }
        List <AudioClip> list            = null;
        bool             flag            = Player.Get().GetFPPController().IsRunning();
        EObjectMaterial  eobjectMaterial = EObjectMaterial.Unknown;

        if (this.m_Player.IsInWater() && !this.m_Player.m_SwimController.IsActive())
        {
            list = ((!flag) ? this.m_ShallowWaterWalkSounds : this.m_ShallowWaterRunSounds);
        }
        else
        {
            eobjectMaterial = Player.Get().GetMaterial();
            switch (eobjectMaterial)
            {
            case EObjectMaterial.Unknown:
            case EObjectMaterial.Sand:
                list = ((!flag) ? this.m_SandStepWalkSounds : this.m_SandStepRunSounds);
                break;

            case EObjectMaterial.Bush:
            case EObjectMaterial.Grass:
                list = ((!flag) ? this.m_GrassStepWalkSounds : this.m_GrassStepRunSounds);
                break;

            case EObjectMaterial.Stone:
                list = ((!flag) ? this.m_StoneStepWalkSounds : this.m_StoneStepRunSounds);
                break;

            case EObjectMaterial.DryLeaves:
                list = ((!flag) ? this.m_DryLeavesStepWalkSounds : this.m_DryLeavesStepRunSounds);
                break;

            case EObjectMaterial.Mud:
                list = ((!flag) ? this.m_MudStepWalkSounds : this.m_MudStepRunSounds);
                break;

            case EObjectMaterial.Soil:
                list = ((!flag) ? this.m_SoilStepWalkSounds : this.m_SoilStepRunSounds);
                break;
            }
        }
        Noise.Type noise_type = Noise.Type.None;
        if (FPPController.Get().IsWalking())
        {
            noise_type = ((!FPPController.Get().IsDuck()) ? Noise.Type.Walk : Noise.Type.Sneak);
        }
        else if (flag)
        {
            noise_type = ((!FPPController.Get().IsDuck()) ? Noise.Type.Run : Noise.Type.Sneak);
        }
        else if (SwimController.Get().IsSwimming())
        {
            noise_type = Noise.Type.Swim;
        }
        if (list == null)
        {
            Debug.Log("ERROR PlayerAudioModule PlayFootstepSound no sounds clips player_pos=" + Player.Get().transform.position.ToString() + " Material = " + eobjectMaterial.ToString());
        }
        this.PlayRandomSound(list, 1f, false, noise_type);
        this.m_LastFootstepSound = Time.time;
    }
예제 #13
0
    private void Hit(CJObject cj_object, Collider coll, Vector3 hit_pos, Vector3 hit_dir)
    {
        Item currentItem = this.m_Player.GetCurrentItem(Hand.Right);

        if (cj_object)
        {
            HumanAI humanAI   = null;
            AI      component = cj_object.GetComponent <AI>();
            if (component && component.IsHuman())
            {
                humanAI = (HumanAI)component;
            }
            if (humanAI)
            {
                if (humanAI.m_Hallucination && humanAI.m_HallucinationDisappearing)
                {
                    return;
                }
                this.HitHumanAI(humanAI, hit_pos, hit_dir);
                this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
                this.m_AlreadyHit = true;
            }
            else
            {
                Fish component2 = cj_object.GetComponent <Fish>();
                if (component2 && component2.m_ID != AI.AIID.AngelFish && component2.m_ID != AI.AIID.DiscusFish && UnityEngine.Random.Range(0f, 1f) < 0.5f)
                {
                    this.m_AlreadyHit = true;
                }
                else if (base.m_ControllerType == PlayerControllerType.WeaponMelee && component2 && component2.m_ID != AI.AIID.AngelFish && component2.m_ID != AI.AIID.DiscusFish)
                {
                    component2.OnHitByItem(null, hit_pos);
                    this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
                    this.m_AlreadyHit = true;
                }
            }
            if (component)
            {
                PlayerConditionModule.Get().GetDirtinessAdd(GetDirtyReason.Combat, null);
            }
            if (!this.m_AlreadyHit)
            {
                this.HitObject(cj_object, hit_pos, hit_dir);
            }
        }
        else
        {
            RagdollBone component3 = coll.gameObject.GetComponent <RagdollBone>();
            if (component3 && component3.m_ParentObject)
            {
                DeadBody component4 = component3.m_ParentObject.GetComponent <DeadBody>();
                if (component4)
                {
                    component4.OnTakeDamage(new DamageInfo
                    {
                        m_DamageItem = currentItem,
                        m_Damager    = base.gameObject,
                        m_Position   = hit_pos,
                        m_HitDir     = hit_dir,
                        m_Normal     = -hit_dir
                    });
                    this.m_AlreadyHit = true;
                }
            }
        }
        DamageInfo     damageInfo = new DamageInfo();
        ObjectMaterial component5;

        if (cj_object != null)
        {
            component5 = cj_object.gameObject.GetComponent <ObjectMaterial>();
        }
        else
        {
            component5 = coll.gameObject.GetComponent <ObjectMaterial>();
        }
        EObjectMaterial mat = (component5 == null) ? EObjectMaterial.Unknown : component5.m_ObjectMaterial;

        damageInfo.m_Damage     = currentItem.m_Info.m_DamageSelf * ObjectMaterial.GetDamageSelfMul(mat);
        damageInfo.m_DamageItem = currentItem;
        this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
        currentItem.TakeDamage(damageInfo);
        this.OnHit();
    }