public DamagePacket(DamageType type, int damage, Vector2 knockback, IDamageDealer damageDealer)
 {
     Type            = type;
     DamageAmount    = damage;
     KnockbackVector = knockback;
     DamageDealer    = damageDealer;
 }
 public PassiveRecoveryResource(IResource _resource, float _interval, int _amount, IDamageDealer _self, IElement _element = null) : base(_resource)
 {
     this.self           = _self;
     this.element        = _element != null ? _element : new NullElement();
     this.recoveryAmount = new RefValue <int>(() => _amount);
     CreateTimer(_interval);
 }
Beispiel #3
0
 // Start is called before the first frame update
 void Start()
 {
     rb = GetComponent <Rigidbody2D>();
     dd = new DamageSystemBullet(gameObject, 1, 1);
     ss = new SoundSystemDefault(gameObject, Sounds.GunCollision, 0.5f);
     rb.AddForce(bulletDirection * bulletSpeed, ForceMode2D.Impulse);
 }
 public DamagePacket(DamageType type, IDamageDealer damageDealer)
 {
     Type            = type;
     DamageAmount    = 1;
     KnockbackVector = Vector2.zero;
     DamageDealer    = damageDealer;
 }
Beispiel #5
0
 public void ApplyDamage(IDamageDealer damageDealer)
 {
     if (health > 0)
     {
         // Уменьшаем уровень здоровья после урона.
         health -= damageDealer.Damage;
     }
     if (health <= 0)
     {
         if (gameObject.tag == "Player")
         {
             Destroy(gameObject);
             // Остановка игры после смерти Игрока.
             Time.timeScale = 0;
             //Вызываем событие конца игры при поражении.
             GameOverEvent.Invoke();
         }
         else
         {
             Destroy(gameObject);
             _hitpoint--;            // Убираем баг с задвоением очков при одновременном попадании более одного снаряда
             if (_hitpoint > 0)
             {
                 //Вызываем события для подсчёта очков Игрока.
                 RewardEvent.Invoke();
                 PlayerScoreEvent.Invoke();
             }
         }
     }
 }
Beispiel #6
0
 public override void Shoot(IDamageDealer shooter)
 {
     Instantiate(_bullet, _bulletSpawn.position, _bulletSpawn.rotation * Quaternion.Euler(0, 0, _bulletSpread / 2.0f)).Initialize(_damage, _knockbackScalar, _bulletSpeed, shooter);
     Instantiate(_bullet, _bulletSpawn.position, _bulletSpawn.rotation * Quaternion.Euler(0, 0, -_bulletSpread / 2.0f)).Initialize(_damage, _knockbackScalar, _bulletSpeed, shooter);
     //Instantiate(_bullet, _bulletSpawn.position, _bulletSpawn.rotation).Initialize(_damage, _knockbackScalar, _bulletSpeed, shooter);
     base.Shoot(shooter);
 }
Beispiel #7
0
    public void Start()
    {
        _dmgDealer = GetComponent <IDamageDealer>();
        _dmgble    = GetComponent <Damageable>();

        _dmgble.EOnDeath -= deathInvoked;
        _dmgble.EOnDeath += deathInvoked;
    }
Beispiel #8
0
 public CombatActor(INameable name, IStats stats, IDamageable damageable, IDamageDealer dealer)
 {
     Name         = name;
     Target       = null;
     Stats        = stats;
     Damageable   = damageable;
     DamageDealer = dealer;
 }
 public void ApplyDamage(IDamageDealer damageDealer)
 {
     HP--;
     if (HP <= 0)
     {
         Destroy(gameObject);
         Lose();
     }
 }
    protected virtual void OnDeath(DamageReceiver dr, IDamageDealer killer)
    {
        if (explosionParticles)
        {
            Instantiate(explosionParticles, transform.position, explosionParticles.transform.rotation);
        }

        explosionData.ExplodeAt(transform.position, killer);
    }
Beispiel #11
0
        public static ISource Unit(IDamageDealer _damageDealer, IElement _element, bool _criticalHit = false)
        {
            var style = _element.GetStyle(_criticalHit);

            return(new Source()
                   .WithDamageDealer(_damageDealer)
                   .WithElement(_element)
                   .WithStyle(style));
        }
