IEnumerator AttackCor() { yield return(new WaitForSeconds(startDelay)); while (collider.enabled) { if (monster.angry) { for (int i = 0; i < shotSpawns.Length; i++) { source.PlayOneShot(attackSound); angryBulletPool.Activate(shotSpawns[i].position, shotSpawns[i].rotation); yield return(new WaitForSeconds(Random.Range(0.01f, 0.1f))); } yield return(new WaitForSeconds(cdAngry)); } else { source.PlayOneShot(attackSound); angryBulletPool.Activate(shotSpawns[1].position, shotSpawns[1].rotation); //normalBulletPool.Activate(shotSpawn.position, shotSpawn.rotation); //normalBulletPool.Activate(shotSpawn.position, Quaternion.Euler(shotSpawn.rotation.eulerAngles + new Vector3(0f, 0f, -15f))); //normalBulletPool.Activate(shotSpawn.position, Quaternion.Euler(shotSpawn.rotation.eulerAngles + new Vector3(0f, 0f, 15f))); yield return(new WaitForSeconds(cdNormal)); } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Keypad0)) { pool.Activate(0, new Vector3(10.45f, 1f, 23.39f), Quaternion.identity); } else if (Input.GetKeyDown(KeyCode.Keypad1)) { pool.Activate(1, new Vector3(15.52f, 0.5f, 24f), Quaternion.identity); } else if (Input.GetKeyDown(KeyCode.Keypad2)) { pool.Activate(2, new Vector3(20.86f, 0.5f, 24f), Quaternion.identity); } }
//void OnTriggerEnter2D(Collider2D other) //{ // if (!hold) // { // if (other.name == "Controller") // { // hold = true; // StartCoroutine(StartAim()); // } // } //} IEnumerator StartAim() { yield return(new WaitForSeconds(aimTime)); hold = false; pool.Activate(transform.position, Quaternion.identity); }
IEnumerator AttackCor() { yield return(new WaitForSeconds(startDelay)); while (collider.enabled) { MathfFunc.RotateToPoint(Toolbox.Instance.handTransform.position, shotSpawn); if (monster.angry) { for (int i = 0; i < 10; i++) { angryBulletPool.Activate(shotSpawn.position, shotSpawn.rotation); yield return(new WaitForSeconds(0.1f)); } yield return(new WaitForSeconds(cdAngry)); } else { for (int i = 0; i < 5; i++) { normalBulletPool.Activate(shotSpawn.position, shotSpawn.rotation); yield return(new WaitForSeconds(0.1f)); } yield return(new WaitForSeconds(cdNormal)); } } }
private void Update() { if (_gameplay.IsRunning()) { if (Input.GetKeyDown(KeyCode.Space)) { _bullets.Activate(); } if (Input.GetKeyDown(KeyCode.Mouse0)) { if (_movement.IsMouse()) { _bullets.Activate(); } } } }
void Spawn() { Pool pool = presets[activePreset].pools[Random.Range(0, presets[activePreset].pools.Length)]; GameObject obj = pool.Activate(spawnPoint.position, spawnPoint.rotation); obj.GetComponent <Rigidbody2D>().velocity = Vector2.zero; obj.GetComponent <Rigidbody2D>().AddForce(startImpulseDirection.normalized * startImpulsePower, ForceMode2D.Impulse); }
// Update is called once per frame void Update() { if (Edges.topEdge > edge - height) { pool.Activate(new Vector2(0.0f, edge), Quaternion.identity); edge += height; } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name == "Hand") { //Instantiate(explosion, transform.position, transform.rotation); fireExplosionPool.Activate(transform.position, transform.rotation); fireShotPool.Deactivate(gameObject); } }
IEnumerator AttackCor() { yield return(new WaitForSeconds(startDelay)); while (true) { var obj = brickPool.Activate(shotSpawn.position, shotSpawn.rotation); //obj.GetComponent<Rigidbody2D>().AddForce(obj.transform.right*5f,ForceMode2D.Impulse); yield return(new WaitForSeconds(spawnCd + Random.Range(0f, 1f))); } }
IEnumerator SpawnDangerZone() { yield return(new WaitForSeconds(Random.Range(0f, 2f))); while (true) { Vector2 spawnPosition = new Vector2(Random.Range((float)Edges.leftEdge, (float)Edges.rightEdge), Edges.topEdge + 1); //Instantiate(flameThrower, spawnPosition, Quaternion.identity); dangerZonePool.Activate(spawnPosition, Quaternion.identity); yield return(new WaitForSeconds(dangerZoneWaveRate)); } }
IEnumerator SpawnCitizen() { while (true) { yield return(new WaitForSeconds(Random.Range(0f, 2f))); Vector2 spawnPosition = new Vector2(Random.Range((float)Edges.leftEdge + 1.0f, (float)Edges.rightEdge - 1.0f), Edges.topEdge + 1); //Instantiate(citizen, spawnPosition, Quaternion.identity); citizenPool.Activate(spawnPosition, Quaternion.identity); yield return(new WaitForSeconds(citizenWaveRate)); } }
IEnumerator SpawnBonus() { while (true) { yield return(new WaitForSeconds(Random.Range(0f, 2f))); float edge = (Random.Range(0.0f, 1.0f) > 0.5f) ? Edges.leftEdge : Edges.rightEdge; Vector2 spawnPosition = new Vector2(edge, Edges.topEdge + 1); //Instantiate(citizen, spawnPosition, Quaternion.identity); bonusPool.Activate(spawnPosition, Quaternion.identity); yield return(new WaitForSeconds(bonusWaveRate)); } }
IEnumerator AttackCor() { yield return(new WaitForSeconds(startDelay)); while (collider.enabled) { MathfFunc.RotateToPoint(Toolbox.Instance.handTransform.position, shotSpawn); if (monster.angry) { angryBulletPool.Activate(shotSpawn.position, shotSpawn.rotation); yield return(new WaitForSeconds(cdAngry)); } else { normalBulletPool.Activate(shotSpawn.position, shotSpawn.rotation); normalBulletPool.Activate(shotSpawn.position, Quaternion.Euler(shotSpawn.rotation.eulerAngles + new Vector3(0f, 0f, -15f))); normalBulletPool.Activate(shotSpawn.position, Quaternion.Euler(shotSpawn.rotation.eulerAngles + new Vector3(0f, 0f, 15f))); yield return(new WaitForSeconds(cdNormal)); } } }
IEnumerator SpawnObject(Pool pool, float waveRate) { yield return(new WaitForSeconds(Random.Range(0f, 2f))); while (true) { Vector2 spawnPosition = new Vector2(Random.Range((float)Edges.leftEdge, (float)Edges.rightEdge), Edges.topEdge + 1); //Instantiate(flameThrower, spawnPosition, Quaternion.identity); while (Physics2D.OverlapCircle(spawnPosition, 0.75f, objLayer)) { spawnPosition.y += 2.0f; } pool.Activate(spawnPosition, Quaternion.identity); yield return(new WaitForSeconds(waveRate)); } }
IEnumerator AttackCor() { yield return(new WaitForSeconds(startDelay)); float lastAttackTime = Time.time; while (true) { MathfFunc.RotateToPoint(Toolbox.Instance.head.transform.position, pistol); if (Time.time > lastAttackTime + spawnCd) { source.PlayOneShot(shootSounds[Random.Range(0, shootSounds.Length)]); var obj = bulletPool.Activate(shotSpawn.position, shotSpawn.rotation); yield return(new WaitForSeconds(spawnCd + Random.Range(0f, 1f))); } else { yield return(null); } } }
IEnumerator AttackCor() { yield return(new WaitForSeconds(startDelay)); while (collider.enabled) { MathfFunc.RotateToPoint(Toolbox.Instance.handTransform.position, shotSpawn); if (monster.angry) { particle.Stop(); lineRend.enabled = true; float startTime = Time.time; while (Time.time - startTime < 2.5f) { lineRend.SetPosition(0, shotSpawn.position); lineRend.startColor = prepareColor; lineRend.endColor = prepareColor; var hit = Physics2D.Raycast(shotSpawn.position, shotSpawn.right, 25f, laserMask); if (hit) { lineRend.SetPosition(1, hit.point + (Vector2)shotSpawn.right * 0.1f); } else { lineRend.SetPosition(1, shotSpawn.position + shotSpawn.right * 35f); } yield return(null); } startTime = Time.time; particle.Play(); while (Time.time - startTime < 2.5f) { lineRend.startColor = attackColor; lineRend.endColor = attackColor; var hit = Physics2D.Raycast(shotSpawn.position, shotSpawn.right, 25f, laserMask); if (hit) { //lineRend.SetPosition(1, hit.point + (Vector2)shotSpawn.right * 0.1f); lineRend.SetPosition(1, hit.point); if (hit.collider.gameObject.CompareTag("Player")) { Toolbox.Instance.hand.GetDamage(damage); } } else { lineRend.SetPosition(1, shotSpawn.position + shotSpawn.right * 35f); } particle.transform.position = lineRend.GetPosition(1); //particle.transform.rotation = Quaternion.Euler shotSpawn.rotation.eulerAngles; yield return(null); } particle.Stop(); lineRend.enabled = false; yield return(new WaitForSeconds(cdAngry)); } else { for (int i = 0; i < 5; i++) { normalBulletPool.Activate(shotSpawn.position, shotSpawn.rotation); yield return(new WaitForSeconds(0.1f)); } yield return(new WaitForSeconds(cdNormal)); } } }