protected override void OnDestroy() { base.OnDestroy(); if (GlobalVariables.applicationIsQuitting) { return; } if (playerScript == null) { playerScript = GetComponent <PlayersGameplay>(); playerFXScript = GetComponent <PlayersFXAnimations>(); } playerScript.OnDashAvailable -= DashDispo; playerScript.OnDash -= Dash; playerScript.OnDashEnd -= DashEnd; playerScript.OnSafe -= SafeStart; playerScript.OnSafeEnd -= SafeEnd; playerScript.OnDeath -= DashEnd; playerFXScript.OnStunFXON -= StunON; playerFXScript.OnStunFXOFF -= StunOFF; }
public virtual IEnumerator Dash() { dashState = DashState.Dashing; playerThatHit = null; if (OnDash != null) { OnDash(); } Vector3 movementTemp = new Vector3(rewiredPlayer.GetAxisRaw("Move Horizontal"), 0f, rewiredPlayer.GetAxisRaw("Move Vertical")); movementTemp = movementTemp.normalized; float dashSpeedTemp = dashSpeed; StartCoroutine(DashEnd()); DOTween.To(() => dashSpeedTemp, x => dashSpeedTemp = x, 0, dashDuration).SetEase(dashEase).SetUpdate(false); while (dashSpeedTemp > 0) { playerRigidbody.velocity = movementTemp * dashSpeedTemp * Time.fixedDeltaTime * GlobalVariables.Instance.fixedDeltaFactor; yield return(new WaitForFixedUpdate()); } }
protected virtual void OnCollisionStay(Collision other) { if (ReplayManager.Instance.isReplaying) { return; } if (playerState == PlayerState.Startup || rewiredPlayer == null) { return; } if (other.collider.tag != "HoldMovable" && other.gameObject.tag == "Player") { PlayersGameplay playerScript = other.gameObject.GetComponent <PlayersGameplay>(); if (playerScript.playerState != PlayerState.Stunned && dashState == DashState.Dashing && !playersHit.Contains(other.gameObject)) { playersHit.Add(other.gameObject); playerScript.StunVoid(false); playerScript.playerThatHit = this; GlobalVariables.Instance.screenShakeCamera.CameraShaking(FeedbackType.DashStun); GlobalVariables.Instance.zoomCamera.Zoom(FeedbackType.DashStun); } } }
protected override void HitPlayer(Collision other) { if (other.collider.tag == "Player") { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay> (); if (playerScript.playerState == PlayerState.Dead) { return; } playerScript.Death(DeathFX.All, other.contacts [0].point); PlayerKilled(); foreach (GameObject g in attracedBy) { StatsManager.Instance.PlayerKills(g.GetComponent <PlayersGameplay> ()); } foreach (GameObject g in repulsedBy) { StatsManager.Instance.PlayerKills(g.GetComponent <PlayersGameplay> ()); } InstantiateParticles(other.contacts [0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors [(int)playerScript.playerName]); GlobalMethods.Instance.Explosion(transform.position); } }
// Use this for initialization protected virtual void Start() { if (dashOngleFX != null) { dashOngleMaterial = dashOngleFX.GetChild(0).GetComponent <Renderer>().material; dashOngleAlpha = dashOngleMaterial.GetColor("_TintColor").a; } playerScript = GetComponent <PlayersGameplay>(); playerSoundsScript = GetComponent <PlayersSounds>(); playerScript.OnShoot += ShootFX; playerScript.OnDashAvailable += DashAvailableFX; playerScript.OnDash += StopDashAvailable; playerScript.OnDashEnd += DisableDashFX; playerScript.OnStun += () => StartCoroutine(StunFX()); playerScript.OnDash += EnableDashFX; playerScript.OnDeath += RemoveAttractionRepulsionFX; playerScript.OnSafe += () => StartCoroutine(SafeFX()); playerScript.OnSafeEnd += OnSafeEnd; DisableDashFX(); SetupMaterials(); Setup(); }
protected override void HitPlayer(Collision other) { if (tag != "Suggestible" && tag != "DeadCube") { base.HitPlayer(other); } else { if (other.collider.tag == "Player") { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay>(); if (playerScript.playerState == PlayerState.Dead) { return; } playerScript.Death(DeathFX.All, other.contacts[0].point, playerThatThrew); if (playerThatThrew != null) { StatsManager.Instance.PlayersHits(playerThatThrew, other.gameObject); } InstantiateParticles(other.contacts[0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors[(int)playerScript.playerName]); GlobalMethods.Instance.Explosion(transform.position); } } }
protected override void OnCollisionStay(Collision other) { if (ReplayManager.Instance.isReplaying) { return; } if (playerState == PlayerState.Startup) { return; } if (other.gameObject.tag == "DeadZone" && gameObject.layer != LayerMask.NameToLayer("Safe")) { if (playerState != PlayerState.Dead && GlobalVariables.Instance.GameState == GameStateEnum.Playing) { Death(DeathFX.All, other.contacts[0].point); } } if (other.collider.tag != "HoldMovable" && other.gameObject.tag == "Player") { PlayersGameplay playerScript = other.gameObject.GetComponent <PlayersGameplay> (); if (playerScript.playerState != PlayerState.Stunned && dashState == DashState.Dashing && !playersHit.Contains(other.gameObject)) { playersHit.Add(other.gameObject); playerScript.StunVoid(false); playerScript.playerThatHit = this; GlobalVariables.Instance.screenShakeCamera.CameraShaking(FeedbackType.DashStun); GlobalVariables.Instance.zoomCamera.Zoom(FeedbackType.DashStun); } } }
public virtual void Death(DeathFX deathFX, Vector3 deathPosition, GameObject killingPlayer = null) { if (ReplayManager.Instance.isReplaying) { return; } if (playerState != PlayerState.Dead && GlobalVariables.Instance.GameState == GameStateEnum.Playing) { if (deathFX == DeathFX.Explosion || deathFX == DeathFX.All) { playerFX.DeathExplosionFX(deathPosition); } if (deathFX == DeathFX.Particles || deathFX == DeathFX.All) { playerFX.DeathParticles(deathPosition); } if (killingPlayer) { playerThatHit = killingPlayer.GetComponent <PlayersGameplay>(); } StartCoroutine(DeathCoroutine()); } }
public void PlayerKills(PlayersGameplay playerThatKilled) { playersStats[playerThatKilled.playerName.ToString()].playersStats[WhichStat.Kills.ToString()]++; totalStats[WhichStat.Kills.ToString()]++; playersStats[playerThatKilled.playerName.ToString()].playersStats[WhichStat.RoundKills.ToString()]++; }
protected override void HitPlayer(Collision other) { if (other.collider.tag == "Player") { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay> (); if (playerScript.playerState == PlayerState.Dead) { return; } playerScript.Death(DeathFX.All, other.contacts [0].point, playerThatThrew); if (hasKilled && GlobalVariables.Instance.CurrentModeLoaded == WhichMode.Pool) { SteamAchievements.Instance.UnlockAchievement(AchievementID.ACH_POOL); } if (!hasKilled) { hasKilled = true; } PlayerKilled(); if (playerThatThrew != null) { StatsManager.Instance.PlayersHits(playerThatThrew, other.gameObject); } InstantiateParticles(other.contacts [0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors [(int)playerScript.playerName]); GlobalMethods.Instance.Explosion(transform.position); } }
public void UpdateWinsText(bool reset = false) { if (reset) { foreach (var t in winsTexts) { t.text = ""; } foreach (var p in GlobalVariables.Instance.EnabledPlayersList) { PlayersGameplay script = p.GetComponent <PlayersGameplay>(); winsTexts[(int)script.playerName].text = "0"; } } foreach (KeyValuePair <string, PlayerStats> p in playersStats) { switch (p.Key) { case "Player1": if (winsTexts[0].text != playersStats[p.Key].playersStats[WhichStat.Wins.ToString()].ToString()) { winsTexts[0].transform.DOPunchScale(Vector3.one * winTextPunchForce, 0.5f); } winsTexts[0].text = playersStats[p.Key].playersStats[WhichStat.Wins.ToString()].ToString(); break; case "Player2": if (winsTexts[1].text != playersStats[p.Key].playersStats[WhichStat.Wins.ToString()].ToString()) { winsTexts[1].transform.DOPunchScale(Vector3.one * winTextPunchForce, 0.5f); } winsTexts[1].text = playersStats[p.Key].playersStats[WhichStat.Wins.ToString()].ToString(); break; case "Player3": if (winsTexts[2].text != playersStats[p.Key].playersStats[WhichStat.Wins.ToString()].ToString()) { winsTexts[2].transform.DOPunchScale(Vector3.one * winTextPunchForce, 0.5f); } winsTexts[2].text = playersStats[p.Key].playersStats[WhichStat.Wins.ToString()].ToString(); break; case "Player4": if (winsTexts[3].text != playersStats[p.Key].playersStats[WhichStat.Wins.ToString()].ToString()) { winsTexts[3].transform.DOPunchScale(Vector3.one * winTextPunchForce, 0.5f); } winsTexts[3].text = playersStats[p.Key].playersStats[WhichStat.Wins.ToString()].ToString(); break; } } }
// Use this for initialization protected virtual void Start() { player = gameObject.transform.parent; playerScript = player.GetComponent <PlayersGameplay>(); fxAnimationsScript = player.GetComponent <PlayersFXAnimations>(); GetComponent <MeshCollider>().enabled = false; GetComponent <MeshCollider>().enabled = true; }
protected override void HitPlayer(Collision other) { base.HitPlayer(other); if (other.collider.tag == "Player" && tag != "DeadCube") { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay>(); if (playerScript.playerState == PlayerState.Stunned) { return; } if (playerScript.dashState != DashState.Dashing) { return; } if (!SteamAchievements.Instance.Achieved(AchievementID.ACH_PUSH)) { StartCoroutine(DashingPlayerCoroutine(playerScript)); } playerThatThrew = other.gameObject; playerThatThrewTemp = other.gameObject; DOTween.Kill("PushNull" + gameObject.GetInstanceID()); DOVirtual.DelayedCall(0.5f, () => playerThatThrewTemp = null).SetId("PushNull" + gameObject.GetInstanceID()); DeadlyTransition(); InstantiateParticles(other.contacts[0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors[(int)playerScript.playerName]); } if (other.collider.tag == "Player" && tag == "DeadCube" && other.gameObject != playerThatThrewTemp) { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay>(); if (playerScript.playerState == PlayerState.Dead) { return; } playerScript.Death(DeathFX.All, other.contacts[0].point, playerThatThrew); PlayerKilled(); if (playerThatThrew != null) { StatsManager.Instance.PlayersHits(playerThatThrew, other.gameObject); } InstantiateParticles(other.contacts[0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors[(int)playerScript.playerName]); GlobalMethods.Instance.Explosion(transform.position); } }
void GamepadsChange() { if (GlobalVariables.Instance.GameState == GameStateEnum.Menu) { return; } List <int> gamepadsIndex = new List <int>() { 1, 2, 3, 4 }; foreach (GameObject p in GlobalVariables.Instance.EnabledPlayersList) { if (p == null) { continue; } PlayersGameplay script = p.GetComponent <PlayersGameplay>(); if (script.rewiredPlayer == null) { continue; } //Gamepad if (gamepadsIndex.Contains(script.controllerNumber)) { gamepadsIndex.Remove(script.controllerNumber); //Unplugged if (script.rewiredPlayer.controllers.joystickCount == 0) { unpluggedPlayers[(int)script.controllerNumber - 1].gameObject.SetActive(true); unpluggedPlayers[(int)script.controllerNumber - 1].DOAnchorPosY(disconnectedPlayersYPos.y, animationDuration).SetEase(easeMenu); } //Plugged else { unpluggedPlayers[(int)script.controllerNumber - 1].DOAnchorPosY(disconnectedPlayersYPos.x, animationDuration).SetEase(easeMenu).OnComplete(() => { unpluggedPlayers[(int)script.controllerNumber - 1].gameObject.SetActive(false); }); } } } foreach (var i in gamepadsIndex) { unpluggedPlayers[i - 1].DOAnchorPosY(disconnectedPlayersYPos.x, animationDuration).SetEase(easeMenu).OnComplete(() => { unpluggedPlayers[i - 1].gameObject.SetActive(false); }); } }
protected override void HitPlayer(Collision other) { if (other.collider.tag == "Player") { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay>(); if (playerScript.playerState == PlayerState.Stunned) { return; } if (tag == "ThrownMovable") { if (playerThatThrew == null || other.gameObject.name != playerThatThrew.name) { playerScript.StunVoid(true); InstantiateParticles(other.contacts[0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors[(int)playerScript.playerName]); if (playerThatThrew != null) { StatsManager.Instance.PlayersHits(playerThatThrew, other.gameObject); } } } } if (other.collider.tag == "Player") { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay>(); if (playerScript.playerState == PlayerState.Dead) { return; } if (tag == "DeadCube") { playerScript.Death(DeathFX.All, other.contacts[0].point, playerThatThrew); PlayerKilled(); if (playerThatThrew != null) { StatsManager.Instance.PlayersHits(playerThatThrew, other.gameObject); if (!SteamAchievements.Instance.Achieved(AchievementID.ACH_STANDOFF) && Vector3.Distance(other.transform.position, shooterPosition) > 30f) { SteamAchievements.Instance.UnlockAchievement(AchievementID.ACH_STANDOFF); } } GlobalMethods.Instance.Explosion(transform.position); } } }
public void PlayerSuicides(PlayersGameplay player) { playersStats[player.playerName.ToString()].playersStats[WhichStat.Suicides.ToString()]++; totalStats[WhichStat.Suicides.ToString()]++; if (OnPlayerSuicide != null) { OnPlayerSuicide(player); } }
// Use this for initialization void Start() { playerScript = GetComponent <PlayersGameplay> (); playerScript.OnDash += Dash; playerScript.OnStun += Stun; playerScript.OnShoot += Shoot; playerScript.OnHold += Hold; playerScript.OnDeath += Death; }
public void PlayersLifeDuration() { foreach (var p in GlobalVariables.Instance.EnabledPlayersList) { PlayersGameplay script = p.GetComponent <PlayersGameplay>(); //playersStats [script.playerName.ToString ()].playersStats [WhichStat.LifeDuration.ToString ()] += script.lifeDuration; playersStats[script.playerName.ToString()].playerLifeDuration += script.lifeDuration; } }
protected virtual void PlayerStats(PlayersGameplay playerThatHit = null) { if (playerThatHit == null || playerThatHit == this) { StatsManager.Instance.PlayerSuicides(this); } else if (playerThatHit != this) { StatsManager.Instance.PlayerKills(playerThatHit); } }
public virtual void PlayerDeath(PlayerName playerName, GameObject player) { PlayersGameplay playerScript = player.GetComponent <PlayersGameplay> (); playerScript.livesCount--; GlobalVariables.Instance.ListPlayers(); //Check Game End int playersCount = 0; GameObject lastPlayer = null; foreach (GameObject g in GlobalVariables.Instance.EnabledPlayersList) { if (g.GetComponent <PlayersGameplay> ().livesCount != 0) { playersCount++; lastPlayer = g; } } if (playersCount == 1 && gameEndLoopRunning == false) { gameEndLoopRunning = true; StatsManager.Instance.Winner(lastPlayer.GetComponent <PlayersGameplay> ().playerName); StartCoroutine(GameEnd()); return; } if (playersCount == 0 && gameEndLoopRunning == false) { gameEndLoopRunning = true; StatsManager.Instance.Winner(WhichPlayer.Draw); StartCoroutine(GameEnd()); return; } //Spawn Play if has lives left if (playerScript.livesCount > 0 && !gameEndLoopRunning) { GlobalMethods.Instance.SpawnDeathText(playerName, player, playerScript.livesCount); GlobalMethods.Instance.SpawnExistingPlayerRandomVoid(player, timeBeforePlayerRespawn, true); } else if (playerDeadCube && !gameEndLoopRunning && player.GetComponent <AIFXAnimations> () == null) { GlobalMethods.Instance.SpawnDeathText(playerName, player, playerScript.livesCount); PlayerDeadCube(playerScript); } GlobalVariables.Instance.OnPlayerDeathEvent(); }
protected virtual IEnumerator Stun(bool cubeHit) { playerState = PlayerState.Stunned; stunnedRotationTemp = stunnedRotation; DOTween.To(() => stunnedRotationTemp, x => stunnedRotationTemp = x, stunnedRotationTemp * 0.3f, stunnedDuration * 0.5f).SetEase(Ease.OutQuint).SetDelay(stunnedDuration * 0.5f).SetUpdate(false); if (gettingMovable || holdState == HoldState.Holding) { holdState = HoldState.CannotHold; yield return(new WaitWhile(() => gettingMovable == true)); Shoot(); } holdState = HoldState.CannotHold; GlobalVariables.Instance.screenShakeCamera.CameraShaking(FeedbackType.Stun); GlobalVariables.Instance.zoomCamera.Zoom(FeedbackType.Stun); if (OnStun != null) { OnStun(); } if (cubeHit && OnCubeHit != null) { OnCubeHit(); } if (!cubeHit && OnDashHit != null) { OnDashHit(); } yield return(new WaitForSeconds(stunnedDuration)); playerRigidbody.velocity = Vector3.zero; playerThatHit = null; if (playerState == PlayerState.Stunned) { playerState = PlayerState.None; } if (holdState == HoldState.CannotHold) { holdState = HoldState.CanHold; } }
public virtual void OnHoldMovable(GameObject movable, bool forceHold = false) { if (!forceHold) { if (playerState == PlayerState.Dead || playerState == PlayerState.Stunned || holdState == HoldState.CannotHold) { return; } } gettingMovable = true; holdState = HoldState.Holding; SetMagnetPointPosition(movable); MovableScript movableScript = movable.GetComponent <MovableScript>(); movable.tag = "HoldMovable"; movableScript.player = transform; movableScript.DestroyRigibody(); movableScript.OnHold(); holdMovableTransform = movable.transform; holdMovableTransform.SetParent(transform); for (int i = 0; i < GlobalVariables.Instance.EnabledPlayersList.Count; i++) { PlayersGameplay playerScript = GlobalVariables.Instance.EnabledPlayersList[i].GetComponent <PlayersGameplay>(); if (playerScript.cubesAttracted.Contains(movableScript)) { playerScript.cubesAttracted.Remove(movableScript); } if (playerScript.cubesRepulsed.Contains(movableScript)) { playerScript.cubesRepulsed.Remove(movableScript); } } cubesAttracted.Clear(); cubesRepulsed.Clear(); if (OnHold != null) { OnHold(); } gettingMovable = false; }
protected override void HitPlayer(Collision other) { PlayersGameplay playerScript = null; if (other.gameObject.tag == "Player") { playerScript = other.gameObject.GetComponent <PlayersGameplay> (); } if (tag == "Movable" && other.gameObject.tag == "Player" || tag == "ThrownMovable" && other.gameObject.tag == "Player" && !trackingPlayer) { if (playerThatThrew == null || playerThatThrew != other.gameObject) { if (!trackingPlayer && playerThatThrew != null) { StatsManager.Instance.PlayersHits(playerThatThrew, other.gameObject); } BombManager manager = (BombManager)GlobalVariables.Instance.lastManManager; if (manager.timer < 1 && !trackingPlayer && playerThatThrew != null) { SteamAchievements.Instance.UnlockAchievement(AchievementID.ACH_BOMB); } playerScript.OnHoldMovable(gameObject, true); playerHolding = other.gameObject; mainCamera.GetComponent <ScreenShakeCamera>().CameraShaking(FeedbackType.Stun); mainCamera.GetComponent <ZoomCamera>().Zoom(FeedbackType.Stun); InstantiateParticles(other.contacts [0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors [(int)playerScript.playerName]); } } if (tag == "DeadCube" && other.gameObject.tag == "Player" && trackingPlayer && playerScript.playerState != PlayerState.Dead) { hold = true; playerHolding = other.gameObject; playerScript.OnDeath -= PlayerSuicide; playerScript.Death(DeathFX.All, other.contacts [0].point); mainCamera.GetComponent <ScreenShakeCamera>().CameraShaking(FeedbackType.Stun); mainCamera.GetComponent <ZoomCamera>().Zoom(FeedbackType.Stun); InstantiateParticles(other.contacts [0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors [(int)playerScript.playerName]); } }
protected override void HitPlayer(Collision other) { if (other.collider.tag == "Player" && tag == "ThrownMovable") { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay> (); if (playerScript.playerState == PlayerState.Stunned) { return; } if (playerThatThrew == null || other.gameObject.name != playerThatThrew.name) { //StartCoroutine (DeadlyTransition ()); playerScript.StunVoid(true); InstantiateParticles(other.contacts [0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors [(int)playerScript.playerName]); if (playerThatThrew != null) { StatsManager.Instance.PlayersHits(playerThatThrew, other.gameObject); } } } if (other.collider.tag == "Player" && tag == "DeadCube") { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay> (); if (playerScript.playerState == PlayerState.Dead) { return; } playerScript.Death(DeathFX.All, other.contacts [0].point, playerThatThrew); PlayerKilled(); if (playerThatThrew != null) { StatsManager.Instance.PlayersHits(playerThatThrew, other.gameObject); } InstantiateParticles(other.contacts [0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors [(int)playerScript.playerName]); GlobalMethods.Instance.Explosion(transform.position); } }
IEnumerator DashingPlayerCoroutine(PlayersGameplay p) { if (!dashingPlayers.Contains(p)) { dashingPlayers.Add(p); } else { SteamAchievements.Instance.UnlockAchievement(AchievementID.ACH_PUSH); yield break; } yield return(new WaitWhile(() => p.dashState == DashState.Dashing)); dashingPlayers.Remove(p); }
protected virtual void OnEnable() { StartCoroutine(WaitTillPlayerEnabled()); if (GlobalVariables.Instance.GameState != GameStateEnum.Playing) { StartCoroutine(Startup()); } cubesAttracted.Clear(); cubesRepulsed.Clear(); if (playerRigidbody != null) { playerRigidbody.velocity = Vector3.zero; } if (playerState != PlayerState.Startup) { playerState = PlayerState.None; } StartCoroutine(LifeDuration()); dashState = DashState.CanDash; holdState = HoldState.CanHold; playerThatHit = null; if (GlobalVariables.Instance != null) { GlobalVariables.Instance.ListPlayers(); } if (controllerNumber == 0) { GlobalVariables.Instance.SetPlayerMouseCursor(); } if (gameObject.layer == LayerMask.NameToLayer("Safe")) { if (OnSafe != null) { OnSafe(); } } }
void OnPlayerDeath() { if (GlobalVariables.Instance.NumberOfPlayers > 0) { foreach (var p in GlobalVariables.Instance.AlivePlayersList) { PlayersGameplay s = p.GetComponent <PlayersGameplay>(); if (s.GetType() != typeof(AIGameplay) && !s.GetType().IsSubclassOf(typeof(AIGameplay))) { return; } } ShowPassFightButton(); } }
protected override void Start() { base.Start(); playerScript = GetComponent <PlayersGameplay>(); playerFXScript = GetComponent <PlayersFXAnimations>(); playerScript.OnDashAvailable += DashDispo; playerScript.OnDash += Dash; playerScript.OnDashEnd += DashEnd; playerScript.OnSafe += SafeStart; playerScript.OnSafeEnd += SafeEnd; playerScript.OnDeath += DashEnd; playerFXScript.OnStunFXON += StunON; playerFXScript.OnStunFXOFF += StunOFF; }
public void UpdateGamepadList() { gamepadsList.Clear(); bool oneGamepadUnplugged = false; foreach (GameObject p in GlobalVariables.Instance.EnabledPlayersList) { if (p == null) { continue; } PlayersGameplay script = p.GetComponent <PlayersGameplay>(); if (script.GetType() == typeof(AIGameplay) || script.GetType().IsSubclassOf(typeof(AIGameplay))) { continue; } //Unplugged if (script.controllerNumber != 0 && script.controllerNumber != -1 && script.controllerNumber != -2) { gamepadsList.Add(new PlayerGamepad()); gamepadsList[gamepadsList.Count - 1].PlayerName = script.playerName; if (script.rewiredPlayer.controllers.joystickCount == 0) { gamepadsList[gamepadsList.Count - 1].GamepadIsPlugged = false; oneGamepadUnplugged = true; } else { gamepadsList[gamepadsList.Count - 1].GamepadIsPlugged = true; } } } OneGamepadUnplugged = oneGamepadUnplugged; if (oneGamepadUnplugged && OnGamepadDisconnected != null) { OnGamepadDisconnected(); } }
protected override void HitPlayer(Collision other) { if (other.collider.tag == "Player") { PlayersGameplay playerScript = other.collider.GetComponent <PlayersGameplay> (); if (playerScript.playerState == PlayerState.Dead) { return; } if (other.gameObject == targetPlayer) { playerScript.Death(DeathFX.All, other.contacts [0].point); InstantiateParticles(other.contacts [0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors [(int)playerScript.playerName]); Explode(); StopTrackingPlayer(); PlayerKilled(); SteamAchievements.Instance.UnlockAchievement(AchievementID.ACH_BURDEN); } else { playerScript.Death(DeathFX.All, other.contacts [0].point); InstantiateParticles(other.contacts [0], GlobalVariables.Instance.HitParticles, GlobalVariables.Instance.playersColors [(int)playerScript.playerName]); Explode(); PlayerKilled(); for (int i = 0; i < otherMovables.Count; i++) { if (otherMovables [i].targetPlayer == other.gameObject) { otherMovables [i].StopTrackingPlayer(); } } } } }