DamageZone.Damage C# (CSharp) Method

Damage() public method

public Damage ( BattleAction, action ) : int
action BattleAction,
return int
    public int Damage(BattleAction action)
    {
        int id = this.GetBattleID();
        if(this.combatant != null &&
            (!this.combatant.isDead || action.reviveFlag))
        {
            CombatantAnimation[] anims = action.Calculate(
                    new Combatant[] {this.combatant}, this.damageFactor);
            if(anims.Length > 0)
            {
                string name = this.combatant.GetAnimationName(anims[0]);
                if(name != "" && this.combatant.prefabInstance != null &&
                    this.combatant.prefabInstance.animation != null &&
                    this.combatant.prefabInstance.animation[name] &&
                    (DataHolder.BattleSystem().playDamageAnim ||
                    !this.combatant.IsInAction() ||
                    !(DataHolder.BattleSystem().dynamicCombat ||
                    DataHolder.BattleSystem().IsRealTime())))
                {
                    this.combatant.prefabInstance.animation.CrossFade(name, 0.3f, PlayMode.StopSameLayer);
                }
            }
        }
        return id;
    }

Usage Example

コード例 #1
0
    public virtual int Simulate()
    {
        int     simulation = -1;
        Vector3 dir        = -transform.forward;
        Vector3 pos        = transform.position + (transform.forward * 0.125f);

        if (Physics.Raycast(pos, dir, out var hit, 0.175f))
        {
            parentAdjuster          = new GameObject().transform;
            parentAdjuster.position = hit.point;

            parentAdjuster.SetParent(hit.transform);
            transform.SetParent(parentAdjuster);
            float dis = Vector3.Distance(hit.point, pos) + 0.05f + size;
            if (Physics.SphereCast(pos, size, dir, out var hitDmg, dis, damageLayer))
            {
                DamageZone damaged = hitDmg.transform.GetComponent <DamageZone>();
                if (damaged != null)
                {
                    if (!damaged.DamageableAlreadyDead())
                    {
                        simulation = Mathf.Max(simulation, 0);
                        if (damaged.Damage(Damage, 1f))
                        {
                            simulation = 1;
                        }
                    }
                }
            }
        }
        return(simulation);
    }
All Usage Examples Of DamageZone::Damage
DamageZone