public BulletMemory getBullet(Bullet.BulletType bullet) { switch (bullet) { case Bullet.BulletType.YellowLazer: return(yellowLazer); case Bullet.BulletType.BlueLazer: return(blueLazer); case Bullet.BulletType.PhotonBomb: return(photonBomb); case Bullet.BulletType.BigJoe: return(bigJoe); case Bullet.BulletType.EnemyLazer: return(enemyLazer); case Bullet.BulletType.BossGun: return(bossGun); default: return(yellowLazer); } }
public void CollectResource(Resource resource) { CollectedResources[(int)resource.Colour] = resource; Score += RETURN_RESOURCE; switch (resource.IslandType) { case (Island.IslandType.Trident): bulletType = Bullet.BulletType.Trident; break; case (Island.IslandType.Bubble): bulletType = Bullet.BulletType.Bubble; break; case (Island.IslandType.Razor): bulletType = Bullet.BulletType.Razor; break; case (Island.IslandType.Magnet): bulletType = Bullet.BulletType.Magnet; break; } }
public Bullet CreateBullet(Vector4 position, Bullet.BulletType bulletType) { var bullet = new Bullet(_models["Bullet"], position + new Vector4(0, 0.1f, 0, 0), Vector4.UnitY, Vector4.Zero, 0.8f, bulletType); bullet.SetScale(new Vector3(0.05f)); return(bullet); }
private void HandleKeyboard(double dt) { var keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Key.Escape)) { Exit(); } if (keyState.IsKeyDown(Key.M)) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Point); } if (keyState.IsKeyDown(Key.Comma)) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); } if (keyState.IsKeyDown(Key.Period)) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); } if (keyState.IsKeyDown(Key.Number1)) { _bulletType = Bullet.BulletType.Straight; } if (keyState.IsKeyDown(Key.Number2)) { _bulletType = Bullet.BulletType.Wave; } if (keyState.IsKeyDown(Key.Number3)) { _bulletType = Bullet.BulletType.Seeker; } if (keyState.IsKeyDown(Key.Number4)) { _bulletType = Bullet.BulletType.SeekerExtra; } if (keyState.IsKeyDown(Key.A)) { _player.MoveLeft(); } if (keyState.IsKeyDown(Key.D)) { _player.MoveRight(); } if (!_gameOver && keyState.IsKeyDown(Key.Space) && _lastKeyboardState.IsKeyUp(Key.Space)) { var bullet = _gameObjectFactory.CreateBullet(_player.Position, _bulletType); if (_bulletType == Bullet.BulletType.Seeker || _bulletType == Bullet.BulletType.SeekerExtra) { var asteroids = _gameObjects.Where(x => x.GetType() == typeof(Asteroid)).ToList(); bullet.SetTarget((Asteroid)asteroids[bullet.GameObjectNumber % asteroids.Count]); } _gameObjects.Add(bullet); } _lastKeyboardState = keyState; }
public static Bullet GetFlyweight(Bullet.BulletType type) { if (!Cache.ContainsKey(type)) { Cache[type] = new Bullet(null, Bullet.Cache[type]); } return(Cache[type]); }
public void Update(GameTime gameTime, bool movementAllowed) { // updating current drone according to shoplevels GetActiveDrone().makeDmg = _makeDmg; GetActiveDrone().maxHealth = _maxHealth; GetActiveDrone().armor = _armor; GetActiveDrone().maxShield = _maxShield; if (_makeDmg >= 30) { curBullet = Bullet.BulletType.BlueLazer; } // updating every bullet foreach (Bullet bullet in _bulletList) { bullet.Update(gameTime); if (bullet._bulletLifeTime < 0) { _removeBulletList.Add(bullet); } // BombTrail if (bullet._trail != null) { bullet._trail.Update(gameTime, bullet.Position); } } foreach (Bullet bullet in _removeBulletList) { _bulletList.Remove(bullet); } _removeBulletList.Clear(); // updating all drones foreach (var drone in _droneShips) { drone.Update(gameTime); // Trail if (drone._trail != null) { drone._trail.Update(gameTime, drone.Position); } //drone.TrailParticles.Update(gameTime); } // let active drone receive input if (GetActiveDrone().IsNotDead&& movementAllowed) { GetActiveDrone().HandleInput(gameTime, curBullet, ref _bulletList); } }
// 弾のPrefab格納パス取得 public string GetBulletPrefabPath(Bullet.BulletType type) { if (bulletPrefabPath.Length > (int)type) { return(bulletPrefabPath[(int)type]); } else { Debug.Log("bullet type is out of range... Max:" + bulletPrefabPath.Length + ", Selected:" + (int)type); return(null); } }
public DroneBuilder() { _droneShips = new List <Drone>(); _bulletList = new List <Bullet>(); _removeBulletList = new List <Bullet>(); _makeDmg = 10; _maxHealth = 100; _armor = 1; _maxShield = 100; curBullet = Bullet.BulletType.YellowLazer; }
// 弾Prefab格納パス取得 public string GetBulletPrefabPath(Bullet.BulletType type) { string retStr = universalData.GetBulletPrefabPath(type); Debug.Log("Get BulletPrefabPath Type:" + type + ", Path:" + retStr); if (loadOK) { return(retStr); } else { Debug.Log("DataLibrarian Load Data NG -> cannot get BulletPrefabPath..."); return(null); } }
public void SetGameColour(Colour colour) { Colour = colour; LoadBullets(); Boat = Boat.InitializeFromColour(colour, content, screenWidth, screenHeight); Island = Island.InitializeFromColour(colour, content); // initially hostile to all players except self HostileToPlayer = new bool[] { true, true, true, true }; HostileToPlayer[(int)Colour] = false; // default bullet delay bulletDelay = new TimeSpan(8000000); // 0.5s bulletTimeElapsed = TimeSpan.Zero; bulletType = Bullet.BulletType.Normal; CollectedResources = new Resource[] { null, null, null, null }; }
public bool Shoot(GameTime gameTime, Bullet.BulletType bullet, int damage, Vector3 position, Vector3 direction, ref List <Bullet> bulletList) { if (_cooldownTime <= 0) { //resetting cooldown _cooldownTime = _defaultCooldown; //playing the sound //Vector3D curListenerPos = new Vector3D(Global.Camera.Target.X, Global.Camera.Target.Y, Global.Camera.Target.Z); //_engine.SetListenerPosition(curListenerPos, new Vector3D(0, 0, 1)); ISound _shootSound = _engine.Play2D(getBullet(bullet).soundSource, false, true, true); _shootSound.Volume = Global.SpeakerVolume / 10; _shootSound.Paused = false; // adding bullet to ref list bulletList.Add(new Bullet(bullet, getBullet(bullet).model, getBullet(bullet).moveSpeed, getBullet(bullet).canDmgStation, damage, position, direction)); return(true); } return(false); }
public void SetGameColour(Colour colour) { Colour = colour; LoadBullets(); Boat = Boat.InitializeFromColour(colour, content,screenWidth,screenHeight); Island = Island.InitializeFromColour(colour, content); // initially hostile to all players except self HostileToPlayer = new bool[] { true, true, true, true }; HostileToPlayer[(int)Colour] = false; // default bullet delay bulletDelay = new TimeSpan(8000000); // 0.5s bulletTimeElapsed = TimeSpan.Zero; bulletType = Bullet.BulletType.Normal; CollectedResources = new Resource[] { null, null, null, null }; }
public void CollectResource(Resource resource) { CollectedResources[(int)resource.Colour] = resource; score += RETURN_RESOURCE; switch (resource.islandType) { case(Island.IslandType.Trident): bulletType = Bullet.BulletType.Trident; break; case (Island.IslandType.Bubble): bulletType = Bullet.BulletType.Bubble; break; case (Island.IslandType.Razor): bulletType = Bullet.BulletType.Razor; break; case (Island.IslandType.Magnet): bulletType = Bullet.BulletType.Magnet; break; } }
private void HandleKeyboard(double dt) { var keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Key.Escape)) { Exit(); } if (keyState.IsKeyDown(Key.PageDown) && _lastKeyboardState.IsKeyUp(Key.PageDown)) { ToggleFullscreen(); } if (keyState.IsKeyDown(Key.M)) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Point); } if (keyState.IsKeyDown(Key.Comma)) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); } if (keyState.IsKeyDown(Key.Period)) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); } if (keyState.IsKeyDown(Key.Number1)) { _bulletType = Bullet.BulletType.Straight; } if (keyState.IsKeyDown(Key.Number2)) { _bulletType = Bullet.BulletType.Wave; } if (keyState.IsKeyDown(Key.Number3)) { _bulletType = Bullet.BulletType.Seeker; } if (keyState.IsKeyDown(Key.Number4)) { _bulletType = Bullet.BulletType.SeekerExtra; } if (keyState.IsKeyDown(Key.T)) { _useFirstPerson = false; } if (keyState.IsKeyDown(Key.F)) { _useFirstPerson = true; } if (keyState.IsKeyDown(Key.A)) { _player.MoveLeft(); } if (keyState.IsKeyDown(Key.D)) { _player.MoveRight(); } if (!_gameOver && keyState.IsKeyDown(Key.Space) && _lastKeyboardState.IsKeyUp(Key.Space)) { var bullet = _gameObjectFactory.CreateBullet(_player.Position, _bulletType); if (_bulletType == Bullet.BulletType.Seeker || _bulletType == Bullet.BulletType.SeekerExtra) { var asteroids = _gameObjects.Where(x => x.GetType() == typeof(Asteroid)).ToList(); bullet.SetTarget((Asteroid)asteroids[bullet.GameObjectNumber % asteroids.Count]); if (_useFirstPerson) { _camera = new FirstPersonCamera(bullet); } else { _camera = new ThirdPersonCamera(bullet, new Vector3(-0.3f, -0.3f, 0.1f)); } } _lastBullet = bullet; _gameObjects.Add(bullet); } _lastKeyboardState = keyState; }
public void HandleInput(GameTime gameTime, Bullet.BulletType curBullet, ref List <Bullet> bulletList) { Vector3 _oldPosition = Position; // handling rotation of the drone // Laser - Mouse control Vector3 screenDirection = this.Position - _input.getMouseInWorldPos(); screenDirection.Normalize(); float worldDirection; for (int i = 0; i < (_turnSpeed / 0.5f); i++) { worldDirection = _rotationMatrixLaser.Forward.Z * screenDirection.X - _rotationMatrixLaser.Forward.X * screenDirection.Z; if (Math.Abs(worldDirection) > 0.01) { _rotationMatrixLaser *= Matrix.CreateRotationY(MathHelper.ToRadians(Math.Sign(worldDirection) * 0.5f)); } } // Drone - Mouse control Vector3 direction = new Vector3(Global.GraphicsManager.PreferredBackBufferWidth / 2.0f, 0, Global.GraphicsManager.PreferredBackBufferHeight / 2.0f) - _input.MousePosition; direction.Normalize(); float vectorDirection; for (float i = 0.5f; i < _turnSpeed; i++) { vectorDirection = RotationMatrix.Forward.Z * direction.X - RotationMatrix.Forward.X * direction.Z; if (vectorDirection > 0.01) { //turn left RotationMatrix *= Matrix.CreateRotationY(MathHelper.ToRadians(0.5f)); } else if (vectorDirection < -0.01) { //turn right RotationMatrix *= Matrix.CreateRotationY(MathHelper.ToRadians(-0.5f)); } } // foward & backward movement if (Keyboard.GetState().IsKeyDown(Keys.W)) { //forward if (_moveSpeedModifier < _moveSpeedForward) { _moveSpeedModifier += 0.04f; } else { _moveSpeedModifier = _moveSpeedForward; } //Position -= new Vector3(0, 0, 1) * _moveSpeedModifier; } else if (Keyboard.GetState().IsKeyDown(Keys.S)) { //backward if (_moveSpeedModifier > _moveSpeedBackward) { _moveSpeedModifier -= 0.04f; } else { _moveSpeedModifier = _moveSpeedBackward; } //Position -= new Vector3(0, 0, 1) * _moveSpeedModifier; } else if (_moveSpeedModifier > 0.02f) { //forward slowing down _moveSpeedModifier -= 0.02f; } else if (_moveSpeedModifier < -0.02f) { //backward slowing down _moveSpeedModifier += 0.02f; } else { _moveSpeedModifier = 0.0f; } Position -= new Vector3(0, 0, 1) * _moveSpeedModifier; if (Keyboard.GetState().IsKeyDown(Keys.A)) { //left if (_moveSpeedModifierSideways < _moveSpeedLeft) { _moveSpeedModifierSideways += 0.04f; } else { _moveSpeedModifierSideways = _moveSpeedLeft; } } else if (Keyboard.GetState().IsKeyDown(Keys.D)) { //right if (_moveSpeedModifierSideways > _moveSpeedRight) { _moveSpeedModifierSideways -= 0.04f; } else { _moveSpeedModifierSideways = _moveSpeedRight; } } else if (_moveSpeedModifierSideways > 0.02f) { //left slowing down _moveSpeedModifierSideways -= 0.02f; } else if (_moveSpeedModifierSideways < -0.02f) { //right slowing down _moveSpeedModifierSideways += 0.02f; } else { _moveSpeedModifierSideways = 0.0f; } Position -= new Vector3(1, 0, 0) * _moveSpeedModifierSideways; // shooting the gun if (_input.IsLeftMouseButtonPressed()) { if (_alternatingGunLogic && gunPrimary.Shoot(gameTime, curBullet, Global.DroneDmg, Position - _rotationMatrixLaser.Left * 3.6f - _rotationMatrixLaser.Forward * 11.0f, _rotationMatrixLaser.Forward, ref bulletList)) { _alternatingGunLogic = false; } else if (gunPrimary.Shoot(gameTime, curBullet, Global.DroneDmg, Position - _rotationMatrixLaser.Right * 3.6f - _rotationMatrixLaser.Forward * 11.0f, _rotationMatrixLaser.Forward, ref bulletList)) { _alternatingGunLogic = true; } } if (_input.IsRightMouseButtonPressed()) { if (Global.NumberOfRockets > 0) { if (gunSecondary.Shoot(gameTime, Bullet.BulletType.BigJoe, 100, Position - _rotationMatrixLaser.Forward * 11.0f, _rotationMatrixLaser.Forward, ref bulletList)) { Global.NumberOfRockets -= 1; } } } curVelocity = Position - _oldPosition; droneMovementBoundaries(); }