public void CreatePickup(GameObject gunObj) { GunPickup item = Instantiate(gunPickupPrefab).GetComponent <GunPickup>(); item.transform.position = RandomlySpawnOnNavMesh.RandomPoint(); item.gunObj = gunObj.gameObject; }
public void UpdateUI(GunPickup gun) { damage.text = gun.theGun.defaultConfig.damage.ToString(); crit.text = gun.theGun.defaultConfig.critChance.ToString(); mana.text = gun.theGun.defaultConfig.mana.ToString(); defection.text = gun.theGun.defaultConfig.deflection.ToString(); nameWeapon.text = gun.theGun.gunName; icon.sprite = gun.GetComponent <SpriteRenderer>().sprite; weapon = gun; }
private void GunPickup(RaycastHit swap) { gunPickupText.text = "Pickup " + swap.collider.name; pickupPanel.SetActive(true); if (Input.GetButtonDown(pickup)) { DropGun(); weapSpecs = swap.collider.GetComponent <GunPickup>(); weapon = Instantiate(weapSpecs.gun, hand.transform.position, hand.transform.rotation, hand.transform); currentWeapon = weapon.GetComponent <Weapon>(); currentWeapon.clipAmmo = weapSpecs.clipAmmo; currentWeapon.playerShot = playerNum; Destroy(swap.collider.gameObject); armed = true; UpdateDictionary(currentWeapon.ammoName, 0); currentAmmo = currentWeapon.ammoName; } }
public void DropGun() { if (armed != false) { GameObject oldWeaponPickup = Instantiate(currentWeapon.gunPickup, hand.transform.position, hand.transform.rotation) as GameObject; oldWeaponPickup.name = weapSpecs.gun.name; oldWeaponPickup.GetComponent <GunPickup>().clipAmmo = currentWeapon.clipAmmo; if (oldWeaponPickup.GetComponent <Rigidbody>()) { Rigidbody rb = oldWeaponPickup.GetComponent <Rigidbody>(); rb.AddForce(transform.forward * 500); } currentWeapon = null; currentAmmo = null; armed = false; weapSpecs = null; Destroy(weapon.gameObject); } }
// Use this for initialization void Start() { //currentLives = startingLives; vpnHUDImage.SetActive(false); tvPlayer = FindObjectOfType <PlayerController>(); evolveScript = FindObjectOfType <Evolve>(); batteryHealthScript = FindObjectOfType <BatteryHealth>(); boss1 = FindObjectOfType <Boss>(); playerGunScript = FindObjectOfType <PlayerGun>(); playerRouterScript = FindObjectOfType <PlayerRouter>(); levelEndScript = FindObjectOfType <LevelEnd>(); gunPickupScript = FindObjectOfType <GunPickup>(); routerPickupScript = FindObjectOfType <RouterPickup>(); //***********************LOADING SAVE DATA******************************************** if (PlayerPrefs.HasKey("ShieldChargeCount")) { playerRouterScript.shieldChargeCount = PlayerPrefs.GetInt("ShieldChargeCount"); } playerRouterScript.shieldChargeText.text = playerRouterScript.shieldChargeCount.ToString(); if (PlayerPrefs.HasKey("HasRouter")) { tvPlayer.hasRouter = PlayerPrefs.GetInt("HasRouter"); } if (PlayerPrefs.HasKey("HasVPN")) { tvPlayer.hasVPN = PlayerPrefs.GetInt("HasVPN"); } if (PlayerPrefs.HasKey("HasGun")) { tvPlayer.hasGun = PlayerPrefs.GetInt("HasGun"); } //Checks for if you have phaser bullets. If there you do, it will load those back. //CODE GOES HERE // if (PlayerPrefs.HasKey("PhaserBulletCount")) { playerGunScript.phaserBulletCount = PlayerPrefs.GetInt("PhaserBulletCount"); } playerGunScript.phaserBulletText.text = playerGunScript.phaserBulletCount.ToString(); //Checks for if you have memory cards, and if there is value, load it back. if (PlayerPrefs.HasKey("MemCount")) { memCount = PlayerPrefs.GetInt("MemCount"); } memText.text = memCount.ToString(); //Checks for if you have upgrades, and if there is a value, load it back. if (PlayerPrefs.HasKey("UpgradeCount")) { upgradeCount = PlayerPrefs.GetInt("UpgradeCount"); } upgradeText.text = upgradeCount.ToString(); //Checks for if you have lives, and if there is value, load it back. if (PlayerPrefs.HasKey("PlayerLives")) { currentLives = PlayerPrefs.GetInt("PlayerLives"); } else { currentLives = startingLives; } //currentLives = startingLives; livesText.text = "x " + currentLives; objectsToReset = FindObjectsOfType <ResetOnRespawn>(); }
private void UpdatePickupMessage() { if (m_MenuController.WeaponManager.Target != null) { if (m_MenuController.WeaponManager.CanSwitch) { GunPickup gunPickup = m_MenuController.WeaponManager.Target.GetComponent <GunPickup>(); if (gunPickup != null) { IWeapon weapon = m_MenuController.WeaponManager.GetWeaponByID(gunPickup.ID); if (weapon != null) { if (!m_MenuController.WeaponManager.IsEquipped(weapon)) { if (m_MenuController.WeaponManager.HasFreeSlot) { m_KeyButton.SetActive(true); ShowPickupMessage("TO PICK UP <color=#FCB628>" + ((Gun)weapon).InspectorName + "</color>"); } else { m_KeyButton.SetActive(true); ShowPickupMessage("TO SWAP <color=#FCB628>" + m_MenuController.WeaponManager.GunName + "</color> FOR THE <color=#FCB628>" + ((Gun)weapon).InspectorName + "</color>"); } } else { m_KeyButton.SetActive(false); ShowPickupMessage("<color=#FCB628>" + ((Gun)weapon).InspectorName + "</color> ALREADY EQUIPPED"); } } } else { HidePickupMessage(); } IActionable target = m_MenuController.WeaponManager.Target.GetComponent <IActionable>(); if (target != null) { m_KeyButton.SetActive(true); ShowPickupMessage("TO " + target.Message()); } if (m_MenuController.WeaponManager.GunID != -1) { if (m_MenuController.WeaponManager.Target.CompareTag(m_MenuController.WeaponManager.AmmoTag)) { m_KeyButton.SetActive(true); ShowPickupMessage("TO REFILL <color=#FCB628>AMMO</color>"); } if (m_MenuController.WeaponManager.Target.CompareTag(m_MenuController.WeaponManager .AdrenalinePackTag) && m_MenuController.Adrenaline.CanRefill) { m_KeyButton.SetActive(true); ShowPickupMessage("TO PICK UP <color=#FCB628>ADRENALINE SHOTS</color>"); } } if (!m_MenuController.WeaponManager.Target.CompareTag(m_MenuController.WeaponManager.AmmoTag) && !m_MenuController.WeaponManager.Target.CompareTag(m_MenuController.WeaponManager .AdrenalinePackTag) && target == null && gunPickup == null) { HidePickupMessage(); } } } else { HidePickupMessage(); } }