protected void GrdReport_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { Inward += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Inward")); Outward += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Outward")); Damaged += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Damage")); Closing += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Closing")); Amount += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Amount")); } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[6].Text = "Total"; e.Row.Cells[7].Text = Inward.ToString("0.00"); e.Row.Cells[8].Text = Outward.ToString("0.00"); e.Row.Cells[9].Text = Damaged.ToString("0.00"); e.Row.Cells[10].Text = Closing.ToString("0.00"); e.Row.Cells[11].Text = Amount.ToString("0.00"); } } catch (Exception ex) { } }
private void OnTriggerStay(Collider other) { Hurtbox Damaged; Damaged = other.GetComponent <Hurtbox>(); Damaged.GetHit(1); }
public void Damage(int amount) { var prev = CurrentHealth; CurrentHealth = Mathf.Max(CurrentHealth - amount, 0); Damaged?.Invoke(this, new DamagedEventArgs(prev - CurrentHealth)); }
public override void takeDamage(int damage, string damageType = "physical") { //sounds.playSound("defeat"); switch (damageType) { case "physical": var damageMod = (100f - physicalResist) / 100f; damage = (int)Mathf.Round(damage * damageMod); break; case "psychic": damage = (int)Mathf.Round(damage * ((100 - psychicResist) / 100)); break; } /*if(shieldDuration > 0){ * Debug.Log("Shield activated. Damage preshield: " + damage + " shield left: " + shieldDuration); * damage = Mathf.Clamp(damage-shieldAmount,0,1000); * shieldDuration -= 1; * Debug.Log("Shield activated. Damage postshield: " + damage + " shield left: " + shieldDuration); * }*/ health -= damage; DamageEffect.Emit(10); // DamageEffect2.Emit(10); switch (health) { case 2: Healthy.SetActive(false); Damaged.SetActive(true); Damaged2.SetActive(false); break; case 1: Healthy.SetActive(false); Damaged.SetActive(false); Damaged2.SetActive(true); break; case 0: Healthy.SetActive(false); Damaged.SetActive(false); Damaged2.SetActive(false); getDefeated(); break; } //healthBar.SetHealth(health); //UI.showDamage(-damage); //hitIndicator.showHit(); //checks if the damage is enough to knock the character out. If character has points of undying he will lose one instead of dying /* * if(health <= 0){ * /*if(undying > 0){ * undying -= 1; * health = 1; * healthBar.SetHealth(health); * }else{ * getDefeated(); * }*/ }
/// <summary> /// Apply damage to the Health. /// </summary> /// <param name="dmg">The damage to apply.</param> /// <returns>The actual damage amount dealt.</returns> public virtual float Damage(Damage dmg) { if (enabled && dmg.amount > 0 && hitInvulnTimer.Use()) { DamageModifier?.Invoke(ref dmg); float prevHealth = health; health -= dmg.amount; health = Mathf.Max(health, 0); dmg.amount = prevHealth - health; healthRegenTimer.Set(); SendMessage("OnDamage", dmg, SendMessageOptions.DontRequireReceiver); Damaged?.Invoke(dmg); if (damageSound) { damageSound.Play(); } if (health == 0 && !dead) { dead = true; SendMessage("OnZeroHealth", SendMessageOptions.DontRequireReceiver); ZeroHealth?.Invoke(); } } else { dmg.amount = 0; } return(dmg.amount); }
/// <inheritdoc /> public void TakeDamage(DamageType damageType, int amount, IEntity source = null, IEntity sourceMob = null) { if (damageType == DamageType.Total) { throw new ArgumentException("Cannot take damage for DamageType.Total"); } InitializeDamageType(damageType); int oldValue = _currentDamage[damageType]; int oldTotalValue = -1; if (amount == 0) { return; } amount = Resistances.CalculateDamage(damageType, amount); _currentDamage[damageType] = Math.Max(0, _currentDamage[damageType] + amount); UpdateForDamageType(damageType, oldValue); Damaged?.Invoke(this, new DamageEventArgs(damageType, amount, source, sourceMob)); if (Resistances.AppliesToTotal(damageType)) { oldTotalValue = _currentDamage[DamageType.Total]; _currentDamage[DamageType.Total] = Math.Max(0, _currentDamage[DamageType.Total] + amount); UpdateForDamageType(DamageType.Total, oldTotalValue); } }
// Update is called once per frame void FixedUpdate() { GameObject player = GameObject.Find("Pickles(Clone)"); anim.SetFloat("existTime", timeCount); if (timeCount > meltTime && !isPlay && Vector3.Distance(cameraObj.transform.position, transform.position) < 30) { audioSource.PlayOneShot(iceBreak); isPlay = true; } if (ground.IsGround()) { timeCount += Time.deltaTime * breakPromotionGround; } else { timeCount += Time.deltaTime; } if (timeCount > iceFloorLifespan) { if (player != null) { float diffy = player.transform.position.y - transform.position.y; if (diffy < diffPlayerY && 0 < diffy && Mathf.Abs(player.transform.position.x - transform.position.x) < diffPlayerX) //乗ってると落ちる { Instantiate(damaged, player.transform.position, Quaternion.identity); Damaged script = damaged.GetComponent <Damaged>(); script.knockBackDirection = new Vector2(0, 0); script.isSetInvincible = false; Destroy(player.gameObject); } } Destroy(gameObject); } }
private void OnDamaged() { if (_onDamaged.IsAssigned()) { _onDamaged.Invoke(); } Damaged?.Invoke(this); }
public void TakeDamage(float damage) { if (_canTakeDamage) { _health -= damage; Damaged?.Invoke(); } }
private void OnTriggerEnter(Collider other) { Hurtbox Damaged; Damaged = other.GetComponent <Hurtbox>(); Damaged.GetHit(1); Destroy(transform.parent.gameObject); }
public override void AttackUnit(Damaged target) { if (Vector2.Distance(target.transform.position, transform.position) <= range && Time.time >= timerDelay) { target.Hit(strong, damageType); timerDelay = Time.time + delay; } }
protected virtual void OnDamaged(HealthAgentDamageArgs args) { Damaged?.Invoke(args); if (!IsAlive) { OnDied(new HealthAgentDeathArgs(_delegator, args.Agressor, args.Amount)); } }
public void Damage(IEnumerable <IDamagable> damagables) { DamageArgs damageArgs = new DamageArgs(Origin, gameObject, damage); foreach (var damagable in damagables) { damagable.TakeDamage(damageArgs); } Damaged?.Invoke(damagables); }
private void DealDamage(int amount) { health -= 10; if (health - amount < 0) { health = 0; } Damaged?.Invoke(amount); }
public void AddDamage(int damageAddition, HitInfo hit) { hit.damageChangeInfo.oldDamage = CurrentDamage; CurrentDamage += Mathf.Abs(damageAddition); CurrentDamage = Mathf.Clamp(CurrentDamage, 0, maxDamage); hit.damageChangeInfo.oldDamage = CurrentDamage; Damaged?.Invoke(hit); }
public void TakeDamage(int amount) { CurrentHealth = Mathf.Max(CurrentHealth - amount, 0); _animator.SetTrigger("TakeDamage"); Damaged?.Invoke(this, new HealthEventArgs(CurrentHealth / (float)MaximumHealth)); if (CurrentHealth <= 0) { GameManager.instance.UnitDefeated(this); } }
protected void GrdReport_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { SystemOpening += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SystemOpening")); ActualOpening += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualOpening")); Purchase += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Purchase")); Sales += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Sales")); SalesReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SalesReturn")); Inward += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Inward")); Outward += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Outward")); OutwardReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "OutwardReturn")); TransferIN += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "TransferIN")); TransferOUT += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "TransferOUT")); Damaged += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Damage")); PurReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ReturnToSupplier")); Deviation += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Deviation")); SystemClosing += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SystemClosing")); ActualClosing += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualClosing")); SystemAmount += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SystemAmount")); ActualAmount += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualAmount")); UNITActualAmount += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "STOCKINHANDWITHUNITCONVERTSYSTEM")); UNITOutwardReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "STOCKINHANDWITHUNITCONVERTACTUAL")); } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[6].Text = "Total"; e.Row.Cells[7].Text = SystemOpening.ToString("0.00"); e.Row.Cells[8].Text = ActualOpening.ToString("0.00"); e.Row.Cells[9].Text = Purchase.ToString("0.00"); e.Row.Cells[11].Text = Sales.ToString("0.00"); e.Row.Cells[12].Text = SalesReturn.ToString("0.00"); e.Row.Cells[13].Text = Inward.ToString("0.00"); e.Row.Cells[14].Text = Outward.ToString("0.00"); e.Row.Cells[15].Text = OutwardReturn.ToString("0.00"); e.Row.Cells[16].Text = TransferIN.ToString("0.00"); e.Row.Cells[17].Text = TransferOUT.ToString("0.00"); e.Row.Cells[18].Text = Damaged.ToString("0.00"); e.Row.Cells[10].Text = PurReturn.ToString("0.00"); e.Row.Cells[19].Text = Deviation.ToString("0.00"); e.Row.Cells[20].Text = SystemClosing.ToString("0.00"); e.Row.Cells[21].Text = ActualClosing.ToString("0.00"); e.Row.Cells[23].Text = UNITActualAmount.ToString("0.00"); e.Row.Cells[24].Text = UNITOutwardReturn.ToString("0.00"); e.Row.Cells[25].Text = SystemAmount.ToString("0.00"); e.Row.Cells[26].Text = ActualAmount.ToString("0.00"); } } catch (Exception ex) { } }
public void Apply(float amount) { health -= amount; Damaged?.Invoke(amount); if (!Alive) { print($"{name} died."); } }
public void AcceptDamage(int damage) { CurrHealth -= damage; if (CurrHealth <= 0) { Died?.Invoke(); } Damaged?.Invoke(this); }
public void OnDamaged(Unit emeny) { if (_isStandUp == false) { return; } _rigidbody.isKinematic = false; _enemy = emeny; Damaged?.Invoke(); StartCoroutine(OnStandUpDelay()); }
public void Damage(DamageInfo damage) { if (damage.Damage > 0) { health.Damage(damage.Damage); Damaged?.Invoke(); } else { UndamagedHit?.Invoke(); } }
// Start is called before the first frame update void Start() { rb2d = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); damaged = knockBackAnim.GetComponent <Damaged>(); canvas = GameObject.Find("Canvas"); statusCounter = canvas.GetComponent <StatusCounter>(); audioSource = GetComponent <AudioSource>(); taglist = new List <string>() { "Enemy", "EnemyBullet", "Boss" }; }
public void ApplyDamage(int amount) { Health -= amount; if (Health > 0) { Damaged?.Invoke(this); } else { MarkedForDestruction = true; } }
public virtual void Ride() { Damaged += delegate { Console.WriteLine("This Vehicle is broken, repair it first"); Console.ReadKey(); }; EmptyFuel += delegate { Console.WriteLine("You are out of fuel."); Console.ReadKey(); }; if (Fuel <= 0) { EmptyFuel?.Invoke(); return; } if (IsBroken) { Damaged?.Invoke(); return; } Random rand = new Random(); Console.WriteLine("Riding for 1 hour..."); Thread.Sleep(1000); Distance += Speed; int chance = rand.Next(1, 4); IsBroken = chance == 2 ? true : false; if (IsBroken) { Console.Clear(); Damaged?.Invoke(); } Fuel -= Consumption; if (Fuel <= 0) { EmptyFuel?.Invoke(); Console.ReadKey(); } }
public virtual void ApplyDamage(float value) { _inflictedDamage += value; if (_visual != null) { _visual.ApplyDamageVisual(); } Damaged?.Invoke(this, value); if (Health <= 0) { Destroy(); } }
public DamageStorage GetCurrentOrCreateDamageStorage() { foreach (var o in Damaged) { var damageStorage = o.GetComponent <DamageStorage>(); if (damageStorage.CurrentDamage < 100) { return(damageStorage); } } var newDamaged = CreateNewDamaged(); Damaged.Add(newDamaged); return(newDamaged.GetComponent <DamageStorage>()); }
public void AddDamageEffect(PeriodicDamageEffect damageEffect) { void applyDamage() { Damaged?.Invoke(this, damageEffect.DamagePerTick); } Coroutine coroutine = _coroutineOwner.StartCoroutine( PeriodicEffectCoroutine( damageEffect.TicksPerSecond, damageEffect.FirstTickImmediately, applyDamage ) ); AddPeriodicEffect(coroutine, _periodicDamageEffects, damageEffect.DurationSeconds); }
public Level(string name) { Name = name; Map = new Map(File.ReadAllLines(GetFolderName() + "\\map.txt")); Map.CellChange += (x, y, creature) => CellChange?.Invoke(x, y, creature); Map.Die += (x, y, creature) => Die?.Invoke(x, y, creature); Map.Damaged += (x, y, creature, damage) => Damaged?.Invoke(x, y, creature, damage); Map.DoingStarted += (x, y, character, doing) => DoingStarted?.Invoke(x, y, character, doing); Map.DoingEnd += (x, y, character, doing) => DoingEnd?.Invoke(x, y, character, doing); Map.Die += (x, y, creature) => { if (creature is Base _base) { EndWin?.Invoke(!_base.IsPlayerCreature); IsEnd = true; } }; }
public Level(string name, Map map) { Name = name; Map = map; Map.CellChange += (x, y, creature) => CellChange?.Invoke(x, y, creature); Map.Die += (x, y, creature) => Die?.Invoke(x, y, creature); Map.Damaged += (x, y, creature, damage) => Damaged?.Invoke(x, y, creature, damage); Map.DoingStarted += (x, y, character, doing) => DoingStarted?.Invoke(x, y, character, doing); Map.DoingEnd += (x, y, character, doing) => DoingEnd?.Invoke(x, y, character, doing); Map.Die += (x, y, creature) => { if (creature is Base _base) { EndWin?.Invoke(!_base.IsPlayerCreature); IsEnd = true; } }; }
IEnumerator Repair() { MissionManager.Mission myMission = mission; for (int i = 1; i < myMission.blocksFound.Count; i++) { if (myMission.blocksFound[i].states.ContainsKey(State.Damaged)) { Damaged state = myMission.blocksFound[i].states[State.Damaged] as Damaged; if (!state.isBeingRepaired) { state.StartRepair(); break; } } } GameManager.instance.missionManager.EndMission(myMission); yield return(null); }
protected virtual void InitializeStateMachine() { Idle idleState = new Idle(this); idleState.AddTransition(Transition.E_FAILGESTURE, StateID.E_ATTACK); idleState.AddTransition(Transition.E_LOSTHP, StateID.E_DAMAGED); idleState.AddTransition(Transition.E_NOHP, StateID.E_DEATH); Attack atkState = new Attack(this); atkState.AddTransition(Transition.E_FINISHATTACK, StateID.E_IDLE); atkState.AddTransition(Transition.E_LOSTHP, StateID.E_DAMAGED); Damaged dmgState = new Damaged(this); dmgState.AddTransition(Transition.E_NOHP, StateID.E_DEATH); dmgState.AddTransition(Transition.E_FINISHATTACK, StateID.E_IDLE); dmgState.AddTransition(Transition.E_LOSTHP, StateID.E_DAMAGED); Death deathState = new Death(this); enemyState = new FiniteStateMachine(); enemyState.AddState(idleState); enemyState.AddState(atkState); enemyState.AddState(dmgState); enemyState.AddState(deathState); }