Beispiel #1
0
    public override void Die(IDamageSource source)
    {
        OnEnemyDeath(this, source);

        dead = true;
        gameObject.Recycle();
    }
Beispiel #2
0
 public override void ReceiveDamage(IDamageSource damageSource, DamagesParameters damagesParameter, ProjectileSpecialParameters projSpecialParameterss)
 {
     if (!GameManager.gameManager.Won && GameManager.gameManager.StartedFight)
     {
         base.ReceiveDamage(damageSource, damagesParameter, projSpecialParameterss);
     }
 }
    private void OnTriggerEnter(Collider other)
    {
        IDamageReceiver damageReceiver = other.GetComponent <IDamageReceiver>();

        if (damageReceiver != null)
        {
            if (damageReceiver == relatedProjectile.GetSourceDamageReceiver)
            {
                return;
            }

            if (GetDamageTag == AttackTag.Environment || GetDamageTag == AttackTag.Enemies || GetDamageTag != damageReceiver.GetDamageTag)
            {
                DealDamage(damageReceiver, relatedProjectile.GetDamagesParameters);
            }
        }

        if (relatedProjectile.PersistantAndPlaced)
        {
            IDamageSource damageSource = other.GetComponent <IDamageSource>();
            if (damageSource != null && damageReceiver == null)
            {
                relatedProjectile.ExplodeOnContact();
            }
        }

        if (other.GetComponent <Obstacle>() != null)
        {
            relatedProjectile.ExplodeOnContact();
        }
    }
Beispiel #4
0
        public void HitBy(IDamageSource damageSource)
        {
            if (UnityEngine.Random.Range(0, 3) == 0)
            {
                currentStrength -= damageSource.Damage;

                if (currentStrength <= 0)
                {
                    EventHandler <EventArgs> handler = Destroyed;
                    if (handler != null)
                    {
                        handler(this, EventArgs.Empty);
                    }
                    Destroy(gameObject);
                }
                else
                {
                    EventHandler <EventArgs> handler = Damaged;
                    if (handler != null)
                    {
                        handler(this, EventArgs.Empty);
                    }
                }
            }
        }
Beispiel #5
0
    public override void Die(IDamageSource source)
    {
        gameObject.SetActive(false);
        dead = true;

        OnPlayerDeath(this, source);
    }
        public virtual void Fire(Vector3 position, Vector3 velocity, float gravity, IAmmoEffect effect, Transform ignoreRoot, LayerMask layers, IDamageSource damageSource = null)
        {
            m_Velocity     = velocity;
            this.gravity   = gravity;
            m_AmmoEffect   = effect;
            m_DamageSource = damageSource;
            m_IgnoreRoot   = ignoreRoot;
            m_Layers       = layers;

            localTransform.position = position;
            if (m_FollowCurve)
            {
                localTransform.LookAt(position + velocity);
            }

            // Reset distance
            m_Distance      = 0;
            m_PassedMinimum = false;

            // Reset pooling
            m_Release = false;
            m_Timeout = m_RecycleDelay;

            // Hide the mesh for the first frame
            if (m_MeshRenderer != null)
            {
                m_MeshRenderer.enabled = false;
            }

            // Store the starting position
            m_LerpToPosition = localTransform.position;

            // Update immediately
            FixedUpdate();
        }
        public void ReadProperties(INeoDeserializer reader, NeoSerializedGameObject nsgo)
        {
            reader.TryReadValue(k_VelocityKey, out m_Velocity, m_Velocity);
            reader.TryReadValue(k_ReleaseKey, out m_Release, m_Release);
            reader.TryReadValue(k_DistanceKey, out m_Distance, m_Distance);

            int layerMask = m_Layers;

            if (reader.TryReadValue(k_LayersKey, out layerMask, layerMask))
            {
                m_Layers = layerMask;
            }

            Vector3 position;

            if (reader.TryReadValue(k_PositionKey, out position, Vector3.zero))
            {
                m_LerpFromPosition      = position;
                m_LerpToPosition        = position;
                localTransform.position = position;
            }

            IAmmoEffect serializedAmmoEffect;

            if (reader.TryReadComponentReference(k_AmmoEffectKey, out serializedAmmoEffect, nsgo))
            {
                m_AmmoEffect = serializedAmmoEffect;
            }
            IDamageSource serializedDamageSource;

            if (reader.TryReadComponentReference(k_DamageSourceKey, out serializedDamageSource, nsgo))
            {
                m_DamageSource = serializedDamageSource;
            }
        }
