IEnumerator OnScoped() { scopeSound.Play(); yield return(new WaitForSeconds(0.15f)); WeaponSwitching w = gameObject.GetComponent <WeaponSwitching>(); for (int i = 0; i < 3; i++) { if (w.currWeapon == i) { scopes[i].SetActive(true); } else { scopes[i].SetActive(false); } } weaponCam.SetActive(false); if (w.currWeapon == 5) //AR { mainCam.fieldOfView = scopedFOV + 20; } else { mainCam.fieldOfView = scopedFOV; } MouseLook ml = mainCamera.GetComponent <MouseLook>(); ml.mouseSensitivity = 80.0f; }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(1)) { if (animator.GetBool("Reloading")) { return; } WeaponSwitching w = gameObject.GetComponent <WeaponSwitching>(); if (w.currWeapon == 3 || w.currWeapon == 4 || w.currWeapon == 6 || w.currWeapon == 7) //laser weapon, knife, grenade or portal gun { return; } isScoped = !isScoped; animator.SetBool("Scoped", isScoped); if (isScoped) { crosshair.enabled = false; StartCoroutine(OnScoped()); } else { //The crosshair bug could be fixed if I add a check for //weapon reload state crosshair.enabled = true; OnUnScoped(); } } }
void OnTriggerEnter(Collider collider) { if (collider.gameObject.tag == "Player") { if (gameObject.tag == "col_gun0") { WeaponSwitching.HAS_MACHINE_GUN = true; WeaponSwitching.index = 0; WeaponSwitching.selectedWeapon = 0; WeaponSwitching.SwitchWeapons(trans_wep_0, trans_wep_1, trans_wep_2); } else if (gameObject.tag == "col_gun1") { WeaponSwitching.HAS_SNIPER_RIFLE = true; WeaponSwitching.index = 1; WeaponSwitching.selectedWeapon = 1; WeaponSwitching.SwitchWeapons(trans_wep_0, trans_wep_1, trans_wep_2); } else if (gameObject.tag == "col_gun2") { WeaponSwitching.HAS_GRANADE_LAUNCHER = true; WeaponSwitching.index = 2; WeaponSwitching.selectedWeapon = 2; WeaponSwitching.SwitchWeapons(trans_wep_0, trans_wep_1, trans_wep_2); } Destroy(gameObject); } }
private void Start() { fakeWeapon = gameObject; pickupSound = audioFX[transform.tag]; weaponHolder = GameObject.FindGameObjectWithTag("WeaponHolder"); switchingScript = weaponHolder.GetComponent <WeaponSwitching>(); }
void Awake() { anim = GetComponent <Animator>(); player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealth>(); playerWeapon = player.GetComponent <Player>().weaponSwitching; }
// Start is called before the first frame update void Start() { isComplete = false; isGameOver = false; killCount = 0; if (PlayerPrefs.HasKey("CurrentGems")) { gemCount = PlayerPrefs.GetInt("CurrentGems"); } else { gemCount = 0; } gemText.text = gemCount.ToString(); if (PlayerPrefs.HasKey("CurrentLevel")) { currentLevel = PlayerPrefs.GetInt("CurrentLevel"); } else { currentLevel = 1; } playerController = FindObjectOfType <PlayerController>(); levelPortal = FindObjectOfType <LevelPortal>(); waveSpawner = FindObjectOfType <WaveSpawner2>(); weaponSwitching = FindObjectOfType <WeaponSwitching>(); crosshair = FindObjectOfType <Crosshair>(); updateKillGoal(); killText.text = killCount.ToString() + "/" + killGoal.ToString(); killText.color = Color.white; }
private void Awake() { playerCamera = GetComponentInChildren <PlayerCamera> (); weaponSwitcher = GetComponentInChildren <WeaponSwitching> (); player = GetComponent <Player> (); weapon = weaponSwitcher?.SelectWeapon(); }
void Start() { weaponSwitching = GameObject.FindObjectOfType <WeaponSwitching>(); //revolverFire = GameObject.FindObjectOfType<RevolverFire>(); //repeaterFire = GameObject.FindObjectOfType<RepeaterFire>(); //shotgunFire = GameObject.FindObjectOfType<ShotgunFire>(); //bowFire = GameObject.FindObjectOfType<BowFire>(); }
void Start() { currentAmmo = maxAmmo; source = GetComponent <AudioSource>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>(); weaponSwitching = GameObject.FindGameObjectWithTag("WeaponHolder").GetComponent <WeaponSwitching>(); ammoTextMesh.SetText(maxAmmo.ToString()); }
// Start is called before the first frame update void Start() { networkAnimator = GetComponent <NetworkAnimator>(); weaponSwitcher = weaponHolder.GetComponent <WeaponSwitching>(); EquipWeapon(defaultWeapon); GetComponent <EquipmentManager>().EquipDefault(weaponHolder); GetComponent <Player>().zombifyPlayer += Disarm; }
/* * private void OnTriggerStay(Collider other) * { * * if (other.gameObject.CompareTag("Player") && Input.GetKeyDown(input)) * { * * if (isLocked && needKey) * { * * Inventory inv = other.transform.GetComponent<Inventory>(); * if (inv != null) * { * * if (inv.key) * { * * doorTextObj.SetActive(false); * UnlockDoor(); * } * * else * { * * doorText.text = "You need a key."; * doorTextObj.SetActive(true); * DoorLocked(); * * } * * } * * return; * * } * else if (isLocked) * { * * WeaponSwitching wpSwitch = other.GetComponentInChildren<WeaponSwitching>(); * if (wpSwitch != null) * { * * if (wpSwitch.selectedWeapon == 0) * { * * doorTextObj.SetActive(false); * UnlockDoor(); * } * * else * { * * doorText.text = "Door is locked or jammed. Try using a crowbar."; * doorTextObj.SetActive(true); * DoorLocked(); * * } * * } * * return; * * } * * if (isOpen) * { * * CloseDoor(); * * } * else OpenDoor(); * * } * * } */ private void OnTriggerStay(Collider other) { if (other.gameObject.CompareTag("Player") && Input.GetKeyDown(input)) { if (isLocked) { if (needKey) { Inventory inv = other.transform.GetComponent <Inventory>(); if (inv != null) { if (inv.key) { doorTextObj.SetActive(false); UnlockDoor(); } else { doorText.text = "You need a key."; doorTextObj.SetActive(true); DoorLocked(); } } return; } else { WeaponSwitching wpSwitch = other.GetComponentInChildren <WeaponSwitching>(); if (wpSwitch != null) { if (wpSwitch.selectedWeapon == 0) { doorTextObj.SetActive(false); UnlockDoor(); } else { doorText.text = "Door is locked or jammed. Try using a crowbar."; doorTextObj.SetActive(true); DoorLocked(); } } return; } } else if (isOpen) { CloseDoor(); } else { OpenDoor(); } } }
void Awake() { weaponSwitching = GetComponentInParent <WeaponSwitching>(); currentAmmo = maxAmmo; shootableMask = LayerMask.GetMask("Shootable"); gunParticles = GetComponent <ParticleSystem>(); gunLine = GetComponent <LineRenderer>(); gunLight = GetComponent <Light>(); }
protected override void Start() { controller = GetComponent <CharacterController>(); cam = Camera.main; weaponSwitching = GetComponentInChildren <WeaponSwitching>(); alertArrowController = GetComponentInChildren <AlertArrowController>(); base.Start(); }
// Start is called before the first frame update void Start() { background.enabled = false; Xlogo.enabled = false; text.enabled = false; text1.enabled = false; Player = GameObject.FindGameObjectWithTag("Player"); script = gc.GetComponent <GameController>(); activated = false; script2 = FPC.GetComponent <WeaponSwitching>(); }
void Start() { animator = GetComponent <Animator>(); clicks = 0; canClick = true; movScript = FindObjectOfType <Movimentacao>(); weaponIdScript = FindObjectOfType <WeaponSwitching>(); dashScript = FindObjectOfType <dashMove>(); jumpScript = FindObjectOfType <PlayerJump>(); }
// adds the obtained Weapon to the weapons slot public void addWeapon(Weapon newWeapon, GameObject weaponButton, int Slot_i) { Weapon newGun = Instantiate(newWeapon, transform.position, Quaternion.identity, WeaponHolder.transform); newGun.currentWeaponSlot = Slot_i; newGun.ammoTextMesh = weaponButton.GetComponentInChildren <TextMeshProUGUI>(); newGun.weaponSlotPosUI = Slot_i; WeaponSwitching weaponSwitching = WeaponHolder.GetComponent <WeaponSwitching>(); weaponSwitching.currentAvailableWeapons++; weaponSwitching.SelectWeapon(); }
protected override void Pickup(Collider2D col) { //get component of the Weapon Switching script WeaponSwitching weaponSwitching = col.gameObject.GetComponentInChildren <WeaponSwitching>(); //Change weapon index weaponSwitching.selectedWeapon = weaponIndex; //call the method to change weapon weaponSwitching.SelectWeapon(); //Destroy powerup Destroy(gameObject); }
void Start() { weaponManager = weaponHolder.GetComponent <WeaponSwitching>(); int nowLoadingGame = PlayerPrefs.GetInt("Game_Starting_Loading", 0); if (nowLoadingGame == 1) //game is loading from save { Debug.Log("Loading from save"); LoadPlayerInfo(); } }
//When entering the state public override async Task Enter(GameObject player) { weaponSwitching = player.GetComponentInChildren <WeaponSwitching>(); //var bob = PlayerStateController.FindState<MovingState>(); //if (bob != null) //{ // bob.speed = 8; // timeToSwitch = 2; //} await new WaitForEndOfFrame(); Debug.Log("entered state " + nameof(BackgroundState)); }
private void Awake() { if (!instance) { instance = this; DontDestroyOnLoad(instance); } else { Destroy(this); } }
// Start is called before the first frame update void Start() { rigidbody = GetComponent <Rigidbody>(); anim = GetComponent <Animator>(); audio = GetComponent <AudioSource>(); weaponSwitching = GetComponentInChildren <WeaponSwitching>(); dbConnection = FindObjectOfType <DBConnection>(); swordAmmo = dbConnection.IniAmmo("Sword"); crossBowAmmo = dbConnection.IniAmmo("Arrow"); }
private void OnEnable() { if (shootJoystick == null) { shootJoystick = ShootJoystick.Instance; // FindObjectOfType<ShootJoystick>(); } shootJoystick.OnUpEvent += Fire; if (wp == null) { wp = FindObjectOfType <WeaponSwitching>(); } }
//public GameObject cameraParent; private void Start() { //cameraParent.SetActive(photonView.IsMine); if (fpsCam == null) { fpsCam = FindObjectOfType <Camera>(); } currentAmmo = maxAmmo; // anim = GetComponent<Animator>(); movementScript = GetComponent <PlayerMovement>(); weaponSwitch = GetComponent <WeaponSwitching>(); }
void Start() { weapon_switching = FindObjectOfType <WeaponSwitching>(); player = FindObjectOfType <FirstPersonController>(); gamePad = InputManager.ActiveDevice; AmmoText.text = "Ammo: " + ammoCount; AmmoInGunText.text = "0"; numberOfBulletsUsed = 0; KeysCollectedText.text = "Keys Collected: 0"; canFire = false; Destroyed = false; }
// Use this for initialization void Start() { _camera = GetComponent <Camera>(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; player = GameObject.FindGameObjectWithTag("Player"); playerAmmo = player.GetComponent <PlayerCharacter>(); //playerHealth = player.GetComponent<PlayerCharacter>(); weaponHolder = GameObject.FindGameObjectWithTag("Guns"); currentWeapon = weaponHolder.GetComponent <WeaponSwitching>(); pistolShot = GetComponent <AudioSource>(); akShot = GetComponent <AudioSource>(); //bulletHolePistol = GameObject.FindGameObjectWithTag("pistolHole"); }
void OnUpgradeMenuToggle(bool active) { Weapon _weapon = GetComponentInChildren <Weapon>(); if (_weapon != null) { _weapon.enabled = !active; } WeaponSwitching _weaponSwitching = GetComponentInChildren <WeaponSwitching>(); if (_weaponSwitching != null) { _weaponSwitching.enabled = !active; } }
void Awake() { cam = Camera.main; bulletLine = GetComponent <LineRenderer>(); magazineText = GameObject.Find("Canvas/MagazineText").GetComponent <Text>(); ammoText = GameObject.Find("Canvas/AmmoText").GetComponent <Text>(); reloadText = GameObject.Find("Canvas/ReloadText").GetComponent <Text>(); weaponText = GameObject.Find("Canvas/WeaponText").GetComponent <Text>(); weaponHolder = GameObject.FindGameObjectWithTag("Weapon Holder"); holder = weaponHolder.GetComponent <WeaponSwitching>(); startingMagazine = maxMagazine; startingAmmo = maxAmmo; currentMagazine = startingMagazine; currentAmmo = startingAmmo; }
// Start is called before the first frame update void Start() { background.enabled = false; Xlogo.enabled = false; text.enabled = false; text1.enabled = false; Player = GameObject.FindGameObjectWithTag("Player"); script = gc.GetComponent <GameController>(); activated = false; script2 = FPC.GetComponent <WeaponSwitching>(); script3 = Player.GetComponent <Healing>(); script4 = AR.GetComponent <Weapon>(); script5 = Shotgun.GetComponent <Weapon>(); audioSource = GetComponent <AudioSource>(); speedUpgrade = 1; boughtShotgunAmmo = false; boughtARAmmo = false; }
public void RpcChangeWeapon(int n) { if (isLocalPlayer)//script already works on local player { return; } //Debug.Log("changing weapon on clients"); WeaponSwitching WS = GetComponentInChildren <WeaponSwitching>(); if (!WS) { Debug.Log("cant find WS script"); return; } WS.selectedWeapon = n; WS.selectWeapon(); }
// checks if there is an empty slot in the weapons slot in order to add a new weapon private void CheckAvailableWeaponSlot(Player player) { for (int i = 0; i < player.weaponsSlots.Length; i++) { bool isEmpty = player.weaponsSlots[i].GetComponent <WeaponSlot>().empty; WeaponSwitching weaponSwitching = GameObject.FindGameObjectWithTag("WeaponHolder").GetComponent <WeaponSwitching>(); // checks for the status of the weaponSlot at index 'i' and if the max no. of weapons to carry has been reached if (isEmpty && weaponSwitching.currentAvailableWeapons < weaponSwitching.maxWeaponsToCarry) { Instantiate(pickUpSound, transform.position, Quaternion.identity); GameObject weaponButton = Instantiate(itemButton, player.weaponsSlots[i].transform, false); player.weaponsSlots[i].GetComponent <WeaponSlot>().empty = false; player.addWeapon(weaponToEquip, weaponButton, i); Destroy(gameObject); break; } } }