コード例 #1
0
    //private void Update()
    //{
    //    if (Input.GetKeyDown(KeyCode.Mouse0))
    //    {
    //        ShootEvent(ShootingType.Primary);
    //    }
    //}


    public void ShootEvent(ShootingType shootingType)
    {
        if (shootingType == ShootingType.Primary)
        {
            if (!Data.PrimaryObjectShooting)
            {
                RayCastShooting(Data.PrimaryBulletCount, Data.PrimaryShootCost, Data.PrimaryDamage, Data.PrimaryDispersion, Data.RayCastDecal, Data.PrimaryShootSound);
            }
            else
            {
                ObjectShooting(Data.PrimaryBulletCount, Data.PrimaryShootCost, Data.PrimaryDamage, Data.PrimaryBulletSpeed, Data.PrimaryDispersion, Data.PrimaryBulletPrefab, Data.PrimaryShootSound);
            }
            if (Data.PrimaryShootSound != null)
            {
                shootSource.pitch = Random.Range(0.7f, 1.3f);
                shootSource.PlayOneShot(Data.PrimaryShootSound);
            }
        }
        else
        {
            if (!Data.SecondaryObjectShooting)
            {
                RayCastShooting(Data.SecondaryBulletCount, Data.SecondaryShootCost, Data.SecondaryDamage, Data.SecondaryDispersion, Data.RayCastDecal, Data.SecondaryShootSound);
            }
            else
            {
                ObjectShooting(Data.SecondaryBulletCount, Data.SecondaryShootCost, Data.SecondaryDamage, Data.SecondaryBulletSpeed, Data.SecondaryDispersion, Data.SecondaryBulletPrefab, Data.SecondaryShootSound);
            }
            shootSource.pitch = Random.Range(0.7f, 1.3f);
            if (Data.SecondaryShootSound != null)
            {
                shootSource.PlayOneShot(Data.SecondaryShootSound);
            }
        }
    }
コード例 #2
0
    public void Execute(ShootingType shootingType)
    {
        _shootingType = shootingType;

        _timer = 1 / shootingType.fireRate;

        _isExecuting = true;
    }
コード例 #3
0
    public static ShootController StartChecking(GameObject addComponentAt, ShootingType shootingType)
    {
        if (addComponentAt.GetComponent <ShootController>())
        {
            return(null);
        }

        ShootController shootController = addComponentAt.AddComponent <ShootController>();

        shootController.Execute(shootingType);

        return(shootController);
    }
コード例 #4
0
 private void CreateShootingType()
 {
     typeInstance = Instantiate(type);
     typeInstance.Init(this);
 }