DamageDealer.DoDamage C# (CSharp) Méthode

DoDamage() private méthode

private DoDamage ( GameObject obj, Vector3 position, Quaternion rotation ) : void
obj GameObject
position Vector3
rotation Quaternion
Résultat void
    private void DoDamage(GameObject obj, Vector3 position, Quaternion rotation)
    {
        if(this.action != null)
        {
            DamageZone zone = (DamageZone)obj.GetComponent(typeof(DamageZone));
            if(zone != null && this.action.CanDamage(zone.GetCombatant()) &&
                (!this.singleDamage || !this.blocked.ContainsKey(zone.GetBattleID())) &&
                (!this.singleEnemy || this.blocked.Count == 0 ||
                (this.blocked.Count == 1 && this.blocked.ContainsKey(zone.GetBattleID()))) &&
                (this.dmgEvery == 0 || !this.blocked.ContainsKey(zone.GetBattleID())))
            {
                int id = zone.Damage(this.action);
                if(this.prefab != null)
                {
                    GameObject pref = (GameObject)GameObject.Instantiate(this.prefab, position, rotation);
                    if(this.destroyPrefabAfter > 0) GameObject.Destroy(pref, this.destroyPrefabAfter);
                }
                if(this.audioClip != null)
                {
                    if(obj.audio == null) obj.AddComponent<AudioSource>();
                    obj.audio.pitch = this.aPitch;
                    obj.audio.volume = this.aVolume;
                    obj.audio.rolloffMode = this.audioRolloffMode;
                    obj.audio.minDistance = this.aMinDistance;
                    obj.audio.maxDistance = this.aMaxDistance;
                    obj.audio.PlayOneShot(this.audioClip);
                }

                if(!this.blocked.ContainsKey(id)) this.blocked.Add(id, this.dmgEvery);
                if(this.destroyOnDamage)
                {
                    GameObject.Destroy(this.gameObject);
                }
            }
        }
    }