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>(); }
void Start() { initializeBullet = GetComponent <InitializeBullet>(); movingBullet = GetComponent <MovingBullet>(); StartCoroutine(RotateBullet()); }
void Start() { initializeBullet = GetComponent <InitializeBullet>(); movingBullet = GetComponent <MovingBullet>(); playerObject = GameObject.Find("PLAYER"); StartCoroutine(SetBullet()); }
// 탄막 그레이즈 private void OnTriggerEnter2D(Collider2D collision) { InitializeBullet initializeBullet = gameObject.GetComponent <InitializeBullet>(); if ((CompareTag("BULLET_ENEMY").Equals(true) && collision.CompareTag("GRAZECIRCLE").Equals(true)) && initializeBullet.isGrazed.Equals(false)) { playerDatabase.grazeCount++; initializeBullet.isGrazed = true; } }
void Start() { enemyFire = GameObject.Find("ENEMY").GetComponent <EnemyFire>(); spriteRenderer = GetComponent <SpriteRenderer>(); initializeBullet = GetComponent <InitializeBullet>(); movingBullet = GetComponent <MovingBullet>(); rotateCount = 0; StartCoroutine(RotateBullet()); }
void Start() { circleCollider2D = GetComponent <CircleCollider2D>(); capsuleCollider2D = GetComponent <CapsuleCollider2D>(); boxCollider2D = GetComponent <BoxCollider2D>(); rigidbody2D = GetComponent <Rigidbody2D>(); gameManager = GameObject.Find("MANAGER").transform.GetChild(0).GetComponent <GameManager>(); playerObject = GameObject.Find("PLAYER"); initializeBullet = GetComponent <InitializeBullet>(); movingBullet = GetComponent <MovingBullet>(); playerDatabase = playerObject.GetComponent <PlayerDatabase>(); bulletRotateTime = 0.0f; grazeDelay = 0.0f; isGrazing = false; }
private void OnTriggerEnter2D(Collider2D collision) { GameObject player = GameObject.Find("PLAYER"); PlayerMove playerMove = player.GetComponent <PlayerMove>(); // PlayerDie playerDie = player.GetComponent<PlayerDie>(); InitializeBullet initializeBullet = GetComponent <InitializeBullet>(); if (gameObject.layer.Equals(LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_INNER1")) && collision.gameObject.layer.Equals(LayerMask.NameToLayer("DESTROYZONE_INNER1"))) { ClearBullet(); } else if (gameObject.layer.Equals(LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_INNER2")) && collision.gameObject.layer.Equals(LayerMask.NameToLayer("DESTROYZONE_INNER2"))) { ClearBullet(); } else if (gameObject.layer.Equals(LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_OUTER1")) && collision.gameObject.layer.Equals(LayerMask.NameToLayer("DESTROYZONE_OUTER1"))) { ClearBullet(); } else if (gameObject.layer.Equals(LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_OUTER2")) && collision.gameObject.layer.Equals(LayerMask.NameToLayer("DESTROYZONE_OUTER2"))) { ClearBullet(); } else if ((gameObject.layer.Equals(LayerMask.NameToLayer("BULLET_ENEMY_LASER")) && gameObject.GetComponent <InitializeBullet>().bulletType.Equals(BulletType.BULLETTYPE_LASER_MOVE)) && collision.gameObject.layer.Equals(LayerMask.NameToLayer("DESTROYZONE_LASER"))) { ClearBullet(); } else if ((CompareTag("BULLET_ENEMY").Equals(true) || CompareTag("BULLET_ENEMY_EMPTY").Equals(true)) && collision.gameObject.layer.Equals(LayerMask.NameToLayer("DESTROYZONE_ALL"))) { ClearBullet(); } else if ((CompareTag("BULLET_ENEMY").Equals(true) && collision.CompareTag("PLAYER").Equals(true)) && playerMove.isDamaged.Equals(false)) { playerDatabase.hitCount++; // playerMove.isDamaged = true; // StartCoroutine(playerDie.CreateDieEffect()); if (initializeBullet.bulletType.Equals(BulletType.BULLETTYPE_NORMAL)) { ClearBullet(); } } }
private void OnTriggerEnter2D(Collider2D collision) { SpriteRenderer spriteRenderer = this.GetComponent <SpriteRenderer>(); InitializeBullet initializeBullet = this.GetComponent <InitializeBullet>(); MovingBullet movingBullet = this.GetComponent <MovingBullet>(); if (!initializeBullet.bulletReflect.Equals(BulletReflect.BULLETREFLECT_NONE) && collision.tag.Equals("REFLECTZONE")) { if (this.gameObject.activeSelf.Equals(true) && reflectCount < reflectLimit) { reflectCount++; if (collision.gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_LEFTRIGHT"))) { movingBullet.ChangeRotateAngle(movingBullet.GetAngle() * -1); } else if ((collision.gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_TOP"))) || (collision.gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_BOTTOM")) && initializeBullet.bulletReflect.Equals(BulletReflect.BULLETREFLECT_CONTAINBOTTOM))) { if (movingBullet.GetAngle() >= 0.0f && movingBullet.GetAngle() <= 180.0f) { movingBullet.ChangeRotateAngle(180.0f - movingBullet.GetAngle()); } else { movingBullet.ChangeRotateAngle(-180.0f - movingBullet.GetAngle()); } } if (!(collision.gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_BOTTOM")) && !initializeBullet.bulletReflect.Equals(BulletReflect.BULLETREFLECT_CONTAINBOTTOM))) { if (isSpriteChange.Equals(true)) { spriteRenderer.sprite = enemyFire.spriteCollection[changeSpriteNumber]; } if (isEffectOutput.Equals(true)) { StartCoroutine(enemyFire.CreateBulletFireEffect(effectSpriteNumber, scaleDownSpeed, scaleDownTime, alphaUpSpeed, transform.position)); } } } } }
void Start() { initializeBullet = GetComponent <InitializeBullet>(); capsuleCollider2D = GetComponent <CapsuleCollider2D>(); movingBullet = GetComponent <MovingBullet>(); eraseBullet = GetComponent <EraseBullet>(); // 최초 변수 초기화 및 박스 콜라이더 해제 laserEnableDelay = 0.0f; laserDisableDelay = 0.0f; if (initializeBullet.bulletType.Equals(BulletType.BULLETTYPE_LASER_HOLD)) { transform.localScale = new Vector3(0.25f, transform.localScale.y, transform.localScale.z); } else { transform.localScale = new Vector3(0.15f, transform.localScale.y, transform.localScale.z); } }
public IEnumerator Fragmentation() { while (true) { // 탄막 2 발사 (파란색 원탄) (랜덤탄) if (movingBullet.bulletMoveSpeed <= 0.0f) { Vector2 bulletFirePosition = transform.position; // 탄막 2 이펙트 StartCoroutine(enemyFire.CreateBulletFireEffect(301, 1.0f, 12.0f, 0.4f, 0.1f, 0.35f, bulletFirePosition)); if (bulletManager.bulletPool.Count > 0) { for (int i = 0; i < 16; i++) { GameObject bullet = bulletManager.bulletPool.Dequeue(); bullet.SetActive(true); EnemyFire.ClearChild(bullet); bullet.transform.position = transform.position; bullet.gameObject.tag = "BULLET_ENEMY"; bullet.gameObject.layer = LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_INNER1"); bullet.transform.SetParent(enemyBullet); if (!bullet.GetComponent <SpriteRenderer>()) { bullet.AddComponent <SpriteRenderer>(); } if (!bullet.GetComponent <CircleCollider2D>()) { bullet.AddComponent <CircleCollider2D>(); } if (!bullet.GetComponent <InitializeBullet>()) { bullet.AddComponent <InitializeBullet>(); } if (!bullet.GetComponent <MovingBullet>()) { bullet.AddComponent <MovingBullet>(); } if (!bullet.GetComponent <EraseBullet>()) { bullet.AddComponent <EraseBullet>(); } SpriteRenderer spriteRenderer = bullet.GetComponent <SpriteRenderer>(); CircleCollider2D circleCollider2D = bullet.GetComponent <CircleCollider2D>(); InitializeBullet initializeBullet = bullet.GetComponent <InitializeBullet>(); MovingBullet movingBullet = bullet.GetComponent <MovingBullet>(); spriteRenderer.sprite = enemyFire.spriteCollection[23]; spriteRenderer.sortingOrder = 3; circleCollider2D.isTrigger = true; circleCollider2D.radius = 0.04f; circleCollider2D.enabled = false; initializeBullet.bulletType = BulletType.BULLETTYPE_NORMAL; initializeBullet.bulletObject = bullet.gameObject; initializeBullet.targetObject = playerObject; initializeBullet.isGrazed = false; movingBullet.bulletMoveSpeed = Random.Range(4.0f, 6.0f); movingBullet.bulletSpeedState = BulletSpeedState.BULLETSPEEDSTATE_NORMAL; movingBullet.bulletRotateState = BulletRotateState.BULLETROTATESTATE_NONE; movingBullet.bulletDestination = initializeBullet.GetRandomAimedBulletDestination(); float angle = Mathf.Atan2(movingBullet.bulletDestination.y, movingBullet.bulletDestination.x) * Mathf.Rad2Deg; movingBullet.ChangeRotateAngle(angle - 90.0f); } bulletManager.bulletPool.Enqueue(gameObject); transform.SetParent(enemyBullet); eraseBullet.ClearBullet(); gameObject.SetActive(false); break; } else { enemyFire.AddBulletPool(); break; } } yield return(new WaitForEndOfFrame()); } }
private IEnumerator CreateBullet() { yield return(new WaitForSeconds(0.075f)); while (true) { // 탄막 2 생성 if (bulletManager.bulletPool.Count > 0) { GameObject bullet = bulletManager.bulletPool.Dequeue(); bullet.SetActive(true); EnemyFire.ClearChild(bullet); bullet.transform.position = transform.position; bullet.gameObject.tag = "BULLET_ENEMY"; bullet.gameObject.layer = LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_INNER1"); bullet.transform.SetParent(enemyBullet); if (!bullet.GetComponent <SpriteRenderer>()) { bullet.AddComponent <SpriteRenderer>(); } if (!bullet.GetComponent <CircleCollider2D>()) { bullet.AddComponent <CircleCollider2D>(); } if (!bullet.GetComponent <InitializeBullet>()) { bullet.AddComponent <InitializeBullet>(); } if (!bullet.GetComponent <MovingBullet>()) { bullet.AddComponent <MovingBullet>(); } if (!bullet.GetComponent <EraseBullet>()) { bullet.AddComponent <EraseBullet>(); } SpriteRenderer spriteRenderer = bullet.GetComponent <SpriteRenderer>(); CircleCollider2D circleCollider2D = bullet.GetComponent <CircleCollider2D>(); InitializeBullet initializeBullet = bullet.GetComponent <InitializeBullet>(); MovingBullet movingBullet = bullet.GetComponent <MovingBullet>(); spriteRenderer.sprite = enemyFire.spriteCollection[18]; spriteRenderer.sortingOrder = 3; circleCollider2D.isTrigger = true; circleCollider2D.radius = 0.04f; circleCollider2D.enabled = false; initializeBullet.bulletType = BulletType.BULLETTYPE_NORMAL; initializeBullet.bulletObject = bullet.gameObject; initializeBullet.targetObject = playerObject; initializeBullet.isGrazed = false; movingBullet.bulletMoveSpeed = 0.0f; movingBullet.bulletSpeedState = BulletSpeedState.BULLETSPEEDSTATE_NORMAL; movingBullet.bulletRotateState = BulletRotateState.BULLETROTATESTATE_NONE; movingBullet.bulletDestination = initializeBullet.GetRandomAimedBulletDestination(); float angle = Mathf.Atan2(movingBullet.bulletDestination.y, movingBullet.bulletDestination.x) * Mathf.Rad2Deg; movingBullet.ChangeRotateAngle(angle - 90.0f); } else { enemyFire.AddBulletPool(); } yield return(new WaitForSeconds(0.15f)); } }
public IEnumerator FragmentationAttack1(Vector2 bulletFirePosition) { int spriteIndex = 0; for (int i = 0; i < 3; i++) { spriteIndex++; // 충돌체 생성 if (bulletManager.bulletPool.Count > 0) { GameObject bullet = bulletManager.bulletPool.Dequeue(); bullet.SetActive(true); EnemyFire.ClearChild(bullet); bullet.transform.position = bulletFirePosition; bullet.gameObject.tag = "BULLET_ENEMY"; bullet.gameObject.layer = LayerMask.NameToLayer("BULLET_ENEMY_DESTROYZONE_INNER2"); bullet.transform.SetParent(enemyFire.enemyBulletTemp2); if (!bullet.GetComponent <CircleCollider2D>()) { bullet.AddComponent <CircleCollider2D>(); } if (!bullet.GetComponent <InitializeBullet>()) { bullet.AddComponent <InitializeBullet>(); } if (!bullet.GetComponent <MovingBullet>()) { bullet.AddComponent <MovingBullet>(); } if (!bullet.GetComponent <EraseBullet>()) { bullet.AddComponent <EraseBullet>(); } if (!bullet.GetComponent <SpriteRenderer>()) { bullet.AddComponent <SpriteRenderer>(); } if (!bullet.GetComponent <ObjectRotate>()) { bullet.AddComponent <ObjectRotate>(); } SpriteRenderer spriteRenderer = bullet.GetComponent <SpriteRenderer>(); CircleCollider2D circleCollider2D = bullet.GetComponent <CircleCollider2D>(); InitializeBullet initializeBullet = bullet.GetComponent <InitializeBullet>(); MovingBullet movingBullet = bullet.GetComponent <MovingBullet>(); ObjectRotate objectRotate = bullet.GetComponent <ObjectRotate>(); Rigidbody2D rigidbody2D = bullet.GetComponent <Rigidbody2D>(); spriteRenderer.sprite = enemyFire.spriteCollection[203 + ((spriteIndex % 3) * 2)]; spriteRenderer.sortingOrder = 3; circleCollider2D.isTrigger = true; circleCollider2D.radius = 0.015f; circleCollider2D.enabled = false; initializeBullet.bulletType = BulletType.BULLETTYPE_NORMAL; initializeBullet.bulletObject = bullet.gameObject; initializeBullet.targetObject = playerObject; initializeBullet.isGrazed = false; movingBullet.bulletMoveSpeed = 0.0f; movingBullet.bulletSpeedState = BulletSpeedState.BULLETSPEEDSTATE_NORMAL; movingBullet.bulletRotateState = BulletRotateState.BULLETROTATESTATE_NONE; movingBullet.bulletDestination = initializeBullet.GetRandomAimedBulletDestination(); float angle = Mathf.Atan2(movingBullet.bulletDestination.y, movingBullet.bulletDestination.x) * Mathf.Rad2Deg; movingBullet.ChangeRotateAngle(angle - 90.0f + Random.Range(-40.0f, 40.0f)); objectRotate.rotateSpeed = 120.0f; rigidbody2D.velocity = movingBullet.bulletDestination.normalized * Random.Range(1.0f, 2.5f); rigidbody2D.gravityScale = 0.2f; } else { enemyFire.AddBulletPool(); } } yield return(null); }