private float ModifyDamageToTake(PositionedObject damageDealer, float weaponLevelModifier, float baseDamage) { float toReturn = baseDamage; if (ShieldHalfAngle != 0) { Vector3 directionOfDamage = damageDealer.Position - Position; directionOfDamage.Normalize(); var directionFacing = TopDownDirectionExtensions.FromDirection(new Vector2(aimingVector.X, aimingVector.Y), PossibleDirections.EightWay); Vector3 forwardVector = directionFacing.ToVector(); var dotProd = directionOfDamage.X * forwardVector.X + directionOfDamage.Y * forwardVector.Y; var angleDegrees = Math.Acos(dotProd) * (180 / Math.PI); toReturn = baseDamage; if (angleDegrees < ShieldHalfAngle) { toReturn /= 2; } } toReturn = toReturn * weaponLevelModifier; return(toReturn); }
private void DoShootingFireActivity(Bullet.DataCategory bulletData) { var direction = aimingVector; var bullet = Factories.BulletFactory.CreateNew(this.X, this.Y); bullet.Owner = this; bullet.CurrentDataCategoryState = bulletData; bullet.Velocity = bullet.BulletSpeed * direction; bullet.SetAnimationChainFromVelocity(TopDownDirectionExtensions.FromDirection(aimingVector, PossibleDirections), EquippedWeapon); CurrentEnergy -= ModifyEnergyDrain(bulletData.EnergyUsePerShot); shootingLayer.PlayOnce(GetChainName(currentPrimaryAction, SecondaryActions.Shooting)); lastFireShotTime = FlatRedBall.Screens.ScreenManager.CurrentScreen.PauseAdjustedCurrentTime; if (bulletData == Bullet.DataCategory.PlayerFire) { FlatRedBall.Audio.AudioManager.Play(PlayerFlameShot); } else if (bulletData == Bullet.DataCategory.PlayerSkull) { switch (FlatRedBallServices.Random.Next(0, 3)) { case 0: FlatRedBall.Audio.AudioManager.Play(PlayerShotSkull1); break; case 1: FlatRedBall.Audio.AudioManager.Play(PlayerShotSkull2); break; case 2: FlatRedBall.Audio.AudioManager.Play(PlayerShotSkull3); break; } } }
private string GetChainName(PrimaryActions primaryAction, SecondaryActions secondaryActions) { if (aimingVector.X != 0 || aimingVector.Y != 0) { var direction = TopDownDirectionExtensions.FromDirection(new Vector2(aimingVector.X, aimingVector.Y), PossibleDirections.EightWay); return(ChainNameHelperMethods.GenerateChainName(primaryAction, null, direction)); } else { return(ChainNameHelperMethods.GenerateChainName(primaryAction, null, TopDownDirection.Right)); } }
public void SetAnimationChainFromVelocity(TopDownDirection aimingDirection, Weapon weapon) { string weaponAnimationName = null; switch (weapon) { case Weapon.ShootingFire: weaponAnimationName = "Fireball"; break; case Weapon.ShootingSkulls: weaponAnimationName = "Skull"; break; } SpriteInstance.CurrentChainName = weaponAnimationName + "_" + aimingDirection.ToFriendlyString(); var positionOffset = TopDownDirectionExtensions.ToVector(aimingDirection); Position += positionOffset * OffsetRadius; }
private string GetChainName(PrimaryActions primaryAction, SecondaryActions secondaryAction = SecondaryActions.None) { Weapon?weapon = null; if (secondaryAction == SecondaryActions.Shooting) { weapon = EquippedWeapon; } if (aimingVector.X != 0 || aimingVector.Y != 0) { var direction = TopDownDirectionExtensions.FromDirection(new Vector2(aimingVector.X, aimingVector.Y), PossibleDirections.EightWay); return(ChainNameHelperMethods.GenerateChainName(primaryAction, weapon, direction)); } else { return(ChainNameHelperMethods.GenerateChainName(primaryAction, weapon, TopDownDirection.Right)); } }