示例#1
0
    /// <summary>
    /// Inflict damages to a specified target.
    /// </summary>
    /// <param name="_target">Target to hit.</param>
    private void InflictDamages(TDS_Damageable _target)
    {
        // Attack the target
        if (CurrentAttack.Attack(this, _target) < -1)
        {
            return;
        }

        // Call local method on the character who hit
        if (Owner)
        {
            if (PhotonNetwork.offlineMode && (Owner is TDS_Player _player))
            {
                _player.HitCallback(_target.Collider.bounds.center.x, _target.Collider.bounds.max.y, _target.transform.position.z);
            }
            else
            {
                TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", Owner.photonView.owner, TDS_RPCManager.GetInfo(Owner.photonView, Owner.GetType(), "HitCallback"), new object[] { _target.Collider.bounds.center.x, _target.Collider.bounds.max.y, _target.transform.position.z });
            }
        }

        // Triggers event
        OnTouch?.Invoke();
    }