Ejemplo n.º 1
0
 public void CheckIfHealthIsZero()
 {
     if (currentHealth <= 0)
     {
         IsDead?.Invoke();
     }
 }
Ejemplo n.º 2
0
 private void OnCollisionEnter(Collision collision)
 {
     if (_canJump == false)
     {
         return;
     }
     if (collision.gameObject.TryGetComponent(out PlatformSegmentDead platformSegmentDead))
     {
         if (_ball.BallCanDead)
         {
             _ball.StaminaZero();
             Dead?.Invoke();
         }
         else
         {
             Jump(platformSegmentDead);
         }
     }
     else if (collision.gameObject.TryGetComponent(out PlatformSegment platformSegment))
     {
         Jump(platformSegment);
     }
     else if (collision.gameObject.TryGetComponent(out FinishSegment finishSegment))
     {
         Finish?.Invoke();
     }
 }
 public float ReceiveDamage(float damage)
 {
     Debug.Log("receive " + damage + " damage, " + health + " hp left");
     health -= damage;
     if (health > 400)
     {
         currentSprite = 0;
     }
     else if (health > 200 && health < 400)
     {
         currentSprite = 1;
     }
     else
     {
         currentSprite = 2;
     }
     if (health <= 0)
     {
         if (Dead != null)
         {
             Dead.Invoke(this, null);
         }
     }
     return(health);
 }
Ejemplo n.º 4
0
        public void StartWork()
        {
            IsWorking = true;
            while (IsWorking)
            {
                Y += 2;
                if (_rnd.NextDouble() <= _brokeChance && !IsBroken && !IsRodsDisconnect)
                {
                    IsBroken = true;
                    Broken?.Invoke(this);
                    _liveTimer          = new Timer(TimeSpan.FromSeconds(TimeToDistraction).TotalMilliseconds);
                    _liveTimer.Elapsed += (o, e) =>
                    {
                        Dead?.Invoke(this);
                        StopWork();
                        _liveTimer?.Stop();
                    };
                    _liveTimer.Start();
                    return;
                }

                if (_rnd.NextDouble() <= _rodDisconnectChance && !IsRodsDisconnect && !IsBroken)
                {
                    IsBroken = true;
                    RodsDisconnect?.Invoke(this);
                    return;
                }
                Thread.Sleep(200);
            }
        }
Ejemplo n.º 5
0
 private void Die()
 {
     target    = null;
     acting    = false;
     currentHp = 0;
     Dead.Invoke(this);
     this.gameObject.SetActive(false);
 }
Ejemplo n.º 6
0
    private IEnumerator Die()
    {
        Debug.Log("test");
        yield return(new WaitForSeconds(dieOffset / 1000f));

        _dead = true;
        Dead?.Invoke();
        Destroy(gameObject);
    }
Ejemplo n.º 7
0
 private void DeathLogic()
 {
     if (!_isDead)
     {
         _isDead = true;
         Destroy(this.gameObject);
         Dead?.Invoke();
     }
 }
Ejemplo n.º 8
0
 protected void Die()
 {
     if (_dieded)
     {
         return;
     }
     _dieded = true;
     Dead?.Invoke(this);
 }
Ejemplo n.º 9
0
        public void TakeDamage(float value)
        {
            Hp -= value;

            if (Hp <= 0)
            {
                IsDead = true;
                Dead?.Invoke(this, new EventArgs());
            }
        }
Ejemplo n.º 10
0
 public void GetDamage(int damage)
 {
     HP -= damage;
     if (HP <= 0)
     {
         StopAllCoroutines();
         StartCoroutine(Die());
         Dead?.Invoke();
     }
 }
Ejemplo n.º 11
0
    public void ApplyDamage()
    {
        _currentHealth--;
        HealthChanged?.Invoke(_currentHealth);

        if (_currentHealth <= 0)
        {
            _isDead = true;
            Dead?.Invoke();
        }
    }
