Exemple #1
0
    public void SetInitInfo(Vector2 _dir, float _velocity, float _effectiveRange, E_BulletType _bulletType = E_BulletType.Independent, int _spreadNum = 1, float _spreadDegree = 0.0f, string _bulletName = "Bullet")
    {
        isActivated    = true;
        bulletType     = _bulletType;
        effectiveRange = _effectiveRange;
        dir            = _dir;
        velocity       = _velocity;
        spreadNum      = _spreadNum;
        spreadDegree   = _spreadDegree;

        if (bulletType == E_BulletType.Group)
        {
            bulletPrefab = Resources.Load("Prefabs/" + _bulletName) as GameObject;

            for (int i = 0; i < spreadNum; i++)
            {
                Quaternion rot       = Quaternion.Euler(0.0f, 0.0f, Random.Range(-spreadDegree / 2.0f, spreadDegree / 2.0f)); // 회전각
                Vector2    rottedDir = rot * dir;
                GameObject newObject = Instantiate(bulletPrefab);
                CS_Bullet  bullet    = newObject.GetComponent <CS_Bullet>();
                bullet.transform.position = transform.position;
                bullet.SetInitInfo(rottedDir, velocity, effectiveRange);
            }

            DestroyObject(this.gameObject);
        }
    }
Exemple #2
0
    public override void AxisAction()
    {
        // 장전 요청이 들어오면 장전을 수행함.
        if (!isReloadCompleted)
        {
            elapsedTime += Time.deltaTime;

            if (elapsedTime >= reloadTime)
            {
                curBulletNum      = maxBulletNum;
                isReloadCompleted = true;
                // 장전이 완료되면 바로 쏠 수 있도록 함.
                remainingTime = 0.0f;
                elapsedTime   = delay - remainingTime;
            }
        }

        if (CS_Managers.Instance.InputManager.IsOutsideOfReloadRadius())
        {
            //elapsedTime = delay - remainingTime;
            if (isReloadCompleted)
            {
                elapsedTime += Time.deltaTime;

                if (elapsedTime >= delay)
                {
                    if (curBulletNum > 0)
                    {
                        curBulletNum--;
                        soundBang.Play();
                        GameObject newObject = Instantiate(bulletPrefab);
                        CS_Bullet  bullet    = newObject.GetComponent <CS_Bullet>();
                        bullet.transform.position = GetPosition();
                        //bullet.SetInitInfo(currentDir, 25.0f, 4.0f, E_BulletType.Group, 8, 20.0f);
                        bullet.SetInitInfo(currentDir, 25.0f, 100.0f);
                        ReboundAgainstShot();
                    }
                    elapsedTime = 0.0f;
                }
            }
        }
        else
        {
            remainingTime = Mathf.Clamp(remainingTime - Time.deltaTime, 0.0f, delay);
        }

        // 반동에 대한 회복
        float translate = (springArmLength - imagePosL.localPosition.x) * 0.4f;

        imagePosL.localPosition = new Vector3(imagePosL.localPosition.x + translate, 0.0f, 0.0f);
    }