Пример #1
0
 // Use this for initialization
 void Start()
 {
     enableTargetingScript = GetComponent<EnemyTargeting> ();
     enableShootingScript = GetComponent<EnemyFire> ();
     _currentPlayerLocation = GameObject.FindGameObjectWithTag("Player").transform.position;
     this._Reset ();
 }
Пример #2
0
    private void Awake()
    {
        //주인공 게임 오브젝트 추출
        var player = GameObject.FindGameObjectWithTag("Player");

        //주인공의 트렌스폼 컨포넌트 추출
        if (player != null)
        {
            playerTr = player.GetComponent <Transform>();
        }
        //적 캐릭터의 트렌스폼 컨포넌트 추출
        enemyTr = GetComponent <Transform>();
        //Animator 컴포넌트 추출
        animator = GetComponent <Animator>();
        //이동을 제어하는 MoveAgent 클래스를 추출
        moveAgent = GetComponent <MoveAgent>();
        //총알 발사를 제어하는 EnemyFire 클래스를 추출
        enemyFire = GetComponent <EnemyFire>();
        enemyFOV  = GetComponent <EnemyFOV>();
        //코루틴 지연시간 생성
        ws = new WaitForSeconds(0.3f);

        animator.SetFloat(hashOffset, Random.Range(0.0f, 1.0f));
        animator.SetFloat(hashWalkSpeed, Random.Range(1.0f, 1.2f));
    }
Пример #3
0
    void Awake()
    {
        //Player GameObject 추출
        var player = GameManager.instance.Player;

        //Player와 Enemy의 Transform 추출
        if (player != null)
        {
            playerTr = player.GetComponent <Transform>();
            playerLv = player.GetComponent <PlayerLv>();
        }
        enemyTr = GetComponent <Transform>();
        //Anumator 추출
        animator = GetComponent <Animator>();
        //MoveAgent 추출
        moveagent = GetComponent <MoveAgent>();
        //EnemyFire 추출
        enemyFire = GetComponent <EnemyFire>();
        //EnemyFOV 추출
        enemyFOV = GetComponent <EnemyFOV>();

        //코루틴 지연 시간
        ws = new WaitForSeconds(0.3f);

        //Offset값과 Speed 값을 불규칙하게 변경
        animator.SetFloat(hashOffset, Random.Range(0.0f, 1.0f));
        animator.SetFloat(hashwalkSpeed, Random.Range(1.0f, 1.2f));
    }
Пример #4
0
    public IEnumerator Stage1()
    {
        // 스테이지 1 BGM 재생
        SoundManager.instance.PlayBGM(1);

        yield return(new WaitForSeconds(2.0f));

        #region Enemy Appear

        int[] enemyItem = new int[11] {
            3, 5, 2, 2, 0, 0, 0, 1, 0, 0, 0
        };
        float[] enemyHP = new float[6] {
            200.0f, 160.0f, 240.0f, 200.0f, 240.0f, 220.0f
        };
        Vector3 spawnPosition  = new Vector3(0.0f, 5.0f, 0.0f);
        Vector3 targetPosition = new Vector3(0.0f, 3.0f, 0.0f);

        GameObject boss = CreateBoss(spawnPosition, "ENEMY", LayerMask.NameToLayer("ENEMY_BODY"), new Vector3(1.5f, 1.5f, 1.0f),
                                     0.2f, 3, false, EnemyType.ENEMYTYPE_BOSS, enemyItem, 1, enemyHP);
        EnemyMove enemyMove = boss.GetComponent <EnemyMove>();
        EnemyFire enemyFire = boss.GetComponent <EnemyFire>();

        StartCoroutine(enemyMove.EnemyMoveOnce(targetPosition, iTween.EaseType.easeOutQuad, 1.0f));

        yield return(new WaitForSeconds(1.5f));

        enemyFire.EnemyBossAttack(GameData.currentStage, GameData.currentChapter);

        #endregion
    }