Beispiel #12
0
    public void Initialize(int damage, float kbScalar, float bulletSpeed, IDamageDealer source)
    {
        Damage          = damage;
        KnockbackScalar = kbScalar;
        bulletSource    = source;

        bulletRig = GetComponent <Rigidbody2D>();
        SetVelocity(bulletSpeed);
    }
 public override void ApplyDamage(IDamageDealer damageDealer)
 {
     _endurance -= damageDealer.Damage; // уменьшаем кол-во здоровья
     EnduranceChanged.Invoke(_endurance);
     if (_endurance <= 0)
     {
         Die.Invoke();
     }
 }
Beispiel #14
0
        public virtual void ApplyDamage(IDamageDealer damageDealer)
        {
            _health.Value -= damageDealer.Damage;

            if (_health.Value <= 0)
            {
                DestroyShip();
            }
        }
Beispiel #15
0
        public virtual void ApplyDamage(IDamageDealer damageDealer)
        {
            CurrentArmor -= damageDealer.Damage;

            if (CurrentArmor <= 0)
            {
                ProcessDie();
            }
        }
Beispiel #16
0
 private void HandleDamage(IDamageDealer damageDealer)
 {
     currentHits += damageDealer.GetDamage();
     if (currentHits >= hitsToDestroy)
     {
         Destroy(this.gameObject);
         return;
     }
     spriteRenderer.sprite = destructionSprites[currentHits - 1];
 }
Beispiel #17
0
        public event UnityAction <float> ArmorChanged;                  // событие вызываемое при изменении количества брони игрока

        public override void ApplyDamage(IDamageDealer damageDealer)
        {
            CurrentArmor -= damageDealer.Damage;
            ArmorChanged?.Invoke(CurrentArmor);                  // вызов события

            if (CurrentArmor <= 0)
            {
                ProcessDie();
            }
        }
Beispiel #18
0
 private void DestroyDamageDealer(IDamageDealer damageDealer)
 {
     damageDealers.Remove(damageDealer);
     if (damageDealer is CCNode)
     {
         var asNode = damageDealer as CCNode;
         gameplayLayer.RemoveChild(asNode);
         asNode.Dispose();
     }
 }
Beispiel #19
0
        //обработка получения урона
        public override void ApplyDamage(IDamageDealer damageDealer)
        {
            _playerData.Health -= damageDealer.Damage;

            if (IsShipDead())
            {
                DestroyShip();
            }

            DisplayHealth();
        }
Beispiel #20
0
    void Start()
    {
        damageDealer = GetComponentInParent <IDamageDealer>();
        attackSpeed  = damageDealer.attackSpeed;
        damage       = damageDealer.damage;

        targetSeaker = GetComponentInParent <ITargetSeaker>();

        bulets = new List <GameObject>();
        ReloadBulets(maxBuletsCount);
    }
        public LegacyCombatCalculator(IDamageDealer _applier, IElement _applierElement, IDamageable _receiver, int _base, float[] _additiveMultipliers, float[] _multiplicativeMultipliers, bool _canCrit = false)
        {
            this.applier  = _applier;
            this.receiver = _receiver;
            this.element  = _applierElement;

            this.baseDamage                = _base;
            this.additiveMultipliers       = _additiveMultipliers;
            this.multiplicativeMultipliers = _multiplicativeMultipliers;
            this.canCrit = _canCrit;
        }
Beispiel #22
0
        //обработка получения урона
        public override void ApplyDamage(IDamageDealer damageDealer)
        {
            _enemyData.Health -= damageDealer.Damage;

            if (IsShipDead())
            {
                _observer.DownEnemyWithReward.Invoke(_enemyData.Reward);
                _observer.ObectOutdated.Invoke(gameObject);
                _observer.EnemyDown.Invoke(gameObject);
            }
        }
Beispiel #23
0
        void OnTriggerEnter(Collider bumpCollider)
        {
            IDamageDealer damageDealer = bumpCollider.GetComponent <IDamageDealer>();

            if (damageDealer == null)
            {
                return;
            }

            HandleHealthPoints(damageDealer.Damage);
        }
Beispiel #24
0
 public void ApplyDamage(IDamageDealer damageDealer)
 {
     health = Mathf.Clamp(health - damageDealer.Damage, 0, maxHealth);
     if (_shipController is ShipControllers.CustomControllers.PlayerShipController)
     {
         UIController.UIControllerSingleton.SetHealth(health / maxHealth);
     }
     if (health <= 0)
     {
         Death();
     }
 }
