private void Attack(GameObject warriorObject) { var lifeController = warriorObject.GetComponent <LifeController>(); var warrior = warriorObject.GetComponent <Warrior>(); if (!lifeController || !warrior) { return; } if (_warrior.Team == warrior.Team) { return; } _animator.SetTrigger("Attack"); lifeController.Attack(.35f); if (lifeController.Life <= 0f) { _lifeController.AddLife(.3f); OnKill?.Invoke(); } OnAttack?.Invoke(); }
private void OnArrowCollision(GameObject obj) { var lifeController = obj.GetComponent <LifeController>(); var warrior = obj.GetComponent <Warrior>(); if (!lifeController || !warrior || _warrior.Team == warrior.Team) { _missed++; if (_missed > 4) { _missed = 0; //OnMissed?.Invoke(); } return; } lifeController.Attack(.35f); if (lifeController.Life <= 0f) { _lifeController.Attack(-1f); OnKill?.Invoke(); } OnAttack?.Invoke(); }
protected override void OnCollideWithDamageable(Health health) { // if what we're colliding with is a CorgiController, we apply a knockback force _colliderCorgiController = health.gameObject.MMGetComponentNoAlloc <CorgiController>(); ApplyDamageCausedKnockback(); OnHitDamageable?.Invoke(); HitDamageableFeedback?.PlayFeedbacks(this.transform.position); if ((FreezeFramesOnHitDuration > 0) && (Time.timeScale > 0)) { MMFreezeFrameEvent.Trigger(Mathf.Abs(FreezeFramesOnHitDuration)); } // we apply the damage to the thing we've collided with var typedHealth = _colliderHealth as TypedHealth; if (typedHealth != null) { typedHealth.Damage(DamageCaused, gameObject, InvincibilityDuration, InvincibilityDuration, _damageDirection, DamageType); } else { _colliderHealth.Damage(DamageCaused, gameObject, InvincibilityDuration, InvincibilityDuration, _damageDirection); } if (_colliderHealth.CurrentHealth <= 0) { OnKill?.Invoke(); } SelfDamage(DamageTakenEveryTime + DamageTakenDamageable); }
public static void Transmit(KillMessage message) { if (OnKill != null) { OnKill.Invoke(message); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { OnKill?.Invoke(this, null); } }
public override void Edit(PixelLayout control) { var editText = new TextBox(); editText.Tag = this; editText.Style = "OverrideSize"; editText.Width = _lastRec.Width; editText.Height = _lastRec.Height; editText.Text = Value.ToString(); control.Add(editText, _lastRec.X, _lastRec.Y); editText.Focus(); editText.CaretIndex = editText.Text.Length; OnKill += delegate { OnKill = null; if (_eventHandler == null) { return; } _eventHandler(editText.Text, EventArgs.Empty); }; editText.EnabledChanged += (sender, e) => OnKill.Invoke(); editText.KeyDown += (sender, e) => { if (e.Key == Keys.Enter) { OnKill.Invoke(); } }; }
private void Attack(Character character, Damage damage) { BeforeAttack?.Invoke(character, damage); character.ReceiveDamage(damage); AfterAttack?.Invoke(character, damage); if (!character.IsAlive) { OnKill?.Invoke(); } }
public void DoDamage(IDamagable damagable, float damage, DamageMatrix.Damage type, Vector3 point, Vector3 direction) { if (damagable != null) { if (damagable.TakeDamage(new DamageInfo(damage, type, point, direction)) <= 0f) { OnKill?.Invoke(this, damagable); } } }
private void AddKill() { kills++; streak++; OnKill?.Invoke(streak); // Reset streak timer on each kill. currentStreakTime = 0; }
private void OnTriggerEnter2D(Collider2D otherCollider) { if (otherCollider.CompareTag("PlayerBullet")) { gameObject.SetActive(false); Destroy(otherCollider.gameObject); // Inform observers that we have died OnKill?.Invoke(); } }
private void ProcessKillCommand(string[] tokens) { string reason = ""; if (tokens.Length >= 4) { tokens[3] = RemoveLeadingColon(tokens[3]); reason = CondenseStrings(tokens, 3); } OnKill?.Invoke(Rfc2812Util.UserFromString(tokens[0]), tokens[2], reason); }
private void Kill() { if (IsDead) { return; } audioSource.PlayOneShot(deathClip); IsDead = true; ragdoll.Activate(); StartCoroutine(DestroyAfter(secondsToDestroy)); onKill?.Invoke(); }
public override void HandleBullet(Bullet bullet) { if (bullet.FriendlyBullet != IsFriendly) { Health -= bullet.Damage; } if (Health == 0) { OnKill.Invoke(); Kill(); } }
void AddEnemyScore(Enemies.EnemyData data, Transform enemyPosition, GameObject initiator) { // if initiator is player, count score if (initiator == gameObject) { currentScore.KillsAmount++; currentScore.ScorePoints += data.Score; OnScoreChange?.Invoke(currentScore); OnKill?.Invoke(enemyPosition); } }
private void ResolveStreak() { if (streak > 10) { var power = Mathf.Floor(streak / 10f); var streakMultiplier = Mathf.Pow(power, 2); var extraPoints = Mathf.CeilToInt(streak * streakMultiplier); kills += extraPoints; } streak = 0; OnKill?.Invoke(streak); }
public void Kill() { if (CanMove == false) { return; } rigidbody2D.velocity = Vector2.zero; rigidbody2D.isKinematic = true; CanMove = false; playerVisuals.PlayDeathParticles(); MusicPlayer.Instance.PlayKill(); OnKill?.Invoke(this); }
public void Kill() { if (!IsPlaying) { return; } IsPlaying = false; IsCompleted = true; OnTweenKill(); OnKill?.Invoke(); OnCompleteOrKill?.Invoke(); }
IEnumerator Kill() { _active = false; _alive = false; Particles.Stop(true, ParticleSystemStopBehavior.StopEmitting); var startTime = Time.time; var lifetime = Particles.main.startLifetime.constant; while (Time.time - startTime < lifetime) { yield return(null); } OnKill?.Invoke(); GetComponent <Prototype>().ReturnToPool(); }
public override void Edit(PixelLayout control) { SkipCellDraw = true; var editText = new TextBox(); editText.Tag = this; editText.Style = "OverrideSize"; editText.Width = _lastRec.Width; editText.Height = _lastRec.Height; char value; char.TryParse(Value.ToString(), out value); editText.Text = ((int)value).ToString(); control.Add(editText, _lastRec.X, _lastRec.Y); editText.Focus(); editText.CaretIndex = editText.Text.Length; OnKill += delegate { SkipCellDraw = false; OnKill = null; if (_eventHandler == null) { return; } int num; if (!int.TryParse(editText.Text, out num)) { return; } _eventHandler((char)num, EventArgs.Empty); }; editText.KeyDown += (sender, e) => { if (e.Key == Keys.Enter) { OnKill.Invoke(); } }; }
public static void RemoveShip(ISpaceship ship) { ShipList.Remove(ship); if (ship.BattleIdentity != UnitBattleIdentity.Enemy) { return; } if (ship.HealthSystem.CurHealth > 0) { return; } KilledShipList.Add(ship); OnKill?.Invoke(ship); }
public override void Edit(PixelLayout control) { SkipCellDraw = true; var editText = new TextBox(); editText.Tag = this; editText.Style = "OverrideSize"; editText.Width = _lastRec.Width; editText.Height = _lastRec.Height; editText.Text = DisplayValue; editText.Tag = this; control.Add(editText, _lastRec.X, _lastRec.Y); editText.Focus(); editText.CaretIndex = editText.Text.Length; OnKill += delegate { SkipCellDraw = false; OnKill = null; if (_eventHandler == null) { return; } try { _eventHandler(_converter.ConvertFrom(editText.Text), EventArgs.Empty); } catch { } }; editText.KeyDown += (sender, e) => { if (e.Key == Keys.Enter) { OnKill.Invoke(); } }; }
public void SetMovementPackage(MovementPackage movementPackage) { _requested = false; _movementPackage = movementPackage; if (movementPackage?.Destination != null) { _distanceToCurrentDestination = Vector2.Distance(_transform.position, _movementPackage.Destination.TargetLocation); OnNewMovementStart?.Invoke(_movementPackage.Destination.DestinationType); if (MovementPackage.MovementCount % 2 != 0) { OnFirstMove?.Invoke(); } else { OnKill?.Invoke(); } } }
public DamageInfo Hit(IDamagable damagable, Collider2D col, Vector3 position, Vector3 normal) { DamageInfo damage = new DamageInfo(Damage, Color); float life = damagable.TakeDamage(damage); HitInfo info = new HitInfo(damage, col, position, normal, this, _weapon, Damage <= 0f); if (Damage - damage.DamageDealt <= 0f) { EmitHitEffect(position, normal); OnDepleted?.Invoke(info); } OnHit?.Invoke(info); if (life <= 0.001f) { OnKill?.Invoke(info); } return(damage); }
public IEnumerator KillRoutine() { lockout = true; OnKill?.Invoke(); KillParticles.transform.position = transform.position; KillParticles.Play(); var ren = GetComponent <SpriteRenderer>(); ren.enabled = false; var mob = GetComponent <Mobile>(); mob.enabled = false; if (DeathSounds.Length > 0) { AudioPool.PlaySound(transform.position, DeathSounds[Random.Range(0, DeathSounds.Length)], pitch: Random.value * .7f + .3f); } Time.timeScale = 0f; yield return(new WaitForSecondsRealtime(.1f)); Time.timeScale = 1f; ScreenShake.Shake(1f); ScreenShake.Quake(1f); ScreenShake.Instance.StartWobble(new Vector2(mob.HMomentum, mob.VMomentum).normalized * .03f); yield return(new WaitForSeconds(.5f)); FindObjectOfType <Stage>().ResetStage(); OnReset?.Invoke(); ren.enabled = true; mob.enabled = true; transform.position = SpawnPoint; lockout = false; }
private void Projectile_OnKill(Projectile projectile, IDamagable damagable) { OnKill?.Invoke(this, projectile, damagable); }
public void Kill() { OnKill?.Invoke(); }
private void ProcessOnExited(object sender, EventArgs eventArgs) { OnKill?.Invoke(this, EventArgs.Empty); }
public void Kill() { OnKill?.Invoke(_killPoints); _onHit.RemoveAllListeners(); }
private void Weapon_OnKill(IWeapon arg1, Projectile arg2, IDamagable arg3) { OnKill?.Invoke(arg1, arg2, arg3); }