public void PopulateDrop() { WeaponInfo = weapon.GetComponent <WeaponInfo>(); ammo = (int)WeaponInfo.gun.ammoLeft; if (!PlayerWeapons.saveUpgradesToDrops) { return; } upgradesApplied = new bool[WeaponInfo.upgrades.Length]; for (int i = 0; i < WeaponInfo.upgrades.Length; i++) { upgradesApplied[i] = WeaponInfo.upgrades[i].applied; } }
//This function displays popup messages, including the weapon locked message. public void WeaponLockedWindow(int windowID) { WeaponInfo g = mdBuy.wi[mdBuy.selection]; GUILayout.BeginArea(new Rect(5, 10, popupLockedRect.width - 10, popupLockedRect.height - 20)); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.Label(g.lockedDescription); GUILayout.FlexibleSpace(); if (GUILayout.Button("Close")) { MDSelection = -1; popupActive = false; popupLockedActive = false; } GUILayout.EndVertical(); GUILayout.EndArea(); }
public int autoEquipWeapon(WeaponInfo w, bool auto) { //Slot the weapon is equipped in, -1 if not equipped int slot = -1; //find the first empty slot that can hold w for (int i = 0; i < playerW.weapons.Length; i++) { if (slotInfo.isWeaponAllowed(i, w) && playerW.weapons[i] == null) { //equipWeapon(w,i); slot = i; } if (slot >= 0) { return(slot); } } if (!auto) { return(slot); } if (slotInfo.isWeaponAllowed(playerW.selectedWeapon, w)) { //equipWeapon(w,i); slot = playerW.selectedWeapon; return(slot); } for (int i = 0; i < playerW.weapons.Length; i++) { if (slotInfo.isWeaponAllowed(i, w)) { //equipWeapon(w,i); slot = i; } if (slot >= 0) { return(slot); } } return(slot); }
public void equipWeapon(WeaponInfo g, int slot) { //if the weapon is equipped in another slot, unequip it if (slot < 0) { return; } for (int i = 0; i < playerW.weapons.Length; i++) { if (g.gameObject == playerW.weapons[i]) { unEquipWeapon(g, i); } } if (playerW.weapons[playerW.selectedWeapon] == null) { playerW.selectedWeapon = slot; } playerW.BroadcastMessage("DeselectWeapon", SendMessageOptions.DontRequireReceiver); GunScript tempGScript = g.gameObject.GetComponent <GunScript>().GetPrimaryGunScript(); tempGScript.ammoLeft = tempGScript.ammoPerClip; playerW.SetWeapon(g.gameObject, slot); }
//the following two functions are used just to cleanup the logic in the Buy/Upgrade popup window public string getBuyMsg(WeaponInfo g) { string msg; msg = "Weapon Name: " + g.gunName + "\n\n"; if (g.owned) { msg += "Weapon Not Owned\n"; } else { msg += "Weapon Owned\n"; } msg += "Description: " + g.gunDescription + "\n\n"; if (g.owned) { msg += "Sell Price: $" + g.sellPriceUpgraded + "\n"; } else { msg += "Price: $" + g.buyPrice; } return(msg); }
public void buyUpgrade(WeaponInfo g, Upgrade u) { withdraw(u.buyPrice); u.owned = true; g.ApplyUpgrade(); }
public void unEquipWeapon(WeaponInfo g, int slot) { playerW.weapons[slot] = null; }
//Swaps out currently selected for given one, dropping currently selected weapon public static void Pickup(GameObject selectedWeapon) { if (GunScript.takingOut) { return; } bool hasFlag = false; if (!PlayerWeapons.canSwapSameWeapon) { for (int i = 0; i < playerWeapons.weapons.Length; i++) { if (playerWeapons.weapons[i] == selectedWeapon.GetComponent <SelectableWeapon>().weapon) { return; } } } if (playerWeapons.weapons[playerWeapons.selectedWeapon] == selectedWeapon.GetComponent <SelectableWeapon>().weapon) { hasFlag = true; } WeaponInfo selectedWeaponInfo = selectedWeapon.GetComponent <SelectableWeapon>().weapon.GetComponent <WeaponInfo>(); //Get applicable slot int theSlot = 1; //store.autoEquipWeaponWithReplacement(selectedWeaponInfo, true); if (theSlot < 0 && !playerWeapons.weapons[playerWeapons.selectedWeapon] == null) { return; } //We now own the weapon if (selectedWeaponInfo != null) { selectedWeaponInfo.owned = true; selectedWeaponInfo.locked = false; } DropObject(theSlot, selectedWeapon); GunScript gscript; if (playerWeapons.weapons[playerWeapons.selectedWeapon] != null) { gscript = playerWeapons.weapons[playerWeapons.selectedWeapon].GetComponent <GunScript>().GetPrimaryGunScript(); } //Get new weapon if (hasFlag) { gscript = playerWeapons.weapons[playerWeapons.selectedWeapon].GetComponent <GunScript>().GetPrimaryGunScript(); selectedWeapon.GetComponent <SelectableWeapon>().Apply(gscript); playerWeapons.weapons[playerWeapons.selectedWeapon].BroadcastMessage("DeselectInstant"); playerWeapons.ActivateWeapon(); //playerWeapons.weapons[playerWeapons.selectedWeapon].BroadcastMessage("SelectWeapon"); } else { playerWeapons.weapons[theSlot] = selectedWeapon.GetComponent <SelectableWeapon>().weapon; playerWeapons.selectedWeapon = theSlot; gscript = playerWeapons.weapons[playerWeapons.selectedWeapon].GetComponent <GunScript>().GetPrimaryGunScript(); selectedWeapon.GetComponent <SelectableWeapon>().Apply(gscript); playerWeapons.ActivateWeapon(); } if (singleton.destroyPickups) { Destroy(selectedWeapon); } }
void Start() { WeaponInfo = weapon.GetComponent <WeaponInfo>(); }
void Start() { WeaponInfo = GetComponent <WeaponInfo>(); display = false; }