Beispiel #25
0
 public void ApplyDamage(IDamageDealer damageDealer)
 {
     _health -= damageDealer.Damage;
     if (!Alive)
     {
         Destroy(gameObject);
     }
     else
     {
         ShowHealth();
     }
 }
Beispiel #26
0
 /// <summary>
 /// Called by the player observing their projectile making contact with this character to inflict
 /// damage to this character. This must never be called from an RPC.
 /// </summary>
 /// <param name='damager'>
 /// An interface to the object dealing the damage.
 /// </param>	
 void IDamageTaker.TakeDamage(IDamageDealer damageDealer)
 {
     if (!IsDying)
     {
         float damage = damageDealer.GetDamage();
         // Tell all players that this character is taking damage. Since we only support players damaging bosses, GetOwningPlayer should never be null.
         myNetworkView.RPC("RPCBoss3TakeDamage", uLink.RPCMode.All, damage, damageDealer.GetOwningPlayer() );
     }
     else
     {
         // Ignore if the character is already dying
     }
 }
Beispiel #27
0
 /// <summary>
 /// Called by the player observing their projectile making contact with this character to inflict
 /// damage to this character. This must never be called from an RPC.
 /// </summary>
 /// <param name='damager'>
 /// An interface to the object dealing the damage.
 /// </param>	
 void IDamageTaker.TakeDamage(IDamageDealer damageDealer)
 {
     if (!IsDying)
     {
         float damage = damageDealer.GetDamage();
         // Tell the master client that this character is taking damage
         photonView.RPC("RPCBoss3TakeDamage", PhotonTargets.All, damage, (damageDealer.IsOwnedByPlayer() ? damageDealer.GetOwningPlayer() : null) );
     }
     else
     {
         // Ignore if the character is already dying
     }
 }
Beispiel #28
0
    public void ReceiveDamage <T>(IDamageDealer dealer, T damage) where T : Damage
    {
        var periodoicDamage = damage as ElementalDamage;

        if (periodoicDamage == null)
        {
            Hp -= damage.amount - Armor;
        }
        else
        {
            Hp -= periodoicDamage.amount;
        }
    }
Beispiel #29
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        IDamageDealer DamageDealer = other.gameObject.GetComponent <IDamageDealer>();

        if (DamageDealer != null)
        {
            if (other.gameObject.GetComponent <EnemyController>() != null)
            {
                Tools.FlashSprite(_spriteRenderer);
                _healthPlayerShared.DoDamage(DamageDealer.Damage());
            }
        }
    }
Beispiel #30
0
    public void ReceiveDamage <T>(IDamageDealer dealer, T damage) where T : Damage
    {
        var periodoicDamage = damage as ElementalDamage;

        if (periodoicDamage != null)
        {
            ReceiveElementalDamage(periodoicDamage);
        }

        else
        {
            ReceivePhysicalDamage(damage);
        }
    }
    protected virtual void DefaultOnDeath(DamageReceiver dr, IDamageDealer killer)
    {
        LetProcessAI = false;
        Rigidbody2D rb = GetComponent <Rigidbody2D>();

        if (rb)
        {
            rb.gravityScale = 1.0f;
        }
        rb.freezeRotation = false;

        GetComponentInChildren <ParticleSystem>().Play();
        Destroy(gameObject, _deathDestroyDelay);
    }
Beispiel #32
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log("Hit: " + other.name);

        IDamageable   hit = other.GetComponent <IDamageable>();
        IDamageDealer dmg = gameObject.GetComponentInParent <IDamageDealer>();

        if (hit != null && _canDamage)
        {
            hit.Damage(dmg.DamageAmount, dmg.DamageSource);
            _canDamage = false;
            StartCoroutine(ResetDamage());
        }
    }
