Exemple #1
0
    private IEnumerator AutoFire() //코루틴
    {
        WaitForSeconds fireRate = new WaitForSeconds(mFireRate);

        while (true)
        {
            yield return(fireRate);

            Bolt bolt = mBoltPool.GetFromPool();
            bolt.transform.position = mBoltPos.position;
            bolt.transform.rotation = mBoltPos.rotation;
            bolt.ReSetDir();
            mSoundController.PlayEffectSound((int)eSFXType.FireEnemy);
        }
    }
Exemple #2
0
    private IEnumerator Phase()
    {
        WaitForFixedUpdate frame      = new WaitForFixedUpdate();
        WaitForSeconds     pointThree = new WaitForSeconds(0.3f);
        float currentTime             = 0;
        float progress   = 0;
        int   startIndex = 1;
        int   endIndex   = 0;
        bool  bAscend    = true;

        while (true)
        {
            Vector3 StartPos = mPosArr[startIndex].position;
            Vector3 EndPos   = mPosArr[endIndex].position;
            progress    = 0;
            currentTime = 0;
            while (currentTime <= mPosMoveTime)//이동
            {
                yield return(frame);

                currentTime       += Time.fixedDeltaTime;
                progress           = currentTime / mPosMoveTime;
                transform.position = Vector3.Lerp(StartPos, EndPos, progress);
            }
            for (int i = 0; i < 3; i++)//발사
            {
                Bolt bolt = mBoltPool.GetFromPool(2);
                bolt.transform.position = mBoltPos.position;
                bolt.transform.LookAt(mPlayer.transform);
                bolt.ReSetDir();
                yield return(pointThree);
            }
            startIndex = endIndex;
            if (bAscend)
            {
                endIndex++;
                bAscend = endIndex < mPosArr.Length - 1;
            }
            else
            {
                endIndex--;
                bAscend = endIndex == 0;
            }
        }
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        float horizontal = Input.GetAxis("Horizontal");
        float vertical   = Input.GetAxis("Vertical");

        Vector3 direction = new Vector3(horizontal, 0, vertical);

        direction = direction.normalized;

        mRB.velocity = direction * mSpeed;
        //transform.Translate(direction * Time.deltaTime);

        mRB.rotation = Quaternion.Euler(0, 0, horizontal * -mTilted);

        mRB.position = new Vector3(Mathf.Clamp(mRB.position.x, mXMin, mXMax),
                                   0,
                                   Mathf.Clamp(mRB.position.z, mZMin, mZMax));

        if (Input.GetButton("Fire1") && mCurrentFireLate >= mFireLate)
        {
            float   currentXStart = -mBoltXGap * ((mCurrentBoltCount - 1) / 2); //총알배치
            Vector3 XPos          = new Vector3(currentXStart, 0, 0);

            for (int i = 0; i < mCurrentBoltCount; i++)
            {
                Bolt bolt = mBoltPool.GetFromPool(mBoltIndex);
                bolt.gameObject.transform.position = mBoltPos.position + XPos;
                bolt.gameObject.transform.rotation = mBoltPos.rotation;
                bolt.ReSetDir();
                XPos.x += mBoltXGap;
            }
            mCurrentFireLate = 0;
            mSoundController.PlayEffectSound((int)eSFXType.FirePlayer);
        }
        else
        {
            mCurrentFireLate += Time.deltaTime;
        }
    }