Пример #5
0
    void Awake()
    {
        //주인공 게임오브젝트 추출
        var player = GameObject.FindGameObjectWithTag("PLAYER");

        //주인공의 TRANSFORM 컴포넌트 추출
        if (player != null)
        {
            playerTr = player.GetComponent <Transform>();
        }
        //적 캐릭터의 Transform 컴포넌트 추출
        enemyTr = GetComponent <Transform>();

        //적 캐릭터의 Transform 컴포넌트를 추출
        animator = GetComponent <Animator>();


        //이동을 제어하는 MoveAgent 클래스를 추출
        moveAgent = GetComponent <MoveAgent>();

        //총알 발사를 제어하는 EnemyFire 클래스를 추출
        enemyFire = GetComponent <EnemyFire>();

        //코루틴의 지연 시간 생성1
        ws = new WaitForSeconds(0.3f);

        //Cycle Offset 값을 불규칙하게 변경
        animator.SetFloat(hashOffset, Random.Range(0.0f, 1.0f));

        //WalkSpeed 값을 불규칙하게 변경
        animator.SetFloat(hashWalkSpeed, Random.Range(1.0f, 1.2f));
    }
Пример #6
0
 void Start()
 {
     _gamemanager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();
     agent        = GetComponent <NavMeshAgent>();
     target       = GameObject.FindGameObjectWithTag("Player").transform;
     gun          = GetComponentInChildren <EnemyFire>();
 }
Пример #7
0
 public override void Spawn(Vector3 position, Quaternion rotation, Vector3 scale)
 {
     powerUpManager = GameObject.FindGameObjectWithTag("PowerUpManager").GetComponent <PowerUpManager> ();
     behaviour      = GetComponent <EnemyFire> ();
     behaviour.onSpawn();
     base.Spawn(position, rotation, scale);
 }
Пример #8
0
    void Awake()
    {
        var player = GameObject.FindGameObjectWithTag("PLAYER");

        if (player != null)
        {
            playerTr = player.GetComponent <Transform>();
        }

        enemyTr = GetComponent <Transform>();

        animator = GetComponent <Animator>();

        moveAgent = GetComponent <MoveAgent>();

        enemyFire = GetComponent <EnemyFire>();

        enemyFOV = GetComponent <EnemyFOV>();

        ws = new WaitForSeconds(0.3f);

        animator.SetFloat(hashOffset, Random.Range(0.0f, 1.0f));

        animator.SetFloat(hashWalkSpeed, Random.Range(1.0f, 1.2f));
    }
Пример #9
0
    private void OnParticleCollision(GameObject other)
    {
        EnemyFire enemyFire = other.GetComponent <EnemyFire>();

        if (enemyFire != null)
        {
            enemyFire.HitHandler();
        }
    }
Пример #10
0
    void Start()
    {
        enemyBullet   = GameObject.Find("BULLET").transform.GetChild(4);
        playerObject  = GameObject.Find("PLAYER");
        bulletManager = GameObject.Find("BulletManager").transform.GetChild(0).GetComponent <BulletManager>();
        enemyFire     = GameObject.Find("ENEMY").GetComponent <EnemyFire>();

        StartCoroutine(CreateBullet());
    }
Пример #11
0
    private void Awake()
    {
        moveAgent = GetComponent <MoveAgent>();
        animator  = GetComponent <Animator>();
        enemyFire = GetComponent <EnemyFire>();
        enemyFOV  = GetComponent <EnemyFOV>();

        animator.SetFloat(hashOffset, Random.Range(0, 1.0f));
        animator.SetFloat(hashWalkSpeed, Random.Range(1.0f, 1.2f));
    }
Пример #12
0
    void Start()
    {
        enemyFire        = GameObject.Find("ENEMY").GetComponent <EnemyFire>();
        spriteRenderer   = GetComponent <SpriteRenderer>();
        initializeBullet = GetComponent <InitializeBullet>();
        movingBullet     = GetComponent <MovingBullet>();

        rotateCount = 0;

        StartCoroutine(RotateBullet());
    }
Пример #13
0
    // Update is called once per frame

    void Start()
    {
        enemyFireScript   = GetComponent <EnemyFire>();
        enemyStatusScript = enemyCollider.GetComponent <EnemyStatus>();
        enemyHealthScript = gameObject.GetComponent <EnemyHealth>();
        gameStateScript   = gameState.GetComponent <GameState>();

        healthThreshold = (int)(enemyHealthScript.maxHP * 0.75f);

        enemyAnim.SetBool("EnterMecha", true);
    }
Пример #14
0
    void Start()
    {
        enemyBullet   = GameObject.Find("BULLET").transform.GetChild(4);
        playerObject  = GameObject.Find("PLAYER");
        bulletManager = GameObject.Find("BulletManager").transform.GetChild(0).GetComponent <BulletManager>();
        movingBullet  = GetComponent <MovingBullet>();
        eraseBullet   = GetComponent <EraseBullet>();
        enemyFire     = GameObject.Find("ENEMY").GetComponent <EnemyFire>();

        StartCoroutine(Fragmentation());
    }
