private void OnAlienAreaEntered(Godot.Object area)
    {
        if (area is Alien)
        {
            return;
        }

        if (area is Bullet)
        {
            var bullet = area as Bullet;

            Health -= (int)(bullet.Damage / Shield);
            Update();
            bullet.QueueFree();
            if (Health <= 0)
            {
                Died?.Invoke(Score);
                QueueFree();
            }
        }

        if (area is Home)
        {
            if (!reachedHome)
            {
                ReachedHome?.Invoke();
                reachedHome = true;
            }
        }
    }
示例#2
0
        public void Die()
        {
            Died?.Invoke();

            Instantiate(_dieEffectPrefab, transform.position, transform.rotation);
            Destroy(gameObject);
        }
示例#3
0
        public void ChangeHealth(float amount)
        {
            m_CurrentHealth += amount;
            if (m_CurrentHealth > maxHealth)
            {
                m_CurrentHealth = maxHealth;
            }
            HealthChanged?.Invoke(m_CurrentHealth / maxHealth);

            if (m_CurrentHealth <= 0 && !dead)
            {
                dead = true;
                if (destroyOnDeath)
                {
                    Died?.Invoke();
                    if (deathEffects.Length > 0)             // Unused, prob not ready for working
                    {
                        var p = transform.position;
                        Pool.Despawn(
                            Pool.Spawn(deathEffects.AnyItem(),
                                       new Vector3(p.x, p.y, p.z),
                                       new Quaternion(0, 0, 0, 0)), 3);
                    }
                }

                if (dyingAnimations.Length > 0)
                {
                    // If there is death animations for this object
                    m_Animator.SetBool(dyingAnimations.AnyItem(),
                                       true);  // TODO: not rly useful if destroyed ... (maybe should add death delay idk)
                }
            }
        }
示例#4
0
 public override bool TakeDamage(float damage, DamageType typing, Node source)
 {
     if (IsDead())
     {
         return(false);
     }
     if (source != null)
     {
         if (source is EnemyProjectiles projectiles)
         {
             playerTookDamage?.Invoke(damage, typing, projectiles);
             projectiles.Remove();
         }
     }
     Damaged(damage);
     if (IsDead())
     {
         death?.Invoke();
         playerTrappedInRoom = false;
     }
     else
     {
         EmitSignal(nameof(UpdateHealth), true, GetHealth());
     }
     return(true);
 }
示例#5
0
 private void CheckDeath()
 {
     if (_healthCurrent <= 0)
     {
         Died.Invoke();
     }
 }
示例#6
0
 public void Die()
 {
     hurtBox.collider.enabled = false;
     hitBox.collider.enabled  = false;
     Died.Invoke(this);
     Destroy(this.gameObject);
 }
示例#7
0
    /// <summary>
    /// Try to have the player take damage, returning true or false depending on whether it
    /// was successful.
    /// </summary>
    public virtual bool TakeDamage(float damageToTake, bool triggerInvin = true)
    {
        if (isInvincible)
        {
            return(false);
        }

        hp -= damageToTake;
        animator.SetTrigger("Hurt");

        TookDamage.Invoke();

        // If invincibility is to be applied, trigger the timer for it
        if (triggerInvin)
        {
            isInvincible = true;
            invinTimer   = invinTime;
        }

        if (hp <= 0)
        {
            Died.Invoke();
            Respawn();
        }

        return(true);
    }
示例#8
0
        public override void Die(int killer, Weapon weapon)
        {
            IsAlive            = false;
            Player.RespawnTick = Server.Tick + Server.TickSpeed / 2;
            var modeSpecial = 0;

            Died?.Invoke(this, GameContext.Players[killer], weapon, ref modeSpecial);

            Console.Print(OutputLevel.Debug, "game",
                          $"kill killer='{killer}:{Server.ClientName(killer)}' " +
                          $"victim='{Player.ClientId}:{Server.ClientName(Player.ClientId)}' " +
                          $"weapon={weapon} special={modeSpecial}");

            Server.SendPackMsg(new GameMsg_SvKillMsg
            {
                Killer      = killer,
                Victim      = Player.ClientId,
                Weapon      = (int)weapon,
                ModeSpecial = modeSpecial
            }, MsgFlags.Vital, -1);

            GameContext.CreateSound(Position, Sound.PlayerDie);
            GameContext.CreateDeath(Position, Player.ClientId);

            Destroy();
        }
示例#9
0
        public void AddHealth(float amount)
        {
            m_CurrentHealth += amount;
            if (m_CurrentHealth > maxHealth)
            {
                m_CurrentHealth = maxHealth;
            }
            HealthChanged?.Invoke(m_CurrentHealth / maxHealth);

            if (m_CurrentHealth <= 1 && !dead)
            {
                dead = true;
                // if (destroyOnDeath)
                // {
                Died?.Invoke();
                // }

                if (dyingAnimations.Length > 0)
                {
                    // If there is death animations for this object
                    m_Animator.SetBool(dyingAnimations.AnyItem(),
                                       true);  // TODO: not rly useful if destroyed ... (maybe should add death delay idk)
                }
            }
        }
示例#10
0
 public virtual async Task KillAsync()
 {
     if (Died != null)
     {
         await Died.Invoke(this);
     }
 }
