コード例 #1
0
 void OnDeathEventClientRpc()
 {
     if (IsHost)
     {
         return;
     }
     onDeathEvent.Invoke();
 }
コード例 #2
0
ファイル: Character.cs プロジェクト: mrZmitser/CatFish
        /* private void Poisoning() {
         *   while (Condition == ConditionType.poisoned && Hp > 0) {
         *       lock (conditionLocker) {
         *           _hp--;
         *           if (_hp == 0) {
         *               Condition = ConditionType.dead;
         *           }
         *           Monitor.Wait(conditionLocker, 2000);
         *       }
         *   }
         * }*/
        private void CheckCondition()
        {
            if (Hp == 0)
            {
                _condition = ConditionType.dead;
                DeathEvent?.Invoke(this, new EventArgs());
            }

            /* if (Condition == ConditionType.poisoned) {
             *   poisoningThread = new Thread(Poisoning);
             *   poisoningThread.Start();
             *   return;
             * } else if (poisoningThread != null) {
             *   lock (conditionLocker) {
             *       poisoningThread.Abort();
             *   }
             * }*/
            if (Condition != ConditionType.healthy && Condition != ConditionType.weakened &&
                Condition != ConditionType.dead)
            {
                return;
            }
            if (Hp > 0 && Hp < 0.1f * MaxHp)
            {
                _condition = ConditionType.weakened;
            }
            if (Hp >= 0.1f * MaxHp)
            {
                _condition = ConditionType.healthy;
            }
        }
コード例 #3
0
ファイル: LivingEntity.cs プロジェクト: Kristoj/MOSS
 public void OnDeathEvent()
 {
     if (DeathEvent != null)
     {
         DeathEvent.Invoke();
     }
 }
コード例 #4
0
    void OnCollisionEnter(Collision other)
    {
        // Add horizontal velocity to the puck depending on where it collides with the paddle
        if (other.gameObject.layer == LayerMask.NameToLayer("Paddle") && !_isTethered)
        {
            // Find the vector between the puck and the paddle
            Vector3 _collisionVector = transform.position - other.transform.position;
            _rb.velocity += new Vector3(_collisionVector.normalized.x * _velocityMultiplier, 0f, 0f);
        }
        // Check collision with the bottom boundary and update lives
        if (other.gameObject.layer == LayerMask.NameToLayer("Death"))
        {
            GameState.decrementLives();
            _scoreEvent.Invoke(GameState.lives);

            // set fade curtain active, reload scene
            if (GameState.lives > 0)
            {
                // _fadeToBlack.SetActive (true);
            }
            else
            {
                // XXX:TODO create the game over scene
                // _fadeToGameOver.SetActive (true);
            }

            _fadeToBlack.SetActive(true);

            _deathEvent.Invoke();
            Destroy(gameObject);
        }
    }
コード例 #5
0
ファイル: BaseEntity.cs プロジェクト: Publol/Engine
 public void InvokeDeath()
 {
     if (DeathEvent != null)
     {
         DeathEvent.Invoke();
     }
 }
コード例 #6
0
 public void Death()
 {
     // Dead
     DeathEvent?.Invoke();
     TurnOrder.Instance.Unsubscribe(this);
     // Instantiate<ParticleSystem>(properties.Explosion, transform);
 }
コード例 #7
0
        /// <summary>
        /// Handles the visual, and technical features of dying, such as giving the tower experience.
        /// </summary>
        private void Die()
        {
            onDeath.Invoke(this); //Anything subscribed to the event will automatically know to call Die() function.


            //Death Visuals
        }
コード例 #8
0
        public void TakeDamage(float damage)
        {
            _currentHealth -= damage;

            // Health is empty
            if (_currentHealth <= 0)
            {
                DeathEvent?.Invoke(Mathf.Abs(_currentHealth));
                deathEvent.Invoke();
            }

            _currentHealth = Mathf.Clamp(_currentHealth, 0f, _health);

            TakeDamageEvent?.Invoke(damage);

            if (_currentHealth <= 0)
            {
                switch (_onDeath)
                {
                case DeathType.Disable:
                    _rootObject.SetActive(false);
                    break;

                case DeathType.Destroy:
                    Destroy(_rootObject);
                    break;
                }
            }
        }