Пример #15
0
    void Start()
    {
        enemy          = GameObject.Find("ENEMY");
        enemyFire      = enemy.GetComponent <EnemyFire>();
        enemySprite    = enemy.transform.GetChild(0).GetComponent <EnemySprite>();
        enemyDatabase  = enemy.GetComponent <EnemyDatabase>();
        effectParent   = GameObject.Find("EFFECT").transform;
        destroyzoneAll = GameObject.Find("DESTROYZONE").transform.GetChild(0).gameObject;

        StartCoroutine(GameStart());
    }
Пример #16
0
 private void Start()
 {
     gameManager      = GameObject.Find("MANAGER").transform.Find("GameManager").GetComponent <GameManager>();
     enemyStatus      = GetComponent <EnemyStatus>();
     enemyFire        = GetComponent <EnemyFire>();
     enemyMove        = GetComponent <EnemyMove>();
     circleCollider2D = GetComponent <CircleCollider2D>();
     animator         = GetComponent <Animator>();
     enemyParent      = GameObject.Find("CHARACTER").transform.Find("Enemy");
     itemPool         = GameObject.Find("ITEM").transform.Find("Item");
     itemParent       = GameObject.Find("ITEM").transform.Find("Item_Temp");
 }
Пример #17
0
    void Awake()
    {
        var player = GameObject.FindGameObjectWithTag("PLAYER");

        if (player != null)
        {
            playerTr = player.GetComponent <Transform>();
        }

        enemyTr   = GetComponent <Transform>();
        animator  = GetComponent <Animator>();
        moveAgent = GetComponent <MoveAgent>();
        enemyFire = GetComponent <EnemyFire>();

        ws = new WaitForSeconds(0.3f);
    }
Пример #18
0
    private void Awake()
    {
        // Player 오브젝트를 씬에서 찾음
        var playerObject = GameObject.FindGameObjectWithTag("Player");

        if (playerObject != null)
        {
            playerTransform = playerObject.GetComponent <Transform>();
        }

        moveAgent = GetComponent <MoveAgent>();
        animator  = GetComponent <Animator>();
        enemyFire = GetComponent <EnemyFire>();
        enemyFOV  = GetComponent <EnemyFOV>();

        waitSecond = new WaitForSeconds(refreshAICycle);
    }
Пример #19
0
    IEnumerator EnemyDrop1()
    {
        while (counter < n)
        {
            GameObject obj = (GameObject)Instantiate(enemyTank, new Vector3(-30, 0, 8), Quaternion.identity);

            EnemyHealth mything  = obj.GetComponent <EnemyHealth>();
            EnemyFire   mything1 = obj.GetComponent <EnemyFire>();

            //set a member variable (must be PUBLIC)
            mything.liv     = l;
            mything1.speedF = speedf;
            // Debug.Log("Hello world 00000"+" "+level);

            //obj.liv = l;
            yield return(new WaitForSeconds(3));

            counter += 1;
        }
    }
Пример #20
0
    void Awake()
    {
        var player = GameObject.FindGameObjectWithTag("PLAYER"); //주인공 게임오브젝트 추출

        if (player != null)
        {
            playerTr = player.GetComponent <Transform>(); //주인공 Transform 추출
        }
        enemyTr   = GetComponent <Transform>();           // 적 Transform 추출
        animator  = GetComponent <Animator>();
        moveAgent = GetComponent <MoveAgent>();
        enemyFire = GetComponent <EnemyFire>();
        audio     = GetComponent <AudioSource>();

        ws = new WaitForSeconds(0.3f); //코루틴 지연시간 생성

        //AI별로 다른 움직임을 가지기 위한 불규칙성 부여
        animator.SetFloat(hashOffset, UnityEngine.Random.Range(0.0f, 1.0f));    //Cycle offset 값을 불규칙하게 변경
        animator.SetFloat(hashWalkSpeed, UnityEngine.Random.Range(1.0f, 1.2f)); //Speed값을 불규칙하게 변경
    }
