コード例 #1
0
ファイル: Health.cs プロジェクト: Winteractive/WickedGameJam
 public void CheckIfHealthIsZero()
 {
     if (currentHealth <= 0)
     {
         IsDead?.Invoke();
     }
 }
コード例 #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();
     }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
ファイル: Trolleybus.cs プロジェクト: JustTeRoR/Att2
        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);
            }
        }
コード例 #5
0
 private void Die()
 {
     target    = null;
     acting    = false;
     currentHp = 0;
     Dead.Invoke(this);
     this.gameObject.SetActive(false);
 }
コード例 #6
0
ファイル: HitCircle.cs プロジェクト: dendy1/Clicker-2D
    private IEnumerator Die()
    {
        Debug.Log("test");
        yield return(new WaitForSeconds(dieOffset / 1000f));

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

            if (Hp <= 0)
            {
                IsDead = true;
                Dead?.Invoke(this, new EventArgs());
            }
        }
コード例 #10
0
ファイル: CEnemy.cs プロジェクト: ATRi111/Quest
 public void GetDamage(int damage)
 {
     HP -= damage;
     if (HP <= 0)
     {
         StopAllCoroutines();
         StartCoroutine(Die());
         Dead?.Invoke();
     }
 }
コード例 #11
0
ファイル: Player.cs プロジェクト: TapAlexxx/ArkanoidClone
    public void ApplyDamage()
    {
        _currentHealth--;
        HealthChanged?.Invoke(_currentHealth);

        if (_currentHealth <= 0)
        {
            _isDead = true;
            Dead?.Invoke();
        }
    }
コード例 #12
0
    public void ApplayDamage(int damage)
    {
        _currentHealth -= damage;
        HealthChanged?.Invoke(_currentHealth, _health);

        if (_currentHealth <= 0)
        {
            Dead?.Invoke(0, Money);
            Destroy(gameObject);
        }
    }
コード例 #13
0
ファイル: ShooterProcessor.cs プロジェクト: rellfy/PPSDemo
    /// <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);
    }
コード例 #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();
        }
    }
コード例 #15
0
ファイル: FirstHerro.cs プロジェクト: Naumenkosergey/P1806
 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++;
     }
 }
コード例 #16
0
ファイル: Player.cs プロジェクト: rayvax/TetrisTower
    private void TakeDamage()
    {
        if (_currentHealth > 0)
        {
            _currentHealth--;
            HealthChanged?.Invoke(_currentHealth);
        }


        if (_currentHealth <= 0)
        {
            Dead?.Invoke();
        }
    }
コード例 #17
0
 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);
 }
コード例 #18
0
ファイル: Health.cs プロジェクト: AnomalousMedical/Engine
 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);
             }
         }
     }
 }
コード例 #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);
 }
コード例 #20
0
ファイル: Hero.cs プロジェクト: Jav800/AbstractFactory
        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
            });
        }
コード例 #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);
                    }
                }
            }
        }
コード例 #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);
        }
    }
コード例 #23
0
 private void DoDead()
 {
     Dead?.Invoke(this, new EventArgs());
 }
コード例 #24
0
ファイル: WFQYDBemul.cs プロジェクト: windygu/WFQYDB
        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()
コード例 #25
0
ファイル: Player.cs プロジェクト: MytanTTeR/BiPlanes
 public void Kill()
 {
     Dead.Invoke();
 }
コード例 #26
0
 private void RaiseDead(bool value) => Dead?.Invoke(this, value);
コード例 #27
0
 /// <summary>
 /// Fired when the entity has died.
 /// </summary>
 protected virtual void OnDead(EntityChangedEventArgs e)
 {
     Dead?.Invoke(this, e);
 }
コード例 #28
0
 public void Die()
 {
     Destroy(gameObject);
     OnDied?.Invoke();
 }
コード例 #29
0
 public void OnDead()
 {
     Dead?.Invoke();
 }
コード例 #30
0
 public void Die()
 {
     Dead?.Invoke();
 }