コード例 #1
0
    public void InstanceProjectile(bool isContinuous, Vector3 attackVector)
    {
        if (conUsing > 0)
        {
            // 투사체를 생성
            GameObject temp = ObjectPullManager.Instance.GetInstanceByName(projectileName);

            // 발사
            if (temp != null)
            {
                if (isContinuous)
                {
                    conContinuousShootingCount++;
                }

                ProjectileScript projectile = temp.GetComponent <ProjectileScript>();
                projectile.Init(muzzle.position, attackVector, isProjectilePenetrating, damage, distance);
            }

            // 총구 이펙트
            muzzleFlash.Emit(1);

            // 총구 반동으로 인한 화면 덜림
            SystemManager.Instance.CameraShake("Shooting", 0.05f, 0.1f * shakeMagnitude, 0.08f * shakeMagnitude);

            // UI 남은 사용 횟수 수정
            UsingWeapon();
        }
    }
コード例 #2
0
    private void ShootingProjectile()
    {
        // 투사체를 생성
        GameObject temp = ObjectPullManager.Instance.GetInstanceByName(projectileName);

        // 발사
        if (temp != null)
        {
            ProjectileScript projectile = temp.GetComponent <ProjectileScript>();
            projectile.Init(projectileGenerationPos.position, transform.forward, false, damage, projectileDistance);
        }
    }
コード例 #3
0
    public void Shoot()
    {
        if (!alive || !canShoot)
        {
            return;
        }
        foreach (ParticleSystem p in cannonParticles)
        {
            p.Play();
        }
        ProjectileScript shot = GameManager.Instance.ProjectilePool.GetObject(shotStart.position, shotStart.rotation).GetComponent <ProjectileScript>();

        shot.Init(shotStart.transform.forward, projectileSpeed, this, shotDamage);
        AudioSource shotSound = AudioManager.Instance.SpawnSound("ShotSound", shotStart, false, false, false, this is PlayerScript ? 1f : 0.8f);

        StopCoroutine("AttackCooldownTimer");
        StartCoroutine("AttackCooldownTimer");
    }
コード例 #4
0
    private void SpawnProjectiles()
    {
        // Init the collection
        int numProjectiles = Mathf.CeilToInt(projectileLifeTime / fireTime) * projectilesPerShot;

        m_numProjectiles = numProjectiles;
        m_projectilePool = new ProjectileScript[numProjectiles];

        // Create a container GO for the projectiles
        m_projectileContainer = new GameObject(gameObject.name + " Projectiles");

        // Spawn the Projectiles
        for (int i = 0; i < numProjectiles; i++)
        {
            GameObject       projectile = (GameObject)Instantiate(projectilePrefab, transform.position, Quaternion.identity);
            ProjectileScript projScript = projectile.GetComponent <ProjectileScript>();
            projScript.transform.parent = m_projectileContainer.transform;
            projScript.Init(damage, projectileSpeed, projectileLifeTime, transform.parent.gameObject);
            m_projectilePool[i] = projScript;
            projectile.SetActive(false);
        }
    }