Пример #21
0
    public void ShipDestroyed(EnemyFire e)
    {
        // Potentially generate a PowerUp
        if (!(UnityEngine.Random.value <= e.powerUpDropChance))
        {
            return;
        }
        // Choose which PowerUp to pick
        // Pick one from the possibilities in powerUpFrequency
        var ndx    = UnityEngine.Random.Range(0, powerUpFrequency.Length);
        var puType = powerUpFrequency[ndx];
        // Spawn a PowerUp
        var go = Instantiate(prefabPowerUp) as GameObject;
        var pu = go.GetComponent <PowerUp>();

        // Set it to the proper WeaponType
        pu.SetType(puType);
        // Set it to the position of the destroyed ship
        pu.transform.position = e.transform.position;
    }
Пример #22
0
    public void GetFromMap(int mapColumn, int mapRow)
    {
        for (int i = 0; i < mapHeight; i++)
        {
            levelData[i] = Map.levelData[mapColumn, mapRow, i];
        }

        // And let's extract the info about the enemies from the map
        Enemies    = new Enemy[MAX_ENEMIES];
        NumEnemies = 0;
        for (int row = 0; row < mapHeight; row++)
        {
            for (int col = 0; col < mapWidth; col++)
            {
                if ((levelData[row][col] == 'e') ||
                    (levelData[row][col] == 'f') ||
                    (levelData[row][col] == 'g'))
                {
                    int posX = col * tileWidth + leftMargin;
                    int posY = row * tileHeight + topMargin;
                    if (levelData[row][col] == 'e')
                    {
                        Enemies[NumEnemies] = new EnemyFire();
                    }
                    else if (levelData[row][col] == 'g')
                    {
                        Enemies[NumEnemies] = new EnemySpring();
                    }
                    else
                    {
                        Enemies[NumEnemies] = new EnemyFish();
                    }
                    Enemies[NumEnemies].MoveTo(posX, posY);
                    Enemies[NumEnemies].SetSpeed(2, 2);
                    NumEnemies++;
                    levelData[row] = levelData[row].
                                     Remove(col, 1).Insert(col, " ");
                }
            }
        }
    }
Пример #23
0
    public void ClearBullet()
    {
        EnemyFire.ClearChild(gameObject);

        bulletManager.bulletPool.Enqueue(gameObject);
        gameObject.transform.SetParent(enemyBullet.transform);
        gameObject.transform.position   = new Vector2(0.0f, 0.0f);
        gameObject.transform.rotation   = Quaternion.Euler(0.0f, 0.0f, 0.0f);
        gameObject.transform.localScale = new Vector3(1.8f, 1.8f, 0.0f);

        // 컴포넌트 제거
        Destroy(spriteRenderer);
        Destroy(circleCollider);
        Destroy(boxCollider);
        Destroy(capsuleCollider);
        Destroy(initializeBullet);
        Destroy(movingBullet);
        Destroy(laserBullet);
        Destroy(reflectBullet);

        // 커스텀 컴포넌트 제거
        // Destroy(stage1BulletFragmentation);
        // Destroy(stage5BulletCreate);
        // Destroy(stage12BulletFragmentation);
        // Destroy(stage13BulletRotate);

        Destroy(pattern6BulletRotate);
        Destroy(pattern6BulletAiming);
        Destroy(pattern7BulletAiming);
        Destroy(pattern8BulletAiming);
        Destroy(pattern9BulletRotate);
        Destroy(pattern14BulletRotate);
        Destroy(pattern19BulletRotate);

        // 최종 컴포넌트 제거 후 비활성화
        StopAllCoroutines();
        gameObject.SetActive(false);
    }
Пример #24
0
    private void Awake()
    {
        //주인공 게임 오브젝트 호출
        var player = GameObject.FindGameObjectWithTag("Player");

        //주인공의 Transform 컴포넌트 추출
        if (player != null)
        {
            playerTr = player.GetComponent <Transform>();
        }
        //적 캐릭터의 Transform 컴포넌트 추출
        enemyTr = GetComponent <Transform>();

        //이동을 제어하는 MoveAgent클래스를 추출
        moveAgent = GetComponent <MoveAgent>();

        //Animator 컴포넌트 추출
        animator = GetComponent <Animator>();
        //코루틴의 지연시간 생성
        ws = new WaitForSeconds(0.3f);
        //총알 발사를 제어하는 EnemyFire 클래스를 추출
        enemyFire = GetComponent <EnemyFire>();
    }
