public virtual void SpawnPlayer(Message message) { OnlinePlayer player; if (message.Count == 4) { // player = ObjectPool.Instance.SpawnComponent<OnlinePlayer>(playerPrefab.prefabIndex, new Vector2(message.GetFloat(1), message.GetFloat(2)), Quaternion.LookRotation(Vector3.forward, VectorExtensions.FromFacingAngle(message.GetFloat(3)))); player = Instantiate(playerPrefab, new Vector2(message.GetFloat(1), message.GetFloat(2)), Quaternion.LookRotation(Vector3.forward, VectorExtensions.FromFacingAngle(message.GetFloat(3)))); OnlineBattle.localPlayer = player; player.owner = GameManager.Instance.teams[0]; player.SetColor(player.owner.color); player.scoreText.text = "Score: " + player.Score; GameManager.updatables = GameManager.updatables.Add(this); // loadingText.text = "Please wait for another player to join"; if (!HasPaused) { pauseInstructionsObj.SetActive(true); } } else { // player = ObjectPool.Instance.SpawnComponent<OnlinePlayer>(playerPrefab.prefabIndex); player = Instantiate(playerPrefab); player.body.trs.position = new Vector2(message.GetFloat(1), message.GetFloat(2)); player.weapon.trs.position = new Vector2(message.GetFloat(3), message.GetFloat(4)); player.ChangeScore(message.GetUnsignedInteger(5)); player.enabled = false; GameManager.updatables = GameManager.updatables.Remove(player); OnlineBattle.nonLocalPlayers = OnlineBattle.nonLocalPlayers.Add(player); // loadingText.enabled = false; } player.playerId = message.GetInteger(0); playerIdsDict.Add(player.playerId, player); OnlineArena.Instance.SetSize((uint)playerIdsDict.Count); }
public override void ApplyEffect(Player player) { if (OnlineBattle.isPlaying) { if (OnlineBattle.localPlayer == player) { OnlineBattle.Instance.bountyMultiplier *= bountyMultiplier; } else { OnlinePlayer onlinePlayer = player as OnlinePlayer; onlinePlayer.scoreText.text = "Bounty: " + Mathf.Clamp(onlinePlayer.Score * bountyMultiplier, 1, int.MaxValue); } } else if (Battle.player1 == player) { Battle.Instance.scoreChangeAmount *= bountyMultiplier; } }
public virtual void OnDeath(Player killer, Body victim) { if (killer != null) { OnlinePlayer onlineKiller = killer as OnlinePlayer; if (OnlineBattle.localPlayer.playerId == onlineKiller.playerId) { onlineKiller.ChangeScore((uint)Mathf.Clamp(victim.player.Score, 1, int.MaxValue)); SendChangeScoreMessage((uint)Mathf.Clamp(score * OnlineBattle.Instance.bountyMultiplier, 1, int.MaxValue)); } } if (OnlineBattle.localPlayer == this) { if (ArchivesManager.player1AccountData != null) { ArchivesManager.player1AccountData.onlineData.deaths++; ArchivesManager.player1AccountData.onlineData.killDeathRatio = ArchivesManager.player1AccountData.onlineData.kills / ArchivesManager.player1AccountData.onlineData.deaths; ArchivesManager.Instance.UpdateAccountData(ArchivesManager.player1AccountData); } GameManager.Instance.ReloadActiveScene(); } }
public override void UnapplyEffect(Player player) { if (OnlineBattle.Instance != null) { if (OnlineBattle.localPlayer == player) { OnlineBattle.Instance.bountyMultiplier /= bountyMultiplier; } else { OnlinePlayer onlinePlayer = player as OnlinePlayer; if (onlinePlayer != null) { onlinePlayer.scoreText.text = "Bounty: " + Mathf.Clamp(onlinePlayer.Score, 1, int.MaxValue); } } } else if (Battle.player1 == player) { Battle.Instance.scoreChangeAmount /= bountyMultiplier; } }