Beispiel #33
0
 /// <summary>
 /// Called by the player observing their projectile making contact with this character to inflict
 /// damage to this character. This must never be called from an RPC.
 /// </summary>
 /// <param name='damager'>
 /// An interface to the object dealing the damage.
 /// </param>	
 void IDamageTaker.TakeDamage(IDamageDealer damageDealer)
 {
     if (!IsDying)
     {
         float damage = damageDealer.GetDamage();
         // Tell the master client that this character is taking damage
         photonView.RPC("RPCBoss2TakeDamage", PhotonTargets.All, damage, (damageDealer.IsOwnedByPlayer() ? damageDealer.GetOwningPlayer() : null) );
         // If we clearly doomed the character, begin its VISIBLE death sequence here. The master
         // client will eventually destroy it from the game.
         if (hitPoints - damage < MinHitpointsBeforeFrag)
         {
             BeginDying(); // This will flag the character as dying
         }
     }
     else
     {
         // Ignore if the character is already dying
     }
 }
Beispiel #34
0
 /// <summary>
 /// Called by the player observing their projectile making contact with this character to inflict
 /// damage to this character. This must never be called from an RPC.
 /// </summary>
 /// <param name='damager'>
 /// An interface to the object dealing the damage.
 /// </param>	
 void IDamageTaker.TakeDamage(IDamageDealer damageDealer)
 {
     if (!IsDying)
     {
         float damage = damageDealer.GetDamage();
         // Tell all players that this character is taking damage. Since we only support players damaging bosses, GetOwningPlayer should never be null.
         myNetworkView.RPC("RPCBoss2TakeDamage", uLink.RPCMode.All, damage, damageDealer.GetOwningPlayer() );
         // If we clearly doomed the character, begin its VISIBLE death sequence here. The master
         // client will eventually destroy it from the game.
         if (hitPoints - damage < MinHitpointsBeforeFrag)
         {
             BeginDying(); // This will flag the character as dying
         }
     }
     else
     {
         // Ignore if the character is already dying
     }
 }
Beispiel #35
0
 /// <summary>
 /// Called by the player observing their projectile making contact with this character to inflict
 /// damage to this character. This must never be called from an RPC.
 /// </summary>
 /// <param name='damager'>
 /// An interface to the object dealing the damage.
 /// </param>	
 void IDamageTaker.TakeDamage(IDamageDealer damageDealer)
 {
     if (!IsDying)
     {
         float damage = damageDealer.GetDamage();
         // Tell everybody that this barrel is taking damage
         uLink.NetworkView.Get(this).RPC("RPCBarrelTakeDamage", uLink.RPCMode.All, damage, damageDealer.GetOwningPlayer() );
     }
     else
     {
         // Ignore if the character is already dying
     }
 }
Beispiel #36
0
	/// <summary>
	/// Called by the player observing their projectile making contact with this character to inflict
	/// damage to this character. This must never be called from an RPC.
	/// </summary>
	/// <param name='damager'>
	/// An interface to the object dealing the damage.
	/// </param>	
	void IDamageTaker.TakeDamage(IDamageDealer damageDealer)
	{
		if (!IsDying)
		{
#if PLAYER_TAKES_DAMAGE
			float damage = damageDealer.GetDamage();
			// Tell everybody that this barrel is taking damage
			photonView.RPC("RPCPlayerOnFootTakeDamage", PhotonTargets.All, damage);
#endif
		}
		else
		{
			// Ignore if the character is already dying
		}
	}
Beispiel #37
0
 public void Awake()
 {
     _applyingDamage = this.GetComponent<ApplyingDamage>();
 }
Beispiel #38
0
	/// <summary>
	/// Called by the player observing their projectile making contact with this character to inflict
	/// damage to this character. This must never be called from an RPC.
	/// </summary>
	/// <param name='damager'>
	/// An interface to the object dealing the damage.
	/// </param>	
	void IDamageTaker.TakeDamage(IDamageDealer damageDealer)
	{
		if (!IsDying)
		{
#if PLAYER_TAKES_DAMAGE
			float damage = damageDealer.GetDamage();
			// Tell everybody that this barrel is taking damage
			networkView.RPC("RPCPlayerCharacterHorseTakeDamage", RPCMode.All, damage);
#endif
		}
		else
		{
			// Ignore if the character is already dying
		}
	}
Beispiel #39
0
		private void DestroyDamageDealer(IDamageDealer damageDealer)
		{
			damageDealers.Remove (damageDealer);
			if (damageDealer is CCNode)
			{
				var asNode = damageDealer as CCNode;
				gameplayLayer.RemoveChild (asNode);
				asNode.Dispose ();
			}
		}