void Start() { currentWeapon = DataHelper.DEFAULT_SELECTED_WEAPON_INDEX; lastSelected = GameObject.FindGameObjectWithTag("defaultWeapon").GetComponent <Button_SwitchWeapon>(); mngScript = Weapons_PUs_Manager.Instance; spCntScript = GetComponent <StaticPlayerController>(); dpCntScript = GetComponent <DynamicPlayerController>(); }
public void switchWeapons(Button_SwitchWeapon button, int weaponIndex) { //before switching //molotove and icebomb if (GetComponent <DynamicPlayerController>()) { GetComponent <DynamicPlayerController>().EnableShooting(); GetComponent <DynamicPlayerController>().ResetRotation(); } if (GetComponent <StaticPlayerController>()) { GetComponent <StaticPlayerController>().EnableShooting(); GetComponent <StaticPlayerController>().ResetRotation(); } if (currentWeapon == 6) { if (spCntScript) { spCntScript.manAnim.SetBool("bottle_idle", false); } if (dpCntScript) { dpCntScript.manAnim.SetBool("bottle_idle", false); } } else if (currentWeapon == 7) { if (spCntScript) { spCntScript.manAnim.SetBool("bomb_idle", false); } if (dpCntScript) { dpCntScript.manAnim.SetBool("bomb_idle", false); } } else { if (spCntScript) { spCntScript.manAnim.SetBool(DataHelper.WEAPONS_NAMES[currentWeapon] + "_idle", false); } if (dpCntScript) { dpCntScript.manAnim.SetBool(DataHelper.WEAPONS_NAMES[currentWeapon] + "_idle", false); } } //after switching if (currentWeapon != weaponIndex) { if (dpCntScript) { dpCntScript.EnableShooting(); } // if(spCntScript) // spCntScript.EnableShooting(); } currentWeapon = weaponIndex; if (lastSelected) { lastSelected.UnhighlightButton(); } lastSelected = button; //reloading = false; CancelInvoke("endReloading"); }