private void ShootBullet() { foreach (var offset in GetBulletOffsets()) { var bullet = BulletFactory.CreateNew(); bullet.Position = this.Position + offset; bullet.YVelocity = BulletVelocity; BulletCreated?.Invoke(bullet); } }
private void HadleInput() { this.XAcceleration = PlayerInput.X * MaxMovementSpeed; this.YAcceleration = PlayerInput.Y * MaxMovementSpeed; if (this.Shoot.IsDown && CanShoot) { BulletFactory.CreateNew(this.X, this.Y); LastShotFired = TimeManager.CurrentTime; CanShoot = false; } }
void Shoot(bool left, JoinedPlayer player) { var ship = MainMenuGum.JoinedPlayerContainer.Children .FirstOrDefault(item => item.SailDesignState == player.ShipType.ToGum()); var bulletVelocity = 600f; var z = 20; ContainerRuntime runtime; if (left) { runtime = ship.GetGunLeft; } else { runtime = ship.GetGunRight; } var gumCamera = RenderingLibrary.SystemManagers.Default.Renderer.Camera; var screenX = runtime.GetAbsoluteX() * gumCamera.Zoom + Camera.Main.DestinationRectangle.Left; var screenY = runtime.GetAbsoluteY() * gumCamera.Zoom + Camera.Main.DestinationRectangle.Top; var bullet = BulletFactory.CreateNew(LayerInstance); bullet.Position = new Vector3() { X = Camera.Main.WorldXAt(screenX, z, LayerInstance), Y = Camera.Main.WorldYAt(screenY, z, LayerInstance), Z = z, }; bullet.YVelocity = 100; bullet.YAcceleration = -600; bullet.TeamIndex = (int)ship.SailDesignState.Value; if (left) { bullet.XVelocity = -bulletVelocity; ship.StopAnimations(); ship.RockRightAnimation.Play(); } else { bullet.XVelocity = bulletVelocity; ship.StopAnimations(); ship.RockLeftAnimation.Play(); } }
private void CreateBullet(Vector2 Direction) { using (Weapon EquippedWeapon = ((Weapon)EquippedItem)) { float MaxAngle = (float)(EquippedWeapon.SpreadAngle / 2 / (180 / Math.PI)); float RandomAngle = FlatRedBallServices.Random.Between(-MaxAngle / 2, MaxAngle / 2); Vector2 NewDirection = Maths.RotateVector(Direction, RandomAngle); var b = BulletFactory.CreateNew(); b.Damage = EquippedWeapon.Damage; b.FlyingSpeed = EquippedWeapon.FlyingSpeed; b.Range = EquippedWeapon.Range; b.SetTrajectory(WeaponInstance.X, WeaponInstance.Y, NewDirection); } }
void CustomActivity(bool firstTimeCalled) { if (!IsInGame) { return; } PlayerShipInstance.Y = PlayerYPosition; PlayerShipInstance.X = GuiManager.Cursor.WorldXAt(0); PlayerShipInstance.EnsureStillOnScreen(); foreach (var bullet in BulletList) { if (!bullet.IsInView()) { bullet.Destroy(); } } if (!AlienList.Any()) { TriggerWinCondition(); return; } if (GuiManager.Cursor.PrimaryClick) { var bullet = BulletFactory.CreateNew(); bullet.X = PlayerShipInstance.X; bullet.Y = PlayerShipInstance.Y; bullet.Z = PlayerShipInstance.Z - 1; bullet.YVelocity = BulletSpeed; CollisionManager.Self.CreateRelationship(bullet, AlienList) .CollisionOccurred = (bullet1, alien) => { bullet.Destroy(); alien.Destroy(); }; } }
/// <summary> /// Ship Shooting /// </summary> private void ShootingActivity() { if (gamePad.ButtonPushed(Xbox360GamePad.Button.A)) { // Create Right bullet Bullet rBullet = BulletFactory.CreateNew(); rBullet.Position = this.Position; rBullet.Position += this.RotationMatrix.Up * 12; rBullet.Position += this.RotationMatrix.Right * 6; rBullet.RotationZ = this.RotationZ; rBullet.Velocity = this.RotationMatrix.Up * rBullet.MovementSpeed; //Create Left bullet Bullet lBullet = BulletFactory.CreateNew(); lBullet.Position = this.Position; lBullet.Position += this.RotationMatrix.Up * 12; lBullet.Position -= this.RotationMatrix.Right * 6; lBullet.RotationZ = this.RotationZ; lBullet.Velocity = this.RotationMatrix.Up * lBullet.MovementSpeed; } }