public override void Attack() { LaserBullet bulletClone = Instantiate(bullet, attackSource.position, attackSource.rotation) as LaserBullet; bulletClone.SetDamage(baseDamage, false); bulletClone.isPlayerBullet = false; }
void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); circleCollider = GetComponent <CircleCollider2D>(); boxCollider = GetComponent <BoxCollider2D>(); capsuleCollider = GetComponent <CapsuleCollider2D>(); bulletManager = GameObject.Find("BulletManager").transform.GetChild(0).GetComponent <BulletManager>(); enemyBullet = GameObject.Find("BULLET").transform.GetChild(0); playerDatabase = GameObject.Find("PLAYER").GetComponent <PlayerDatabase>(); initializeBullet = GetComponent <InitializeBullet>(); movingBullet = GetComponent <MovingBullet>(); laserBullet = GetComponent <LaserBullet>(); reflectBullet = GetComponent <ReflectBullet>(); // 커스텀 컴포넌트 캐싱 // stage1BulletFragmentation = GetComponent<Stage1BulletFragmentation>(); // stage5BulletCreate = GetComponent<Stage5BulletCreate>(); // stage12BulletFragmentation = GetComponent<Stage12BulletFragmentation>(); // stage13BulletRotate = GetComponent<Stage13BulletRotate>(); pattern6BulletRotate = GetComponent <Pattern6BulletRotate>(); pattern6BulletAiming = GetComponent <Pattern6BulletAiming>(); pattern7BulletAiming = GetComponent <Pattern7BulletAiming>(); pattern8BulletAiming = GetComponent <Pattern8BulletAiming>(); pattern9BulletRotate = GetComponent <Pattern9BulletRotate>(); pattern14BulletRotate = GetComponent <Pattern14BulletRotate>(); pattern19BulletRotate = GetComponent <Pattern19BulletRotate>(); }
public void BulletInteractionTest() { //organization Ufo firstUfo = new Ufo(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(1, 1)); Ufo secondUfo = new Ufo(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(1, 1)); AEntity laserBullet = new LaserBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(1, 1)); GunBullet gunBullet = new GunBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(1, 1)); List <AEntity> bigAsteroidIntResult = new List <AEntity>(); bigAsteroidIntResult.Add(new Asteroid(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(2, 1), 1)); bigAsteroidIntResult.Add(new Asteroid(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(0, 1), 1)); //activity List <AEntity> laserSmalInteraction = firstUfo.Interaction(laserBullet); List <AEntity> gunSmalInteraction = secondUfo.Interaction(gunBullet); //assertion Assert.AreEqual(laserSmalInteraction, null); Assert.AreEqual(gunSmalInteraction, null); Assert.IsTrue(firstUfo.WasKilled); Assert.IsTrue(secondUfo.WasKilled); }
private void Shoot(Enemy enemy) { if (enemies.Count > 0 && enemy.position.Y < playerYposition) { var laserBullet = new LaserBullet(laserTexture, centerX, playerYposition); float a = (playerYposition - (enemy.position.Y + enemy.Height)) / (centerX - enemy.CenterX); laserBullet.Alpha = a; var aAngle = MathHelper.ToDegrees((float)Math.Atan(a)); //var x = 180 - aAngle; var angle = 180 - 90 - (180 - aAngle); laserBullet.Angle = MathHelper.ToRadians(angle); var b = (enemy.position.Y + enemy.Height) - ((enemy.CenterX) * a); laserBullet.Bparam = b; float v = ((Math.Abs(centerX - enemy.CenterX)) / ((float)refreshRate)); if (v == 0) { ; } laserBullet.Vs = v; bullets.Add(laserBullet); enemy.Shoot(); //Debug.WriteLine(String.Format(" vSpeed: {0}", v.ToString())); } }
public void StateUpdateTest() { AEntity testedBullet = new LaserBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1)); testedBullet.ChengeState(new CoupleDouble(100, 100)); Assert.IsTrue(testedBullet.WasKilled); }
private void Start() { SlowingRate = 0.5f; ReloadTime = 0; target = null; turret = new LaserTurret(); laserbullet = new LaserBullet(turret.attack); InvokeRepeating("UpdateTarget", 0f, 0.5f); }
private void OnTriggerStay2D(Collider2D collision) { LaserBullet laserBullet = gameObject.GetComponent <LaserBullet>(); if ((gameObject.layer.Equals(LayerMask.NameToLayer("BULLET_ENEMY_LASER")) && laserBullet.isLaserEnabled.Equals(true)) && collision.CompareTag("GRAZECIRCLE").Equals(true)) { isGrazing = true; } }
private void LaserShoot() { if (laserBullet == null) { laserBullet = Instantiate(bullet, transform.position + new Vector3(0, shootPadding, 0), Quaternion.identity);; laserBullet.transform.parent = transform; laserBulletScript = laserBullet.GetComponent <LaserBullet>(); laserBulletScript.Shoot(); } }
public LaserBulletXna(PlanesGame game, LaserBullet bullet, CoordinatesTransformer coordinatesTransformer) : base(game, bullet, coordinatesTransformer) { var sound = game.GameManager.GameWorldXna.SoundManager.CreateBasicSoundEffect("bullet_sound"); sound.Position = bullet.Position; sound.Play(); m_particlesEmitter = new SymmetricParticlesEmitter(game.GameManager.GameWorldXna); m_trailDrawer = new TrailDrawer(game.Content.Load <Texture2D>("Other/line_3px"), coordinatesTransformer, Color.White, 0.3, 0.2f, 0.05f, 15, 3); }
private void Attack() { if (Time.time > nextAttack) { LaserBullet bulletClone = Instantiate(bullet, attackSource.position, attackSource.rotation) as LaserBullet; bulletClone.SetDamage(baseDamage, false); bulletClone.isPlayerBullet = false; nextAttack = Time.time + attackRate; } }
private void OnTriggerEnter2D(Collider2D collision) { Obstacle obstacle = collision.GetComponentInParent <Obstacle>(); if (obstacle) { Debug.Log("Obstacle In Range!"); LaserBullet bullet = Instantiate(laserBullet, bulletSpawn.position, Quaternion.identity).GetComponent <LaserBullet>(); bullet.Target = obstacle; onShoot?.Invoke(); } }
public void FireBullet(float damage, Combatant enemy, float flightTime) { LaserBullet bullet = GameObject.Instantiate(bulletPrefab); bullet.transform.SetPositionAndRotation(this.transform.position + new Vector3(distanceToMyNose, 0, 0), this.transform.rotation); float size = Mathf.Sqrt(damage) / 10.0f; bullet.transform.localScale = new Vector3(size, size, size); bullet.GetComponent <Rigidbody>().velocity = new Vector3(distanceBetweenShips / flightTime, 0, 0); bullet.Initialize(enemy, flightTime, damage); }
void OnTriggerEnter2D(Collider2D collider) { LaserBullet bullet = collider.gameObject.GetComponent <LaserBullet>(); if (bullet) { life -= bullet.GetDamage(); if (life <= 0) { Die(); } bullet.Hit(); } }
void OnTriggerEnter2D(Collider2D collider) { LaserBullet bullet = collider.gameObject.GetComponent <LaserBullet>(); if (bullet) { life -= bullet.GetDamage(); scorePoint.addScore(hitScorePoint); if (life <= 0) { Destroy(gameObject); AudioSource.PlayClipAtPoint(dieSound, transform.position); } bullet.Hit(); } }
public void BulletInteractionTest() { GunBullet testedBullet = new GunBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1)); GunBullet someGunBullet = new GunBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1)); AEntity someLaserBullet = new LaserBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1)); List <AEntity> gunBullIntRes = testedBullet.Interaction(someGunBullet); List <AEntity> laserBullIntRes = testedBullet.Interaction(someLaserBullet); Assert.AreEqual(null, gunBullIntRes); Assert.AreEqual(null, laserBullIntRes); Assert.IsFalse(testedBullet.WasKilled); }
public void EnemyInteractionTest() { AEntity firstTestedLaserBullet = new LaserBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1)); AEntity secondTestedLaserBullet = new LaserBullet(new CoupleDouble(2, 2), new CoupleDouble(2, 2), new CoupleDouble(-1, -1)); Ufo someUfo = new Ufo(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1)); Asteroid someAsteroid = new Asteroid(new CoupleDouble(2, 2), new CoupleDouble(2, 2), new CoupleDouble(-1, -1)); List <AEntity> interUfoResult = firstTestedLaserBullet.Interaction(someUfo); List <AEntity> interaAsterResult = secondTestedLaserBullet.Interaction(someAsteroid); Assert.AreEqual(null, interUfoResult); Assert.AreEqual(null, interaAsterResult); Assert.IsTrue(firstTestedLaserBullet.WasKilled); Assert.IsTrue(secondTestedLaserBullet.WasKilled); }
public override bool Shoot(bool isVampire = false, bool isQuick = false) { if (power > 0 && Time.time > nextFire) { power--; // Create the bullet. LaserBullet bulletClone = Instantiate(bullet, spawnPoint.position, transform.rotation) as LaserBullet; bulletClone.SetDamage(baseDamage, isVampire); bulletClone.OnTargetReached = HealPlayer; // Register the vampibot delegate. // Adjust the bullet direction. RaycastHit hit; if (Physics.Raycast(cameraTransform.position, cameraTransform.forward, out hit, 500.0f)) { // If the raycast impacts, shoot exactly in that direction. bulletClone.transform.LookAt(hit.point); } else { // If the raycast does not impact, shoot to the point in the perpendicular direction of the camera. bulletClone.transform.LookAt(spawnPoint.position + cameraTransform.forward * 500.0f); } // Adjust the dispersion. Vector3 euler = bulletClone.transform.localRotation.eulerAngles; euler.x += Random.Range(-5.0f + accuracyCapacity * 4.0f, 5.0f - accuracyCapacity * 4.0f); euler.y += Random.Range(-5.0f + accuracyCapacity * 4.0f, 5.0f - accuracyCapacity * 4.0f); bulletClone.transform.localRotation = Quaternion.Euler(euler); if (isQuick) { nextFire = Time.time + fireRate * 0.5f; } else { nextFire = Time.time + fireRate; } nextRecharge = Time.time + rechargeRate; return(true); } return(false); }
// Currently not in use void ShotSpecialLaser() { List <GameObject> bullets = new List <GameObject>(); GameObject upperBullet = Instantiate(specialLaserBullet, transform.position, Quaternion.identity) as GameObject; GameObject lowerBullet = Instantiate(specialLaserBullet, transform.position, Quaternion.identity) as GameObject; upperBullet.transform.rotation *= Quaternion.Euler(0, 0, specialLaserAngle); lowerBullet.transform.rotation *= Quaternion.Euler(0, 0, -specialLaserAngle); bullets.Add(upperBullet); bullets.Add(lowerBullet); bullets.ForEach(bullet => { bullet.transform.parent = transform; LaserBullet lb = bullet.GetComponent <LaserBullet>(); lb.speed = specialLaserBulletSpeed; lb.remainTime = specialLaserRemainTime; }); }
private void Awake() { _bullet = _bulletPrefab.GetComponent <LaserBullet>(); _projectilesParent = GameObject.FindWithTag("Projectile").transform; }
void HitAnimation() { if (endAttack || canAttack == false) { return; } mHitDelta += RealTime.deltaTime; if (data.attackRate < mHitDelta) { mHitDelta = (data.attackRate > 0f) ? mHitDelta - data.attackRate : 0f; if (curFps > 0) { curFps = 0; GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f); QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui.ScaleFactor = 0.5f; endAttack = true; canAttack = false; } else { if (curEnemy != null) { GameObject bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("laserbullet")); LaserBullet bullet = bulletgo.GetComponent <LaserBullet>(); bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f; //bulletgo.transform.position = gun.position ; bullet.parent10 = this; if (enemyLists.Count > 0) { for (int i = 0; i < EnemySpawnManager._instance.enemyList.Count; i++) { for (int j = 0; j < enemyLists.Count; j++) { if (EnemySpawnManager._instance.enemyList[i].ID == enemyLists[j].ID) { curEnemy = enemyLists[j]; break; } } if (curEnemy != null) { break; } } if (curEnemy != null) { AudioSource.PlayClipAtPoint(AudioManager._instance.tower10FireMusic, this.GetPos()); bullet.Fire(curEnemy); } Vector3 dir = Vector3.back * moveDistance; GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z); QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui.ScaleFactor = scalefactor; curFps++; } else if (enemyLists.Count == 0) { curEnemy = null; return; } } } } }
/// <summary> /// Allows the page to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> private void OnUpdate(object sender, GameTimerEventArgs e) { // TODO: Add your update logic here refreshRate = (int)(1 / ((double)e.ElapsedTime.Milliseconds / 1000d)); if (isGameOver == false) { #region key control var eq = enemies.Where(x => x.FirstCharacter.Equals(keysQueue.Text, StringComparison.OrdinalIgnoreCase) && !String.IsNullOrEmpty(x.FirstCharacter)).FirstOrDefault(); if (eq != null) { Debug.WriteLine(String.Format(" shoot {0} keys {1}", eq.FirstCharacter, keysQueue.Count.ToString())); Shoot(eq); keysQueue.Clear(); } else { var eqp = enemies.Where(x => x.Text.StartsWith(keysQueue.Text, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (eqp != null) { ; } else { keysQueue.Clear(); } } #endregion CreateEnemy(); LaserBullet tmpBullet = null; foreach (var laserBullet in bullets) { if (laserBullet != null) { laserBullet.Update(); if (laserBullet.x < 0 || laserBullet.y < 0) { //laserBullet = null; tmpBullet = laserBullet; } } } bullets.Remove(tmpBullet); #region collisions Enemy tmp = null; foreach (var item in enemies) { item.Update(); if (item.position.Y > SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Height) { tmp = item; } if (item.ShouldBeRemoved) { tmp = item; } foreach (var laserBullet in bullets) { if (laserBullet != null && laserBullet.Bounds.Intersects(item.Bounds)) { //remove letter form item item.Hit(); tmpBullet = laserBullet; score += 20; } } bullets.Remove(tmpBullet); if (item.Bounds.Intersects(player.Bounds) && item.IsExploding == false) { player.Explode(); item.Explode(); playExplodeSound(); } } if (tmp != null) { enemies.Remove(tmp); tmp = null; } #endregion #region end game var enemyToExplode = enemies.Where(x => x.IsExploding == false && x.CenteryY > SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Height - 40).ToList(); if (enemyToExplode.Count > 0) { foreach (var item in enemyToExplode) { item.Explode(); playExplodeSound(); } } if (player.IsExploded || enemies.Any(x => x.IsExploded)) { //remove all game over isGameOver = true; enemies.Clear(); } #endregion } else { endGameScore.Update(); var touchCollection = TouchPanel.GetState(); if (touchCollection.Count > 0) { if (NavigationService.CanGoBack) { NavigationService.GoBack(); } else { NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } } } player.Update(); particleSystem.Update(e.ElapsedTime.Milliseconds / 2000f); //background.Update(SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Bounds); }
private LaserGun(TimeSpan minimalTimeBetweenShots, double initialVelocity, double maximumCharge, double regeneration, LaserBullet bulletPrototype, Vector bulletOffset) : base(minimalTimeBetweenShots, initialVelocity, maximumCharge, regeneration, bulletPrototype, bulletOffset) { Size = new Size(1.2, 1.3); }