Пример #25
0
    void Toggle_EnemyShoot()
    {
        // store all current Enemies in a variable
        GameObject[] Enemies01 = GameObject.FindGameObjectsWithTag("Enemy01");
        GameObject[] Enemies02 = GameObject.FindGameObjectsWithTag("Enemy02");
        GameObject[] Enemies03 = GameObject.FindGameObjectsWithTag("Enemy03");

        // make a variable that can hold all the scripts
        EnemyFire[]       FireScripts01 = new EnemyFire[Enemies01.Length];
        EnemyDoubleShot[] FireScripts02 = new EnemyDoubleShot[Enemies02.Length];
        EnemyFire[]       FireScripts03 = new EnemyFire[Enemies03.Length];

        // Enemy01 Toggle
        for (int i = 0; i < Enemies01.Length; i++)
        {
            // put each script in the variable that was just made
            FireScripts01[i] = Enemies01[i].GetComponent <EnemyFire> ();
            // then enable or disable the script
            FireScripts01[i].enabled = !FireScripts01[i].enabled;
        }
        // Enemy02 Toggle
        for (int i = 0; i < Enemies02.Length; i++)
        {
            // put each script in the variable that was just made
            FireScripts02[i] = Enemies02[i].GetComponent <EnemyDoubleShot> ();
            // then enable or disable the script
            FireScripts02[i].enabled = !FireScripts02[i].enabled;
        }
        // Enemy03 Toggle
        for (int i = 0; i < Enemies03.Length; i++)
        {
            // put each script in the variable that was just made
            FireScripts03[i] = Enemies03[i].GetComponent <EnemyFire> ();
            // then enable or disable the script
            FireScripts03[i].enabled = !FireScripts03[i].enabled;
        }
    }
Пример #26
0
 void Start()
 {
     enemyFire = GameObject.Find("ENEMY").GetComponent <EnemyFire>();
 }
Пример #27
0
    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());
        }
    }
Пример #28
0
    // Use this for initialization
    void Start()
    {
        //	this._audioSources = gameObject.GetComponents<AudioSource> ();
        //	this._deathSound = this._audioSources [1];
        //	this._hitSound = this._audioSources [2];
        enableTargetingScript = GetComponent<EnemyTargeting> ();
        enableShootingScript = GetComponent<EnemyFire> ();
        droppings = GetComponent<LootDrop> ();
        //_currentPlayerLocation = GameObject.FindGameObjectWithTag("Player").transform.position;
        this._Reset ();

        /////////////////////////////////
        /// Stats Script
        diffuclty = 0;
        speed = 5;
        //player = GameObject.Find ("player");
        //this.playerStats = player.GetComponent<PlayerStats>();
        //otherDamage = playerStats.bulletDamage;
        maxHealth = 100;
        currentHealth = maxHealth;
        armour = 0;
        maxShield = 0;
        currentShield = maxShield;
        otherDamage = 50;
        damage =  10;
    }
Пример #29
0
    void Fire()
    {
        Vector3 FirePosLPosition = FirePosL.transform.position;
        Vector3 FirePosRPosition = FirePosR.transform.position;

        Quaternion FirePosLRotation = FirePosL.transform.rotation;
        Quaternion FirePosRRotation = FirePosR.transform.rotation;

        PlayerTime += 1;


        if (gameObject.CompareTag("Player"))
        {
            if (PlayerTime % 6 == 1)
            {
                ObjectPool.Instance.SpawnFromPool("PlayerBullet", FirePosLPosition, FirePosLRotation);
                ObjectPool.Instance.SpawnFromPool("PlayerBullet", FirePosRPosition, FirePosRRotation);

                FireSound.Play();
            }
        }

        else if (gameObject.CompareTag("Enemy"))
        {
            if (EnemyState == EnemyFire.wait)
            {
                ModenTime += Time.deltaTime;

                //Random.Range(0, 2);

                if (ModenTime > WaitTime)
                {
                    //Debug.Log(Random.Range(0, 2));
                    if (Random.Range(0, 2) == 0)
                    {
                        ModenTime  = 0f;
                        EnemyState = EnemyFire.attack;
                    }
                    if (Random.Range(0, 2) == 1)
                    {
                        ModenTime  = 0f;
                        EnemyState = EnemyFire.Sattack;
                    }
                }
            }


            if (EnemyState == EnemyFire.attack)
            {
                ObjectPool.Instance.SpawnFromPool("EnemyBullet", FirePosLPosition, FirePosLRotation);
                ObjectPool.Instance.SpawnFromPool("EnemyBullet", FirePosRPosition, FirePosRRotation);
                //Bullet.tag = "Enemy";
                EnemyState = EnemyFire.wait;
            }
            if (EnemyState == EnemyFire.Sattack)
            {
                ObjectPool.Instance.SpawnFromPool("EnemyBullet", FirePosLPosition, FirePosLRotation).name = "SatackL";

                ObjectPool.Instance.SpawnFromPool("EnemyBullet", FirePosRPosition, FirePosRRotation).name = "SatackR";



                EnemyState = EnemyFire.wait;
                ModenTime  = 0f;
            }
        }
    }
