//- 创建子弹 // // @param id 子弹id // @param dest 由谁发出来的子弹 // @param src 由谁发出来的子弹 // @param poShootStartPosition 子弹生成的位置 // @param poShootEndPosition 子弹要到达的位置 // @return none public void createBullet(LiveObject src, LiveObject dest, FixVector3 poShootStartPosition, FixVector3 poShootEndPosition) { BaseBullet bullet = null; //直射子弹 bullet = new DirectionShootBullet(); //根据名字加载资源 bullet.createBody(m_scBulletName); bullet.initData(src, dest, poShootStartPosition, poShootEndPosition); bullet.shoot(); if (null != bullet) { //刷新显示位置 bullet.updateRenderPosition(0); //立即记录最后的位置,否则通过vector3.lerp来进行移动动画时会出现画面抖动的bug bullet.recordLastPos(); //加入子弹列表 GameData.g_listBullet.Add(bullet); } }
private void ShootBullet() { BaseBullet bullet = bulletPool.GetOrCreate <BaseBullet>(); bullet.InitializeBullet(); bullet.SetBulletPos(this.transform.position); }
//[Berdy] Agrego el shooter para identificar el PlayerName que dispara y evitar un autodisparo (bug de disparo sobre planeta con Pusher Gun) //[Berdy] Tener en cuenta que solo sirve para comparar, si la comparacion no se hace se puede permitir el autodisparo (ej. Bala orbital) public void Shoot(int shooter) { if (!CanShoot) { Debug.Log("Weapon in cooldown state.", gameObject); return; } if (_ammo == 0) { Debug.LogError("Trying to fire a weapon with no ammo. Should have switched to the default weapon!", gameObject); return; } _particles.Play(); BaseBullet newBullet = Instantiate(_bullet, _bulletSpawnPoint.position, Quaternion.identity, null); newBullet.transform.right = _bulletSpawnPoint.transform.right; //[Berdy] Nuevo llamado a OnShoot pasandole el shooter newBullet.OnShot(shooter); // if (_ammo != -1) { _ammo--; } _lastTimeShot = Time.time; }
protected override void Shoot() { for (int i = 0; i < ShotAmount; i++) { GameObject NewLaser = Instantiate(base.Projectile, ProjectileSpawnLocations[CurrentBarrel].position, ProjectileSpawnLocations[CurrentBarrel].rotation); Transform NewLaserT = NewLaser.GetComponent <Transform>(); NewLaserT.Rotate(new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)), Random.Range(-SpreadAngle / 2, SpreadAngle / 2)); BaseBullet NewLaserScript = NewLaser.GetComponent <BaseBullet>(); NewLaserScript.Damage = ShotDamage; } //MuzzleFlare(CurrentBarrel); if (Magazine >= 1) { Magazine--; } else { StartCoroutine(Reload()); } CurrentBarrel++; if (CurrentBarrel == ProjectileSpawnLocations.Count) { CurrentBarrel = 0; } }
void Shoot() { for (int nAngle = 0; nAngle <= 180; nAngle += 10) { m_cCreateBullet = Instantiate(m_cBulletPrefab); m_cCreateBullet.transform.parent = m_cBulletParent; m_scBaseBullet = m_cCreateBullet.GetComponent <BaseBullet>(); Quaternion stRotation = m_cGun.rotation; m_cGun.Rotate(new Vector3(0f, 0f, -90f + nAngle + m_nCircleState)); m_scBaseBullet.Create(m_cGun.position, m_cGun.rotation, new Vector3(1f, 1.5f), 1, 10f, transform.tag); m_cGun.rotation = stRotation; } if (m_bCircleState == true) { if (m_nCircleState == 0) { m_nCircleState = 15; } else if (m_nCircleState == 15) { m_nCircleState = -15; } else if (m_nCircleState == -15) { m_nCircleState = 0; } } }
protected override void OnFire(byte fireStatue, Vector3 dir) { if (fireStatue == 1 && !fireCD) { fireCD = true; float offset = row % 2 == 1 ? 0 : bulletSpace / 2; float start = -Mathf.Floor(row / 2) * bulletSpace + offset; for (int i = 0; i < row; i++) { GameObject bulletGo = ObjectPool.goPool.GetObj(bulletPrefab.GetInstanceID()); if (bulletGo == null) { bulletGo = Instantiate(bulletPrefab) as GameObject; } float x = start + i * bulletSpace; bulletGo.transform.position = transform.localToWorldMatrix.MultiplyPoint(new Vector3(x, 0, 0)); bulletGo.transform.rotation = transform.rotation; BaseBullet bullet = bulletGo.GetComponent <BaseBullet>(); bullet.ResetBullet(); bullet.tagetTag = tagetTag; bullet.master = master; bullet.pookKey = bulletPrefab.GetInstanceID(); if (bullet != null) { bullet.SetDir(dir); } bulletGo.SetActive(true); } ShowFireEff(); } }
// Update is called once per frame void Update() { float delta = (360.0f / numBullets); counter += Time.deltaTime; if (counter > duration) { counter -= duration; for (int i = 1; i <= numBullets; i++) { float angle; if (b) { angle = i * delta + (delta / 2); } else { angle = i * delta; } BaseBullet.Create(Bullet, transform.position, angle); } b = !b; } }
public override void Shoot() { mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 lookDir = mousePosition - (Vector2)firePoint.position; lookDir.Normalize(); //Debug.Log(lookDir); float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90; transform.rotation = Quaternion.Euler(firePoint.rotation.x, firePoint.rotation.y, angle); if (Time.time >= bulletTimer) { GameObject bullet = ObjectPooler.Instance.SpawnFromPool(bulletUsed, firePoint.position, transform.rotation); if (bullet == null) { return; } BaseBullet bulletScript = bullet.GetComponent <BaseBullet>(); bulletScript.Owner = gameObject; bulletScript.SetDirection(Vector2.up, bulletSpeed); bulletTimer = Time.time + attackSpeed; CameraShake.Trauma = 0.3f; } }
/// <summary> /// 使用中でないBulletを探してListで返す /// </summary> /// <param name="requestNum">必要なBulletの数</param> public BaseBullet[] GetBullet(int requestNum = 1) { if (requestNum < 1) { return(null); } var array = new BaseBullet[requestNum]; var supplyNum = 0; var bulletNum = BulletList.Count; for (int i = 0; i < bulletNum; i++) { var bullet = BulletList[i]; if (bullet != null && bullet.gameObject.activeSelf == false) { array[supplyNum] = bullet; supplyNum++; if (supplyNum == requestNum) { return(array); } } } // 全て使用中だったら新しく作って返す while (supplyNum < requestNum) { var newObj = CreateNewObject(); BulletList.Add(newObj); array[supplyNum] = newObj; supplyNum++; } return(array); }
protected virtual void Shoot() { GameObject NewLaser = Instantiate(Projectile, ProjectileSpawnLocations[CurrentBarrel].position, ProjectileSpawnLocations[CurrentBarrel].rotation); Transform NewLaserT = NewLaser.GetComponent<Transform>(); NewLaserT.Rotate(new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)), Random.Range(-SpreadAngle / 2, SpreadAngle / 2)); if (HaveMuzzleParticles) MuzzleFlare(CurrentBarrel, 30); BaseBullet NewLaserScript = NewLaser.GetComponent<BaseBullet>(); NewLaserScript.Damage = ShotDamage; CurrentBarrel++; if (CurrentBarrel == ProjectileSpawnLocations.Count) CurrentBarrel = 0; if (Magazine >= 1) { Magazine--; } else { StartCoroutine(Reload()); } }
void InstanceNewBullet() { if (m_CurFireCount < m_FireCount) { if (m_FireTimes % 2 == 0) { if (m_FireEffect != null) { m_FireEffect.transform.Find(GameConstVal.ParticleName).GetComponent <ParticleSystem>().Play(); } } } for (int i = 0; i < m_CreateCount; i++) { if (m_CurFireCount < m_FireCount) { float newAngle = m_FireDtAngle * m_CurFireCount; BaseBullet bullet = GetBullet(); bullet.SetLockEnemyObj(m_LockEnemyObj); bullet.Init(m_Damage, FirePoint, m_Offset, newAngle); m_CurFireCount++; } } m_FireTimes++; }
private void Shoot(Vector3 ShootDirection, Vector3 RotateAngle, float Velocity, BaseBullet BulletPrefab) { currentBullet = SimplePool.Spawn(BulletPrefab, shootTransform.position, Quaternion.identity); currentBullet.GetComponent <Rigidbody2D>().velocity = Vector3.Normalize(ShootDirection) * Velocity; currentBullet.transform.localEulerAngles = RotateAngle; currentBullet.SetBulletDamage(playerDamage); }
/// <summary> /// Spawn new projectile /// </summary> /// <param name="worldPos">position in 2D space</param> /// <param name="speed">speed</param> /// <param name="direction">direction</param> /// <param name="source">source of projectile</param> /// <param name="damage">damage</param> /// <param name="shapeName">name of the projectile prefab</param> /// <param name="behaviourName">name of the projectile AI class</param> /// <param name="sound">projectile sound when spawning</param> /// <returns>GameObject of spawned projectile</returns> public static BaseBullet Spawn(Vector2 worldPos, float speed, Vector2 direction, GameObject source, int damage = 5, string shapeName = "Bullet", string behaviourName = "BaseBullet", string sound = null) { Type type; GameObject prefab = Resources.Load <GameObject>("Prefabs/Bullets/" + shapeName); try { type = Type.GetType(behaviourName); } catch { //type = typeof(DefaultBullet); return(null); } direction.Normalize(); GameObject result = Instantiate(prefab, worldPos, Quaternion.identity, Brain.main.area.transform); BaseBullet bulletSpawned = Activator.CreateInstance(type) as BaseBullet; bulletSpawned.bullet = result; bulletSpawned.source = source.transform.localPosition; bulletSpawned.defaultSpeed = speed; bulletSpawned.speed = speed; bulletSpawned.defaultDirection = direction; bulletSpawned.direction = direction; bulletSpawned.damage = damage; bulletSpawned.BaseInit(); result.transform.rotation = Utility.TopDownRotationFromDirection(direction); main.bullets.Add(bulletSpawned); return(bulletSpawned); }
private void CheckPlayerBulletVsEnemiesCollision(BaseBullet playerBullet) { for (var j = 0; j < onScreenEnemies.Count; j++) { var enemy = (IEnemy)onScreenEnemies[j]; CheckPlayerBulletVsEnemyCollision(playerBullet, enemy); } }
/// <summary> /// Fire the weapon /// </summary> public void Fire(Entity.EntityType entityType) { if (nozzle != null) { BaseBullet obj = Instantiate(Details.BulletPrefab, nozzle.position, nozzle.rotation); obj.SetUp(Details.Damage, Details.BulletSpeed, entityType); } }
private void CheckPlayerBulletVsBonusesCollision(BaseBullet playerBullet) { for (var j = 0; j < onScreenBonuses.Count; j++) { var bonus = (Bonus)onScreenBonuses[j]; CheckPlayerBulletVsBonusCollision(playerBullet, bonus); } }
private void CheckPlayerBulletVsWeaponsCollision(BaseBullet playerBullet) { for (var j = 0; j < onScreenWeapons.Count; j++) { var weapon = (Weapon)onScreenWeapons[j]; CheckPlayerBulletVsWeaponCollision(playerBullet, weapon); } }
private void CheckPlayerBulletVsPowerUpsCollision(BaseBullet playerBullet) { for (var j = 0; j < onScreenPowerUps.Count; j++) { var powerUp = (PowerUp)onScreenPowerUps[j]; CheckPlayerBulletVsPowerUpCollision(playerBullet, powerUp); } }
public override void RespondToCollision(GameObject hitObject) { var currentType = this.GetType().Name; var enemyType = ""; switch (currentType) { case "Minion": enemyType = "Player"; break; case "Player": enemyType = "Warrior"; break; case "Boyko": enemyType = "Player"; break; default: break; } if (hitObject is BaseBullet) { BaseBullet bullet = (BaseBullet)hitObject; if (enemyType.Equals("Minion")) { var warrior = GameEngine.GameObjects.FirstOrDefault(w => w is Minion) as Minion; if (warrior != null) { this.HealthPoints -= warrior.Attack; } } if (enemyType.Equals("Boyko")) { var boyko = GameEngine.GameObjects.FirstOrDefault(w => w is Boyko) as Boyko; if (boyko != null) { this.HealthPoints -= boyko.Attack; } } else if (enemyType.Equals("Player")) { var player = GameEngine.GameObjects.FirstOrDefault(w => w is Player) as Player; if (player != null) { this.HealthPoints -= player.Attack; } } this.State = GameObjectState.Damaged; } if (this.HealthPoints <= 0) { this.State = GameObjectState.Destroyed; } }
protected void InitBullet(Vector3 shootPosition, Vector3 shootDirection, float bulletVelocity, float bulletDamage) { currentBullet = SimplePool.Spawn(bulletPrefab, shootPosition, Quaternion.identity); currentBullet.BulletController(this); currentBullet.transform.SetParent(transform); currentBullet.SetBulletVelocity(Vector3.Normalize(shootDirection) * bulletVelocity); currentBullet.SetBulletDamage(bulletDamage); currentBulletQuantity++; }
public virtual void GetDamage(BaseBullet hitter) { Debug.Log("BaseEnemy Got Damage by" + hitter.ToString()); _hp -= hitter.bulletDamage; if (_hp <= 0) { _notifier.Notify((int)EEnemyEvent.ENEMY_DEATH); } }
public void InitBulletInControl(Vector3 DirecShot, Vector3 AngleShoot, float Velocity, float SpeedMoveTween, float Damage) { currentBullet = SimplePool.Spawn(prefabBullet, shotPos.position, Quaternion.identity); currentBullet.SetBulletControl(this); currentBullet.transform.SetParent(transform); currentBullet.SetBaseBulletVelocity(DirecShot, AngleShoot, Velocity, SpeedMoveTween); currentBullet.SetBulletDame(Damage); currentBulletQuantity++; }
public virtual void Fire(Vector3 pos) { BaseBullet b = BulletManager.Instance.Spawn(this.id); if (b != null) { b.Init(pos, angle, FoxController.Instance.facingRight); } }
public void OnLocking(BaseBullet Attacker) { if (LockedList_.Contains(Attacker)) { return; } LockedList_.Add(Attacker); }
private void AddExternBullet() { if (m_Player != null) { BaseBullet baseBullet = Global.gApp.gGameCtrl.BulletCache.GetBullet(BulletConfig.Bullet_Extern); baseBullet.SetLockEnemyObj(m_LockEnemyObj); baseBullet.Init(m_Damage, null, 0, 0); } }
void Shoot() { m_cCreateBullet = Instantiate(m_cBulletPrefab); m_cCreateBullet.transform.parent = m_cBulletParent; m_scBaseBullet = m_cCreateBullet.GetComponent <BaseBullet>(); m_scBaseBullet.Create(m_cGun.position, m_cGun.rotation, new Vector3(1f, 1.5f), 1, 10f, transform.tag); }
private void Fire() { _isFire = true; BaseBullet baseBullet = Instantiate(_bullet, _firePos.position, Quaternion.identity); baseBullet._firePos = _firePos; baseBullet.BulletMove(); Debug.Log("Test Weapon fired"); }
private void CheckPlayerBulletVsPowerUpCollision(BaseBullet playerBullet, PowerUp powerUp) { var collisionResult = playerBullet.TestCollision(powerUp, powerUp.Position - new Vector2(0, gameMap.ScrollRows), gameMap.ScrollRows); if (player.State == CharacterState.Alive && collisionResult.CollisionType == CollisionType.Blocked) { powerUp.Hit(playerBullet.Position); playerBullets.Remove(playerBullet); } }
private void CheckPlayerBulletVsWeaponCollision(BaseBullet playerBullet, Weapon weapon) { var collisionResult = playerBullet.TestCollision(weapon, weapon.Position - new Vector2(0, gameMap.ScrollRows), gameMap.ScrollRows); if (player.State == CharacterState.Alive && collisionResult.CollisionType == CollisionType.Blocked) { weapon.Hit(playerBullet.Position); playerBullets.Remove(playerBullet); } }
public void InitializeProjectile(BaseBullet loadedBullet, string tag, Vector3 bulletDirection) { bullet = loadedBullet; rb = GetComponent <Rigidbody2D>(); visualBullet = GetComponent <Animator>(); visualBullet.runtimeAnimatorController = bullet.GetSprite(); direction = Vector3.Normalize(bulletDirection - transform.position); senderTag = tag; isReady = true; }
/// <summary> /// Raises the shoot on event. /// </summary> protected override void OnShootOnEvent() { GameObject bulletPrefab = ResourceManager.GetInstance.LoadPrefab (testDB [0].Prefab); GameObject parent = StageManager.SharedInstance.EffectLayer; GameObject bullet = StageManager.SharedInstance.AddToStage (parent, bulletPrefab); baseBullet = bullet.AddComponent<BaseBullet> (); baseBullet.BattleAgent = this.BattleAgent; //baseBullet.transform.position = battleAgent.GameObject.transform.position; baseBullet.Speed = 1136.0f / 1000.0f; Vector3 pos = MapUtil.RelativeMovePosition (BattleAgent.BaseSprite.HitPoint, BattleAgent.GameObject.transform); baseBullet.transform.position = new Vector3 (pos.x, pos.y, BattleAgent.GameObject.transform.position.z); AttackMessage message = new AttackMessage (BattleAgent, BattleAgent.Targets, 1); baseBullet.AttachTarget (message); }
protected override void OnUltShootOnEvent() { List<BattleAgent> targets = BattleManager.SharedInstance.GetEnemyList (); for (int i = 0; i < targets.Count; i++) { List<BattleAgent> tlist=new List<BattleAgent>(); tlist.Add(targets[i]); GameObject bulletPrefab = ResourceManager.GetInstance.LoadPrefab (TestData.charDB [1].Prefab); GameObject parent = StageManager.SharedInstance.EffectLayer; GameObject bullet = StageManager.SharedInstance.AddToStage (parent, bulletPrefab); baseBullet = bullet.AddComponent<BaseBullet> (); baseBullet.BattleAgent = this.BattleAgent; baseBullet.transform.position = MapUtil.GetHitPointWorld(targets[i]); AttackMessage message = new AttackMessage (BattleAgent, tlist, 1); baseBullet.FlyToTargetRoot (message,0.5f); } }
protected override void OnUltShootOnEvent() { GameObject bulletPrefab = ResourceManager.GetInstance.LoadPrefab (TestData.charDB[4].Prefab); GameObject parent = StageManager.SharedInstance.EffectLayer; GameObject bullet = StageManager.SharedInstance.AddToStage (parent, bulletPrefab); baseBullet = bullet.AddComponent<BaseBullet> (); baseBullet.BattleAgent = this.BattleAgent; //baseBullet.transform.position = battleAgent.GameObject.transform.position; baseBullet.Speed = 1136.0f / 1000.0f; Vector3 pos = MapUtil.GetHitPointWorld(BattleAgent.Targets[0]); baseBullet.transform.position = pos; baseBullet.FaceTo = this.BattleAgent.BaseSprite.FaceTo; AttackMessage message = new AttackMessage (BattleAgent, BattleAgent.Targets, 1); //baseBullet.FlyToTargetOutScreen (message); baseBullet.FlyToTarget (message); }
/// <summary> /// 大招触发 /// </summary> protected override void OnUltShootOnEvent() { this.lastTargets = this.BattleAgent.Targets; //优先攻击浮空目标 Combo List<BattleAgent> floatList = BattleManager.SharedInstance.GetFloatTarget (); if (floatList.Count > 0) { this.BattleAgent.ChangeTargets(floatList); isComboAttack=true; } lastPosition = this.gameObject.transform.position; GameObject bulletPrefab = ResourceManager.GetInstance.LoadPrefab (TestData.charDB [10].Prefab); GameObject parent = StageManager.SharedInstance.EffectLayer; GameObject bullet = StageManager.SharedInstance.AddToStage (parent, bulletPrefab); baseBullet = bullet.AddComponent<BaseBullet> (); baseBullet.BattleAgent = this.BattleAgent; baseBullet.transform.position = MapUtil.GetHitPointWorld (this.BattleAgent.Targets [0]); //baseBullet去目标所在行 屏幕中间播放 StartCoroutine (MoveToSide ()); AttackMessage message = new AttackMessage (BattleAgent, this.BattleAgent.Targets, 1); if (isComboAttack) { message.ComboCount = 3; } baseBullet.AttachMiddle (message); this.BattleAgent.ChangeTargets(this.lastTargets); isComboAttack=false; }
public BulletData(GameObject slot, BaseBullet data) { beltSlotInstance_m = slot; bullet_m = data; }
public void DestroyTurret(Turret turret, BaseBullet bullet) { /* _turrets.Remove(turret); _structure.Vertices.Add(new Vector2()); var index = _structure.Vertices.FindIndex(vertex => vertex == turret.InitialPosition); var newPosition = turret.InitialPosition + bullet.Direction * 20f; _structure.Vertices[index] = newPosition; var newTurret = new Turret(GameRef, this, newPosition, _myPatterns[0]); newTurret.Initialize(); _turrets.Add(newTurret); var allVertices = new HashSet<Vector2>(_structure.Vertices).ToList(); */ //_polygonShape = new PolygonShape(GameRef.GraphicsDevice, allVertices.ToArray()); }