private void FixedUpdate() { RotateWheels(350); if (lives < 15 && !damaged) { damaged = true; agent.speed = damagedSpeed; AudioFW.Play("TruckDamaged"); } if (lives < 1) { EnemyManager.enemiesLeft--; GunShoot gun = GameObject.Find("BulletSpawn").GetComponent <GunShoot>(); gun.kills++; Clipboard.instance.ChangeKills(gun.kills.ToString()); Destroy(gameObject); GameObject deadTruck = Instantiate(truckDeath, transform.position, transform.rotation); Destroy(deadTruck, 5f); CameraShaker.GetInstance("Main Camera").ShakeOnce(6f, 5f, 0.0f, 2.5f); AudioFW.Play("TruckDie"); } if (damaged) { flames.SetActive(true); } }
// Use this for initialization void Start() { ammoBoxAnims = gameObject.GetComponent <Animator>(); lifting = false; currentAmmoClip = null; Gun = GameObject.Find("Gun").GetComponent <GunShoot>(); }
IEnumerator ShootWaiter() { yield return(new WaitForSeconds(0.1f)); GunShoot gunShoot = (GunShoot)GameObject.Find("GunShoot").GetComponent("GunShoot"); gunShoot.FireIt = true; }
// Use this for initialization void Start() { ammoLeft = 1f; startPoint = transform.position; ClipPoint = GameObject.Find("ClipPoint").transform; Gun = GameObject.Find("Gun").GetComponent <GunShoot>(); ClipAnims = gameObject.GetComponent <Animator>(); }
public void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player") { GunShoot shoot = other.gameObject.GetComponentInChildren <GunShoot>(); shoot.currentAmmo += ammoNumber; Destroy(gameObject); } }
private void OnCollisionEnter(Collision collision) { GameObject player = GameObject.FindObjectOfType <PlayerHealth>().gameObject; GunShoot muzzle = GameObject.FindObjectOfType <GunShoot>(); if (collision.gameObject == player) { muzzle.rechargeAmmo(100); Destroy(gameObject, 1f); } }
// Use this for initialization void Start() { ammoAmount = ammoText.GetComponent <Text>(); playerHealthText = playerText.GetComponent <Text>(); pis = pistol.GetComponent <GunShoot>(); /* * shot = shotgun.GetComponent<GunShoot>(); * rif = rifle.GetComponent<GunShoot>(); * sub = subway.GetComponent<GunShoot>(); */ playerHealthText.text = playerHealth.ToString(); }
void LoadClip() { transform.position = LoadPoint.position; transform.rotation = LoadPoint.rotation; transform.SetParent(ClipPoint); flyingToTarget = false; ClipAnims.enabled = true; ClipAnims.SetTrigger("Insert"); if (Gun == null) { Gun = GameObject.Find("Gun").GetComponent <GunShoot>(); } Gun.ReloadClip(gameObject); }
void Start() { gunsParent = transform.FindChild("Guns"); gunShoot = GameObject.FindGameObjectWithTag("Ammo").GetComponent <GunShoot> (); if (PlayerPrefs.GetString("currentGun1") != "") { ActualEquipedGun = ("Equip" + PlayerPrefs.GetString("currentGun1")); ActualGun = PlayerPrefs.GetString("currentGun1"); } else { ActualEquipedGun = ("Equip" + PlayerPrefs.GetString("currentGun2")); ActualGun = PlayerPrefs.GetString("currentGun2"); } }
void ThrowWeapon(GameObject weaponToThrow) { GameObject tempWeapon = Instantiate(weaponToThrow.GetComponent <PickUpProperties>().actualGunPrefab, weaponSlot.position, weaponSlot.rotation); tempWeapon.GetComponent <Rigidbody>().AddForce(4 * weaponSlot.transform.forward, ForceMode.Impulse); tempWeapon.GetComponent <Rigidbody>().AddTorque(2 * weaponSlot.transform.up, ForceMode.Impulse); Weapon weaponValues = tempWeapon.GetComponent <Weapon>(); weaponValues.CopyFrom(weaponToThrow.GetComponent <Weapon>()); weaponValues.isPickup = true; if (weaponValues.weaponType == Weapon.WeaponType.Gun) { Shoot tempShoot = (Shoot)weaponValues; tempShoot.CopyFrom(weaponToThrow.GetComponent <Shoot>()); switch (tempShoot.shootType) { case Shoot.ShootType.GunShoot: GunShoot tempGunShoot = (GunShoot)(tempShoot); tempGunShoot.CopyFrom(weaponToThrow.GetComponent <GunShoot>()); break; case Shoot.ShootType.ShotgunShoot: ShotgunShoot tempShotgun = (ShotgunShoot)(tempShoot); tempShotgun.CopyFrom(weaponToThrow.GetComponent <ShotgunShoot>()); break; case Shoot.ShootType.SemiAutoShoot: break; case Shoot.ShootType.ChargeShoot: ChargeShoot chargeShoot = (ChargeShoot)tempShoot; chargeShoot.CopyFrom(weaponToThrow.GetComponent <ChargeShoot>()); break; case Shoot.ShootType.ProjectileShoot: break; } } else { MeleeAttack tempMelee = (MeleeAttack)weaponValues; tempMelee.CopyFrom(weaponToThrow.GetComponent <MeleeAttack>()); } Destroy(weaponToThrow); UpdateEquippedWeapons(); }
// Use this for initialization void Start() { gunShoot = GameObject.Find("Player").GetComponent <GunShoot>(); if (selectWeapon == SelectWeapon.machineGun) { machineGun = Resources.Load("Guns/MachineGun", typeof(GameObject)) as GameObject; timer = 60.0f; machineGunToDestroy = Instantiate(machineGun, this.transform); } if (selectWeapon == SelectWeapon.bazooka) { bazooka = Resources.Load("Guns/Bazooka", typeof(GameObject)) as GameObject; timer = 120.0f; bazookaToDestroy = Instantiate(bazooka, this.transform); } }
public virtual void PickUpWeapon(GameObject weapon) { if (weapon.name == "m4a1(Clone)") { currGun = guns[0]; guns[1].SetActive(false); } else if (weapon.name == "ump45(Clone)") { currGun = guns[1]; guns[0].SetActive(false); } currGun.SetActive(true); gunShoot = currGun.GetComponent <GunShoot>(); isHaveWeapon = true; weapon.SetActive(false); }
public override void CopyFrom(Weapon weapon) { base.CopyFrom(weapon); if (weapon.weaponType == WeaponType.Gun) { Shoot tempShoot = (Shoot)weapon; if (tempShoot.shootType == ShootType.GunShoot) { GunShoot gunShoot = (GunShoot)tempShoot; angleSpreadAdder = gunShoot.angleSpreadAdder; reticleDecreaseSpeed = gunShoot.reticleDecreaseSpeed; reticleGameObject = gunShoot.reticleGameObject; reticleIncreaseAmount = gunShoot.reticleIncreaseAmount; reticleHasBloom = gunShoot.reticleHasBloom; } } }
void TypeingCorrectionSecond(char c) { StringBuilder sb = new StringBuilder(); if (c == bullshitCharSetSecond[correctCharNumbSecond]) { GunAim gunAim = (GunAim)GameObject.Find("GunAim").GetComponent("GunAim"); float mouseX = Screen.width * 0.670f + UnityEngine.Random.Range(-30f, 30f); float mouseY = Screen.height * ASPECT_RATIO_MULTIPLIER + UnityEngine.Random.Range(-26f, 30f); gunAim.mouseX = mouseX; gunAim.mouseY = mouseY; GunShoot gunShoot = (GunShoot)GameObject.Find("GunShoot").GetComponent("GunShoot"); gunShoot.FireIt = true; if (correctCharNumbSecond > 0) { sb.Append("<color=#00FF00><b>"); sb.Append(secondPartString.Substring(0, correctCharNumbSecond)); } else { sb.Append("<color=#00FF00><b>"); } correctCharNumbSecond++; sb.Append(c); sb.Append("</b></color>"); sb.Append("<color=white>"); BadSubString = secondPartString.Substring(correctCharNumbSecond); sb.Append(BadSubString); sb.Append("</color>"); correctString = sb.ToString(); //Debug.Log(correctString); //description.text = correctString; scriptFlesh.npcName = correctString; scriptFlesh.IsCorrectType = true; } else { scriptFlesh.IsCorrectType = false; } }
public void Start() { Damage = GetComponent <GunShoot>(); EmenySOund = GetComponent <AudioSource>(); }
void Start() { gunShoot = GameObject.FindGameObjectWithTag("Ammo").GetComponent <GunShoot>(); }
void Update() { if ((Input.GetKey(control.pauseMenu) || Input.GetKey(control.inventory)) && isCoroutineRunning) { gameObject.GetComponent <PauseGame>().HideAttachmentMenu(); StopCoroutine("AttachWeapon"); attachmentToAttach = null; isCoroutineRunning = false; } Ray ray = new Ray(cam.transform.position, cam.transform.forward); RaycastHit hit; Debug.DrawRay(ray.origin, ray.direction); if (Physics.Raycast(ray, out hit, 5)) { if (hit.collider.CompareTag("Chest") || hit.collider.gameObject.GetComponent <ChestContents>()) { useText.SetActive(true); chest = hit.collider.GetComponent <ChestContents>(); useText.GetComponent <Text>().text = chest.ammoChest ? "Pick up Ammo" : "Open Chest"; if (Input.GetKeyDown(control.use)) { if (chest.ammoChest) { currentAmmo = weaponSwitch.equippedWeapon.GetComponent <Weapon>().ammo.GetComponent <Amount>(); currentAmmo.amountOf += currentAmmo.limit; } else { pause.ShowChestAndInventory(); chestDisplay.SetChestContents(chest); inventoryDisplay.SetOpenChest(chest); } } } else if (hit.collider.gameObject.CompareTag("Weapon")) { useText.SetActive(true); useText.GetComponent <Text>().text = "Pick up " + hit.collider.gameObject.GetComponent <PickUpProperties>().actualGunPrefab.name; string weaponName = hit.collider.gameObject.GetComponent <PickUpProperties>().actualGunPrefab.name; if (weaponSlot.childCount >= weaponSwitch.maxWeapons) { useText.GetComponent <Text>().text = "Replace current weapon with " + weaponName; } UpdateEquippedWeapons(); if (Input.GetKeyDown(control.use)) { if (weaponSlot.childCount >= weaponSwitch.maxWeapons) { GameObject tempWeapon = Instantiate(hit.collider.gameObject.GetComponent <PickUpProperties>().actualGunPrefab, weaponSlot.position, weaponSlot.rotation, weaponSlot); tempWeapon.name = weaponName; equippedWeapons[weaponSwitch.currentWeapon].name = hit.collider.gameObject.GetComponent <PickUpProperties>().actualGunPrefab.name; equippedWeapons[weaponSwitch.currentWeapon].weapon = tempWeapon; Weapon weaponValues = tempWeapon.GetComponent <Weapon>(); weaponValues.CopyFrom(hit.collider.gameObject.GetComponent <Weapon>()); if (weaponValues.weaponType == Weapon.WeaponType.Gun) { Shoot tempShoot = (Shoot)weaponValues; tempShoot.CopyFrom(hit.collider.gameObject.GetComponent <Shoot>()); switch (tempShoot.shootType) { case Shoot.ShootType.GunShoot: GunShoot gunShoot = (GunShoot)tempShoot; gunShoot.CopyFrom(hit.collider.gameObject.GetComponent <GunShoot>()); break; case Shoot.ShootType.ShotgunShoot: ShotgunShoot shotgun = (ShotgunShoot)tempShoot; shotgun.CopyFrom(hit.collider.gameObject.GetComponent <ShotgunShoot>()); break; case Shoot.ShootType.SemiAutoShoot: break; case Shoot.ShootType.ChargeShoot: ChargeShoot chargeShoot = (ChargeShoot)tempShoot; chargeShoot.CopyFrom(hit.collider.gameObject.GetComponent <ChargeShoot>()); break; case Shoot.ShootType.ProjectileShoot: break; } } else { MeleeAttack tempMelee = (MeleeAttack)weaponValues; tempMelee.CopyFrom(hit.collider.GetComponent <MeleeAttack>()); } tempWeapon.transform.SetSiblingIndex(weaponSwitch.currentWeapon); GameObject weaponToDestroy = weaponSlot.GetChild(weaponSwitch.currentWeapon + 1).gameObject; hit.collider.gameObject.GetComponent <MiniMapIndicator>().DestroyCurrentIcon(); ThrowWeapon(weaponToDestroy); Destroy(weaponToDestroy); UpdateEquippedWeapons(); Destroy(hit.collider.gameObject); } else { GameObject weaponPickedUp = hit.collider.gameObject; GameObject tempWeapon = Instantiate(weaponPickedUp.GetComponent <PickUpProperties>().actualGunPrefab, weaponSlot.position, weaponSlot.rotation, weaponSlot); tempWeapon.name = weaponName; UpdateEquippedWeapons(); Weapon weaponValues = tempWeapon.GetComponent <Weapon>(); weaponValues.CopyFrom(weaponPickedUp.GetComponent <Weapon>()); weaponValues.isPickup = false; if (weaponValues.weaponType == Weapon.WeaponType.Gun) { Shoot tempShoot = (Shoot)weaponValues; tempShoot.CopyFrom(hit.collider.gameObject.GetComponent <Shoot>()); switch (tempShoot.shootType) { case Shoot.ShootType.GunShoot: GunShoot gunShoot = (GunShoot)tempShoot; gunShoot.CopyFrom(hit.collider.gameObject.GetComponent <GunShoot>()); break; case Shoot.ShootType.ShotgunShoot: ShotgunShoot shotgun = (ShotgunShoot)tempShoot; shotgun.CopyFrom(hit.collider.gameObject.GetComponent <ShotgunShoot>()); break; case Shoot.ShootType.SemiAutoShoot: break; case Shoot.ShootType.ChargeShoot: ChargeShoot chargeShoot = (ChargeShoot)tempShoot; chargeShoot.CopyFrom(hit.collider.gameObject.GetComponent <ChargeShoot>()); break; case Shoot.ShootType.ProjectileShoot: break; } } else { MeleeAttack tempMelee = (MeleeAttack)weaponValues; tempMelee.CopyFrom(hit.collider.GetComponent <MeleeAttack>()); } weaponSwitch.DisableWeapon(tempWeapon); hit.collider.gameObject.GetComponent <MiniMapIndicator>().DestroyCurrentIcon(); Destroy(hit.collider.gameObject); } } } else if (hit.collider.gameObject.CompareTag("Door")) { Door tempDoor = hit.collider.gameObject.GetComponent <Door>(); useText.SetActive(true); Text text = useText.GetComponent <Text>(); if (tempDoor.GetIsLocked()) { bool hasKey = false; int keyLoc = 0; for (int i = 0; i < keyNumbers.Count; i++) { hasKey = tempDoor.IsCorrectKey(keyNumbers[i]); if (hasKey) { keyLoc = i; } } text.text = (hasKey) ? "Unlock door" : "Door requires key!"; if (Input.GetKeyDown(control.use) && hasKey) { tempDoor.UnlockDoor(keyNumbers[keyLoc]); keyNumbers.RemoveAt(keyLoc); } } else if ((tempDoor.doorType == Door.DoorType.Use || tempDoor.doorType == Door.DoorType.RequiresKeyAfter || tempDoor.doorType == Door.DoorType.RequiresKeyInit) && !tempDoor.isOpen) { text.text = "Open door"; if (Input.GetKeyDown(control.use)) { tempDoor.OpenDoorWithUse(); } } else if (tempDoor.isOpen && tempDoor.doorType == Door.DoorType.Use) { text.text = "Close door"; if (Input.GetKeyDown(control.use)) { tempDoor.CloseDoorWithUse(); } } else { useText.SetActive(false); } } else if (hit.collider.gameObject.CompareTag("Key")) { useText.SetActive(true); Text text = useText.GetComponent <Text>(); text.text = "Pickup key"; if (Input.GetKeyDown(control.use)) { try { Key key = hit.collider.gameObject.GetComponent <Key>(); keyNumbers.Add(key.keyNumber); Destroy(hit.collider.gameObject); } catch (MissingComponentException e) { Debug.LogException(e); } } } else { useText.SetActive(false); } } else { useText.SetActive(false); } if (Input.GetKeyDown(control.throwWeapon)) { if (weaponSlot.GetChild(weaponSwitch.currentWeapon).gameObject != null) { ThrowWeapon(weaponSlot.GetChild(weaponSwitch.currentWeapon).gameObject); weaponSwitch.SwitchWeaponUp(); } UpdateEquippedWeapons(); } }
private void Awake() { Shoot = FindObjectOfType <GunShoot>(); Stats = GetComponent <PlayerStats>(); CurrentStats = Instantiate(CurrentStats); }