Ejemplo n.º 1
0
    public override void Die(IDamageSource source)
    {
        OnEnemyDeath(this, source);

        dead = true;
        gameObject.Recycle();
    }
Ejemplo n.º 2
0
 public override void ReceiveDamage(IDamageSource damageSource, DamagesParameters damagesParameter, ProjectileSpecialParameters projSpecialParameterss)
 {
     if (!GameManager.gameManager.Won && GameManager.gameManager.StartedFight)
     {
         base.ReceiveDamage(damageSource, damagesParameter, projSpecialParameterss);
     }
 }
Ejemplo n.º 3
0
    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();
        }
    }
Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 9
0
 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();
             // }
         }
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 11
0
 /// <inheritdoc />
 public void Damage(int amount, IDamageSource source)
 {
     health -= amount;
     if (health <= 0)
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 14
0
 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)
 {
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 16
0
    public void Damage(IDamageSource hSource)
    {
        //DELETE?
        hRigidbody.useGravity = true;
        //DELETE?

        //Rigidbody hRigidbody = AddRigidbody();
        hRigidbody.velocity = hSource.GetDamage(Armor) * hSource.Owner.gameObject.transform.forward;
    }
Ejemplo n.º 17
0
 public override int Damage(int amount, IDamageSource damageSource)
 {
     amount -= defense;
     if (amount < 0)
     {
         amount = 0;
     }
     return(base.Damage(amount, damageSource));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 19
0
    public void ReceiveAttack(IDamageSource source)
    {
        int reducedDmg = source.Damage - c_Def;

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

            _chaseTimer.Start(ChaseTime);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 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();
         }
     }
 }
Ejemplo n.º 27
0
    void OnPlayerDeath(Player player, IDamageSource source)
    {
        foreach (Player _player in level.players)
        {
            if (!_player.dead)
            {
                return;
            }
        }

        menuControl.ShowPanel(deathPanel);
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 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);
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 33
0
 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);
     }
 }
Ejemplo n.º 34
0
 public void Damage(IDamageSource hSource)
 {
     RpcDie(Vector3.up);
 }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 38
0
 public DamageEventArgs(float damage, IDamageSource damageSource)
 {
     DamageSource = damageSource;
     Damage = damage;
 }
Ejemplo n.º 39
0
 public void Damage(IDamageSource source)
 {
 }
Ejemplo n.º 40
0
 protected virtual void HandleDamage(IDamageSource source, float damage)
 {
     InternalDamage += damage;
 }
Ejemplo n.º 41
0
 float InvincibilityModifier(IDamageSource source, float damage)
 {
     return enabled ? damage : 0f;
 }
Ejemplo n.º 42
0
    public virtual void Damage(IDamageSource hSource)
    {

    }