//INGAMEINFO SECTION END //WEAPON CHANGE SECTION //Change weapon in inventory public void ChangePrefab(BaseWeapon newWeapon, WeaponBackUp weaponAddInfo) { for (int i = 0; i < prefabWeapon.Length; i++) { if (prefabWeapon[i].slotType == newWeapon.slotType) { DropWeapon(prefabWeapon[i], weaponInfo[i]); prefabWeapon[i] = newWeapon; weaponInfo[i] = new WeaponBackUp(prefabWeapon[i].clipSize, prefabWeapon[i].ammoType); return; } } BaseWeapon[] oldprefabWeapon = prefabWeapon; WeaponBackUp[] oldweaponInfo = weaponInfo; prefabWeapon = new BaseWeapon[oldprefabWeapon.Length + 1]; weaponInfo = new WeaponBackUp[prefabWeapon.Length]; for (int i = 0; i < oldprefabWeapon.Length; i++) { prefabWeapon[i] = oldprefabWeapon[i]; weaponInfo[i] = new WeaponBackUp(oldweaponInfo[i]); } prefabWeapon[prefabWeapon.Length - 1] = newWeapon; weaponInfo[prefabWeapon.Length - 1] = weaponAddInfo;; return; }
//AMMO BAG SECTION END //INGAMEINFO SECTION void GenerateInfo() { weaponInfo = new WeaponBackUp[prefabWeapon.Length]; for (int i = 0; i < prefabWeapon.Length; i++) { weaponInfo[i] = new WeaponBackUp(prefabWeapon[i].clipSize, prefabWeapon[i].ammoType); } }
//TODO: implementation of dropping weapon on ground after picking another one void DropWeapon(BaseWeapon oldWeapon, WeaponBackUp weaponinfo) { GameObject droppedWeapon = PhotonNetwork.Instantiate(oldWeapon.pickupPrefabPrefab.name, transform.position, transform.rotation, 0) as GameObject; OldWeaponPicker picker = (OldWeaponPicker)droppedWeapon.GetComponent(typeof(OldWeaponPicker)); picker.info = weaponinfo; picker.prefabWeapon = oldWeapon; picker.isOneUse = true; }
//INGAMEINFO SECTION END //WEAPON CHANGE SECTION //Change weapon in inventory public void ChangePrefab(BaseWeapon newWeapon,WeaponBackUp weaponAddInfo) { for(int i=0;i<prefabWeapon.Length;i++){ if(prefabWeapon[i].slotType==newWeapon.slotType){ DropWeapon(prefabWeapon[i],weaponInfo[i]); prefabWeapon[i]=newWeapon; weaponInfo[i]=new WeaponBackUp(prefabWeapon[i].clipSize, prefabWeapon[i].ammoType); _ChangeWeapon(i); return; } } BaseWeapon[] oldprefabWeapon = prefabWeapon; WeaponBackUp[] oldweaponInfo = weaponInfo; prefabWeapon = new BaseWeapon[oldprefabWeapon.Length+1]; weaponInfo = new WeaponBackUp[prefabWeapon.Length]; for(int i=0;i<oldprefabWeapon.Length;i++){ prefabWeapon[i]= oldprefabWeapon[i]; weaponInfo[i]=new WeaponBackUp(oldweaponInfo[i]); } prefabWeapon[prefabWeapon.Length-1] = newWeapon; weaponInfo[prefabWeapon.Length-1]=weaponAddInfo;; return; }
public WeaponBackUp(WeaponBackUp oldInfo) { amount =oldInfo.amount; type=oldInfo.type; }
//implementation of dropping weapon on ground after picking another one void DropWeapon(BaseWeapon oldWeapon,WeaponBackUp weaponinfo) { GameObject droppedWeapon =PhotonNetwork.Instantiate(oldWeapon.pickupPrefabPrefab.name,transform.position,transform.rotation,0) as GameObject; WeaponPicker picker = droppedWeapon.GetComponent<WeaponPicker>(); picker.SetNewData (weaponinfo); //picker.info =weaponinfo; }
//AMMO BAG SECTION END //INGAMEINFO SECTION /*Generate cahche info for bag We don't store all weapon just important info about it when player put weapon down */ protected void GenerateInfo() { weaponInfo = new WeaponBackUp[prefabWeapon.Length]; for(int i=0;i<prefabWeapon.Length;i++){ weaponInfo[i]=new WeaponBackUp(prefabWeapon[i].clipSize,prefabWeapon[i].ammoType); } }
public WeaponBackUp(WeaponBackUp oldInfo) { amount = oldInfo.amount; type = oldInfo.type; }