Beispiel #8
0
 public void Initialize(Vector3 dir, string weaponName, float damage, float damageMultiplier, IDamageSource damageSource)
 {
     GetComponent <Rigidbody2D>().velocity = dir * speed;
     from        = damageSource;
     this.damage = damage;
     damage     *= damageMultiplier;
 }
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Projectile"))
     {
         // Get the source of the projectile
         GameObject source     = other.gameObject;
         Projectile projectile = source.GetComponent <Projectile>();
         if (projectile != null)
         {
             // Apply damage based on the source
             IDamageSource from = projectile.from;
             //Update the damage dealt data, this can also be used to calculate 'healing on hit'
             //TargetOnDealDamage(from.connectionToClient, projectile.damage);
             //Update the damage taken and also update the new health
             //TargetOnRecevieDamage(connectionToClient, projectile.damage, from.stats.playerName);
             // if (from != null)
             // {
             //     from.OnDealDamage(projectile.Damage);
             // }
             OnRecevieDamage(from, projectile.Damage);
             Destroy(other.gameObject);
             // Let the projectile decied what to do on contact
             // ProjectileAI projectile = other.GetComponent<ProjectileAI>();
             // if(projectile != null)
             // {
             //     projectile.OnContact();
             // }
         }
     }
 }
Beispiel #10
0
        /// <summary>
        /// Called when the reactor is first activated
        /// </summary>
        /// <returns>Determines if other reactors should process.</returns>
        public override bool Activate()
        {
            base.Activate();
            CombatMessage    combatMessage = (CombatMessage)mMessage;
            IDamageSource    damageSource  = (IDamageSource)combatMessage.Weapon;
            NeoFPSWeaponCore weapon        = (NeoFPSWeaponCore)combatMessage.Weapon;

            mDamageHandler.AddDamage(combatMessage.Damage, damageSource);

            // Get character kicker
            var character = mOwner.GetComponent <NeoFPS.ICharacter>();

            if (character != null)
            {
                var kicker = character.headTransformHandler.GetComponent <NeoFPS.AdditiveKicker>();
                if (kicker != null)
                {
                    // Kick the camera position & rotation
                    float kickDuration = 0.25f;
                    float kickRotation = 5f;
                    kicker.KickPosition(combatMessage.HitDirection * combatMessage.ImpactPower, kickDuration);
                    kicker.KickRotation(Quaternion.AngleAxis(kickRotation, Vector3.Cross(combatMessage.HitDirection, Vector3.up)), kickDuration);
                }
            }

            //Debug.Log(damageMessage.Sender + " hit for " + ((DamageMessage)mMessage).Damage + " on " + mOwner);
            Deactivate();
            return(true);
        }
Beispiel #11
0
 /// <inheritdoc />
 public void Damage(int amount, IDamageSource source)
 {
     health -= amount;
     if (health <= 0)
     {
         Destroy(gameObject);
     }
 }
Beispiel #12
0
 public UnturnedPlayerDamagedEvent(UnturnedPlayer player, byte damageAmount, EDeathCause cause, ELimb limb, CSteamID killer, IDamageSource damageSource) : base(player)
 {
     DamageAmount = damageAmount;
     Cause        = cause;
     Limb         = limb;
     Killer       = killer;
     DamageSource = damageSource;
 }
Beispiel #13
0
    public bool TakeHit(IDamageable target, IDamageSource source, out int armorDamageTaken, out int bodyDamageTaken)
    {
        target.onTakeHit.Invoke(source);
        bool result = TakeDamage(target, source, out armorDamageTaken, out bodyDamageTaken);

        target.onHitTaken.Invoke(source, result, armorDamageTaken, bodyDamageTaken);
        return(result);
    }
 public UnturnedPlayerDyingEvent(UnturnedPlayer player, byte amount,
                                 EDeathCause cause, ELimb limb,
                                 CSteamID killer, IDamageSource source,
                                 bool trackKill,
                                 Vector3 ragdoll, ERagdollEffect ragdollEffect,
                                 bool canCauseBleeding) : base(player, amount, cause, limb,
                                                               killer, source, trackKill, ragdoll, ragdollEffect, canCauseBleeding)
 {
 }
Beispiel #15
0
        public DamageResult AddDamage(float damage, IDamageSource source)
        {
            bool isDead = m_EmeraldAISystem.IsDead;

            if (source == null)
            {
                return(AddDamage(damage));
            }

            // Apply damage
            if (m_Multiplier > 0f)
            {
                int scaledDamage = Mathf.CeilToInt(damage * m_Multiplier);

                if (CombatTextSystem.Instance != null)
                {
                    CombatTextSystem.Instance.CreateCombatTextAI(scaledDamage, transform.position, m_Critical, false);
                }

                if (source.controller != null)
                {
                    // Apply damage
                    m_EmeraldAISystem.Damage(
                        scaledDamage,
                        EmeraldAISystem.TargetType.Player,
                        source.damageSourceTransform
                        );

                    // Report damage dealt
                    if (damage > 0f && source != null && source.controller != null)
                    {
                        source.controller.currentCharacter.ReportTargetHit(m_Critical);
                    }

                    // Report killed
                    if (!isDead && m_EmeraldAISystem.IsDead && source.controller.isPlayer)
                    {
                        OnPlayerKilledAI();
                    }
                }
                else
                {
                    // Apply damage
                    m_EmeraldAISystem.Damage(
                        scaledDamage,
                        EmeraldAISystem.TargetType.NonAITarget,
                        source.damageSourceTransform
                        );
                }

                return(m_Critical ? DamageResult.Critical : DamageResult.Standard);
            }
            else
            {
                return(DamageResult.Ignored);
            }
        }
    public void Damage(IDamageSource hSource)
    {
        //DELETE?
        hRigidbody.useGravity = true;
        //DELETE?

        //Rigidbody hRigidbody = AddRigidbody();
        hRigidbody.velocity = hSource.GetDamage(Armor) * hSource.Owner.gameObject.transform.forward;
    }