示例#11
0
 private void OnDied()
 {
     if (_onDied.IsAssigned())
     {
         _onDied.Invoke();
     }
     Died?.Invoke(this);
 }
    public virtual bool Die()
    {
        health          = 0;
        effectiveHealth = health;
        Died.Invoke();

        return(true);
    }
示例#13
0
 internal DiedEvent InvokeEvent(DiedEvent arg)
 {
     if (_api.ValidateEvent(arg))
     {
         Died?.Invoke(_api, arg);
     }
     return(arg);
 }
示例#14
0
        public void TakeDamage(int damage)
        {
            Current = Mathf.Max(0, Current - damage);

            if (Current <= 0)
            {
                Died?.Invoke();
            }
        }
示例#15
0
 public void ReceiveDamage(ICombatable damageDealer, float damage)
 {
     health -= damage;
     if (health <= 0)
     {
         Died?.Invoke(this);
         Destroy(this.gameObject);
     }
 }
示例#16
0
    void Die()
    {
        GetComponent <Collider>().enabled = false;
        _navMeshAgent.enabled             = false;
        _anim.SetTrigger("Died");

        Died?.Invoke();
        Destroy(gameObject, 5f);                          //enemy will disapear after die from scene view after 5 seconds
    }
示例#17
0
文件: Wall.cs 项目: Grechukha/ARWall
    private void OnMouseDown()
    {
        _currentLife--;

        if (_currentLife <= 0)
        {
            Died?.Invoke(new Vector3[] { BuildedFirstColumnPosition, BuildedSecondColumnPosition });
        }
    }
示例#18
0
 private void ApplyDamage()
 {
     _health--;
     HealthChanged?.Invoke(_health);
     if (_health <= 0)
     {
         Died?.Invoke();
         gameObject.SetActive(false);
     }
 }
示例#19
0
 public void TakeDamage(float damage)
 {
     _health -= damage;
     OnPlayerHealthChangedEvent?.Invoke(_health / _maxHealth);
     if (_health <= 0)
     {
         Died?.Invoke(gameObject);
         ChangeScore?.Invoke();
     }
 }
示例#20
0
    public void TakeDamage(int damage)
    {
        _health -= damage;

        if (_health <= 0)
        {
            Destroy(gameObject);
            Died?.Invoke(this);
        }
    }
        public CharacterDeadBody Die()
        {
            CharacterObj.SetActive(false);
            CharacterDeadBody deadBody = characterDeadBodyPooler.Get();

            deadBody.Set(Transform.position, SpriteRenderer.flipX, DeadBody);
            deadBody.gameObject.SetActive(true);
            Died?.Invoke(this, deadBody);
            return(deadBody);
        }
示例#22
0
    private void FixedUpdate()
    {
        Ray ray = new Ray(transform.position + Vector3.up, Vector3.down);

        if (Physics.Raycast(ray, _fallDistance) == false)
        {
            Rigidbody.constraints = RigidbodyConstraints.None;
            Died?.Invoke();
        }
    }
示例#23
0
 private void ForceDeath()
 {
     health = 0;
     ValueChanged?.Invoke(health);
     Died?.Invoke();
     if (deathGameEvent)
     {
         deathGameEvent.Raise();
     }
 }
示例#24
0
    private IEnumerator DeathPlayer()
    {
        var waitForSeconds = new WaitForSeconds(_deathTime);

        yield return(waitForSeconds);

        _animator.StopPlayback();
        Destroy(gameObject);
        Died?.Invoke(); // оповещаем GameOverScreen о смерти игрока
    }
示例#25
0
    public void Die()
    {
        if (TryGetComponent <PlayerInput>(out PlayerInput playerInput))
        {
            Destroy(playerInput);
        }

        _animator.SetBool("Die", true);
        Died?.Invoke();
    }
示例#26
0
    void OnDied()
    {
        ParticleSystem particleSystem = Instantiate(ExplosionPrefab, transform.position, Quaternion.identity).GetComponentInChildren <ParticleSystem>();
        var            main           = particleSystem.main;

        main.startColor = TeamColors.Colors[Team];

        Died?.Invoke();
        Destroy(gameObject);
    }
示例#27
0
        public static void ApplyDamage(float damage)
        {
            Health -= damage;

            TookDamage?.Invoke(Current, EventArgs.Empty);

            if (Health.CompareTo(0.0F) < 0)
            {
                Died?.Invoke(Current, EventArgs.Empty);
            }
        }
示例#28
0
 public override void Tick()
 {
     if (Steps > 1)
     {
         Steps--;
     }
     else
     {
         Died?.Invoke(this, false);
     }
 }
示例#29
0
 public void TakeDemage()
 {
     _health--;
     HealthChanged?.Invoke(_health);
     _visualEffector.PlayDamageEffects();
     if (_health <= 0)
     {
         Died?.Invoke();
         Die();
     }
 }
示例#30
0
 public void Die()
 {
     State = SnakeState.Dead;
     _moveTimer?.Dispose();
     _turnTimer?.Dispose();
     if (_conn.State == WebSocketState.Open)
     {
         Send(new DiedResponseModel());
     }
     Died?.Invoke(this, null);
 }