protected void Fire() { if (fireType == FireType.Hitscan) { Vector3 fireOriginPos = fireOriginTransform.position; Ray ray = new Ray(fireOriginPos, fireOriginTransform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, maxFireDistance, hitLayers, QueryTriggerInteraction.Ignore)) { GameObject hitObj = hit.collider.gameObject; if (hitObj.CompareTag("Actor")) { DamageInstance di = new DamageInstance(gameObject, damage); hitObj.GetComponentInParent <ActorHealth>().Damage(di); } } } else if (fireType == FireType.Projectile) { GameObject proj = Instantiate(projectile, fireOriginTransform.position, fireOriginTransform.rotation); proj.SetActive(true); } }
public IceballMissile(Zerd zerd, DamageInstance damageInstance, Point p) : base("Missiles/iceball.png") { Damage = damageInstance; Width = 64; Height = 64; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.IceballDistance; Speed = AbilityConstants.IceballSpeed; Velocity = Creator.Facing.Normalized(); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(64 * 0, 0, 64, 64), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); var deathAnimation = new Animation(AnimationTypes.Death); deathAnimation.AddFrame(new Rectangle(64 * 0, 0, 64, 64), TimeSpan.FromSeconds(0.08)); deathAnimation.AddFrame(new Rectangle(64 * 1, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.93f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 2, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.85f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 3, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.78f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 4, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.71f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 5, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.64f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 6, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.58f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 7, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.51f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 8, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.46f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 9, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.38f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 10, 0, 64, 64), TimeSpan.FromSeconds(0.08), () => { Opacity = 0.3f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 11, 0, 64, 64), TimeSpan.FromSeconds(0.08), DeathFunc); Animations.Add(deathAnimation); }
protected override void GetCommands(Entity entity) { if (_cooldownCounter > 0) { _cooldownCounter--; return; } if (InputSource.Attack2Held) { Vector2 centerLine = InputSource.CursorPosition.normalized * 3; float angle = 30; _command = (attackingEntity) => { ConeHitbox hitbox = new ConeHitbox(attackingEntity.Position, centerLine, angle, GameInfo.EnemiesLayer); Debug.DrawRay(attackingEntity.Position, centerLine, Color.red, 1); foreach (Entity entityHit in hitbox.GetFreshHits()) { if (entityHit.IsDead) { continue; } DamageInstance inst = new DamageInstance(attackingEntity, entityHit, 5, 0); inst.OnAfterApplied += (damageInstance) => { if (damageInstance.IsValid) { damageInstance.AffectedEntity.ApplyKnockback(Behaviours.GetDirectionToTargetEntity(attackingEntity, entityHit), 2); entityHit.ApplyBuff(new StunDebuff(6)); } }; entityHit.TakeDamage(inst); } _cooldownCounter = CooldownTime; }; } }
private void DefaultKnockback(DamageInstance damageInstance) { float strength = damageInstance.KnockBackStrength; _controller.SetHorizontalForce(-strength * 0.5f); _controller.SetVerticalForce(strength); }
public void TakeDamage(DamageInstance damage, Entity source) { _hitState.Pre.ExecuteEffects(); TakeDamageImpl(damage, source); _hitState.CombatStage.ExecuteEffects(); _hitState.Post.ExecuteEffects(); }
public IcicleMissile(Zerd zerd, DamageInstance damageInstance, Point p, int index) : base("Missiles/icicle.png") { Damage = damageInstance; Width = 40; Height = 40; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.IcicleDistance; Speed = AbilityConstants.IcicleSpeed; Velocity = Creator.Facing.Normalized().Rotate(360f * index / 8); // Move the icicle away from the caster a bit X += Velocity.X * 45; Y -= Velocity.Y * 45; Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(64 * 0, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 1, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 2, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 3, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 4, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 5, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 6, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 7, 0, 64, 64), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); }
public void Apply(BattleState state) { DamageInstance lastHit = state.Dealt.GetLastHit(); int amount = (int)(0.2 * lastHit.TrueAmount); _parent.Heal(_parent, amount); _log.Log($"{_parent} was healed for {amount}(20% lifesteal)."); }
public DamageInstance GetDamageInstance() { DamageInstance result = new DamageInstance(); result.Amount = Get(); result.Type = Type; return(result); }
public void TakeDamage(DamageInstance damage) { currentHealth -= resistances.CalculateDamage(damage); if (currentHealth <= 0) { Die(); } }
public void GetInvincibilityFromDamage(DamageInstance damageInstance) { if (damageInstance.Amount > 0 && damageInstance.InvincibilityDuration > 0) { IsInvincible = true; _invincibilityTimer = damageInstance.InvincibilityDuration; } }
protected override void AttackImpl(Entity[] targets) { foreach (Entity target in targets) { DamageInstance hit = _physicalDamage.GetDamageInstance(); target.TakeDamage(hit, this); State.Dealt.AddHit(hit); } }
private void OnTriggerEnter(Collider collider) { var dest = collider.GetComponent <IDestructible>(); if (dest != null) { // var damage = new DamageInstance(_source, _damageType, _damageValue); dest.TakeDamage(damage); } }
public virtual void TakeDamage(DamageInstance damageInstance) { Health -= damageInstance.Damage; onTakeDamage(); if (Health <= 0) { OnDestroy(); Destroy(gameObject); return; } }
public override void TakeEffect(Character caster, Character target) { float scaledDamage = baseDamage + (caster.Power * powerScaling); DamageInstance attack = DamageInstance.NewAttack(caster, target, scaledDamage, damageType, attackType, critChanceOverride, critMultiplierOverride); attack.DoDamage(); if (effectOnHit != null && !attack.IsMiss) { effectOnHit.TakeEffect(caster, target); } }
// where the enemy damage happens (for now) TODO make player and enemy damage the same public void EnemyDidHit() { Weapon weapon = enemy.GetComponent <Enemy>().currentWeapon; DamageInstance dmg = CalculateDamage(player.GetComponent <CoreCharacterController>().statMaximum, weapon, enemyAttack, false, player.GetComponent <CoreCharacterController>().resistances); CreateDamageIndicator(dmg.value, false, dmg.critical, dmg.miss); player.GetComponent <InventoryManager>().currentHealth = Mathf.Min(player.GetComponent <InventoryManager>().currentHealth - dmg.value, player.GetComponent <InventoryManager>().maxHealth); UpdatePointBars(); }
public bool Casted() { Cooldown = TimeSpan.FromMilliseconds(FullCooldown.TotalMilliseconds); var numMissiles = 10; for (var i = 0; i < numMissiles; i++) { var direction = Being.Facing.Rotate(i * 360f / numMissiles); var knockback = new Knockback(direction, TimeSpan.FromMilliseconds(250), 500f); var damageInstance = new DamageInstance(knockback, 45f, DamageTypes.Fire, Being, AbilityTypes.SkeletonKingBlast); Globals.GameState.Missiles.Add(new SkeletonKingMissile(Being, damageInstance, direction)); } return(false); }
protected override bool Execute() { var damage = new DamageInstance(null, AbilityConstants.FrostPoundDamage, DamageTypes.Frost, Being, AbilityTypes.FrostPound); foreach (var enemy in Being.Enemies().Where(e => e.Position.DistanceBetween(Being.Position) < AbilityConstants.FrostPoundRange)) { damage.DamageBeing(enemy); enemy.Buffs.Add(new FrozenBuff(enemy, AbilityConstants.FrostPoundFrozenLength)); } // replenish mana based on bonuses Being.Mana += AbilityConstants.FrostPoundManaCost * (Being.SkillValue(SkillType.FrozenSoul, false) / 100f); return(base.Execute()); }
IEnumerator hitDots(float secs, List <Attack> pDots, List <Attack> eDots, List <StatusEffect> pEffs, List <StatusEffect> eEffs) { foreach (Attack a in pDots) { DamageInstance dmg = CalculateDamage(player.GetComponent <CoreCharacterController>().statMaximum, enemy.GetComponent <Enemy>().currentWeapon, a, false, new List <Armour.Resistance>(), true); dmg.element = pEffs[pDots.IndexOf(a)].element; CreateDamageIndicator(dmg.value, true, false, false); player.GetComponent <InventoryManager>().currentHealth = Mathf.Min(player.GetComponent <InventoryManager>().currentHealth - dmg.value, player.GetComponent <InventoryManager>().maxHealth); bool pded = checkPlayerDead(player); UpdatePointBars(); if (pded) { yield break; } yield return(new WaitForSeconds(secs)); } foreach (Attack a in eDots) { DamageInstance dmg = CalculateDamage(player.GetComponent <CoreCharacterController>().statMaximum, player.GetComponent <InventoryManager>().currentWeapon, a, false, new List <Armour.Resistance>(), true); dmg.element = eEffs[eDots.IndexOf(a)].element; CreateDamageIndicator(dmg.value, true, false, false); print("ENEMY HEALTH"); print(enemy.GetComponent <Enemy>().currentHealth); enemy.GetComponent <Enemy>().currentHealth = Mathf.Min(enemy.GetComponent <Enemy>().currentHealth - dmg.value, enemy.GetComponent <Enemy>().maxHealth); UpdatePointBars(); print(enemy.GetComponent <Enemy>().currentHealth); bool eded = checkEnemyDead(enemy); if (eded) { yield break; } yield return(new WaitForSeconds(secs)); } ShowButtons(); yield break; }
public float CalculateDamage(DamageInstance damage) { float res = 0; damage.penetration -= antiPenetrationArmor; res += damage.normalDamage * (1 - normalResistance); res += damage.fireDamage * (1 - fireResistance); res += damage.iceDamage * (1 - iceResistance); res += damage.lightningDamage * (1 - lightningResistance); if (damage.penetration <= 0) { damage.DestroyProjectile(); } return(res); }
protected override void TakeDamageImpl(DamageInstance damage, Entity source) { if (!IsAlive()) { return; } damage.TrueAmount = damage.Amount; Resources[ResourceType.Health].Modify(-1 * damage.TrueAmount); Log.Log($"{this} took {damage} from {source.Name}"); if (!IsAlive()) { Log.Log($"{Name} has died."); } State.Taken.AddHit(damage); }
public LavaBlastMissile(Zerd zerd, DamageInstance damageInstance, Point p) : base("Missiles/lava_blast.png") { Damage = damageInstance; Width = 86; Height = 86; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.FireballDistance * (1 + zerd.Player.AbilityUpgrades[AbilityUpgradeType.LavaBlastDistance] / 100f); Speed = AbilityConstants.FireballSpeed; Velocity = Creator.Facing.Normalized(); TargetsHit = new List <Being>(); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(120 * 0, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 1, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 2, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 3, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 0, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 1, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 2, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 3, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 0, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 1, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 2, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(120 * 3, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); var deathAnimation = new Animation(AnimationTypes.Death); deathAnimation.AddFrame(new Rectangle(120 * 0, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.03)); deathAnimation.AddFrame(new Rectangle(120 * 1, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.91f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 2, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.82f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 3, 120 * 0, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.73f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 0, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.64f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 1, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.55f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 2, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.46f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 3, 120 * 1, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.37f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 0, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.28f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 1, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.19f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 2, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.03), () => { Opacity = 0.1f; return(true); }); deathAnimation.AddFrame(new Rectangle(120 * 3, 120 * 2, 120, 120), TimeSpan.FromSeconds(0.03), DeathFunc); Animations.Add(deathAnimation); }
// where the player damage happens public void PlayerDidHit() { // Use weapon to get random base damage int max = player.GetComponent <CoreCharacterController>().statMaximum; Weapon weapon = player.GetComponent <InventoryManager>().currentWeapon; if (enemy != null) { DamageInstance dmg = CalculateDamage(max, weapon, playerAttack, true, enemy.GetComponent <Enemy>().resistances); CreateDamageIndicator(dmg.value, true, dmg.critical, dmg.miss); enemy.GetComponent <Enemy>().currentHealth = Mathf.Min(enemy.GetComponent <Enemy>().currentHealth - dmg.value, enemy.GetComponent <Enemy>().maxHealth); checkEnemyDead(enemy); UpdatePointBars(); } }
public void TakeDamage(DamageInstance damageInstance) { if (IsInvincible) { damageInstance.IsValid = false; } OnBeforeDamage?.Invoke(damageInstance); if (damageInstance.IsValid) { damageInstance.Amount -= GetStat(GameInfo.Stats.FlatDamageReduction); CurrentHealth -= damageInstance.Amount; OnDamaged?.Invoke(damageInstance); damageInstance.DoOnAfterApplied(); } if (CurrentHealth <= 0) { TriggerDeath(); } }
static DamageInstance GetNextInstance() { int startingIndex = poolIndex; DamageInstance result = pool[poolIndex]; while (result.isActive) { HelperMethods.CyclicalIncrement(ref poolIndex, pool.Count); result = pool[poolIndex]; if (poolIndex == startingIndex) { Debug.LogWarning("No inactive instances available in object pool."); return(null); } } HelperMethods.CyclicalIncrement(ref poolIndex, pool.Count); return(result); }
public ArrowMissile(Being being, DamageInstance damageInstance, Point p) : base("Missiles/arrow.png") { Damage = damageInstance; Width = 22; Height = 22; X = p.X; Y = p.Y; Creator = being; Origin = p; Distance = EnemyConstants.ArcherArrowLength; Speed = EnemyConstants.ArcherArrowSpeed; Velocity = Creator.Facing.Normalized().Rotate(Helpers.RandomInRange(-3, 3)); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(0, 0, 32, 32), TimeSpan.FromSeconds(0.15)); Animations.Add(moveAnimation); }
public DragonBreathMissile(Zerd zerd, DamageInstance damageInstance, Point p) : base("Missiles/dragons_breath.png") { Damage = damageInstance; Width = 26f; Height = 26f; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.FireballDistance; Speed = AbilityConstants.FireballSpeed; Velocity = Creator.Facing.Normalized().Rotate(Globals.Random.Next(11) - 5); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(32 * 0, 0, 32, 32), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(32 * 1, 0, 32, 32), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(32 * 2, 0, 32, 32), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); }
public void TakeDamage(DamageInstance damageInstance) { if (IsInvulnerable) { return; } Health -= damageInstance.Damage; if (Health <= 0) { gameManager.OnPlayerDeath(); return; } hudManager.HealthDisplay.SendMessage("SetDisplayedHealth", Health); if (damageInstance.TriggersInvulnerability) { IsInvulnerable = true; GameManager.DelayedFunction(gameManager.InvulnerabilityTime, () => IsInvulnerable = false); StartCoroutine(BlinkingMode(gameManager.InvulnerabilityTime)); } if (damageInstance.TriggersKnockback) { if (damageInstance.SpecialKnockbackBehaviour != null) { damageInstance.SpecialKnockbackBehaviour(this); return; } HasControl = false; Action regainControl = () => { HasControl = true; }; DefaultKnockback(damageInstance); GameManager.DelayedFunction(gameManager.OutOfControlTime, regainControl); } }
public FireballMissile(Zerd zerd, DamageInstance damageInstance, Point p) : base("Missiles/fireball.png") { Damage = damageInstance; var size = 64f * zerd.SkillValue(SkillType.ImprovedFireball, true); Width = (int)size; Height = (int)size; X = p.X; Y = p.Y; Creator = zerd; Origin = p; Distance = AbilityConstants.FireballDistance; Speed = AbilityConstants.FireballSpeed; Velocity = Creator.Facing.Normalized(); Animations = new AnimationList(); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(64 * 0, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 1, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 2, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 3, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 4, 0, 64, 64), TimeSpan.FromSeconds(0.1)); moveAnimation.AddFrame(new Rectangle(64 * 5, 0, 64, 64), TimeSpan.FromSeconds(0.1)); Animations.Add(moveAnimation); var deathAnimation = new Animation(AnimationTypes.Death); deathAnimation.AddFrame(new Rectangle(64 * 6, 0, 64, 64), TimeSpan.FromSeconds(0.1)); deathAnimation.AddFrame(new Rectangle(64 * 7, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.92f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 8, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.84f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 9, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.76f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 10, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.68f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 11, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.6f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 12, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.5f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 13, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.4f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 14, 0, 64, 64), TimeSpan.FromSeconds(0.1), () => { Opacity = 0.3f; return(true); }); deathAnimation.AddFrame(new Rectangle(64 * 15, 0, 64, 64), TimeSpan.FromSeconds(0.1), DeathFunc); Animations.Add(deathAnimation); }
protected override void UpdatePhysics() { Vector2 velocityThisFrame = _velocity; bool hasHitAnObstacle = false; int num1 = Physics2D.CircleCastNonAlloc(_rigidbody.position, _projectileRadius, _velocity.normalized, _hitResults, _velocity.magnitude, GameInfo.HighWallsLayer); for (int i = 0; i < num1; i++) { RaycastHit2D hit = _hitResults[i]; if (hit.distance < velocityThisFrame.magnitude) { hasHitAnObstacle = true; velocityThisFrame = velocityThisFrame.normalized * hit.distance; } } int num2 = Physics2D.CircleCastNonAlloc(_rigidbody.position, _projectileRadius, velocityThisFrame.normalized, _hitResults, velocityThisFrame.magnitude, _layerMask); for (int i = 0; i < num2; i++) { RaycastHit2D hit = _hitResults[i]; Entity entity = Entity.GetEntityForGameObject(hit.collider.gameObject); if (entity == null) { continue; } DamageInstance d = new DamageInstance(_sourceEntity, entity, 3, 0); d.OnAfterApplied += (DamageInstance) => { entity.ApplyKnockback(_velocity * 0.08f, 8); entity.ApplyBuff(new StunDebuff(2, 1)); Destroy(); }; entity.TakeDamage(d); } if (hasHitAnObstacle) { Destroy(); return; } _rigidbody.MovePosition(_rigidbody.position + velocityThisFrame); }
public SkeletonKingMissile(Being being, DamageInstance damageInstance, Vector2 velocity) : base("Missiles/orbs.png") { Damage = damageInstance; Width = 96; Height = 96; X = being.X; Y = being.Y; Creator = being; Origin = being.Position; Distance = 1000f; Speed = 600f; Velocity = velocity; Animations = new AnimationList(); var spawnAnimation = new Animation(AnimationTypes.Spawn); spawnAnimation.AddFrame(new Rectangle(32 * 3, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); spawnAnimation.AddFrame(new Rectangle(32 * 4, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); spawnAnimation.AddFrame(new Rectangle(32 * 5, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15), SpawnedFunc); Animations.Add(spawnAnimation); var moveAnimation = new Animation(AnimationTypes.Move); moveAnimation.AddFrame(new Rectangle(32 * 0, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 1, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 2, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); moveAnimation.AddFrame(new Rectangle(32 * 1, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); Animations.Add(moveAnimation); var dieAnimation = new Animation(AnimationTypes.Death); dieAnimation.AddFrame(new Rectangle(32 * 5, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); dieAnimation.AddFrame(new Rectangle(32 * 4, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); dieAnimation.AddFrame(new Rectangle(32 * 3, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15)); dieAnimation.AddFrame(new Rectangle(32 * 3, 32 * 4, 32, 32), TimeSpan.FromSeconds(0.15), DeathFunc); Animations.Add(dieAnimation); }