Пример #30
0
 protected virtual void Start()
 {
     fireControl = gameObject.GetComponent <EnemyFire>();
     StartCoroutine(MovementLoop());
 }
Пример #31
0
    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));
        }
    }
Пример #32
0
    public GameObject CreateMinion(Vector3 spawnPosition, string enemyTag, int enemyLayer, Vector3 enemyScale, float colliderRadius, int animationNumber,
                                   bool enemyCounter, EnemyType enemyType, int[] enemyItem, int enemyNumber, float enemyHP, int enemyPatternNumber, int enemyCounterPatternNumber,
                                   float enemyAttackWaitTime, float enemyAttackDelayTime, bool isPatternOnce, bool isPatternRepeat, int enemyFireCount, float enemyAttackRepeatTime,
                                   int enemyCustomPatternNumber = 0, bool isAutoDestroy = false, float waitTime = 0.0f)
    {
        GameObject enemy = enemyPool.GetChild(0).gameObject;

        enemy.SetActive(true);
        enemy.transform.position = spawnPosition;
        enemy.gameObject.tag     = enemyTag;
        enemy.gameObject.layer   = enemyLayer;
        enemy.transform.SetParent(enemyParent);
        enemy.transform.localScale = enemyScale;

        CircleCollider2D circleCollider2D = enemy.GetComponent <CircleCollider2D>();

        circleCollider2D.enabled = true;
        circleCollider2D.radius  = colliderRadius;

        Animator animator = enemy.GetComponent <Animator>();

        animator.runtimeAnimatorController = characterAnimatorController[animationNumber];

        EnemyStatus enemyStatus = enemy.GetComponent <EnemyStatus>();

        enemyStatus.SetCounter(enemyCounter);
        enemyStatus.SetEnemyType(enemyType);
        enemyStatus.SetEnemyItem(enemyItem);
        if (enemyType.Equals(EnemyType.ENEMYTYPE_BOSS))
        {
            enemyStatus.SetEnemyNumber(0);
            enemyStatus.SetEnemyBossNumber(enemyNumber);
        }
        else if (enemyType.Equals(EnemyType.ENEMYTYPE_NONE))
        {
            enemyStatus.SetEnemyNumber(0);
            enemyStatus.SetEnemyBossNumber(0);
        }
        else
        {
            enemyStatus.SetEnemyNumber(enemyNumber);
            enemyStatus.SetEnemyBossNumber(0);
        }
        enemyStatus.SetEnemyMaxHP(enemyHP);
        enemyStatus.SetEnemyCurrentHP(enemyStatus.GetEnemyMaxHP());

        EnemyFire enemyFire = enemy.GetComponent <EnemyFire>();

        enemyFire.SetEnemyPatternNumber(enemyPatternNumber);
        enemyFire.SetEnemyCounterPatternNumber(enemyCounterPatternNumber);
        enemyFire.SetEnemyAttackWaitTime(enemyAttackWaitTime);
        enemyFire.SetEnemyAttackDelayTime(enemyAttackDelayTime);
        enemyFire.SetEnemyPatternOnce(isPatternOnce);
        enemyFire.SetEnemyPatternRepeat(isPatternRepeat);
        enemyFire.SetEnemyFireCount(enemyFireCount);
        enemyFire.SetEnemyAttackRepeatTime(enemyAttackRepeatTime);
        enemyFire.SetEnemyCustomPatternNumber(enemyCustomPatternNumber);

        EnemyDestroy enemyDestroy = enemy.GetComponent <EnemyDestroy>();

        if (isAutoDestroy.Equals(true))
        {
            StartCoroutine(enemyDestroy.EnemyAutoDestroy(waitTime));
        }

        return(enemy);
    }