private void DamageButton_Click(object sender, RoutedEventArgs e) { if (DamageAmountTextBox.Text.IsPositiveInteger()) { DD4EDamageType damageFlag = DD4EDamageType.None; if (DamageTypeList.SelectedItems.Count < 1) { damageFlag = DD4EDamageType.Unaspected; } else { foreach (var flag in DamageTypeList.SelectedItems) { damageFlag |= (DD4EDamageType)flag; } } var damage = Convert.ToInt32(DamageAmountTextBox.Text); Combatant.TakeDamage(damageFlag, damage); this.Close(); } else { MessageBox.Show("Please input a positive integer", "Warning"); } }
void OnCollisionEnter(Collision collision) { Combatant impactee = collision.collider.GetComponent <Combatant>(); Debug.Log("Impacted object"); if (impactee != null && impactee != origin) { foreach (DamageEffect effect in GetComponents <DamageEffect>()) { Debug.Log("Apply damage"); impactee.TakeDamage(effect); } if (explosionPrefab != null) { ContactPoint contact = collision.contacts[0]; Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal); Vector3 pos = contact.point; Instantiate(explosionPrefab, pos, rot); } Destroy(gameObject); } }
// Update is called once per frame void Update() { timePassed += Time.deltaTime; for (int x = 0; x < damageAmounts.Length; x++) { if (timePassed > 3.5f * (x + 1) && !damageTimes[x]) { toSabotage.TakeDamage(damageAmounts[x]); damageTimes[x] = true; } } }
// Update is called once per frame void Update() { flightTime -= Time.deltaTime; if (flightTime <= 0) { personImAttacking.TakeDamage(damage); GameObject.Destroy(this.gameObject); if (MissionManager.triggerCallbacksOnAttackHit) { MissionManager.instance.grossCallbackHack.enabled = true; } } }
private void PlayAttack(Combatant attacker, Combatant defender) { Console.WriteLine($"{attacker.Name} strikes with their {attacker.Weapon.Name}"); int damageDealt = attacker.DealDamage(); Console.WriteLine($"{attacker.Name} rolls a hit of {damageDealt} points!"); int actualDamage = defender.TakeDamage(damageDealt, attacker.Weapon.DamageType); if (actualDamage < damageDealt) { Console.WriteLine($"What moves! {defender.Name} only took {actualDamage} damage."); } else if (actualDamage > damageDealt) { Console.WriteLine($"{defender.Name} actually took {actualDamage} damage from that hit!"); } }
/// <summary> /// Makes the two combatants fight. /// </summary> /// <param name="aggresor">The agressor passed by val</param> /// <param name="defendant">The defendant passed by ref</param> /// <returns>Report of the defendant's status.</returns> public static string Attack(Combatant aggresor, ref Combatant defendant) { defendant.TakeDamage(aggresor.GetDamage()); return(defendant.ReportDamage()); }