コード例 #9
0
 private void TriggerDeathEvent()
 {
     if (isAlive)
     {
         DeathEvent?.Invoke();
         isAlive = false;
     }
 }
コード例 #10
0
 /// <summary>
 /// Получение урона
 /// </summary>
 public void TakeDamage(int damage)
 {
     HP -= damage;
     if (HP <= 0)
     {
         DeathEvent?.Invoke();
     }
 }
コード例 #11
0
 public void OnDestroy()
 {
     if (_myNextOfKin == null)
     {
         Debug.LogError("Unregistered enemy just died");
         return;
     }
     _myNextOfKin.Invoke(this);
 }
コード例 #12
0
 public virtual void OnDeath()
 {
     EXEventManager.TriggerEvent(new EnemyEvent(EnemyEvent.EnemyEventType.Death, this));
     if (DeathEvent != null)
     {
         DeathEvent.Invoke(this);
     }
     Destroy(gameObject);
 }
コード例 #13
0
 public void Death()
 {
     if (dead)
     {
         return;
     }
     dead = true;
     SoundManager.Instance.PlaySound(SoundManager.Instance.deathScream);
     Die.Invoke();
 }
コード例 #14
0
    public void TakeDamage(int Damage)
    {
        Health -= Damage;

        if (Health <= 0)
        {
            OnDie?.Invoke(this);
            gameObject.SetActive(false);
        }
    }
コード例 #15
0
ファイル: PlayerHealth.cs プロジェクト: rumpff/t4nks
    protected virtual void OnDeath()
    {
        if (DeathEvent != null)
        {
            DeathEvent.Invoke(RecentDamager);
        }

        // Since we destroy this instance we remove all subscribers
        DeathEvent = null;
    }
コード例 #16
0
 public void GetDamage(int damage)
 {
     DamageEvent?.Invoke();
     CurrentHealth -= damage;
     if (CurrentHealth <= 0)
     {
         DeathEvent?.Invoke();
         Die();
     }
 }
コード例 #17
0
    public void GetDamage(float damage)
    {
        float health = (float)blackboard.GetValue("health") - damage;

        blackboard.UpdateValue("health", health);
        if (health <= 0f)
        {
            DeathEvent?.Invoke();
        }
    }
コード例 #18
0
ファイル: EnemyController.cs プロジェクト: wolfrug/ldjam42
 public void Die(Vector3 direction)
 {
     //rb.isKinematic = false;
     //rb.WakeUp();
     //rb.AddForce(direction*(enemyStats_.health - 5), ForceMode.Impulse);
     rb.gameObject.tag   = "Untagged";
     rb.gameObject.layer = 9;
     dead_ = true;
     characterAnimator_.SetTrigger("Die");
     unit_dead.Invoke(this);
 }
コード例 #19
0
 protected virtual void Die()
 {
     onDeath.Invoke();
     GameManager.SelectionSystem.RemoveInteractable(this);
     GameManager.XpSystem.IncrementXp(xpGain);
     if (selected)
     {
         Deselect();
     }
     Destroy(gameObject);
 }
コード例 #20
0
ファイル: AbstractEnemy.cs プロジェクト: sanosenx86/STGSample
 public virtual void Damaged(float damage)
 {
     if (IsAlive)
     {
         float loseHealth = Math.Max(damage - Defense, damage * 0.2f); //At least each bullet make 20% damage.
         Health -= loseHealth;
         if (Health <= 0)
         {
             DeathEvent?.Invoke(this);
             IsDestroyed = true;
         }
     }
 }
コード例 #21
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.gameObject.CompareTag("Wall"))
        {
            OnWallCollide.Invoke();
        }

        if (collider.gameObject.CompareTag("playerBullet"))
        {
            --numAliens;
            OnDeath.Invoke(points);
            Destroy(this.gameObject);
        }
    }