Ejemplo n.º 12
0
    public void ApplayDamage(int damage)
    {
        _currentHealth -= damage;
        HealthChanged?.Invoke(_currentHealth, _health);

        if (_currentHealth <= 0)
        {
            Dead?.Invoke(0, Money);
            Destroy(gameObject);
        }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Returns true if the attack killed the Shooter.
    /// </summary>
    public bool Attack(float damage, ShooterProcessor attacker)
    {
        this.profile.Health -= damage;
        bool dead = this.profile.Health <= 0;

        if (dead)
        {
            Dead?.Invoke(this, attacker);
        }

        return(dead);
    }
Ejemplo n.º 14
0
    public void ReduceSize()
    {
        transform.localScale = new Vector3(transform.localScale.x - Time.deltaTime,
                                           transform.localScale.y - Time.deltaTime,
                                           transform.localScale.z - Time.deltaTime);
        _currentSize = transform.localScale.x;

        if (IsMinimumSize())
        {
            Dead?.Invoke();
        }
    }
Ejemplo n.º 15
0
 public void CheckVictoryORDeath(HerroTemplate other)
 {
     if (Helth <= 0)
     {
         Dead?.Invoke(this, new ResultBatle($"герой {Name} побежден"));
         countDeath++;
     }
     if (other.Helth <= 0)
     {
         Victory?.Invoke(this, new ResultBatle($"герой {Name} одержал победу"));
         countVictory++;
     }
 }
Ejemplo n.º 16
0
    private void TakeDamage()
    {
        if (_currentHealth > 0)
        {
            _currentHealth--;
            HealthChanged?.Invoke(_currentHealth);
        }


        if (_currentHealth <= 0)
        {
            Dead?.Invoke();
        }
    }
 public float ReceiveDamage(float damage)
 {
     health               -= damage;
     currentSprite         = 1;
     SpriteRenderer.sprite = Sprites[currentSprite];
     Debug.Log("receive " + damage + " damage, " + health + " hp left");
     if (health <= 0)
     {
         if (Dead != null)
         {
             Dead.Invoke(this, null);
         }
     }
     return(health);
 }
Ejemplo n.º 18
0
 public void takeDamage(Damage damage)
 {
     if ((this.Group & damage.Attacks) != 0)
     {
         this.Amount -= damage.Amount;
         if (DamageTaken != null)
         {
             DamageTaken.Invoke(this);
         }
         if (this.Amount <= 0)
         {
             if (Dead != null)
             {
                 Dead.Invoke(this);
             }
         }
     }
 }
Ejemplo n.º 19
0
 public float ReceiveDamage(float damage)
 {
     health      -= damage;
     sp          -= 10;
     stopSP       = true;
     accelerateSP = false;
     if (sp < 0)
     {
         sp = 0;
     }
     if (health <= 0)
     {
         if (Dead != null)
         {
             Dead.Invoke(this, null);
         }
     }
     return(health);
 }
Ejemplo n.º 20
0
        public void Defence(int damage)
        {
            int oldHP = HP;

            if (Armor.Durability >= 100)
            {
                HP -= damage;
            }
            else if (Armor.Defence < damage)
            {
                HP -= damage - Armor.Defence;
            }
            Armor.Using();
            if (HP <= 0)
            {
                Dead?.Invoke(this, new DeadEventArgs());
                return;
            }
            Defenced?.Invoke(this, new DefencedEventArgs()
            {
                Damage = oldHP - HP
            });
        }
Ejemplo n.º 21
0
        public void Intersect(IInteractable intersectedObject)
        {
            if (UserState == UserState.Dead)
            {
                return;
            }

            if (intersectedObject is Bullet bullet)
            {
                if (bullet.UserId != Id)
                {
                    StarShip.HitPoints -= bullet.Damage;

                    if (StarShip.HitPoints <= 0)
                    {
                        UserState  = UserState.Dead;
                        TimeToLive = 42;
                        DeadCount++;

                        Dead?.Invoke(bullet.UserId);
                    }
                }
            }
        }
Ejemplo n.º 22
0
    public void ScaleShrinkGrow()
    {
        if (Input.GetButton("Fire1"))
        {
            StaffANIM.SetBool("TranGrowP", true);
            StaffANIM.SetBool("IsGrowingP", true);
            if (TranGP == true)
            {
                if (InVol == false)
                {
                    if (mass > 0f)
                    {
                        Player.transform.localScale = Vector3.Lerp(Player.transform.localScale, new Vector3(PSgrow, PSgrow, PSgrow), Time.deltaTime * PSgrowtime);

                        if (CurrentSize.magnitude <= maxSize.magnitude)
                        {
                            gameManager.GetComponent <GameManager>().MassAvailable -= (GrowTime * Time.deltaTime);
                        }
                        if (CurrentSize.magnitude >= maxSize.magnitude)
                        {
                            Debug.Log("TooLorge");
                        }
                    }
                    if (mass <= 0f)
                    {
                        Debug.Log("NoMass");
                    }
                }
            }
        }

        if (Input.GetButtonDown("Fire1"))
        {
            PlayerUP.Invoke();
            if (TooLorge == true)
            {
                Debug.Log("DeadByLorge");
                Dead.Invoke();
                StartCoroutine(DiedDead(.5f));
            }
        }
        if (Input.GetButtonUp("Fire1"))
        {
            StaffANIM.SetBool("IsGrowingP", false);
            StaffANIM.SetBool("TranGrowP", false);
            Wipe.Invoke();
        }


        if (Input.GetButton("Fire2"))
        {
            StaffANIM.SetBool("TranShrinkP", true);
            StaffANIM.SetBool("IsShrinkingP", true);
            if (InVol == false && TranSP == true)
            {
                Player.transform.localScale = Vector3.Lerp(Player.transform.localScale, new Vector3(PSshrink, PSshrink, PSshrink), Time.deltaTime * PSshrinktime);
                if (CurrentSize.magnitude < avgSize.magnitude)
                {
                    if (CurrentSize.magnitude >= PminSize.magnitude)
                    {
                        gameManager.GetComponent <GameManager>().MassAvailable += (GrowTime * Time.deltaTime) * 1.25f;
                    }
                    if (CurrentSize.magnitude <= PminSize.magnitude)
                    {
                        Debug.Log("smol");
                    }
                }
            }
        }


        if (Input.GetButtonDown("Fire2"))
        {
            PlayerDown.Invoke();
            if (TooSmol == true)
            {
                Debug.Log("DeadBySmol");
                Dead.Invoke();
                StartCoroutine(DiedDead(.5f));
            }
        }
        if (Input.GetButtonUp("Fire2"))
        {
            Wipe.Invoke();
            StaffANIM.SetBool("TranShrinkP", false);
            StaffANIM.SetBool("IsShrinkingP", false);
        }
    }
 private void DoDead()
 {
     Dead?.Invoke(this, new EventArgs());
 }
Ejemplo n.º 24
0
        protected override async Task ServiceTaskAsync(CancellationToken cancellationToken)
        {
            var buffer = new byte[525];

            while (!cancellationToken.IsCancellationRequested)
            {
                try
                {
                    if (streamSource.Aviable < 12)
                    {
                        await Task.Delay(10, cancellationToken);

                        continue;
                    }

                    var stream = await streamSource.GetStreamAsync();

                    var i = await stream.ReadAsync(buffer, 0, 12, cancellationToken);

                    Message request = new Message(buffer);
                    if (!request.IsHeaderValid)
                    {
                        await stream.FlushAsync(cancellationToken);

                        continue;
                    }
                    i = await stream.ReadAsync(buffer, 12, request.DataLength + 1, cancellationToken);

                    request = new Message(buffer);
                    Story.Add(new MessageStoryItem(MessageStoryItem.Direction.Rx, request));

                    switch (request.Command)
                    {
                    case Command.BroadcastQuery:
                        await MakeResponseAndSend(request, cancellationToken);

                        break;

                    case Command.IndividualQuery:
                        await MakeResponseAndSend(request, cancellationToken);

                        break;

                    case Command.AutoRun:
                        Status.Start = true;
                        A4           = A4PeriodicSend(request.Source, cancellationToken);
                        // await MakeResponseAndSend(request, cancellationToken);
                        break;

                    case Command.Shutdown:
                        Status.Start = false;
                        await MakeResponseAndSend(request, cancellationToken);

                        break;

                    //case Command.RealtimeData:
                    default:
                        // ignore
                        stream.Flush();
                        break;
                    }
                }catch (Exception ex)
                {
                    await OnErrorAsync(ex, cancellationToken);

                    break;
                }

                await Task.Delay(100, cancellationToken);
            }
            Status.Start = false;
            Dead?.Invoke(this, null);
        }//ServiceTaskAsync()
Ejemplo n.º 25
0
 public void Kill()
 {
     Dead.Invoke();
 }
Ejemplo n.º 26
0
 private void RaiseDead(bool value) => Dead?.Invoke(this, value);
Ejemplo n.º 27
0
 /// <summary>
 /// Fired when the entity has died.
 /// </summary>
 protected virtual void OnDead(EntityChangedEventArgs e)
 {
     Dead?.Invoke(this, e);
 }
Ejemplo n.º 28
0
 public void Die()
 {
     Destroy(gameObject);
     OnDied?.Invoke();
 }
Ejemplo n.º 29
0
 public void OnDead()
 {
     Dead?.Invoke();
 }
Ejemplo n.º 30
0
 public void Die()
 {
     Dead?.Invoke();
 }