public override void OnEnter(GameManager gameManager) { GUIManager guiManager = gameManager.GetGUIManager(); guiManager.ShowActions(); guiManager.ShowMoveSelectCountdown(); guiManager.SetMoveSelectCountdownMinMax(0, turnDuration); guiManager.SetMoveSelectCountdownValue(turnDuration); guiManager.HideStatusPanel(); gameManager.ShowTargetingIndicator(); timeElapsed = turnDuration; // Move the camera back into place. gameCamera.GetComponent<CameraMoves>().MoveAndLook(startCameraPosition, gameManager.GetPlayer().transform.position, 2.0f); bool autoSelectPlayerTarget = (gameManager.GetPlayerTarget() == null); // Decided whether auto-select a target if the player hasn't selected any // Pick random actions for the non-player combatants. List<GameObject> actors = gameManager.GetActiveCombatants(); if (actors.Count > 1) { foreach (GameObject actor in actors) { // We don't need to pick an action for the player automatically. if (actor.CompareTag("Player")) { continue; } // Auto-select the first available enemy as the player's target. if (autoSelectPlayerTarget) { gameManager.OnCombatantSelect(actor); autoSelectPlayerTarget = false; } CombatantActions combatant = actor.GetComponent<CombatantActions>(); // Choose a target. // Make sure the combatant doesn't target itself. List<int> possibleTargets = new List<int>(); for (int i = 0; i < actors.Count; i++) { if (actors[i] != actor) { possibleTargets.Add(i); } } int targetIndex = Random.Range(0, possibleTargets.Count); GameObject target = actors[possibleTargets[targetIndex]]; combatant.SetTarget(target); // Pick the action. int randAction = Random.Range(0, combatant.GetActionCount()); CombatantAction action = combatant.GetAction(randAction); gameManager.QueueAction(action); } } gameManager.UnsetSelectedAction(); gameManager.GetPlayer().GetComponent<CombatantActions>().SelectedAction = null; }
public void RegisterPlayerCameraEvents() { _gameManager.GetPlayer().playerInput.OnLookEvent += OnLookEventCalled; }
public void OnCreateTetherAnimEvent() { CreateTimeTetherIndicator(GameManager.GetPlayer().transform.position, LevelStateManager.curState); }
void CmdPlayerShot(string playerID, int damage) { Player player = GameManager.GetPlayer(playerID); //find player that gets damage player.RpcTakeDamage(damage); //taking damage from shooting }
void Start() { GameManager gm = FindObjectOfType <GameManager> (); player = gm.GetPlayer(); }
protected virtual void PlayerHit(string _ID, int _damage, string _attackerID) { Player _player = GameManager.GetPlayer(_ID); _player.RpcTakeDamage(_damage, _attackerID); }
void Update() { bool renderHealthBar = false; if (!GetComponent <PlayerMove>() || !GetComponent <PlayerMove>().thisIsMine) { if (Player.thisPlayer != null && Player.thisPlayer.playerObject != null) { if (Player.thisPlayer.playerObject.GetComponent <ClassControl>().classNum == 4 && Player.thisPlayer.team == team) { renderHealthBar = true; if (!this.renderHealthBar) { this.renderHealthBar = true; healthBar.GetComponent <Renderer>().enabled = true; healthBar.parent.GetComponent <Renderer>().enabled = true; } // Display health bar: if (healthBar != null) { healthBar.localScale = new Vector3(1.01f * health / maxHealth, 1.01f, 1.01f); healthBar.localPosition = new Vector3(-0.505f + 0.505f * health / maxHealth, 0, -0.01f); healthBar.parent.rotation = Quaternion.LookRotation(healthBar.parent.position - Player.thisPlayer.playerCamera.transform.position); } } } } else { // Kill bind if (Input.GetKeyDown(KeyCode.K)) { GetComponent <OperationView> ().RPC("KillSelf", OperationNetwork.ToServer); } // SOUND QUEUES: timeSinceLastVoiceQueue += Time.deltaTime; if (timeSinceLastVoiceQueue > 0.7f) { // Call for medic: if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.X)) { VoiceLine((byte)Random.Range(0, 2), 255, true); // Full volume for now.. timeSinceLastVoiceQueue = 0f; } } while (damageIndicatorsTime.Count > 0 && Time.time - damageIndicatorsTime[0] > 2.0f) { Destroy(damageIndicators[0]); damageIndicators.RemoveAt(0); damageIndicatorsFrom.RemoveAt(0); damageIndicatorsTime.RemoveAt(0); } for (int i = 0; i < damageIndicators.Count; i++) { Vector3 loc = Vector3.ProjectOnPlane(GetComponent <PlayerMove>().mainCamera.transform.forward, damageIndicatorsFrom[i] - GetComponent <PlayerMove>().mainCamera.transform.position); Quaternion rotation = Quaternion.LookRotation(damageIndicatorsFrom[i] - GetComponent <PlayerMove>().mainCamera.transform.position) * Quaternion.Inverse(GetComponent <PlayerMove>().mainCamera.transform.rotation); float angleUsed = -rotation.eulerAngles.y + 90f; damageIndicators[i].GetComponent <RectTransform>().anchoredPosition = new Vector2(0 + 1.6f * Mathf.Cos(angleUsed * Mathf.PI / 180f) * 200, 0 + Mathf.Sin(angleUsed * Mathf.PI / 180f) * 200); damageIndicators[i].GetComponent <RectTransform>().rotation = Quaternion.Euler(0, 0, angleUsed); if (Time.time - damageIndicatorsTime[i] > 1f) { Color color = damageIndicators[i].GetComponent <RawImage>().color; damageIndicators[i].GetComponent <RawImage>().color = new Color(color.r, color.g, color.b, damageIndicatorsTime[i] - Time.time + 2.0f); } } // See player name & your trigger / trap. PlayerMove pMove = GetComponent <PlayerMove>(); displayName = ""; RaycastHit hit; float dist = 50; // It should be noted that it has to hit the hitboxes, not the player right now because otherwise it would just the raycast would always hit your own player.. (Easy fix is just to move the raycast forward) if (Physics.Raycast(pMove.mainCamera.transform.position, pMove.mainCamera.transform.forward, out hit, dist, LayerLogic.HitscanShootLayer())) { if (hit.transform.gameObject.layer == 16 + pMove.GetComponent <Combat>().team || hit.transform.gameObject.layer == 17 - pMove.GetComponent <Combat>().team) // Can see both allies and enemies right now. { // Finds the actual player object Transform plyr = hit.transform; do { plyr = plyr.parent; } while (plyr.GetComponent <Combat>() == null); if (plyr.GetComponent <PlayerMove> ()) // facades don't have names for now.. { short playerOwner = plyr.GetComponent <PlayerMove> ().plyr; if (GameManager.PlayerExists(playerOwner)) { displayName = GameManager.GetPlayer(playerOwner).playerName; } } } if (hit.transform.gameObject.layer == 14) { if (hit.transform.GetComponent <ArrowLauncher>()) { if (hit.transform.GetComponent <ArrowLauncher>().playerOwner == pMove.plyr) // "myArrowTrap" { hit.transform.GetComponent <ArrowLauncher>().Highlight(); } } if (hit.transform.GetComponent <ArrowTrigger>()) { if (hit.transform.GetComponent <ArrowTrigger>().playerOwner == pMove.plyr) // "myArrowTrap" { hit.transform.GetComponent <ArrowTrigger>().Highlight(); } } } } } if (OperationNetwork.isServer) { // Loss of overheal over time: if (health > maxHealth && (int)(Time.time) > (int)(Time.time - Time.deltaTime)) // This = every second. { TakeDamage(Mathf.Min(5, health - maxHealth), OTHER); // Every second, lose 5 of the buff. } // You get healed within your respawn room: if (GetComponent <PlayerMove>() && GetComponent <PlayerMove>().isInSpawnRoom&& health < maxHealth && (int)(Time.time) > (int)(Time.time - Time.deltaTime)) { TakeDamage(Mathf.Max(-50, health - maxHealth), HEALING); // 50 heal per second in spawn. } } if (!renderHealthBar && this.renderHealthBar) { this.renderHealthBar = false; if (healthBar != null) { healthBar.GetComponent <Renderer>().enabled = false; healthBar.parent.GetComponent <Renderer>().enabled = false; } } // Assign to its own game object: // Needs to be at least 10 buffed to get particle effect: if (health <= maxHealth + 10 && isOverHealEffectDisplayed) { isOverHealEffectDisplayed = false; transform.Find("OverHealParticles").gameObject.SetActive(false); } else if (health > maxHealth + 10 && !isOverHealEffectDisplayed) { isOverHealEffectDisplayed = true; transform.Find("OverHealParticles").gameObject.SetActive(true); } }
// Use this for initialization protected void Start() { detectedLayers.Add(GameManager.GetPlayer().gameObject.layer); }
public void InitializeCheckObjectCamera(GameManager gameManager) { _gameManager = gameManager; actionKey = false; _gameManager.GetPlayer().playerInput.OnActionKeyPressedEvent += OnActionKeyPressed; }
void CmdPlayerShot(string id, int damage) { Debug.Log(id + " has been shot"); GameManager.GetPlayer(id).Hit(damage); }
void Start() { _gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); _player = _gameManager.GetPlayer(); _emitter = GetComponent <ProjectileEmitter>(); }
// PRIVATE PARTS -------------------------------------------------------------------------------------------------------------------------- // Use this for initialization void Start() { gm = GameObject.FindWithTag("GameController").GetComponent <GameManager>(); player = gm.GetPlayer();; minimap = gm.GetMinimap();; }
private void CmdShootPlayer(string idOfShot, int damageDone, string shooterId, int killVal, int teamVal) { PlayerManager playerShot = GameManager.GetPlayer(idOfShot); playerShot.RpcTakeDamage(damageDone, shooterId, killVal, teamVal); }
public override void TakeDamageObject(float amount, Vector3 fromWhere, bool isHitscan, short playerSender) { // Intercept it if it cames from an allied player: if (GameManager.PlayerExists(playerSender) && GameManager.GetPlayer(playerSender) && GameManager.GetPlayer(playerSender).team == team && OperationNetwork.isServer) { TakeDamageIcicle(amount); } else { base.TakeDamageObject(amount, fromWhere, isHitscan, playerSender); } }
public void CmdSetAmmo(string playerID, int value) { PlayerManager player = GameManager.GetPlayer(playerID); player.gameObject.GetComponent <CharacterStates>().RpcSetAmmo(value); }
public void OnDestroy() { _gameManager.GetPlayer().playerInput.OnActionKeyPressedEvent -= OnActionKeyPressed; }
private void OnGameStarted() { m_player.Assignment = GameManager.GetPlayer(); }
public void RpcPlayerWon(string playerID, string username, string playerColor) { GameManager.GetPlayer(playerID).wins++; GameManager.Instance.onPlayerWonCallback.Invoke(username, playerColor); }
//OperationRPC. fromWhere is NOT used in the rpc, it is only used when this is called manually; otherwise it's just set to Vector3.zero. public void TakeDamageProper(float amount, float knockBackMult, Vector3 dir, bool isMine, byte damageType, bool isHitscan, Vector3 fromWhere, short playerSender) { // PlayerSender int is "info". fromWhere is used by server only to indicate the location this damage was sent from. (This will be sent to this player's owner) if (!OperationNetwork.isServer) { print("[--ERROR--]"); // Must call this on the server! return; } // If the sender is not alive, the damage is not done. if (isHitscan && GameManager.PlayerExists(playerSender) && GameManager.GetPlayer(playerSender).playerObject == null) { return; } if (!GetComponent <PlayerMove> ()) { if (GameManager.PlayerExists(GetComponent <SyncFacade>().playerOwner) && GameManager.GetPlayer(GetComponent <SyncFacade>().playerOwner).playerObject != null) { // This is a "way" of doing things. An alternative way is let the facade be able to die, but this way it's.. hmm.. obviously subject to change. // Note that this assumes that armor is on & is phasing GameManager.GetPlayer(GetComponent <SyncFacade> ().playerOwner).playerObject.GetComponent <Combat> ().TakeDamageProper(amount * 2 * 2, knockBackMult, dir, isMine, damageType, isHitscan, fromWhere, playerSender); // Note that if/when we implement facade dieing, the PLAYER will still be teleported over to create the ragdoll } return; } // Phase Shift = not take damage. EVEN for hitscan. (phase is synonymous with "invincible") It is OKAY to do this check to prevent damage (?) Maybe not for hitscan though!! if (GetComponent <PlayerMove> ().isPhasing() && amount > 0) { amount *= 0.5f; // Half damage taken AND with armor on, that's almost no damage taken. knockBackMult = 0; } // 150% damage taken while armor is off // 50% damage taken while armor is on if (GetComponent <ClassControl> ().classNum == 0 && amount > 0) { amount = amount * 1.5f - amount * 1f * GetComponent <PlayerMove> ().isArmorOn; } // For stuff that does constant damage, it only triggers like 10 times per second, so using a short should be fine. health -= amount; // Play sound on server: (grunt sound) if (amount > 0 && damageType < 200) // Minimum damage. { VoiceLine(SoundHandler.GRUNT, (byte)(Mathf.Clamp(amount * 5, 2, 255)), true); // Minimum volume of 2/255. Note that ~50 damage is full volume. } else if (amount < -8 && damageType == HEALING) { VoiceLine(SoundHandler.BEEN_HEALED, 255, true); // Full sound for now. } if (dir != Vector3.zero && !isMine) { TakeDamageMove(amount, knockBackMult, dir); } // Damage went through. (Currently no checks are made for this, (isDead check) but is "todo") // Death / Health situation: if (health <= 0) { health = 0; Kill(playerSender, true); } else { // Just a health change. Sends this to everyone but the player. if (isHitscan) { // Comes from player: if (GameManager.PlayerExists(playerSender)) { fromWhere = GameManager.GetPlayer(playerSender).playerObject.transform.position; } } } if (damageType < 200) { GetComponent <SyncPlayer> ().playerTriggerSet.trigger(SyncPlayer.DAMAGE_TAKEN, new DamageNumber(fromWhere, amount)); if (playerSender != GetComponent <PlayerMove> ().plyr) { // Damage went through callback is now implemented like this: if (GameManager.PlayerExists(playerSender) && GameManager.GetPlayer(playerSender).playerObject != null) { GameManager.GetPlayer(playerSender).playerObject.GetComponent <SyncPlayer> ().playerTriggerSet.trigger(SyncPlayer.DAMAGE_NUMBER, new DamageNumber(transform.position, amount)); } } } }
private void Start() { basePos = transform.position; player = GameManager.GetPlayer(); baseCollider = GetComponent <Collider2D>(); }
void CmdPlayerWasShot(string _playerID, int _damage) { Player _player = GameManager.GetPlayer(_playerID); _player.RpcTakeDamage(_damage); }
private void CreateAblityCards() { int count = ItemData.itemCards.Count; for (int i = 0; i < count; i++) { AbilityCard card = CardFactory.CreateCard(ItemData.itemCards[i].abiliites, GameManager.GetPlayer(), ItemData.itemCards[i].cardSlotType, ItemID); //Debug.Log(ItemData.itemCards[i].abiliites.Count + " abilities found"); abilityCards.Add(card); } }
// Start is called before the first frame update void Start() { gm = GameObject.Find("GameManager").GetComponent <GameManager>(); p = gm.GetPlayer(Camera.main.GetComponent <PlayerManager>().playerId); }
void HudUpdate() { GameManager.UpdateKillFeed(); HealthBarUpdate(); UpdateTrapSelectionZoneMenu(); for (int i = 0; i < trapsHud.Length; i++) { trapsHud [i].SetActive(isTrapSelectionMenuOpen); } respawnHud.transform.parent.gameObject.SetActive(Player.thisPlayer != null && Player.thisPlayer.playerObject == null); if (Player.thisPlayer != null && Player.thisPlayer.playerObject == null) { respawnHud.fillAmount = Mathf.Clamp01(1 - Player.thisPlayer.getRespawnTimer() / Player.thisPlayer.getNetRespawnTimer()); respawnHud.transform.parent.GetComponent <Image>().fillAmount = Mathf.Clamp01(Player.thisPlayer.getRespawnTimer() / Player.thisPlayer.getNetRespawnTimer()); int respawnTimer = (int)(Player.thisPlayer.getRespawnTimer() + 1); if (respawnTimer == 1) { respawnHud.transform.parent.Find("Text").GetComponent <Text> ().text = "Respawning in 1 second."; } else { respawnHud.transform.parent.Find("Text").GetComponent <Text> ().text = "Respawning in " + respawnTimer + " seconds."; } } // Class Selection Hud gets priority if (Player.thisPlayer && Player.thisPlayer.team == 1 && !OptionsMenu.classSelectionMenuOpen) { bool needTrap = false; for (int i = 0; i < Player.thisPlayer.trapTypes.Length; i++) { if (Player.thisPlayer.trapTypes [i] == 255) { needTrap = true; } } if (needTrap && !PlayerHud.isTrapSelectionMenuOpen) { PlayerHud.isTrapSelectionMenuOpen = true; OptionsMenu.ChangeLockState(); } else if (!needTrap && PlayerHud.isTrapSelectionMenuOpen) { PlayerHud.isTrapSelectionMenuOpen = false; OptionsMenu.ChangeLockState(); } } if (Player.thisPlayer && PlayerHud.isTrapSelectionMenuOpen) { for (int x = 0; x < trapsChoices.GetLength(0); x++) { for (int y = 0; y < trapsChoices.GetLength(1); y++) { trapsChoices [x, y].transform.Find("Text").GetComponent <Text> ().text = BuyNewTrap.trapNames [BuyNewTrap.trapIndecies[Player.thisPlayer.myRandomTrapChoices[x * trapsChoices.GetLength(1) + y]]]; trapsChoices [x, y].GetComponent <BuyNewTrap> ().buyId = Player.thisPlayer.myRandomTrapChoices [x * trapsChoices.GetLength(1) + y]; trapsChoices [x, y].GetComponent <BuyNewTrap> ().rowID = (byte)x; } } } // This is how HUD should work for all unlocks: if (Player.thisPlayer) { for (int i = 0; i < displayTraps.Length; i++) { byte actual = Player.thisPlayer.trapTypes [i]; if (Player.thisPlayer.team != 1) { actual = 255; } if (displayTraps [i] != actual) { displayTraps [i] = actual; if (displayTraps [i] == 255 || Player.thisPlayer.team != 1) { trapPlayerHudTypes [i].SetActive(false); } else { trapPlayerHudTypes [i].SetActive(true); trapPlayerHudTypes [i].transform.Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [OptionsMenu.TRAP_1 + i]) + ") " + BuyNewTrap.trapNames [BuyNewTrap.trapIndecies[displayTraps [i]]]; } } if (displayTraps[i] != 255 && Player.thisPlayer.playerObject) { int trapTypeIndex = BuyNewTrap.trapIndecies[Player.thisPlayer.trapTypes [i]]; PlacePlayerMade.setCharge(trapPlayerHudTypes [i], Mathf.Clamp01((Player.thisPlayer.playerObject.GetComponent <SyncPlayer>().playerTime - Player.thisPlayer.trapCoolDownsStartedAt [i]) / (float)(BuyNewTrap.baseTrapCosts [trapTypeIndex] * BuyNewTrap.maxTrapsLoaded[trapTypeIndex] * Time.fixedDeltaTime)), 1f / BuyNewTrap.maxTrapsLoaded[trapTypeIndex]); } } } if (OperationNetwork.connected) { if (Time.time - lastNetworkSettingsRead > 1) { if (OperationNetwork.isServer) { dataSentPerSecond = OperationNetwork.getClient(32767).dataSent / (Time.time - lastNetworkSettingsRead); OperationNetwork.getClient(32767).dataSent = 0; networkSettings.GetComponent <Text> ().text = (int)(dataSentPerSecond / 100) / 10.0f + " KB/s"; } else { dataSentPerSecond = RunGame.myClient.dataOutRate / (Time.time - lastNetworkSettingsRead); RunGame.myClient.dataOutRate = 0; float dataRecievedPerSecond = RunGame.myClient.dataInRate / (Time.time - lastNetworkSettingsRead); RunGame.myClient.dataInRate = 0; networkSettings.GetComponent <Text> ().text = "Sent: " + (int)(dataSentPerSecond / 100) / 10.0f + " KB/s Recieved: " + (int)(dataRecievedPerSecond / 100) / 10.0f + " KB/s"; } lastNetworkSettingsRead = Time.time; } } if (OperationNetwork.connected && Player.thisPlayer != null && Player.thisPlayer.playerObject != null) { PlayerMove pMove = Player.thisPlayer.playerObject.GetComponent <PlayerMove> (); float touchPercent = DamageCircle.isTouchingDamageCircle(pMove.timeSinceTouchingDamageCircle); if (touchPercent > 0) { buffHud.transform.parent.GetComponent <Image> ().enabled = true; buffHud.enabled = true; buffHud.fillAmount = touchPercent; } else { // Disable the rendering of it: buffHud.transform.parent.GetComponent <Image> ().enabled = false; buffHud.enabled = false; } healthHud.enabled = true; healthHud.transform.parent.GetComponent <Image> ().enabled = true; healthHudText.enabled = true; healthHud.transform.parent.GetComponent <Image> ().fillAmount = 1 - pMove.GetComponent <Combat> ().health / pMove.GetComponent <Combat> ().maxHealth; healthHud.fillAmount = pMove.GetComponent <Combat> ().health / pMove.GetComponent <Combat> ().maxHealth; healthHudText.text = (short)pMove.GetComponent <Combat> ().health + " HP"; if (Player.thisPlayer.playerObject != playerObjectHudLoaded) { playerObjectHudLoaded = Player.thisPlayer.playerObject; float origNum = getHudHeightUsed(classHud.transform); // Unload old hud: foreach (Transform t in classHud.transform) { if (t.name != "AdjacentClassHud") { Destroy(t.gameObject); } } foreach (Transform t in classHud.transform.Find("AdjacentClassHud")) { Destroy(t.gameObject); } // Create new hud: foreach (Unlock unlock in Player.thisPlayer.playerObject.GetComponent <ClassControl>().getUnlocks()) { if (unlock != null) { unlock.setHudElement(classHud.transform, origNum); } } int classLoaded = Player.thisPlayer.playerObject.GetComponent <ClassControl> ().classNum; // Phase through & Speed Boost are not unlocks, despite having some similar qualities: (Like the HUD) if (classLoaded == 0) { Player.thisPlayer.playerObject.GetComponent <PlayerMove> ().hudElement = Unlock.setHudElement(classHud.transform, "Cooldown", "Phase Shift", OptionsMenu.MOVEMENT_ABILITY_BIND, null, origNum); Player.thisPlayer.playerObject.GetComponent <PlayerMove> ().hudElement2 = Unlock.setHudElement(classHud.transform, "Armor", "Armor", OptionsMenu.MAIN_ABILITY, null, origNum); } else if (classLoaded == 3) { Player.thisPlayer.playerObject.GetComponent <PlayerMove> ().hudElement = Unlock.setHudElement(classHud.transform, "Cooldown", "Speed Boost", OptionsMenu.MOVEMENT_ABILITY_BIND, null, origNum); } else if (classLoaded == 4) { if (OptionsMenu.hudPanels.ContainsKey("Healthtaken")) { Player.thisPlayer.playerObject.GetComponent <PlayerMove> ().hudElement = Unlock.setHudElement(classHud.transform, "Healthtaken", "Health Taken", OptionsMenu.ULTIMATE_ABILITY, null, origNum); } } // The updating for the HUD is handled within the unlocks / class itself } } else { // Hide hud completely: buffHud.transform.parent.GetComponent <Image> ().enabled = false; buffHud.enabled = false; healthHud.enabled = false; healthHud.transform.parent.GetComponent <Image> ().enabled = false; healthHudText.enabled = false; } // SCOREBOARD: if (Input.GetKey(KeyCode.Tab)) { scoreBoard.SetActive(true); for (byte team = 0; team < 2; team++) { List <Player> players = GameManager.getPlayersOnTeam(team); for (int i = 0; i < scoreBoardPlayers[team].Count; i++) { if (i < players.Count) { scoreBoardPlayers [team] [i].SetActive(true); scoreBoardPlayers [team] [i].transform.Find("Text").GetComponent <Text> ().text = players [i].playerName; Color c = scoreBoardPlayers [team] [i].GetComponent <Image> ().color; if (players [i].playerObject != null) { scoreBoardPlayers [team] [i].GetComponent <Image> ().color = new Color(c.r, c.g, c.b, 1f); } else { scoreBoardPlayers [team] [i].GetComponent <Image> ().color = new Color(c.r, c.g, c.b, 0.2f); } scoreBoardKills [team] [i].text = "" + players[i].kills; scoreBoardDeaths [team] [i].text = "" + players[i].deaths; } else { scoreBoardPlayers [team] [i].SetActive(false); scoreBoardKills [team] [i].text = ""; scoreBoardDeaths [team] [i].text = ""; } } } } else { scoreBoard.SetActive(false); } // Display kill feed: for (int i = 0; i < killFeed.Count; i++) { if (GameManager.recentPlayerKillers.Count > i) { killFeed [i].parent.gameObject.SetActive(true); string killDisplay = ""; if (GameManager.PlayerExists(GameManager.recentPlayerKillers [i])) { killDisplay = GameManager.GetPlayer(GameManager.recentPlayerKillers [i]).playerName + " killed "; } if (GameManager.PlayerExists(GameManager.recentPlayerDeaths [i])) { killFeed [i].GetComponent <Text> ().text = killDisplay + GameManager.GetPlayer(GameManager.recentPlayerDeaths [i]).playerName; } } else { killFeed [i].parent.gameObject.SetActive(false); } } // Class Selection Menu: if (OptionsMenu.classSelectionMenuOpen && Player.thisPlayer != null) { classSelectionMenu.SetActive(true); Color color; if (Player.thisPlayer.team == 0) { color = new Color(0, 0, 1f, 0.5f); } else if (Player.thisPlayer.team == 1) { color = new Color(1f, 0, 0, 0.5f); } else { color = new Color(1f, 1f, 1f, 0.5f); } classSelectionMenu.GetComponent <Image> ().color = color; for (byte i = 0; i < classSelectionTeams.Length; i++) { if (Player.thisPlayer.team == i) { classSelectionTeams [i].color = new Color(classSelectionTeams [i].color.r, classSelectionTeams [i].color.g, classSelectionTeams [i].color.b, 1f); } else { classSelectionTeams [i].color = new Color(classSelectionTeams [i].color.r, classSelectionTeams [i].color.g, classSelectionTeams [i].color.b, 0.6f); } } for (byte i = 0; i < classTypes.Count; i++) { if (Player.thisPlayer.team == 0) { classTypes [i].gameObject.SetActive(true); if (Player.thisPlayer.classNum == i) { classTypes [i].color = new Color(0.2f, 0.2f, 1f, 1f); } else { classTypes [i].color = new Color(0.7f, 0.7f, 1f, 0.8f); } } else if (Player.thisPlayer.team == 1) { classTypes [i].gameObject.SetActive(true); if (Player.thisPlayer.classNum == i) { classTypes [i].color = new Color(1f, 0.2f, 0.2f, 1f); } else { classTypes [i].color = new Color(1f, 0.7f, 0.7f, 0.8f); } } else { classTypes [i].gameObject.SetActive(false); } } } else { classSelectionMenu.SetActive(false); } }
private void Die(string _sourceID) { isDead = true; PlayerSetupNetwork sourcePlayer = GameManager.GetPlayer(_sourceID); if (sourcePlayer != null) { sourcePlayer.kills++; Debug.Log("xx:" + sourcePlayer.username); GameManager.instance.onPlayerKilledCallback.Invoke(GetComponent <PlayerSetupNetwork>().username, "Kill", sourcePlayer.username); } GetComponent <PlayerSetupNetwork>().deaths++; //Disable components for (int i = 0; i < disableOnDeath.Length; i++) { disableOnDeath[i].enabled = false; } //Disable GameObjects for (int i = 0; i < disableGameObjectsOnDeath.Length; i++) { disableGameObjectsOnDeath[i].SetActive(false); } //SeUIMode Onpause(); //Disable the collider Collider _col = GetComponent <Collider>(); if (_col != null) { _col.enabled = true; } Rigidbody rigidbody = GetComponent <Rigidbody>(); if (rigidbody != null) { rigidbody.isKinematic = true; } /* Transform _spawnPoint = NetworkManager.singleton.GetStartPosition(); * rigidbody.position = _spawnPoint.position; * rigidbody.rotation = _spawnPoint.rotation;*/ //set up position respawn acording to tag if (tag == "Cat") { GetComponent <Rigidbody>().MovePosition(GameObject.Find("Cat").transform.position); GetComponent <Rigidbody>().MoveRotation(GameObject.Find("Cat").transform.rotation); } //set up position respawn acording to tag if (tag == "Bear") { GetComponent <Rigidbody>().MovePosition(GameObject.Find("Bear").transform.position); GetComponent <Rigidbody>().MoveRotation(GameObject.Find("Bear").transform.rotation); } //Spawn a death effect /*GameObject _gfxIns = (GameObject)Instantiate(deathEffect, transform.position, Quaternion.identity); * Destroy(_gfxIns, 3f);*/ //Switch cameras /*if (isLocalPlayer) * { * GameManager.instance.SetSceneCameraActive(true); * GetComponent<PlayerSetup>().playerUIInstance.SetActive(false); * }*/ Debug.Log(transform.name + " is DEAD!"); StartCoroutine(Respawn()); }
void CmdPlayerShot(GameObject obj, string _playerID, int damage) { Player player = GameManager.GetPlayer(_playerID.Replace("Player ", "")); player.RpcTakeDamage(obj, damage); }
IEnumerator TetherBackAnimation(int stateToLoad) { //Debug.Log("TetherBackAnimation coroutine started"); // The tether menu should be gone by this point // Make Margot play her tether animation // start animation playerScript.PlayTetherAnimation(); AudioLibrary.PlayTetherRewindSound(); // Play ripple out particle effect ParticleSystem ripples = Instantiate(Resources.Load("Prefabs/ParticlesRippleOut") as GameObject, GameManager.GetPlayer().transform).GetComponent <ParticleSystem>(); ripples.transform.position = GameManager.GetPlayer().transform.position; ripples.Play(); // Temporary way of delaying; should eventually have the animation controller tell this script that Margot's animation has finished yield return(new WaitForSeconds(0.5f)); /* * while (false) * { * // Wait for Margot's animation to finish * yield return null; * } */ // Next, start two simultaneous actions // (1) Make the screen transition play tetherTransition.SetFadeOut(); tetherShaderTransition.SetFadeOut(); // (2) Make the timeline arrow move directly above the previous tether point SetArrowTarget(stateToLoad, false, false); while (!ArrowReachedTarget() || tetherTransition.TransitionInProgress()) { // Wait for both conditions to finish yield return(null); } Destroy(ripples.gameObject); // Load the desired state via LevelStateManager LoadTetherPoint(stateToLoad); //RemoveTimeTetherIndicator(stateToLoad + 1); //LevelStateManager.loadTetherPoint(stateToLoad); // How long to wait on the black screen yield return(new WaitForSeconds(0.3f)); // Now that the state has been loaded, make the transition fade back in playerScript.PlayReappearAnimation(); yield return(new WaitForSeconds(0.1f)); tetherTransition.SetFadeIn(); tetherShaderTransition.SetFadeIn(); // Play ripple in particle effect ripples = Instantiate(Resources.Load("Prefabs/ParticlesRippleIn") as GameObject, GameManager.GetPlayer().transform).GetComponent <ParticleSystem>(); ripples.transform.position = GameManager.GetPlayer().transform.position; ripples.Play(); while (tetherTransition.TransitionInProgress()) { // Wait for the transition in to finish yield return(null); } // When the transition is done, start these simultaneous actions // (1) Make Margot play her appear animation ripples.enableEmission = false; yield return(new WaitForSeconds(0.2f)); // (2) Move the timeline arrow to the middle position in front of the tether point we just reverted to SetArrowTarget(stateToLoad, true, false); // TODO need compound boolean while (!ArrowReachedTarget()) { // Wait for both conditions to finish yield return(null); } yield return(new WaitForSeconds(0.5f)); Destroy(ripples.gameObject); // Now that the process has finished, restore control to the player // TODO tetherUIState = TetherUIState.GAMEPLAY; //GameManager.setPause(false); GameManager.inst.ExitPauseState(); CursorManager.inst.lockCursorType = false; CursorManager.inst.OnCursorBoundsUpdated(); }
void CmdPlayerShot(uint netId, int damage) { Player player = GameManager.GetPlayer(netId); player.RpcTakeDamage(damage); }
public void Update() { // If the element is being dragged if (dragging) { // Follow the mouse position transform.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y); // If the mouse lets go if (Input.GetMouseButtonUp(0)) { // The element is no longer being dragged dragging = false; overlap = GetClosestOverlap(); // Grab the player data manager for ease PlayerDataManager playerDataManager = manager.GetPlayer(); // If this element is an ingredient if (ingredient) { // If nothing is being overlapped if (overlap == null) { // Return to spawn returning = true; } // If the element overlaps with a "Catcher" else if (overlap.CompareTag("Catcher")) { // Check if the origin was the player's inventory (We don't want the player to sell stuff to the shop from the shop's inventory, for example) if (spawn.transform.parent.CompareTag("Inventory") || spawn.transform.CompareTag("Generic")) { // If the overlap is a cauldron if (overlap.GetComponent <Cauldron>()) { // Add the ingredient to the cauldron overlap.GetComponent <Cauldron>().AddIngredientToCauldron(ingredient); } // Otherwise it must be the sell field of a shop else { playerDataManager.AddMoney(ingredient.cost / 2); } // Cleanup the element Cleanup(); } else { // Return to spawn returning = true; } } // If the element overlaps with an inventory slot else if (overlap.transform.parent.CompareTag("Inventory")) { // If the overlapping storage is empty, or the overlapped storage already contains this ingredient if (overlap.GetComponent <Storage>().IsEmpty() || playerDataManager.CompareIDs(ingredient.ids, overlap.GetComponent <Storage>().GetIngredient().ids)) { if (!spawn.transform.CompareTag("Generic")) { // Add it to the inventory slot playerDataManager.AddToInventoryAtSlot(overlap.GetComponent <Storage>().GetSlotNumber(), ingredient); // If the element is from the shop if (spawn.transform.parent.CompareTag("Shop")) { // PAY FOR IT!!! playerDataManager.Purchase(ingredient.cost); } // Cleanup the element Cleanup(); } else { returning = true; } } // If the overlapping storage is not empty, and does not contain this ingredient, but is still an inventory slot else if (spawn.transform.parent.name == "Inventory") { // Swap round the items! playerDataManager.SwapIngredientLocs(spawn.GetComponent <Storage>().GetSlotNumber(), overlap.GetComponent <Storage>().GetSlotNumber(), ingredient, overlap.GetComponent <Storage>().GetIngredient()); // Account for the decrement on pickup overlap.GetComponent <Storage>().quantity++; // Cleanup the element Cleanup(); } else { // Get back to spawn returning = true; } } else { // Get back to spawn returning = true; } } else if (potion) { if (overlap) { if (overlap.CompareTag("Customer")) { playerDataManager.AddMoney(overlap.GetComponent <Customer>().Sell(potion)); Cleanup(); } } } } } }
private void OnDestroy() { _gameManager.GetPlayer().playerInput.OnLookEvent -= OnLookEventCalled; }
public void PassBallClient(ulong passerPid, Vector3 pos, PassType type) { Player passer = GameManager.GetPlayerByNetworkID(passerPid); StartCoroutine(AutoCatchPass(GameManager.GetPlayer(), pos)); }
void QueueSelectedAction(GameManager gameManager) { CombatantAction selectedAction = gameManager.GetPlayer().GetComponent<CombatantActions>().SelectedAction; if (selectedAction != null) { gameManager.QueueAction(selectedAction); } gameManager.UnsetSelectedAction(); }