// Use this for initialization public void Start() { transform.GetComponent <Rigidbody>().centerOfMass = Vector3.zero; SetSpecialImage(); idx = (GamePad.Index)PlayerIndex; xIdx = (XInputDotNetPure.PlayerIndex)PlayerIndex; }
void Awake() { movement = GetComponent<PlayerMovement>(); //Extract the player index from the name of player if (this.name == "Player1") currentIndex = XInputDotNetPure.PlayerIndex.One; else if (this.name == "Player2") currentIndex = XInputDotNetPure.PlayerIndex.Two; flashlight = GetComponent<Flashlight>(); flashlight.currentIndex = currentIndex; }
#pragma warning restore IDE0044 // Add readonly modifier // Start is called before the first frame update void Start() { playerHeight = GetComponent <CapsuleCollider>().bounds.size.y; tongueHitPoints = new List <Vector3> { Vector3.zero }; // Only draws tongue if there is a line renderer on the game object line = GetComponent <LineRenderer>(); line.positionCount = 0;; rb = gameObject.GetComponent <Rigidbody>(); if (!didQueryNumOfCtrlrs) { didQueryNumOfCtrlrs = true; int queriedNumberOfCtrlrs = XCI.GetNumPluggedCtrlrs(); if (queriedNumberOfCtrlrs == 1) { Debug.Log("Only " + queriedNumberOfCtrlrs + " Xbox controller plugged in."); } else if (queriedNumberOfCtrlrs == 0) { Debug.Log("No Xbox controllers plugged in!"); } else { Debug.Log(queriedNumberOfCtrlrs + " Xbox controllers plugged in."); } XCI.DEBUG_LogControllerNames(); } // getting component for animation and sound anim = GetComponent <Animator>(); audiosource = GetComponent <AudioSource>(); TongueCoolDownSoundPlayed = true; // Set variables on spawn point SpawnPos = transform.position; SpawnRot = transform.rotation; playernumber = (XInputDotNetPure.PlayerIndex)controller - 1; }
IEnumerator Shoot(float waitTime) { if (_shootRout == true) { yield break; } _shootRout = true; if (_shooting == false) { _shootRout = false; yield break; } else { // Steve if (Spreadshot == true) { Vector3 targetDir = (_reticlePosition + new Vector3(2.0f, 0.0f)) - transform.position; Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, _FORCE * Time.deltaTime, 0.0F); Vector3 targetDir2 = (_reticlePosition + new Vector3(-2.0f, 0.0f)) - transform.position; Vector3 newDir2 = Vector3.RotateTowards(transform.forward, targetDir2, _FORCE * Time.deltaTime, 0.0F); // Gabriel // Subtle rumble XInputDotNetPure.PlayerIndex playerIndex = XInputDotNetPure.PlayerIndex.One; if (this.gameObject.tag == "P2") { playerIndex = XInputDotNetPure.PlayerIndex.Two; } RumbleManager.instance.SetVibration(playerIndex, 3.0f, 0.01f); // End Gabriel Vector3 startPos = this.transform.position + this.transform.forward; Vector3 endPos = _reticleHolder.transform.position - (this.transform.forward * Time.fixedDeltaTime); GameObject newBullet = ObjectPool.Instance.InstantiateObject("P_Rapid Fire", startPos); newBullet.GetComponent <Rigidbody>().AddForce((endPos - startPos).normalized * _FORCE * Time.fixedDeltaTime, ForceMode.Impulse); newBullet.GetComponent <SimpleBullet>().shooter = this.gameObject; Vector3 startPos1 = this.transform.position + this.transform.forward; Vector3 endPos1 = _reticleHolder.transform.position - (this.transform.forward * Time.fixedDeltaTime); GameObject newBullet1 = ObjectPool.Instance.InstantiateObject("P_Rapid Fire", startPos); newBullet1.transform.Translate(2.0f, 0, 0); newBullet1.GetComponent <Rigidbody>().AddForce((endPos - startPos).normalized * _FORCE * Time.fixedDeltaTime, ForceMode.Impulse); newBullet1.GetComponent <SimpleBullet>().shooter = this.gameObject; Vector3 startPos2 = this.transform.position + this.transform.forward; Vector3 endPos2 = _reticleHolder.transform.position - (this.transform.forward * Time.fixedDeltaTime); GameObject newBullet2 = ObjectPool.Instance.InstantiateObject("P_Rapid Fire", startPos); newBullet2.transform.Translate(-2.0f, 0, 0); newBullet2.GetComponent <Rigidbody>().AddForce((endPos - startPos).normalized * _FORCE * Time.fixedDeltaTime, ForceMode.Impulse); newBullet2.GetComponent <SimpleBullet>().shooter = this.gameObject; GetComponent <AudioSource>().PlayOneShot(Shot); } // End Steve else { // Subtle rumble XInputDotNetPure.PlayerIndex playerIndex = XInputDotNetPure.PlayerIndex.One; if (this.gameObject.tag == "P2") { playerIndex = XInputDotNetPure.PlayerIndex.Two; } RumbleManager.instance.SetVibration(playerIndex, 1.0f, 0.01f); //GameObject newBullet = ObjectPool.Instance.InstantiateObject("Bullet", new Vector3 (_reticlePosition.x, _reticlePosition.y, this.transform.position.z) + this.transform.forward * 1.5f); //newBullet.GetComponent<Rigidbody>().AddForce(this.transform.forward * _FORCE * Time.fixedDeltaTime, ForceMode.Impulse); // Diagonal, sometimes misss Vector3 startPos = this.transform.position + this.transform.forward; Vector3 endPos = _reticleHolder.transform.position - (this.transform.forward * Time.fixedDeltaTime); GameObject newBullet = ObjectPool.Instance.InstantiateObject("P_Rapid Fire", startPos); newBullet.GetComponent <Rigidbody>().AddForce((endPos - startPos).normalized * _FORCE * Time.fixedDeltaTime, ForceMode.Impulse); newBullet.GetComponent <SimpleBullet>().shooter = this.gameObject; //Steve if (Rocketon == true) { newBullet.GetComponent <SimpleBullet>().Rocketmode(Rocketon); Debug.Log("Active Rocket Shot"); } else { newBullet.GetComponent <SimpleBullet>().Rocketmode(Rocketon); } GetComponent <AudioSource>().PlayOneShot(Shot); // } yield return(new WaitForSeconds(waitTime)); } _shootRout = false; }
void OnTriggerEnter(Collider other) { // Steve if (Rocket == true) { Boom = Physics.OverlapSphere(gameObject.transform.position, 20.0f); Debug.Log("Boom"); // Gabriel// XInputDotNetPure.PlayerIndex playerIndex = XInputDotNetPure.PlayerIndex.One; if (shooter.tag == "P2") { playerIndex = XInputDotNetPure.PlayerIndex.Two; } RumbleManager.instance.SetVibration(playerIndex, 40.0f, 0.15f); // END Gabriel// foreach (Collider Drone in Boom) { if (Drone.tag == "Enemy") { // Destroy(Drone.gameObject); Drone.gameObject.GetComponent <AIHealth>().TakeDamage(100, shooter); ObjectPool.Instance.DestroyObject(Drone.gameObject); Debug.Log(shooter); } } GameObject rocket = Instantiate(explosion, this.transform.localPosition, this.transform.localRotation); Debug.Log(rocket.name); rocket.transform.position = this.transform.position; //Destroy(gameObject); ObjectPool.Instance.DestroyObject(gameObject); return; } //end steve if (other.gameObject.GetComponent <AIHealth>() && shooter.tag != "Enemy") { XInputDotNetPure.PlayerIndex playerIndex = XInputDotNetPure.PlayerIndex.One; if (shooter.tag == "P2") { playerIndex = XInputDotNetPure.PlayerIndex.Two; } RumbleManager.instance.SetVibration(playerIndex, 15.0f, 0.05f); other.gameObject.GetComponent <AIHealth>().TakeDamage(1, shooter); ObjectPool.Instance.DestroyObject(this.gameObject); return; } else if (other.tag == "P1" || other.tag == "P2") { // Subtle rumble XInputDotNetPure.PlayerIndex playerIndex = XInputDotNetPure.PlayerIndex.One; if (other.tag == "P2") { playerIndex = XInputDotNetPure.PlayerIndex.Two; } RumbleManager.instance.SetVibration(playerIndex, 60.0f, 0.2f); // Steve other.gameObject.GetComponent <PlayerScore>().player_hit(damage); Debug.Log(other.tag + damage); // end steve ObjectPool.Instance.DestroyObject(this.gameObject); return; } if (shooter != null && shooter.tag == "Enemy") { if (other.tag != "Enemy" && other.tag != "Bullet") { ObjectPool.Instance.DestroyObject(this.gameObject); return; } } if (other.tag != "Player" && other.tag != "Bullet") { ObjectPool.Instance.DestroyObject(this.gameObject); } }