コード例 #22
0
 public void TakeDamage()
 {
     if (Dead)
     {
         return;
     }
     Health -= GameManager.Properties.damage;
     if (Health <= 0)
     {
         DeathEvent?.Invoke(this);
         Health = 0;
         Dead   = true;
     }
 }
コード例 #23
0
    public IEnumerator DeathTransition()
    {
        DeathEvent?.Invoke();
        //  Debug.Log("Start");
        yield return(new WaitForSeconds(PlayerManager._instance.GetPlayerGFX.GetDeathAnimLength));

        // Debug.Log("Player Died");
        UIManager._instance.BlackPanel(true);

        yield return(new WaitForSeconds(extraDelay));

        UIManager._instance.BlackPanel(false);
        RespawnEvent?.Invoke();
        startedDeathEvent = false;
    }
コード例 #24
0
        private void LoseLife(byte numberOfLivesLost)
        {
            if (m_numberOfLives <= 0)
            {
                return;
            }

            m_numberOfLives -= numberOfLivesLost;

            Broadcast.Send <IBroadcast>(gameObject, (x, y) => x.Inform(Broadcasts.BroadcastMessage.Dead));

            gameObject.layer = (int)Layer.Dead;

            DeathEvent?.Invoke(m_numberOfLives);
        }
コード例 #25
0
    protected virtual void ReduceHP(Actor source, float damage)
    {
        HP = Mathf.Max(0, HP - damage);
        if (_healthReference != null)
        {
            _healthReference.Value = HP;
        }

        if (Dead() && _alive)
        {
            _alive = false;
            StaticActorDeathEvent?.Invoke(source, this);
            DeathEvent?.Invoke(source);
        }
    }
コード例 #26
0
ファイル: AIController.cs プロジェクト: FizziMilk/laserguns
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == player)
        {
            gameManager.health -= 1;
            gameManager.HealthTracker();

            Destroy(gameObject);
        }
        if (other.GetComponent <BulletController>() != null)
        {
            onDeath.Invoke(body.position);

            Destroy(other.gameObject);
            Destroy(gameObject);
        }
    }
コード例 #27
0
ファイル: SampleBoss.cs プロジェクト: sanosenx86/STGSample
 public override void Damaged(float damage)
 {
     if (IsAlive)
     {
         float loseHealth = Math.Max(damage - Defense, damage * 0.2f); //At least each bullet make 20% damage.
         Health -= loseHealth;
         if (Health <= 0)
         {
             DeathEvent?.Invoke(this);
             foreach (IBarrage barrage in barrages)
             {
                 barrage.Destroy();
             }
             IsDestroyed = true;
         }
     }
 }
コード例 #28
0
 public void TakeDamage(int damage)
 {
     // There's a [screamChance] chance that enemy is going to scream from pain
     Scream(screamChance);
     health          -= damage;
     healthBar.value -= damage;
     if (health <= 0)
     {
         // Allow events to fire only once after dying
         if (!this.enabled)
         {
             return;
         }
         DeathEvent?.Invoke();
         this.enabled = false;
     }
 }
コード例 #29
0
    private void Update()
    {
        if (health <= 0 && isPlayer && !died)
        {
            DeathEvent?.Invoke();
        }

        if (health <= 0 && !died)
        {
            died = true;
            Die();
        }
        else if (died && deathTrigger.transform.position.z - transform.position.z <= fadeDistance)
        {
            StartCoroutine(FadeOut());
        }
    }
コード例 #30
0
    private void Kill(string reason)
    {
        // Don't do anything if we're already dead
        if (!Alive)
        {
            return;
        }

        Alive = false;

        // We died, stop animating the player
        animator.SetBool("Playing", false);

        // Remove the player's collider so they fall
        Destroy(GetComponent <BoxCollider2D>());

        // Fire the OnDeath event
        OnDeath.Invoke(reason);
    }