/// <summary> /// Damage this damageable. /// </summary> /// <param name="damage">The damage amount.</param> /// <param name="hitPoint">The world position where the damage occurred.</param> public virtual void Damage(float damage, Vector3 hitPoint, DamageSourceType damageSourceType, Transform damageSourceRootTransform) { if (destroyed) { return; } if (isDamageable) { // Reduce the health currentHealth -= damage; // Destroy if (currentHealth <= 0) { currentHealth = 0; Destroy(); } // Damage else { // Call the damage event onDamaged.Invoke(damage, hitPoint, damageSourceType, damageSourceRootTransform); } } }
public DamageActor(GameActor target, GameActor source, float damageAmount, DamageSourceType damageType, DamageSourceColor damageColor) { _damageSourceType = damageType; _damageSourceColor = damageColor; _target = target; _source = source; _damageAmount = damageAmount; }
public DamageActor() { _damageSourceType = DamageSourceType.Undefined; _damageSourceColor = DamageSourceColor.None; _target = null; _source = null; _damageAmount = 0; }
public void fireFireball(int duration, int damage, DamageSourceType source) { GameObject fireBallGameObject = GameObject.Instantiate(fireBallPrefab); fireBallGameObject.transform.position = this.transform.position; FireBall fireBall = fireBallGameObject.GetComponent <FireBall>(); bool isRight = GetComponent <PlatformerCharacter2D>().facingRight; fireBall.init(duration, damage, source, isRight); }
public void init(int duration, int damage, DamageSourceType source, bool isRight) { this.source = source; this.damageAmount = damage; StartCoroutine(killSelf(duration)); Rigidbody2D rigidbody = this.gameObject.GetComponent <Rigidbody2D>(); int modifier = isRight ? 1 : -1; this.transform.localRotation = new Quaternion(0, 0, isRight ? 0 : 180, 0); rigidbody.AddForce(new Vector2(force * modifier, 0), ForceMode2D.Impulse); }
private void OnDamageTaken(DamageSourceType damageSourceType, int damageTaken) { switch (damageSourceType) { case (DamageSourceType.CollidingCharger): damageTakenFromChargers += damageTaken; break; case (DamageSourceType.CollidingObstacle): damageTakenFromObstacles += damageTaken; break; case (DamageSourceType.FallingIntoVoid): damageTakenFromVoid += damageTaken; break; case (DamageSourceType.HitByEnemyLaser): damageTakenFromLasers += damageTaken; break; default: break; } }
protected virtual void OnDamageableModuleDamaged(float damage, Vector3 hitPoint, DamageSourceType damageSourceType, Transform damageSourceRootTransform) { onDamageableModuleDamaged.Invoke(damage, hitPoint, damageSourceType, damageSourceRootTransform); }
/// <summary> /// Calls this method on all mods /// </summary> /// <param name="killedCharacter"></param> /// <param name="killerCharacter"></param> /// <param name="damageSourceType"></param> /// <param name="attackID"></param> public override void OnCharacterKilled(Character killedCharacter, Character killerCharacter, DamageSourceType damageSourceType, int attackID) { List <Mod> mods = ModsManager.Instance.GetAllLoadedMods(); for (int i = 0; i < mods.Count; i++) { mods[i].OnCharacterKilled(killedCharacter, killerCharacter, damageSourceType, attackID); } }
/// <summary> /// Called in <see cref="Character.onDeath(Character, DamageSourceType, int)"/> /// </summary> /// <param name="killedCharacter">The <see cref="Character"/> that was killed</param> /// <param name="killerCharacter">The killer <see cref="Character"/></param> /// <param name="damageSourceType">The cause of death</param> /// <param name="attackID">The attack ID that killed <paramref name="killedCharacter"/></param> public virtual void OnCharacterKilled(Character killedCharacter, Character killerCharacter, DamageSourceType damageSourceType, int attackID) { }
/// <summary> /// Damage this damageable. /// </summary> /// <param name="damage">The damage amount.</param> /// <param name="hitPoint">The world position where the damage occurred.</param> public virtual void Damage(float damage, Vector3 hitPoint, DamageSourceType damageSourceType, Transform damageSourceRootTransform) { onDamaged.Invoke(damage, hitPoint, damageSourceType, damageSourceRootTransform); }
public static void Character_onDeath_Prefix(Character __instance, Character killer, DamageSourceType damageSourceType, int attackID) { ModsManager.Instance.PassOnMod.OnCharacterKilled(__instance, killer, damageSourceType, attackID); }
/// <summary> /// Called when a <see cref="Character"/> is killed /// </summary> /// <param name="killedCharacter">The <see cref="GameObject"/> for the <see cref="Character"/> that was killed</param> /// <param name="killerCharacter">The <see cref="GameObject"/> for the killer <see cref="Character"/></param> /// <param name="damageSourceType">The cause of death</param> public virtual void OnCharacterKilled(GameObject killedCharacter, GameObject killerCharacter, DamageSourceType damageSourceType) { }