public void OnPreviousWeapon(InputAction.CallbackContext context) { if (context.phase == InputActionPhase.Started) { SwitchWeapon.Invoke(false); } }
// Use this for initialization void Start() { // Assigns all game objects in the scene heirachy to their created variables SW = GameObject.Find("Player").GetComponent <SwitchWeapon>(); generalInfo = GameObject.Find("GeneralInfo").GetComponent <Text>(); weaponText = GameObject.Find("WeaponText").GetComponent <Text>(); grenadeCount = GameObject.Find("GrenadeText").GetComponent <Text>(); FPScount = GameObject.Find("FPSText").GetComponent <Text>(); winScreen = GameObject.Find("VictoryMenu").GetComponent <Text>(); deathScreen = GameObject.Find("DeathMenu").GetComponent <Text>(); // Used as a starting time reference fl_nextUpdate = Time.time; // Sets the default UI and game screen state pauseScreen.gameObject.SetActive(false); damageOverlay.SetActive(false); QualitySettings.vSyncCount = 1; BL_Paused = true; TogglePause(); // Default weapon ammo in_weapon2ammo = 50; in_weapon3ammo = 80; in_grenades = 3; }
// Use this for initialization void Start() { // Assigns reference to SwitchWeapon script child object SW = GameObject.Find("Player").GetComponent <SwitchWeapon>(); // Checks for the type of weapon in use WeaponCheck(); }
// Update is called once per frame void Update() { if (StartMenu.activeInHierarchy) { Time.timeScale = 0f; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; WeaponPickup wp = FindObjectOfType <WeaponPickup> (); if (wp != null) { wp.SetAlive(false); } SwitchWeapon sw = GameObject.Find("Camera").GetComponent <SwitchWeapon> (); if (sw != null) { sw.SetAlive(false); } MouseLook ml = FindObjectOfType <MouseLook> (); if (ml != null) { ml.SetAlive(false); } player.GetComponent <MouseLook> ().enabled = false; } }
public void OnNextWeapon(InputAction.CallbackContext context) { if (context.phase == InputActionPhase.Started) { SwitchWeapon.Invoke(true); } }
void Awake() { pauseText = GetComponent <Text>(); player = GameObject.FindGameObjectWithTag("Player"); switchWeapon = player.GetComponent <SwitchWeapon>(); playerHealth = player.GetComponent <PlayerHealth>(); }
void Awake() { anim = GetComponent <Animator> (); playerAudio = GetComponent <AudioSource> (); playerMovement = GetComponent <PlayerMovement> (); switchWeapon = GetComponent <SwitchWeapon>(); currentHealth = startingHealth; }
void Start() { rb = GetComponent <Rigidbody>(); ui = UIController.instance; audioP = AudioPlayer.instance; weaponImage = GameObject.FindGameObjectWithTag("WeaponImage").GetComponent <SwitchWeapon>(); health = maxHealth; weaponImage.ChangeWeapon(GunType.Pistol); }
void OnTriggerEnter(Collider other) { PlayerCharacter player = other.GetComponent <PlayerCharacter>(); if (safe) { missiontext.SetActive(true); resett.SetActive(true); exitt.SetActive(true); FPSInput f = FindObjectOfType <FPSInput> (); if (f != null) { f.SetAlive(false); } WeaponPickup wp = FindObjectOfType <WeaponPickup> (); if (wp != null) { wp.SetAlive(false); } SwitchWeapon sw = GameObject.Find("Camera").GetComponent <SwitchWeapon> (); if (sw != null) { sw.SetAlive(false); } GameObject[] e = GameObject.FindGameObjectsWithTag("Enemy"); Shooting[] s = new Shooting[e.Length]; for (int i = 0; i < e.Length; i++) { s[i] = e [i].GetComponent <Shooting> (); if (s [i] != null) { s[i].SetAlive(false); } } CrateShooting[] cs = new CrateShooting[e.Length]; for (int i = 0; i < e.Length; i++) { cs[i] = e [i].GetComponent <CrateShooting> (); if (cs [i] != null) { cs[i].SetAlive(false); } } StartCoroutine(startCutScene()); } }
private IEnumerator startCutScene() { player.SetActive(false); canvas.SetActive(false); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; cameraCutScene.SetActive(true); heli.SetActive(true); yield return(new WaitForSeconds(5.0f)); player.SetActive(true); canvas.SetActive(true); cameraCutScene.SetActive(false); heli.SetActive(false); WeaponPickup wp = FindObjectOfType <WeaponPickup> (); if (wp != null) { wp.SetAlive(true); } SwitchWeapon sw = GameObject.Find("Camera").GetComponent <SwitchWeapon> (); if (sw != null) { sw.SetAlive(true); } MouseLook ml = FindObjectOfType <MouseLook> (); if (ml != null) { ml.SetAlive(true); } player.GetComponent <MouseLook> ().enabled = true; }
protected override void ExecuteCombo(int id) { switch (id) { case 40: SwitchWeapon?.Invoke(); break; case 50: FireOn?.Invoke(); break; case 51: FireOff?.Invoke(); break; } }
IEnumerator Start() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); if (GetComponent <PlayerControl>()) { updateUI.HighlightSlot(activeSlot); isPlayer = true; } else { isPlayer = false; } switchWeapon = GameObject.Find("Weapon").GetComponent <SwitchWeapon>(); }
void Awake() { instance = this; }
// Update is called once per frame public void Update() { //Check keys in keymap //Has Released Keys foreach (var item in input.keysPressed) { if (Input.GetKeyDown(item.Key)) { Command command = null; // Debug.Log(string.Format("onReleasedKeyMap Key pressed {0}", item.Value.ToString())); //Log key to console switch (item.Value) { case "Move Up": //trigger Move Up command command = new MoveUp(); break; case "Move Down": command = new MoveDown(); break; case "Move Left": command = new MoveLeft(); break; case "Move Right": command = new MoveRight(); break; case "Switch": command = new SwitchWeapon(); break; case "Roll": command = new Roll(); break; case "Shoot": command = new Shoot(); break; case "DEBUG": GameObject temp; temp = MoveableEntity; MoveableEntity = DEBUGEntity; DEBUGEntity = temp; break; } if (command != null) { ActivateCommand(command); } } if (Input.GetKeyUp(item.Key)) { Command command = null; // Debug.Log(string.Format("onReleasedKeyMap Key released {0}", item.Value.ToString())); //Log key to console switch (item.Value) { case "Move Up": command = new WaitUp(); break; case "Move Down": command = new WaitDown(); break; case "Move Left": command = new WaitLeft(); break; case "Move Right": command = new WaitRight(); break; } if (command != null) { ActivateCommand(command); } } } }
// Update is called once per frame public void Update() { Command p1command = null; Command p2command = null; if (Input.GetAxis("Vertical") < -.25f) { p1command = new MoveUp(); p1ActivateCommand(p1command); } if (Input.GetAxis("Vertical") > .25f) { p1command = new MoveDown(); p1ActivateCommand(p1command); } if (Input.GetAxis("Horizontal") < -.25f) { p1command = new MoveLeft(); p1ActivateCommand(p1command); } if (Input.GetAxis("Horizontal") > .25f) { p1command = new MoveRight(); p1ActivateCommand(p1command); } if (Input.GetButtonDown("switch")) { p1command = new SwitchWeapon(); p1ActivateCommand(p1command); } if (Input.GetButtonDown("Roll")) { p1command = new Roll(); p1ActivateCommand(p1command); } if (Input.GetButtonDown("Shoot")) { p1command = new Shoot(); p1ActivateCommand(p1command); } if (Input.GetAxis("Vertical") > -.75f && Input.GetAxis("Vertical") <= .25f) { p1command = new WaitUp(); p1ActivateCommand(p1command); } if (Input.GetAxis("Vertical") >= -.25f && Input.GetAxis("Vertical") < .75f) { p1command = new WaitDown(); p1ActivateCommand(p1command); } if (Input.GetAxis("Horizontal") > -.75f && Input.GetAxis("Horizontal") <= 25f) { p1command = new WaitLeft(); p1ActivateCommand(p1command); } if (Input.GetAxis("Horizontal") >= -.25f && Input.GetAxis("Horizontal") < .75f) { p1command = new WaitRight(); p1ActivateCommand(p1command); } //////////////////////////////////////P2 = aka, there has to be a better way... if (Input.GetAxis("VerticalP2") < -.25f) { p2command = new MoveUp(); p2ActivateCommand(p2command); } if (Input.GetAxis("VerticalP2") > .25f) { p2command = new MoveDown(); p2ActivateCommand(p2command); } if (Input.GetAxis("HorizontalP2") < -.25f) { p2command = new MoveLeft(); p2ActivateCommand(p2command); } if (Input.GetAxis("HorizontalP2") > .25f) { p2command = new MoveRight(); p2ActivateCommand(p2command); } if (Input.GetButtonDown("switchP2")) { p2command = new SwitchWeapon(); p2ActivateCommand(p2command); } if (Input.GetButtonDown("RollP2")) { p2command = new Roll(); p2ActivateCommand(p2command); } if (Input.GetButtonDown("ShootP2")) { p2command = new Shoot(); p2ActivateCommand(p2command); } if (Input.GetAxis("VerticalP2") > -.75f && Input.GetAxis("VerticalP2") <= .25f) { p2command = new WaitUp(); p2ActivateCommand(p2command); } if (Input.GetAxis("VerticalP2") >= -.25f && Input.GetAxis("VerticalP2") < .75f) { p2command = new WaitDown(); p2ActivateCommand(p2command); } if (Input.GetAxis("HorizontalP2") > -.75f && Input.GetAxis("HorizontalP2") <= 25f) { p2command = new WaitLeft(); p2ActivateCommand(p2command); } if (Input.GetAxis("HorizontalP2") >= -.25f && Input.GetAxis("HorizontalP2") < .75f) { p2command = new WaitRight(); p2ActivateCommand(p2command); } }
IEnumerator Start() { yield return(new WaitForEndOfFrame()); mouseFollow = GameObject.Find("MouseFollower"); Weapons = GameObject.Find("Items").GetComponent <SpawnWeapons>().Weapons; serverRefrenceKeeper = GameObject.Find("Server Refrences").GetComponent <ServerRefrenceKeeper>(); spawnWeapons = GameObject.Find("Items").GetComponent <SpawnWeapons>(); localiseTransform = GameObject.Find("Items").GetComponent <LocaliseTransform>(); switchWeapon = GameObject.Find("Weapon").GetComponent <SwitchWeapon>(); shoot = GameObject.Find("Weapon").GetComponent <Shoot>(); //Get script Items = GameObject.Find("Items").transform; bulletPositioner = GameObject.Find("Bullet Positioner").transform; //Get the bullet positioner object //Wait because some of the next parts have not completed yet aimShoot = GameObject.Find("Ragdoll").GetComponent <AimShoot>(); //Get script refrenceKeeper = GameObject.Find("Local").GetComponent <RefrenceKeeper>(); refrenceKeeper.itemDistanceRefrences.Add(0); //Add a new space in the list for this item yield return(new WaitForEndOfFrame()); updateUI = refrenceKeeper.updateUI; WeaponHand = refrenceKeeper.WeaponParent; Player = GameObject.Find("Ragdoll").transform; if (isClient) { transform.parent = Items; WeaponModel = Instantiate( Weapons[WeaponIndex].WeaponItem.itemModel, transform.position, transform.rotation); WeaponModel.gameObject.layer = 11; for (int z = 0; z < WeaponModel.transform.childCount; z++) { WeaponModel.transform.GetChild(z).gameObject.layer = 11; } WeaponModel.transform.SetParent(transform); colliders = WeaponModel.transform.GetComponentsInChildren <MeshCollider>(); /*foreach (MeshCollider collider in colliders) * { * collider.convex = true; * }*/ renderers = WeaponModel.transform.GetComponentsInChildren <Renderer>(); foreach (Renderer renderer in renderers) { renderer.material = WeaponMat; } WeaponModel.transform.localPosition = Weapons[WeaponIndex].WeaponItem.spawnPosition; WeaponModel.transform.localEulerAngles = Weapons[WeaponIndex].WeaponItem.spawnRotation; WeaponModel.transform.localScale = Weapons[WeaponIndex].WeaponItem.spawnScale; } localiseTransform.setTransformItem(gameObject.transform.GetChild(0).gameObject, WeaponIndex); //Update global list of total items refrenceKeeper.itemCount++; NumberOfWeapons = serverRefrenceKeeper.numOfWeapons; individualCount = refrenceKeeper.itemCount; //Update private version of itemCount to add a private "id" so this script knows which part of the list is it's own entry; done = true; }
void Update() { if (_health == 0) { FPSInput f = GetComponent <FPSInput> (); f.SetAlive(false); WeaponPickup wp = FindObjectOfType <WeaponPickup> (); if (wp != null) { wp.SetAlive(false); } SwitchWeapon sw = GameObject.Find("Camera").GetComponent <SwitchWeapon> (); if (sw != null) { sw.SetAlive(false); } GameObject[] e = GameObject.FindGameObjectsWithTag("Enemy"); Shooting[] s = new Shooting[e.Length]; for (int i = 0; i < e.Length; i++) { s[i] = e [i].GetComponent <Shooting> (); if (s [i] != null) { s[i].SetAlive(false); } } CrateShooting[] cs = new CrateShooting[e.Length]; for (int i = 0; i < e.Length; i++) { cs[i] = e [i].GetComponent <CrateShooting> (); if (cs [i] != null) { cs[i].SetAlive(false); } } Gameovert.SetActive(true); resett.SetActive(true); exitt.SetActive(true); } if (_health == 0) { healthbar1.SetActive(false); healthbar2.SetActive(false); healthbar3.SetActive(false); healthbar4.SetActive(false); healthbar5.SetActive(false); healthbar6.SetActive(false); healthbar7.SetActive(false); healthbar8.SetActive(false); healthbar9.SetActive(false); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 1) { healthbar1.SetActive(true); healthbar2.SetActive(false); healthbar3.SetActive(false); healthbar4.SetActive(false); healthbar5.SetActive(false); healthbar6.SetActive(false); healthbar7.SetActive(false); healthbar8.SetActive(false); healthbar9.SetActive(false); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 2) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(false); healthbar4.SetActive(false); healthbar5.SetActive(false); healthbar6.SetActive(false); healthbar7.SetActive(false); healthbar8.SetActive(false); healthbar9.SetActive(false); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 3) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(true); healthbar4.SetActive(false); healthbar5.SetActive(false); healthbar6.SetActive(false); healthbar7.SetActive(false); healthbar8.SetActive(false); healthbar9.SetActive(false); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 4) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(true); healthbar4.SetActive(true); healthbar5.SetActive(false); healthbar6.SetActive(false); healthbar7.SetActive(false); healthbar8.SetActive(false); healthbar9.SetActive(false); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 5) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(true); healthbar4.SetActive(true); healthbar5.SetActive(true); healthbar6.SetActive(false); healthbar7.SetActive(false); healthbar8.SetActive(false); healthbar9.SetActive(false); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 6) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(true); healthbar4.SetActive(true); healthbar5.SetActive(true); healthbar6.SetActive(true); healthbar7.SetActive(false); healthbar8.SetActive(false); healthbar9.SetActive(false); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 7) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(true); healthbar4.SetActive(true); healthbar5.SetActive(true); healthbar6.SetActive(true); healthbar7.SetActive(true); healthbar8.SetActive(false); healthbar9.SetActive(false); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 8) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(true); healthbar4.SetActive(true); healthbar5.SetActive(true); healthbar6.SetActive(true); healthbar7.SetActive(true); healthbar8.SetActive(true); healthbar9.SetActive(false); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 9) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(true); healthbar4.SetActive(true); healthbar5.SetActive(true); healthbar6.SetActive(true); healthbar7.SetActive(true); healthbar8.SetActive(true); healthbar9.SetActive(true); healthbar10.SetActive(false); healthbar11.SetActive(false); } if (_health == 10) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(true); healthbar4.SetActive(true); healthbar5.SetActive(true); healthbar6.SetActive(true); healthbar7.SetActive(true); healthbar8.SetActive(true); healthbar9.SetActive(true); healthbar10.SetActive(true); healthbar11.SetActive(false); } if (_health == 11) { healthbar1.SetActive(true); healthbar2.SetActive(true); healthbar3.SetActive(true); healthbar4.SetActive(true); healthbar5.SetActive(true); healthbar6.SetActive(true); healthbar7.SetActive(true); healthbar8.SetActive(true); healthbar9.SetActive(true); healthbar10.SetActive(true); healthbar11.SetActive(true); } }
public void SendWeaponSwitch(int id) { SwitchWeapon switchWeapon = new SwitchWeapon(client.localClientID, id); client.sendToServer(switchWeapon.constructMessage()); }
private void Update() { if (Input.GetKeyDown(KeyCode.Alpha1) && playerTransform.gameObject.activeInHierarchy) { //networkInstantiate.instantiate(NetworkInstantiate.prefabNames.fireworks, playerTransform.position, Quaternion.identity, client.localClientID); //networkInstantiate.instantiate(NetworkInstantiate.prefabNames.ragdoll, playerTransform.position, playerTransform.rotation, client.localClientID); } if (client != null) { // Runs the main loop messages on the client object client.mainThread(); } // Dequeues and parses main thread messages for the game client. if (mainThreadQueue.Count > 0) { string nextMessage = mainThreadQueue.Dequeue(); Message message = JsonUtility.FromJson <Message>(nextMessage); switch (message.message) { case (int)Message.messageTypes.NewPlayerData: NewPlayerMessage newPlayerMessage = JsonUtility.FromJson <NewPlayerMessage>(nextMessage); GameObject newRemote = Instantiate(playerPrefab, new Vector3(0, 2, 0), playerPrefab.transform.rotation); RemoteController controller = newRemote.GetComponentInChildren <RemoteController>(); controller.initRemote(newPlayerMessage.newPlayerID); remoteGameObjects.Add(newRemote); break; case (int)Message.messageTypes.SwitchWeapon: SwitchWeapon switchWeapon = JsonUtility.FromJson <SwitchWeapon>(nextMessage); if (switchWeapon.clientID == client.localClientID) { return; } foreach (GameObject remote in remoteGameObjects) { remote.GetComponentInChildren <RemoteController>().changeWeapon(switchWeapon.weaponID); } break; } } // Update the position of the remote clients if (remoteGameObjects != null) { for (int i = 0; i < remoteGameObjects.Count; i++) { RemoteController rem = remoteGameObjects[i].GetComponentInChildren <RemoteController>(); if (rem.id == client.remoteClients[i].clientID) { remoteGameObjects[i].transform.localPosition = Vector3.Lerp(remoteGameObjects[i].transform.position, client.remoteClients[i].clientTransform, clientSmoothness); remoteGameObjects[i].transform.localRotation = Quaternion.Lerp(remoteGameObjects[i].transform.rotation, client.remoteClients[i].clientRotation, clientRotateSmoothness); } } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.P)) { if (Time.timeScale == 1.0f) { pauseText.SetActive(true); exitText.SetActive(true); audioText.SetActive(true); WeaponPickup wp = FindObjectOfType <WeaponPickup> (); if (wp != null) { wp.SetAlive(false); } SwitchWeapon sw = GameObject.Find("Camera").GetComponent <SwitchWeapon> (); if (sw != null) { sw.SetAlive(false); } MouseLook ml = FindObjectOfType <MouseLook> (); if (ml != null) { ml.SetAlive(false); } player.GetComponent <MouseLook> ().enabled = false; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; Time.timeScale = 0.0f; } else if (Time.timeScale == 0.0f) { pauseText.SetActive(false); exitText.SetActive(false); audioText.SetActive(false); WeaponPickup wp = FindObjectOfType <WeaponPickup> (); if (wp != null) { wp.SetAlive(true); } SwitchWeapon sw = GameObject.Find("Camera").GetComponent <SwitchWeapon> (); if (sw != null) { sw.SetAlive(true); } MouseLook ml = FindObjectOfType <MouseLook> (); if (ml != null) { ml.SetAlive(true); } player.GetComponent <MouseLook> ().enabled = true; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; Time.timeScale = 1.0f; } } }