Beispiel #1
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();
        }
Beispiel #2
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)
                }
            }
        }
    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;
            }
        }
    }
Beispiel #4
0
    public static int points = 0; // I am so sorry - Antonio Bottelier

    // Use this for initialization
    void Awake()
    {
        _lastDamage = Time.time;
        savedHP     = health;

        HasDied += Dead;
    }
Beispiel #5
0
 /// <summary>
 /// Handle the case where the player dies and all commodities
 /// are removed
 /// </summary>
 /// <param name="e"></param>
 public override void Handle(Died e)
 {
     if (CharacterDied != null)
     {
         CharacterDied(this, new DeathEventArgs(e));
     }
 }
Beispiel #6
0
        public void Die()
        {
            Died?.Invoke();

            Instantiate(_dieEffectPrefab, transform.position, transform.rotation);
            Destroy(gameObject);
        }
Beispiel #7
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)
                }
            }
        }
Beispiel #8
0
 public void Die()
 {
     hurtBox.collider.enabled = false;
     hitBox.collider.enabled  = false;
     Died.Invoke(this);
     Destroy(this.gameObject);
 }
Beispiel #9
0
 private void CheckDeath()
 {
     if (_healthCurrent <= 0)
     {
         Died.Invoke();
     }
 }
Beispiel #10
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);
    }
Beispiel #11
0
 public virtual async Task KillAsync()
 {
     if (Died != null)
     {
         await Died.Invoke(this);
     }
 }
Beispiel #12
0
 internal DiedEvent InvokeEvent(DiedEvent arg)
 {
     if (_api.ValidateEvent(arg))
     {
         Died?.Invoke(_api, arg);
     }
     return(arg);
 }
    public virtual bool Die()
    {
        health          = 0;
        effectiveHealth = health;
        Died.Invoke();

        return(true);
    }
Beispiel #14
0
    public static int points = 0; // I am so sorry - Antonio Bottelier

    // Use this for initialization
    void Awake()
    {
        _lastDamage = Time.time;
        savedHP     = health;

        HasDied           += Dead;
        defaultSpriteColor = sprite.color;
    }
Beispiel #15
0
 private void OnDied()
 {
     if (_onDied.IsAssigned())
     {
         _onDied.Invoke();
     }
     Died?.Invoke(this);
 }
Beispiel #16
0
        public void TakeDamage(int damage)
        {
            Current = Mathf.Max(0, Current - damage);

            if (Current <= 0)
            {
                Died?.Invoke();
            }
        }
Beispiel #17
0
 public void ReceiveDamage(ICombatable damageDealer, float damage)
 {
     health -= damage;
     if (health <= 0)
     {
         Died?.Invoke(this);
         Destroy(this.gameObject);
     }
 }
Beispiel #18
0
    private void OnMouseDown()
    {
        _currentLife--;

        if (_currentLife <= 0)
        {
            Died?.Invoke(new Vector3[] { BuildedFirstColumnPosition, BuildedSecondColumnPosition });
        }
    }
Beispiel #19
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
    }
Beispiel #20
0
 public void TakeDamage(float damage)
 {
     _health -= damage;
     OnPlayerHealthChangedEvent?.Invoke(_health / _maxHealth);
     if (_health <= 0)
     {
         Died?.Invoke(gameObject);
         ChangeScore?.Invoke();
     }
 }
Beispiel #21
0
 private void ApplyDamage()
 {
     _health--;
     HealthChanged?.Invoke(_health);
     if (_health <= 0)
     {
         Died?.Invoke();
         gameObject.SetActive(false);
     }
 }
Beispiel #22
0
    public void TakeDamage(int damage)
    {
        _health -= damage;

        if (_health <= 0)
        {
            Destroy(gameObject);
            Died?.Invoke(this);
        }
    }
Beispiel #23
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();
        }
    }
Beispiel #24
0
    private IEnumerator DeathPlayer()
    {
        var waitForSeconds = new WaitForSeconds(_deathTime);

        yield return(waitForSeconds);

        _animator.StopPlayback();
        Destroy(gameObject);
        Died?.Invoke(); // оповещаем GameOverScreen о смерти игрока
    }
Beispiel #25
0
 private void ForceDeath()
 {
     health = 0;
     ValueChanged?.Invoke(health);
     Died?.Invoke();
     if (deathGameEvent)
     {
         deathGameEvent.Raise();
     }
 }
Beispiel #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);
    }
Beispiel #27
0
    public void Die()
    {
        if (TryGetComponent <PlayerInput>(out PlayerInput playerInput))
        {
            Destroy(playerInput);
        }

        _animator.SetBool("Die", true);
        Died?.Invoke();
    }
        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);
        }
Beispiel #29
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);
            }
        }
Beispiel #30
0
 public override void Tick()
 {
     if (Steps > 1)
     {
         Steps--;
     }
     else
     {
         Died?.Invoke(this, false);
     }
 }