Beispiel #17
0
 public override int Damage(int amount, IDamageSource damageSource)
 {
     amount -= defense;
     if (amount < 0)
     {
         amount = 0;
     }
     return(base.Damage(amount, damageSource));
 }
Beispiel #18
0
 protected virtual void OnHealthChanged(float from, float to, bool critical, IDamageSource source)
 {
     // Fire event
     if (onHealthChanged != null)
     {
         onHealthChanged(from, to, critical, source);
     }
     m_OnHealthChanged.Invoke(to);
 }
Beispiel #19
0
    public void ReceiveAttack(IDamageSource source)
    {
        int reducedDmg = source.Damage - c_Def;

        if ((this._currentHP = this._currentHP - reducedDmg) < 0)
        {
            _currentHP = 0;
        }
    }
Beispiel #20
0
        protected override void HandleDamage(IDamageSource damageSource)
        {
            if (damageSource.HasActorSource())
            {
                _chasing = damageSource.GetActorSource();
            }

            _chaseTimer.Start(ChaseTime);
        }
Beispiel #21
0
    public void Initalize(IDamageSource source, int damage, float distance, LayerMask targetMask)
    {
        this.damage     = damage;
        this.source     = source;
        this.targetMask = targetMask;

        float destroyTime = distance / speed;

        Invoke("Die", destroyTime);
    }
 /// <summary>
 /// Implementation of the <see cref="ILivingCreature"/> interaface
 /// </summary>
 /// <param name="damage">Amount of damage to be applied</param>
 /// <param name="damageSource">Source of the damage</param>
 /// <returns></returns>
 public bool TakeDamage(int damage, IDamageSource damageSource)
 {
     Health -= damage;
     if (Health <= 0)
     {
         //Die
         return(true);
     }
     return(false);
 }
Beispiel #23
0
        void SetHealth(float to, bool crit, IDamageSource source)
        {
            if (to < 0f)
            {
                to = 0f;
            }

            m_Critical = crit;
            m_Source   = source;
            m_HealthStat.SetCurrentValueRaw(to);
        }
Beispiel #24
0
        public virtual void AddHealth(float h, IDamageSource source)
        {
            // Change health
            SetHealth(health + h, false, source);

            // Check if brought back to life
            if (!isAlive && health > 0f)
            {
                isAlive = true;
            }
        }
        private void OnHurt(Player nativePlayer, byte damage, Vector3 force, EDeathCause cause, ELimb limb, CSteamID killer)
        {
            UnturnedPlayer player = GetUnturnedPlayer(nativePlayer);

            IDamageSource source = GetDamageSource(player, damage, cause, limb, killer);

            UnturnedPlayerDamagedEvent @event =
                new UnturnedPlayerDamagedEvent(player, damage, cause, limb, killer, source);

            Emit(@event);
        }
Beispiel #26
0
 public override void ReceiveDamage(IDamageSource damageSource, DamagesParameters damagesParameters, ProjectileSpecialParameters projSpecialParameters)
 {
     if (damageSource.GetDamageTag == AttackTag.Player)
     {
         if (!GameManager.gameManager.CinematicMng.CinematicProcessing)
         {
             IntroControler dialogue = dialoguesToLaunchOnFleeingEnemyHitByShot[Random.Range(0, dialoguesToLaunchOnFleeingEnemyHitByShot.Length)];
             dialogue.PlayCinematic();
         }
     }
 }
Beispiel #27
0
    void OnPlayerDeath(Player player, IDamageSource source)
    {
        foreach (Player _player in level.players)
        {
            if (!_player.dead)
            {
                return;
            }
        }

        menuControl.ShowPanel(deathPanel);
    }
