Example #1
0
    // Awake is called when the script instance is being loaded
    protected virtual void Awake()
    {
        // Get missing references
        if (!rigidbody)
        {
            rigidbody = GetComponentInChildren <Rigidbody>();
        }
        if (!collider)
        {
            collider = GetComponentInChildren <BoxCollider>();
        }
        if (!hitBox)
        {
            hitBox = GetComponentInChildren <TDS_HitBox>();
        }
        if (!shadow)
        {
            shadow = transform.GetChild(0).GetChild(1).gameObject;
        }
        if (!sprite)
        {
            sprite = GetComponentInChildren <SpriteRenderer>();
        }

        // Set event on hitbox hit
        hitBox.OnTouch += OnHitSomething;
    }
 // Awake is called when the script instance is being loaded
 private void Awake()
 {
     if (!animator)
     {
         animator = GetComponent <Animator>();
         if (!animator)
         {
             Debug.LogWarning("Animator is missing on Fire Ball !");
         }
     }
     if (!hitBox)
     {
         hitBox = GetComponent <TDS_HitBox>();
         if (!hitBox)
         {
             Debug.LogWarning("HitBox is missing on Fire Ball !");
         }
     }
     if (!photonView)
     {
         photonView = GetComponent <PhotonView>();
         if (!photonView)
         {
             Debug.LogWarning("PhotonView is missing on Fire Ball !");
         }
     }
 }
Example #3
0
    /// <summary>
    /// Attacks the target, by inflicting damages and applying effects.
    /// </summary>
    /// <param name="_attacker">The HitBox attacking the target.</param>
    /// <param name="_target">Target to attack.</param>
    /// <returns>Returns -2 if target didn't take any damages, -1 if the target is dead, 0 if no effect could be applied, and 1 if everything went good.</returns>
    public virtual int Attack(TDS_HitBox _attacker, TDS_Damageable _target)
    {
        // Roll the dice to know if the attack effect should be applied
        int  _percent  = Random.Range(1, 100);
        bool _noEffect = (_percent > Effect.PercentageLowest) && ((_percent > Effect.PercentageHighest) || (_percent > Random.Range(Effect.PercentageLowest, Effect.PercentageHighest + 1)));

        // Get attack damages
        int _damages = GetDamages + _attacker.BonusDamages;

        if (!_noEffect)
        {
            _damages += Random.Range(Effect.DamagesMin, Effect.DamagesMax + 1);
        }

        // Inflict damages, and return if target don't get hurt, if no effect or if target is dead
        if ((_damages < 1) || !_target.TakeDamage(_damages, _attacker.Collider.bounds.center))
        {
            return(-2);
        }

        // Increase score
        if ((_attacker.Owner is TDS_Player _player) && (_target is TDS_Enemy _enemyTarget))
        {
            TDS_GameManager.PlayersInfo.First(p => p.PlayerType == _player.PlayerType).PlayerScore.IncreaseInflictedScore(_enemyTarget, _damages);
        }
Example #4
0
 /// <summary>
 /// Attacks the target, by inflicting damages and applying effects.
 /// </summary>
 /// <param name="_attacker">The HitBox attacking the target.</param>
 /// <param name="_target">Target to attack.</param>
 /// <returns>Returns -2 if target didn't take any damages, -1 if the target is dead, 0 if no effect could be applied, and 1 if everything went good.</returns>
 public override int Attack(TDS_HitBox _attacker, TDS_Damageable _target)
 {
     if (canBreakGuard && (_target is TDS_Player _player))
     {
         _player.StopParry();
     }
     return(base.Attack(_attacker, _target));
 }
 // Awake is called when the script instance is being loaded
 private void Awake()
 {
     if (!hitBox)
     {
         hitBox = GetComponent <TDS_HitBox>();
         if (!hitBox)
         {
             Debug.LogWarning("HitBox is missing on Projectile !");
         }
     }
 }
    /// <summary>
    /// Attacks the target, by inflicting damages and applying effects.
    /// </summary>
    /// <param name="_attacker">The HitBox attacking the target.</param>
    /// <param name="_target">Target to attack.</param>
    /// <returns>Returns -1 if target didn't take any damages, 0 if no effect could be applied, and 1 if everything went good.</returns>
    public override int Attack(TDS_HitBox _attacker, TDS_Damageable _target)
    {
        // If should not apply burn effect, return
        int _result = base.Attack(_attacker, _target);

        if (_result < 0)
        {
            return(_result);
        }

        // Roll the dices to get if burn effect should be applied
        int _percent = Random.Range(1, 101);

        if ((_percent > burnPercentageLowest) && ((_percent > burnPercentageHighest) || (_percent > Random.Range(burnPercentageLowest, burnPercentageHighest + 1))))
        {
            return(0);
        }

        // Burn it
        _target.Burn(burnDamagesMin, burnDamagesMax, burnDuration);
        return(1);
    }
Example #7
0
 // Awake is called when the script instance is being loaded
 protected override void Awake()
 {
     base.Awake();
     // Try to get components references if they are missing
     if (!hitBox)
     {
         hitBox = GetComponentInChildren <TDS_HitBox>();
         if (!hitBox)
         {
             Debug.LogWarning("The HitBox of \"" + name + "\" for script TDS_Character is missing !");
         }
     }
     if (!rigidbody)
     {
         rigidbody = GetComponent <Rigidbody>();
         if (!rigidbody)
         {
             Debug.LogWarning("The Rigidbody of \"" + name + "\" for script TDS_Character is missing !");
         }
     }
     if (!handsTransform)
     {
         Debug.LogWarning("The Hands Transform of \"" + name + "\" for script TDS_Character is missing !");
     }
     if (!shadowTransform)
     {
         Debug.LogWarning("The Shadow Transform of \"" + name + "\" for script TDS_Character is missing !");
     }
     if (!audioSource)
     {
         audioSource = GetComponent <AudioSource>();
         if (!audioSource)
         {
             Debug.LogWarning("The AudioSource of \"" + name + "\" for script TDS_Character is missing !");
         }
     }
 }