コード例 #1
0
ファイル: SoundTest.cs プロジェクト: sahillshaikh1/Scripts
 public void Update()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     if (WeaponPanelIsActive == true)
     {
         WeaponPanel.SetActive(true);
     }
     if (WeaponPanelIsActive == false)
     {
         WeaponPanel.SetActive(false);
     }
     if (FireBtn.Instance.isPress == true && IsOkToShoot())
     {
         Shoot();
     }
     if (ShotGunT.isOn)
     {
         ShotGun.SetActive(true);
         ShotGunBtn.SetActive(true);
         Rifle.SetActive(false);
         revolver.SetActive(false);
         HuntingRifle.SetActive(false);
     }
     if (RifleT.isOn)
     {
         fireRate = 0.14f;
         ShotGun.SetActive(false);
         Rifle.SetActive(true);
         revolver.SetActive(false);
         HuntingRifle.SetActive(false);
         ShotGunBtn.SetActive(false);
     }
     if (revolverT.isOn)
     {
         ShotGun.SetActive(false);
         Rifle.SetActive(false);
         revolver.SetActive(true);
         HuntingRifle.SetActive(false);
         ShotGunBtn.SetActive(false);
     }
     if (HuntingRifleT.isOn)
     {
         ShotGun.SetActive(false);
         Rifle.SetActive(false);
         revolver.SetActive(false);
         HuntingRifle.SetActive(true);
         ShotGunBtn.SetActive(false);
     }
 }
コード例 #2
0
    /**
     * Spawn hunting rifles in the area
     */
    private void SpawnHuntingRifles()
    {
        string funcName = "SpawnHuntingRifles";

        FunctionPeriodic.Create(
            () =>
        {
            if (WeaponManager.WeaponCount <HuntingRifle>() < _HUNTING_RIFLE_MAX_SPAWNS)
            {
                Vector3 huntingRifleWorldPosition = new Vector3(
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS),
                    AssetManager.Get_Prefab_HuntingRifle().transform.localScale.y / 2 + AssetManager.GetTerrain().localScale.y,
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS)
                    );

                HuntingRifle huntingRifle = Instantiate(
                    AssetManager.Get_Prefab_HuntingRifle(),
                    huntingRifleWorldPosition,
                    Quaternion.identity
                    );

                WeaponManager.AddWeapon(huntingRifle);
            }
        },
            funcName,
            0f,
            0f,
            () =>
        {
            if (WeaponManager.WeaponCount <HuntingRifle>() >= _HUNTING_RIFLE_MAX_SPAWNS)
            {
                Destroy(GameObject.Find(funcName));
            }
        }
            );
    }