protected override void Start() { base.Start(); gun = GetComponent <GunScript>(); gun.ShooterTransform = transform; }
public void reapply() { //This is AmmoDisplay getting all of the GunScripts from this weapon, then saving the primary and secondary. gunScripts = this.GetComponents <GunScript>(); GunScript g; for (int i = 0; i < gunScripts.Length; i++) { g = gunScripts[i] as GunScript; if (g.isPrimaryWeapon) { gunScript = g; } } for (int q = 0; q < gunScripts.Length; q++) { g = gunScripts[q] as GunScript; if (!g.isPrimaryWeapon) { if (gunScript.secondaryWeapon == g) { gunScriptSecondary = g; } } } }
void checkBullet() { currentGun = theGunController.GetGun(); bulletText[0].text = currentGun.carryBulletCount.ToString(); bulletText[1].text = currentGun.reloadBulletCount.ToString(); bulletText[2].text = currentGun.currentBulletCount.ToString(); }
public GameObject bloodEffect; //blod effect prefab; /* * Upon hitting enemy it calls this method, gives it raycast hit info * and at that position it creates our blood prefab. */ void InstantiateBlood(RaycastHit _hitPos, bool swordHitWithGunOrNot) { if (currentWeapo == "gun") { GunScript.HitMarkerSound(); if (_hitSound) { _hitSound.Play(); } else { print("Missing hit sound"); } if (!swordHitWithGunOrNot) { if (bloodEffect) { Instantiate(bloodEffect, _hitPos.point, Quaternion.identity); } else { print("Missing blood effect prefab in the inspector."); } } } }
public void Apply(GunScript gscript) { gscript.ApplyToSharedAmmo(); cache = gscript.ammoSetUsed; gscript.ammoSetUsed = val; gscript.AlignToSharedAmmo(); }
// Use this for initialization void Start() { AIScript s = ((AIScript)gameObject.GetComponent<AIScript>()); s.AddStateScript(this); g = this.gameObject.GetComponent<GunScript>(); }
private void Awake() { objectiveText = GameObject.Find("Objective Text").GetComponent <TextMeshProUGUI>(); objectiveText.text = objective; objectiveText.CrossFadeAlpha(0, 0, true); savedText = GameObject.Find("Saved Text").GetComponent <TextMeshProUGUI>(); savedText.CrossFadeAlpha(0, 0, true); deathScreen = GameObject.Find("Death Screen"); deathScreen.SetActive(false); victoryScreen = GameObject.Find("Victory Screen"); victoryScreen.SetActive(false); player = GameObject.Find("Player"); playerController = player.GetComponent <PlayerControllerCC>(); playerHealth = player.GetComponent <PlayerHealth>(); cameraScript = player.GetComponentInChildren <MouseRotate>(); foreach (Transform child in player.transform.Find("First Person Camera")) { if (child.name.StartsWith("Gun ")) { ownedGuns.Add(child.GetComponent <GunScript>()); if (child.gameObject.activeInHierarchy) { currentGun = child.GetComponent <GunScript>(); } } } enemies = new List <GameObject>(GameObject.FindGameObjectsWithTag("Enemy")); livingEnemies = enemies.ToList(); }
// Use this for initialization void Start() { poweredUp = false; canPick = 0; anim = GetComponent <Animator>(); gun = FindObjectOfType <GunScript>(); }
public void Remove(GunScript g) { if (removeAnim != "" && g.gunActive) { transform.parent.BroadcastMessage("PlayAnim", applyAnim); } }
void Update() { var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); MouseOutlineTransform.position = new Vector3(mousePosition.x, mousePosition.y, 0F); var mouseX = mousePosition.x; if (mouseX > 0) { changeGunDirection(1); this.transform.position = new Vector3(mousePosition.x + 0.5F, this.transform.position.y, 0F); } else { changeGunDirection(-1); this.transform.position = new Vector3(mousePosition.x - 0.5F, this.transform.position.y, 0F); } bool shoot = Input.GetButtonDown("Fire1"); shoot |= Input.GetButtonDown("Fire2"); if (shoot) { GunScript gun = GetComponent <GunScript>(); if (gun != null) { gun.Attack(MouseOutlineTransform.position); } } }
void AimAction(int i) { // --------------------- Aim -------------------------- if (activeDevices[i] == Device.KeyboardMouse) // Mouse aiming { mouseInput = Input.mousePosition; activeGun = Main.Player <PuppetManip>(i).GetActiveGunScript(); if (activeGun != null) { activeGun.MouseAimUpdate(mouseInput, i); } //Debug.Log(DeviceNames[ (int)activeDevices[i] ] + "_Mouse" + mouseInput); } else // Normal aiming { aimInput.x = Input.GetAxisRaw(DeviceNames[(int)activeDevices[i]] + "_AimHorizontal"); aimInput.y = Input.GetAxisRaw(DeviceNames[(int)activeDevices[i]] + "_AimVertical"); activeGun = Main.Player <PuppetManip>(i).GetActiveGunScript(); if (activeGun != null) { activeGun.KeyAimUpdate(aimInput, i); } //Debug.Log( DeviceNames[ (int)activeDevices[i] ] + "_Aim" + aimInput); } }
public override void OnInspectorGUI() { EditorUtility.SetDirty(target); GunScript gunScript = (GunScript)target; gunScript.active = EditorGUILayout.Toggle("Enabled", gunScript.active); gunScript.hitEffect = (GameObject)EditorGUILayout.ObjectField("Hit Particle Effect", gunScript.hitEffect, typeof(GameObject), false); gunScript.shootSound = (AudioClip)EditorGUILayout.ObjectField("Sound of Shot", gunScript.shootSound, typeof(AudioClip), false); gunScript.emptySound = (AudioClip)EditorGUILayout.ObjectField("Sound of Empty Shot", gunScript.emptySound, typeof(AudioClip), false); gunScript.reloadSound = (AudioClip)EditorGUILayout.ObjectField("Sound of Reload", gunScript.reloadSound, typeof(AudioClip), false); EditorGUILayout.Space(); gunScript.damage = EditorGUILayout.FloatField("Damage", gunScript.damage); gunScript.range = Mathf.Max(EditorGUILayout.FloatField("Bullet Range", gunScript.range), 0); gunScript.automatic = EditorGUILayout.Toggle("Automatic Firing", gunScript.automatic); gunScript.cooldown = Mathf.Max(EditorGUILayout.FloatField("Shot Cooldown (s)", gunScript.cooldown), 0); gunScript.useMagazine = EditorGUILayout.Toggle("Use Magazines", gunScript.useMagazine); if (gunScript.useMagazine) { EditorGUI.indentLevel++; gunScript.magazineSize = Mathf.Max(EditorGUILayout.IntField("Magazine Size", gunScript.magazineSize), 1); gunScript.bulletsInMag = Mathf.Max(EditorGUILayout.IntField("Bullets in Magazine", gunScript.bulletsInMag), 0); gunScript.reloadTime = Mathf.Max(EditorGUILayout.FloatField("Reload Time (s)", gunScript.reloadTime), 0); gunScript.autoReload = EditorGUILayout.Toggle("Automatic Reloading", gunScript.autoReload); EditorGUI.indentLevel--; } GUILayout.BeginHorizontal(); if (!gunScript.infiniteBullets) { gunScript.bulletPile = Mathf.Max(EditorGUILayout.IntField("Other Bullets", gunScript.bulletPile), 0); } gunScript.infiniteBullets = EditorGUILayout.Toggle("Infinite Bullets", gunScript.infiniteBullets); GUILayout.EndHorizontal(); }
// Use this for initialization void Start() { script = GetComponent("Gun" + gun + "Script") as GunScript; script.SwitchIn(); //anim = GetComponentInParent<Animator>(); }
void Start() { playerScript = GetComponent <PlayerScript>(); inputScript = GetComponent <InputScript>(); gunScript = transform.GetComponentInChildren <GunScript>(); grappleScript = transform.GetComponentInChildren <GrappleScript>(); xRotation = 0f; }
private void GetAutoRifleAmmoInfo() { // Get automatic rifle ammo info auto_rifle_script = auto_rifle.GetComponent <GunScript>(); auto_rifle_max_ammo = auto_rifle_script.maxAmmo; auto_rifle_ammo = auto_rifle_script.currentAmmo; auto_rifle_mags = auto_rifle_script.mags; }
// Start is called before the first frame update void Start() { gunObject = transform.parent.parent.parent.GetComponent <GunScript>(); // Gets gun object materialRenderer = GetComponent <Renderer>(); // Gets material renderer maxLightIntensity = gunObject.maxLightMult; // Sets max light strength minLightIntensity = gunObject.normLightMult; // Sets min light strength }
// Start is called before the first frame update void Start() { audioSource = GetComponent <AudioSource>(); audioSource.clip = iceNoise; gun = GetComponentInChildren <GunScript>(); hook = grappleHook.GetComponent <HookScript>(); hook.ammo = 1f; }
public void GunInteraction(GunScript gun) { _gunScript.DropGun(); HoldGun(gun); _playerController.RemoveTriggersFromList(_closestGameObject.GetComponents <Collider>()); _gunScript = gun; }
public void AddGun(GunScript gun) { if(guns == null) { guns = new List<GunScript>(); } guns.Add(gun); }
public void BuyAmmo(WeaponInfo g) { withdraw(g.ammoPrice); GunScript temp = g.gameObject.GetComponent <GunScript>().GetPrimaryGunScript(); temp.clips = Mathf.Min(temp.clips + temp.ammoPerClip, temp.maxClips); temp.ApplyToSharedAmmo(); }
public void Remove(GunScript gscript) { gscript.ammoPerClip -= cache; if (gscript.ammoLeft > gscript.ammoPerClip) { gscript.ammoLeft = gscript.ammoPerClip; } }
private void OnEnable() { gun_script = (GunScript)target; systems = gun_script.GetGunSystems(); possible_components = typeof(GunComponent).GetAllDerivedTypes(); possible_systems = typeof(GunSystemBase).GetAllDerivedTypes(systems.GetType()); Update(); }
public void SwitchGun(GunScript gun) { if (currentGun != null) { Destroy(gun.gameObject); } currentGun = Instantiate(gun, gunPos.position, gunPos.rotation); currentGun.transform.parent = gunPos; }
void Start() { gun = transform.GetChild(0).gameObject; grapple = transform.GetChild(1).gameObject; playerScript = GetComponent <PlayerScript>(); gunScript = gun.GetComponent <GunScript>(); grappleScript = grapple.GetComponent <GrappleScript>(); }
public void Apply(GunScript gscript) { cache = val - gscript.ammoPerClip; gscript.ammoPerClip += cache; if (gscript.ammoLeft > gscript.ammoPerClip) { gscript.ammoLeft = gscript.ammoPerClip; } }
void Awake() { playerTransform = transform; playerBody = GetComponent <Rigidbody2D>(); playerAnim = GetComponent <Animator>(); playerRender = GetComponent <SpriteRenderer>(); armRender = transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>(); gun = transform.GetChild(0).gameObject.GetComponent <GunScript>(); }
// Start is called before the first frame update void Start() { _hero = GetComponent <Rigidbody2D>(); _heroZone = GetComponent <Collider2D>(); _heroImages = GetComponentsInChildren <SpriteRenderer>(); Debug.Log($"Init projectile {projectile.GetHashCode()}"); _direction = new Vector3(1, 0); _gun = _marker.GetComponent <GunScript>(); }
void Update() { player = GameObject.FindGameObjectWithTag("LocalPlayer"); GunScript gunScript = player.GetComponentInChildren <GunScript>(); leftBar.GetComponent <RectTransform>().localScale = new Vector2(initialScale.x, (gunScript.ammo > 0) ? initialScale.y : 0f); centerBar.GetComponent <RectTransform>().localScale = new Vector2(initialScale.x, (gunScript.ammo > 1) ? initialScale.y : 0f); rightBar.GetComponent <RectTransform>().localScale = new Vector2(initialScale.x, (gunScript.ammo > 2) ? initialScale.y : 0f); }
void Start() { gScript = GameObject.FindGameObjectWithTag("Gun").GetComponent <GunScript>(); soundScript = GameObject.FindGameObjectWithTag("Sound").GetComponent <SoundScript>(); anim = gameObject.GetComponent <Animator>(); InvokeRepeating("Flap", 0.15f, 0.15F); ranSpeed = Random.Range(0.002f, 0.008f); RandomColour = Random.Range(1, 5); anim.SetInteger("IntChooser", RandomColour); }
void updateGunUI() { gunImage.sprite = currWeapon.GetComponent <SpriteRenderer>().sprite; gunName.text = currWeapon.GetComponent <WeaponPickup>().weaponName; gun = currWeapon.GetComponent <GunScript>(); gun.ammoText = AmmoText; gun.setAmmoCounter(); }
private void HoldGun(GunScript gunScript) { if (gunScript) { _gunScript = gunScript; _gunScript.HoldGun(_playerController.RightHand, _playerController.GunAnchor); _animationsController.HoldGunIK.Gun = _gunScript.transform; } }
public void SwitchWeapons(int weaponIndex) { // If a weapon is equiped, disable it if (currentWeapon != -1) weapons[currentWeapon].SetActive(false); currentWeapon = weaponIndex; // Enable the new weapon weapons[currentWeapon].SetActive(true); weaponScript = weapons[currentWeapon].GetComponent<GunScript>(); }
// Use this for initialization void Awake() { if (mainPlayer == null) { DontDestroyOnLoad (gameObject); mainPlayer = this; } else if (mainPlayer!=this) { Destroy (gameObject); } gun = GetComponentInChildren<GunScript> (); ship = GetComponentInChildren<ShipController> (); platformer = GetComponentInChildren<PlatformController> (); }
void Update() { _getGun = gun.GetComponent<GunScript>(); }
// Use this for initialization void Start() { gun = GetComponentInParent<GunScript> (); master = MasterPlayer.mainPlayer; }