private static void Detect(BulletPool bulletPool) { bulletPool.bullets.Clear(); var selfPath = AssetDatabase.GetAssetPath(bulletPool); var lastIndex = selfPath.LastIndexOf('/'); var guidList = AssetDatabase.FindAssets("", new[] { selfPath.Substring(0, lastIndex) }); foreach (var guid in guidList) { var assetPath = AssetDatabase.GUIDToAssetPath(guid); var prefab = AssetDatabase.LoadMainAssetAtPath(assetPath) as GameObject; if (prefab is null) { continue; } var type = PrefabUtility.GetPrefabAssetType(prefab); if (type != PrefabAssetType.Regular && type != PrefabAssetType.Variant) { continue; } if (prefab.TryGetComponent(out IBulletSystem bulletSystem)) { bulletPool.bullets.Add(bulletSystem.Name, bulletSystem); } } }
private void Awake() { characterController2D = GetComponent <CharacterController2D>(); rigidbody2D = GetComponent <Rigidbody2D>(); collider = GetComponent <Collider2D>(); animator = GetComponent <Animator>(); spriteRenderer = GetComponent <SpriteRenderer>(); originalColor = spriteRenderer.color; if (projectilePrefab != null) { bulletPool = BulletPool.GetObjectPool(projectilePrefab.gameObject, 8); } spriteForward = spriteFaceLeft ? Vector2.left : Vector2.right; if (spriteRenderer.flipX) { spriteForward = -spriteForward; } if (meleeDamager != null) { EndAttack(); } }
private void Awake() { m_HashMeleeAttackPara = Animator.StringToHash(meleeAttackTransitionName); m_HashShootingPara = Animator.StringToHash(rangeAttackTransitionName); m_CharacterController2D = GetComponent <CharacterController2D>(); m_Collider = GetComponent <Collider2D>(); m_Animator = GetComponent <Animator>(); m_SpriteRenderer = GetComponent <SpriteRenderer>(); m_OriginalColor = m_SpriteRenderer.color; if (projectilePrefab != null) { m_BulletPool = BulletPool.GetObjectPool(projectilePrefab.gameObject, 8); } m_SpriteForward = spriteFaceLeft ? Vector2.left : Vector2.right; if (m_SpriteRenderer.flipX) { m_SpriteForward = -m_SpriteForward; } if (meleeDamager != null) { EndAttack(); } }
public GameObject CreateBullet(GameObject prefab, Transform fier_point, bool isdestroy) { GameObject temp = null; if (BulletPool.Count > 0) { temp = BulletPool[0]; BulletPool.Remove(temp); temp.SetActive(true); } else { temp = Instantiate(prefab); } temp.transform.position = fier_point.position; temp.transform.rotation = fier_point.rotation; temp.tag = SenceGameObject.PLAYER_BULLET_TAG; Collider_items co = temp.AddComponent <Collider_items>(); co.recever = this; if (temp.GetComponent <Rigidbody>()) { Rigidbody rb = temp.GetComponent <Rigidbody>(); rb.useGravity = false; rb.isKinematic = false; rb.AddForce(fier_point.forward * LUACH_FORCE * 2); } if (isdestroy) { // Destroy(temp, 5f); } return(temp); }
void Awake() { instance = this; hitPos = HitPos.instance; BP = BulletPool.instance; InitializeProperties(); }
// Start is called before the first frame update void Start() { _rb = GetComponent <Rigidbody2D>(); _managerObj = GameObject.FindGameObjectWithTag("Manager"); _manager = _managerObj.GetComponent <BulletPool>(); }
// Use this for initialization protected virtual void Start() { //Debug.Log("Starting bullet"); rb = GetComponent <Rigidbody>(); //Destroy(gameObject, lifeTime); //audioSource = GetComponent<AudioSource>(); // explosiveBullet = GetComponent <ExplosiveBullet>(); // bulletSoundManager = FindObjectOfType <AudioObjectManager>(); // bulletPool = FindObjectOfType <BulletPool>(); // missileComponent = GetComponent <Missile>(); // trailRenderer = GetComponent <TrailRenderer>(); // TODO: Esto ahora va en el POOL if (dangerousEnough) { // Instanciamos el trail renderer carolHelp = FindObjectOfType <CarolBaseHelp>(); if (drawTrayectory) { detectionTrail = Instantiate(carolHelp.dangerousProyetilesTrailPrefab, transform.position, Quaternion.identity); detectionTrailRenderer = detectionTrail.GetComponent <LineRenderer>(); // //AllocateTrailRenderer(); } // //carolHelp.TriggerGeneralAdvice("DangerIncoming"); // //bulletPool.AddDangerousBulletToList(gameObject); } }
public void Start() { //测试 anim = GetComponentInChildren <AnimatorPlay>(); pool = GameObject.FindGameObjectWithTag("Respawn").GetComponent <BulletPool>(); dazzleInsist = anim.currentAnimName == AnimationName.swordAttack_3 || anim.currentAnimName == AnimationName.gunAttack_3; }
public void Update() { TimeUpdate(); if (dead) { return; } SetRotation(); if (t > splitTime && !didSplit) { didSplit = true; for (int x = 0; x < 8; x++) { float angle = ((float)x) / 8; BulletPool obj = BulletPool.GetObject(); obj.spawnTime = spawnTime + splitTime; obj.dir = new Vector3(Mathf.Sin(angle * 2 * 3.141529f), -Mathf.Cos(angle * 2 * 3.141529f), 0); obj.parentAgeAtBirth = GameManager.time - spawnTime; obj.Init(evaluable); obj.transform.localScale *= 0.2f; obj.scheduledDeathTime = 4; obj.splitTime = 100; } } CheckCounts(); }
protected override void Fire() { float angleStep = 360 / Amount; float angle = 0; float directionX; float directionY; Vector2 direction; for (int i = 0; i < Amount + 1; i++) { directionX = Mathf.Cos((angle * Mathf.PI) / 180f); directionY = Mathf.Sin((angle * Mathf.PI) / 180f); direction = new Vector2(directionX, directionY); direction = direction.normalized; Bullet bullet = BulletPool.GetBullet(); bullet.transform.position = transform.position + (Vector3)direction * 2f; bullet.transform.eulerAngles = new Vector3(0, 0, angle - 90); bullet.gameObject.SetActive(true); bullet.SetData(direction, 3, 0.1f, 10f, 1, 0); angle += angleStep; } _count++; if (_count == 3) { CancelInvoke("Fire"); } }
protected void Start() { // proyectileRb = GetComponent <Rigidbody>(); audioObjectManager = FindObjectOfType <AudioObjectManager>(); bulletPool = FindObjectOfType <BulletPool>(); bulletScript = GetComponent <Bullet>(); // Tenemos que mirar bien la conversion kg/TNT -> julios -> newton // Julios = newtons/m // Para aplicar la cantidad correcta de fuerza // Recordando también kilos -> toneladas // We calculate the force with the proportion of kilograms in TNT //explosionForce = explosiveLoad * 4184000; explosionForce = explosiveLoad * 4.184f; shockWaveRange = Mathf.Sqrt(explosionForce); // Debug.Log("Explosion range: " + shockWaveRange); // Recordar que el peso de los rigidbodies lo medimos en toneladas // Vamos a asumir que la masa de cada fragmento es la fracción correspondiente del proyectil // Una vez descontada la carga explosiva //if (generatesFragments) // fragmentMass = (proyectileRb.mass - (explosiveLoad / 1000)) / (fragmentsPerHeight * fragmentsPerWidth); }
private void Start() { m_sphere = GameObject.FindGameObjectWithTag("Player"); var bulletRoot = GameObject.Find("SphereBulletRoot"); m_bulletPool = bulletRoot.GetComponent <BulletPool>(); }
// Use this for initialization void Start() { mainCamera = Camera.main.transform; inputManager = FindObjectOfType <InputManager>(); //cameraControl = mainCamera.GetComponent<SpringCamera>(); cameraControl = FindObjectOfType <SpringCamera>(); rb = GetComponent <Rigidbody>(); repulsor = GetComponent <Repulsor>(); gameManager = FindObjectOfType <GameManager>(); audioSource = GetComponent <AudioSource>(); //impactInfoManager = FindObjectOfType<ImpactInfoManager>(); bulletPool = FindObjectOfType <BulletPool>(); // TODO: No hacerlo tan hardcodeado bulletPool.RegisterBullets(elipticProyectilePrefab, 30, 10); // PlayerReference.Initiate(gameObject); // lastAxisXZ = Vector3.forward; // proyectileToUse = elipticProyectilePrefab; proyectileRb = proyectileToUse.GetComponent <Rigidbody>(); PlayerReference.currentProyectileRB = proyectileRb; // Recordar que la masa va en gramos (de momento) currentMuzzleSpeed = gameManager.playerAttributes.forcePerSecond.CurrentValue / (gameManager.playerAttributes.massPerSecond / 1000); // Debug.Log("Muzzle speed :" + currentMuzzleSpeed); }
// Use this for initialization // Use this for initialization void Start() { base.Start(); ReadData("EnemyState"); pool = GameObject.FindGameObjectWithTag("Respawn").GetComponent <BulletPool>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerState>(); }
private void Awake() { if (!_instance && (!_instance == this)) { _instance = this; } _bullet = Resources.Load("Prefabs/Bullet") as GameObject; _bulletSpawn = transform.Find("BulletSpawn"); // Initiate bullet pools _inactivePool = new List <GameObject>(); _activePool = new List <GameObject>(); GameObject obj; for (int i = 0; i < _size; ++i) { obj = Instantiate(_bullet, _bulletSpawn.transform.position, Quaternion.identity); _inactivePool.Add(obj); obj.hideFlags = HideFlags.HideInHierarchy; obj.SetActive(false); } shotsFired = 0; }
private void DeactivateAndEnqueue() { if (BulletPool.GetInstance() != null) { BulletPool.GetInstance().Enqueue(this); } }
void Awake() { bulletPool = BulletPool.GetObjectPool(bullet, 5); animator = GetComponent <Animator>(); frame = transform.parent.GetComponentInParent <Frame>(); frame.onPlayerExitFrame.AddListener(OnPlayerExitFrame); }
private void Awake() { if (Instance == null) { Instance = this; } }
private void Awake() { property = GetComponent <ShipProperty>(); bulletManager = GameObject.Find("BulletManager"); bulletPool = bulletManager.GetComponent <BulletPool>(); dirIdx = 0; }
void Shoot(float speed) { GameObject g2 = BulletPool.getBullet(); //bullets[0]; if (g2 == null) { //Debug.Log ("well shit"); return; } Vector3 temp = Input.mousePosition; temp.z = 0f; Ray ray = Camera.main.ScreenPointToRay(temp); temp = ray.origin; // temp = Vector3. g2.GetComponent <Rigidbody2D>().velocity = Vector2.zero; g2.GetComponent <Rigidbody2D>().angularVelocity = 0f; g2.transform.position = player.transform.position; // g2.transform.LookAt(temp); // g2.rigidbody2D.AddForce(g2.transform.up*1000f); Vector3 finalTemp = ray.origin - player.transform.position; finalTemp.z = 0f; //*10000f); //g2.rigidbody2D.AddForce((finalTemp.normalized)*(10000f));//+rigidbody2D.velocity.magnitude*10000f)); g2.GetComponent <Rigidbody2D>().AddForce(((Vector2)finalTemp.normalized) * (10000f) + (GetComponent <Rigidbody2D>().velocity *1000f)); //+rigidbody2D.velocity.magnitude*10000f)) }
public bool FireBullet(BulletPool pool, int idx, Vector3 startPos, Vector3 startAngle, Gunner shooter, Gunner target) { if (target == null) { return(false); } if (idx < 0 || idx >= m_bulletPool[(int)pool].Count) { Debug.Log("the bullet idx is out of the range"); return(false); } if (m_bulletPool[(int)pool][idx].Count == 0) { Debug.Log("the bullets is not allocated"); return(false); } m_bulletPool[(int)pool][idx][m_bulletPoolIndex[(int)pool][idx]].gameObject.SetActive(true); m_bulletPool[(int)pool][idx][m_bulletPoolIndex[(int)pool][idx]].Fire(startPos, startAngle, shooter, target); m_bulletPoolIndex[(int)pool][idx] += 1; if (m_bulletPoolIndex[(int)pool][idx] >= m_bulletPool[(int)pool][idx].Count) { m_bulletPoolIndex[(int)pool][idx] = 0; } return(true); }
/// <summary> /// Processes trigger collisions with other game objects /// </summary> /// <param name="other">information about the other collider</param> void OnTriggerEnter2D(Collider2D other) { // if colliding with teddy bear, add score, destroy teddy bear, // and return self to pool if (other.gameObject.CompareTag("Enemy")) { unityEvents[EventName.PointsAddedEvent].Invoke(ConfigurationUtils.BearPoints); Instantiate(prefabExplosion, other.gameObject.transform.position, Quaternion.identity); // Destroy(other.gameObject); Instantiate(prefabExplosion, transform.position, Quaternion.identity); BulletPool.ReturnBullets(gameObject); EnemyPool.ReturnEnemies(other.gameObject); } else if (other.gameObject.CompareTag("EnemyProjectile")) { // if colliding with teddy bear projectile, destroy projectile and // return self to pool Instantiate(prefabExplosion, other.gameObject.transform.position, Quaternion.identity); Destroy(other.gameObject); Instantiate(prefabExplosion, transform.position, Quaternion.identity); BulletPool.ReturnBullets(gameObject); } }
// Start is called before the first frame update void Start() { player = FindObjectOfType <RobotControl>(); if (player != null) { playerRB = player.GetComponent <Rigidbody>(); } // shootPoint = transform.Find("Shoot Point"); if (shootPoint == null) { shootPoint = transform.Find("Barrel/Shoot Point"); } // originalRotation = transform.localRotation; // audioSource = GetComponent <AudioSource>(); // bodyRb = GetComponentInParent <Rigidbody>(); // Registramos las correspondientes balas en el pool bulletPool = FindObjectOfType <BulletPool>(); Bullet bulletData = proyectilePrefab.GetComponent <Bullet>(); bulletPool.RegisterBullets(proyectilePrefab, rateOfFire, bulletData.lifeTime); }
public void ShootHelix() { // Increment timer t_rotateToPosition += Time.deltaTime; // rotate to position if (t_rotateToPosition <= 2) { transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 90, 0), Time.deltaTime); } else // Fire helix shot { // hot dog roll the ship transform.Rotate(Time.deltaTime * 300, 0, 0); if (t_fireRate > fireRate) { foreach (var e in emitters) { GameObject bulletInst = BulletPool.GetInstance().GetBullet_Boss(); AudioManager.GetInstance().PlaySoundOnce(AudioManager.Sound.EnemyFire2, AudioManager.Priority.Low, transform); bulletInst.SetActive(true); bulletInst.transform.position = e.transform.position; bulletInst.transform.LookAt(player.transform.position); t_fireRate = 0; } } } }
void Start() { bulletPool = BulletPool.instance; gameManager = GameManager.Instance; bulletDamage = gameManager.BulletDamage; bulletPenetration = gameManager.BulletPenetration; }
// ----------------------------------------------------- protected override void Awake() { base.Awake(); // register in List A or B w = MonoBehaviour.FindObjectOfType(typeof(Weapon)) as Weapon; bp = MonoBehaviour.FindObjectOfType(typeof(BulletPool)) as BulletPool; this.Radius = 1; }
private void OnTriggerEnter2D(Collider2D collision) { var obj = collision.gameObject; while (obj) { if (Ship == obj) { return; } var parentTransform = obj.transform.parent; if (!parentTransform) { break; } obj = parentTransform.gameObject; } obj = collision.gameObject; Ship ship = obj.GetComponent <Ship>(); ShildFunction shild = obj.GetComponent <ShildFunction>(); if (ship) { OnBoom(); ship.Boom(Damage, WeaponType); BulletPool.get().Recycle(gameObject); } if (shild) { OnBoom(); shild.Boom(Damage, WeaponType); BulletPool.get().Recycle(gameObject); } }
public void Start() { sprite = GetComponent <SpriteRenderer>().sprite; pool = Pools.bulletPools.Find(x => x.type == data.bulletType); bulletCount = bulletInHolder; bulletPool = GameObject.FindGameObjectWithTag("BulletPool").transform; }
void Awake() { if (Singleton == null) { Singleton = this; } else { Destroy(this); } bullets = new GameObject[numBullets]; bullets_Boss = new GameObject[numBossBullets]; for (int i = 0; i < numBullets; i++) { GameObject b = Instantiate(bulletPrefab, transform); b.SetActive(false); bullets[i] = b; } for (int i = 0; i < numBossBullets; i++) { GameObject bullet = Instantiate(bulletBossPrefab, transform); bullet.SetActive(false); bullets_Boss[i] = bullet; } }
protected override void Fire() { float angleStep = 360 / Amount; float angle = angleStep * _count; _count = (_count + 1) % Amount; float directionX; float directionY; Vector2 direction; if (_count % 10 == 0) { angle += angleStep; return; } directionX = Mathf.Cos((angle * Mathf.PI) / 180f); directionY = Mathf.Sin((angle * Mathf.PI) / 180f); direction = new Vector2(directionX, directionY); direction = direction.normalized; Bullet bullet = BulletPool.GetBullet(); bullet.transform.position = transform.position + (Vector3)direction * 2f; bullet.transform.eulerAngles = new Vector3(0, 0, angle + 90); bullet.gameObject.SetActive(true); bullet.SetData(direction, 2, 3f, 3f, 0, 0); }
void OnEnable() { pool = serializedObject.FindProperty("pool"); bulletPrefab = serializedObject.FindProperty("bulletPrefab"); inspectedComponent = target as BulletPool; }
// ----------------------------------------------------- public virtual void Awake() { wpn = MonoBehaviour.FindObjectOfType(typeof(Weapon)) as Weapon; p = MonoBehaviour.FindObjectOfType(typeof(Pool)) as Pool; bp = MonoBehaviour.FindObjectOfType(typeof(BulletPool)) as BulletPool; s = MonoBehaviour.FindObjectOfType(typeof(Ship)) as Ship; gameStarted = true; }
// Use this for initialization public void initialize(float x, float z, Quaternion nheading, BulletPool pool, Team.TeamEnum alignment = Team.TeamEnum.kEnemy) { bPool = pool; this.alignment = alignment; temp.Set(x, bullet_height, z); gameObject.transform.position = temp; gameObject.transform.rotation = nheading; velocity.Set(0.0f, 0.0f, bullet_speed); }
void Start() { ContainerObject = new GameObject("Bullets"); _instance = this; m_tPooledObjects = new List<GameObject>(); for ( int n=0; n<DefaultBufferSize; n++) { GameObject tObj = Instantiate(BulletPrefab) as GameObject; tObj.transform.parent = ContainerObject.transform; tObj.name = "Bullet"; PoolObject(tObj); } }
// Use this for initialization void Start () { gun = new BulletPool(pool_size, bullet_class); }
void Awake() { current = this; }
public SpawnBullet_Command(BulletPool p_bulletPool, Vector2 p_spawnPosition, Vector2 p_direction) { m_spawnPosition = p_spawnPosition; m_bulletPool = p_bulletPool; m_direction = p_direction; }
public virtual void Start() { m_cmanager = Managers.GetInstance().GetCommandManager(); m_bulletPool = Managers.GetInstance().GetBulletPoolManager().GetBulletPool(100, Managers.GetInstance().GetGameProperties().enemyBulletPrefab); m_sineBulletPool = Managers.GetInstance().GetBulletPoolManager().GetBulletPool(40, Managers.GetInstance().GetGameProperties().sineEnemyBulletPrefab); }
void Awake(){ instance = this; }
//initialization public void Start() { m_inp = Managers.GetInstance().GetInputManager(); m_cmanager = Managers.GetInstance().GetCommandManager(); m_bulletPool = Managers.GetInstance().GetBulletPoolManager().GetBulletPool(20, Managers.GetInstance().GetGameProperties().playerBulletPrefab); m_moveTimer = m_cmanager.GetTimer(); m_isAlive = true; m_explosion = transform.GetChild(0).gameObject; m_sprite = GetComponent<SpriteRenderer>(); m_deathCounter = 0; m_stillDead = false; }
public void AddSpawnBulletCommand(BulletPool p_bulletPool, Vector2 m_position, Vector2 m_direction) { if (!m_isRewinding) { m_currentFrame.Value.AddFirst(new SpawnBullet_Command(p_bulletPool, m_position, m_direction)); m_currentFrame.Value.First.Value.Execute(); //execute the command you just added } }
public void SetBulletManager(BulletPool p_bulletManager) { m_bulletManager = p_bulletManager; }
// Use this for initialization void Start() { bulletpool = GetComponent<BulletPool>(); }
// Use this for initialization void Start() { physics = GetComponent<EntityPhysics>(); entity = GetComponent<Entity>(); animator = GetComponent<Animator>(); bulletPool = GetComponent<BulletPool>(); sprite = GetComponent<SpriteRenderer>(); }