public void ChangeGun(int gunIndex, PlayerGunType type) { var gun = Instantiate(gunPrefabs[(int)type]) as GameObject; gun.transform.parent = weaponSlots[gunIndex].transform; gun.transform.localPosition = Vector3.zero; gun.transform.localRotation = Quaternion.identity; var oldGun = guns[gunIndex]; var newGun = gun.GetComponent<PlayerGun>(); foreach(var skill in oldGun.skills) { newGun.AddSkill(skill.Type); } Destroy(guns[gunIndex].gameObject); guns[gunIndex] = newGun; }
public void ChangeGun(int gunIndex, PlayerGunType type) { var gun = Instantiate(gunPrefabs[(int)type]) as GameObject; gun.transform.parent = weaponSlots[gunIndex].transform; gun.transform.localPosition = Vector3.zero; gun.transform.localRotation = Quaternion.identity; var oldGun = guns[gunIndex]; var newGun = gun.GetComponent <PlayerGun>(); foreach (var skill in oldGun.skills) { newGun.AddSkill(skill.Type); } Destroy(guns[gunIndex].gameObject); guns[gunIndex] = newGun; }
void ChangeGun(int gunIndex, PlayerGunType type) { GunController.ChangeGun(gunIndex, type); }