Beispiel #28
0
    IEnumerator GameOverActions(IDamageSource killer)
    {
        Character unit = killer as Character;
        Obstacle obst = killer as Obstacle;
        string name = unit != null? unit.name : obst.name;
        
        if (killer != null)
            print("Вас убил объект " + name + "!");

        yield return new WaitForSeconds(gameoverDelay);
        
        Application.LoadLevel(Application.loadedLevel);
    }
        public void Damage(IDamageSource source)
        {
            if (source == null)
                return;

            float damage = Mathf.Abs(source.BaseDamage);

            foreach(var modifier in _damageModifiers)
                damage = modifier(source, damage);

            HandleDamage(source, damage);
            OnDamage.SafeInvoke(source, damage);
        }
Beispiel #30
0
    public bool TakeDirectDamage(IDamageable target, IDamageSource source, out int damageTaken)
    {
        damageTaken       = Mathf.Clamp(source.GetTotalDamage(), 0, target.currentIP);
        target.currentIP -= damageTaken;
        bool result = target.currentIP > 0;

        target.onDirectDamage.Invoke(result, damageTaken);
        if (!result)
        {
            Die(target);
        }
        return(result);
    }
Beispiel #31
0
    public bool SurvivedHit(IDamageable target, IDamageSource source, ref int remainingDamage, out int damageTaken)
    {
        damageTaken       = Mathf.Clamp(remainingDamage, 0, target.currentIP);
        remainingDamage   = Mathf.Clamp(remainingDamage - damageTaken, 0, int.MaxValue);
        target.currentIP -= damageTaken;
        bool result = target.currentIP > 0;

        target.onBodyDamage.Invoke(result, damageTaken);
        if (!result)
        {
            Die(target);
        }
        return(result);
    }
Beispiel #32
0
    public virtual void Damage(IDamageSource source, int damage, Vector3 hitPoint, Vector3 hitDirection)
    {
        if (debug)
        {
            Debug.Log("[Damage] LivingEntity \"" + names.techName + "\" was attacked by \"" + source.names.techName + "\" and now has \"(" + health + " - " + damage + ")\" = " + (health - damage) + " health");
        }

        health -= damage;

        if (health <= 0)
        {
            Die(source);
        }
    }
 public void OnRecevieDamage(IDamageSource from, float damage)
 {
     StartCoroutine(ShowDamageEffect());
     if (currentHP > 0)
     {
         character.data.totalDamageTaken += damage;
         currentHP -= damage;
     }
     if (currentHP <= 0)
     {
         OnPlayerEliminated(from);
         //CmdRemovePlayerFromAlivePlayers(connectionToClient.connectionId);
     }
 }
 public void Damage(IDamageSource hSource)
 {
     RpcDie(Vector3.up);
 }
Beispiel #35
0
    public override void Damage(IDamageSource hSource)
    {
        if (hSource.Owner == this)
            return;

        if (!CanTakeDamage)
            return;

        //dmgImgMGR.FlashIn();

        LastActor = hSource.Owner;

        this.currentHealth -= hSource.GetDamage(this.Armor);

        if (this.currentHealth <= 0f)
        {
            HealthBar.enabled = false;
            RpcDie(hSource.Owner.netId);
        }
    }
Beispiel #36
0
    /// <summary>
    /// Заставляет персонажа получить урон.
    /// </summary>
    /// <param name="damage">наносимый урон</param>
    /// <param name="damageSource">персонаж-источник наносимого урона</param>
    public void TakeDamage(float damage, IDamageSource damageSource)
    {
        if (damage > 0)
        {
            if (OnTakingDamage != null)
                OnTakingDamage(this, new DamageEventArgs(damage, damageSource));
            _currentHP -= damage;

            IsTakingDamage = true;
            TimeFromTakenDamage = 0;
        }

        if (_currentHP <= 0 && IsAlive)
        {
            Die(damageSource);
        }
    }
Beispiel #37
0
    /// <summary>
    /// Заставляет персонажа умереть.
    /// </summary>
    /// <param name="killer">персонаж-убийца</param>
    public void Die(IDamageSource killer)
    {
        if (OnDeath != null)
            OnDeath(this, killer);

        _isDead = true;

        //foreach (var item in Spellbook)
        //{
        //    DestroyObject(item.gameObject);
        //}

        if (this is Runner)
        {
            _animator.SetTrigger("Death");
            DestroyObject(this.gameObject);
        }
        else
        {
            DestroyObject(this.gameObject);
        }
    }
Beispiel #38
0
 public DamageEventArgs(float damage, IDamageSource damageSource)
 {
     DamageSource = damageSource;
     Damage = damage;
 }
 public void Damage(IDamageSource source)
 {
 }
 protected virtual void HandleDamage(IDamageSource source, float damage)
 {
     InternalDamage += damage;
 }
 float InvincibilityModifier(IDamageSource source, float damage)
 {
     return enabled ? damage : 0f;
 }
Beispiel #42
0
    public virtual void Damage(IDamageSource hSource)
    {

    }