void Start() { MyExtensionMethods.InitAudio(ref shootSound, StringNamesInfo.FIRE_SOUND); MyExtensionMethods.InitAudio(ref deniedSound, StringNamesInfo.DENIED_SOUND); if (!whatToControll) { return; } #region CACHE_COMPONENTS controllGun = whatToControll.GetComponent <BuildGunScript>().ControllGunSystem; controllShoot = whatToControll.GetComponent <BuildGunScript>().ShootSystem; #endregion Slider rotateController = GameObject.Find(StringNamesInfo.ROTATEGUNCONTROLLER_name).GetComponent <Slider>(); rotateController.value = 90.0f; rotateController.minValue = controllGun.MinAngle; rotateController.maxValue = controllGun.MaxAngle; rotateController.onValueChanged.AddListener(delegate { controllGun.RotateGun(rotateController.value); }); StartCoroutine(LateStart()); }
void Awake() { baseSprite = GunRendererScript.baseSprite[GunRendererScript.indexToSet]; barrelSprite = GunRendererScript.barrelSprite[GunRendererScript.indexToSet]; if (baseSprite) { transform.GetComponentInParent <SpriteRenderer>().sprite = baseSprite; } if (barrelSprite) { transform.GetComponentInChildren <SpriteRenderer>().sprite = barrelSprite; } gunStats = GunStats.Instance; shootSystem = transform.FindChild("FirePoint").GetComponent <ShootSystem>(); shootSystem.ToInstantiate = toInstatiate; shootSystem.AttackRate = (float)gunStats.AttackRate; shootSystem.AmmoStats = gunStats.AmmoStats; shootSystem.transform.localPosition = new Vector2(barrelSprite.rect.height / (Mathf.Abs(transform.parent.position.y)), 0.0f); controllGunSystem = transform.GetComponent <ControllGunSystem>(); controllGunSystem.MinAngle = (float)gunStats.MinAngle; controllGunSystem.MaxAngle = (float)gunStats.MaxAngle; }