public void RpcLockTeams() { LockTeams(); List <Player> list = MultiplayerManager.GetInstance().playerList; Player localPlayer = MultiplayerManager.FindPlayer(GetLocalPlayer().GetComponent <NetworkIdentity>().netId); string info = "You are on the " + (localPlayer.team == 0 ? "Red" : "Blue") + " team "; List <Player> teammates = list.FindAll(p => p.team == localPlayer.team && !p.Equals(localPlayer)); if (teammates.Count > 0) { info += "(Teammates: "; for (int i = 0; i < teammates.Count - 1; i++) { info += teammates[i].name + ", "; } info += teammates[teammates.Count - 1].name + ")"; } infoText.text = info; //Disable other team's player names foreach (Player p in list) { if (p.team != localPlayer.team) { ClientScene.FindLocalObject(p.objectId).SetActive(false); } } humanToggle.isOn = true; }
public void CmdChangeTeam(short team) { if (lobby.currentState != LobbyManager.LobbyState.TeamSelect || MultiplayerManager.GetInstance().playerList.FindAll(p => p.team == team).Count >= 4) { return; //team to switch to already has 4 players, abort } MultiplayerManager.FindPlayer(GetComponent <NetworkIdentity>().netId).team = team; playerTeam = team; RpcChangeTeam(team); }
public void CmdLockIn() { MultiplayerManager.FindPlayer(GetComponent <NetworkIdentity>().netId).ready = true; List <Player> playerList = MultiplayerManager.GetInstance().playerList; textColor = new Color(0.4f, 0.8f, 0.4f); if (playerList.FindAll(p => p.ready).Count == playerList.Count) { lobby.LockShips(); lobby.RpcLockShips(); } }
public override void OnInteractWithPlayer(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collision collision) { //notifies the player events system that the player who interacted with this object picked up a health pack (this object) //also sets isHealthPack to true, since this is a health pack Player.ActivateEventPlayerPickup(MultiplayerManager.FindPlayer(playerBoat.GetComponent <NetworkIdentity>().netId), true); //send out the command to change the players health //setting the source of the healthpack to nothing, since no player is responsible if (isServer) { playerHealth.ChangeHealth(ammoAmmount, NetworkInstanceId.Invalid); Destroy(gameObject); } }
public override void OnInteractWithPlayerTrigger(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collider collider) { //notifies the player events system that the player who interacted with this object picked up a health pack (this object) //also sets isHealthPack to true, since this is a health pack if (isServer) { if (playerBoat.GetComponent <HeavyWeapon>().AmmoCount >= playerBoat.GetComponent <HeavyWeapon>().ammoCapacity) { return; } playerBoat.GetComponent <HeavyWeapon>().AddAmmo(ammoAmmount); Player.ActivateEventPlayerPickup(MultiplayerManager.FindPlayer(playerBoat.GetComponent <NetworkIdentity>().netId), true); RpcConsumePack(playerBoat.GetComponent <NetworkIdentity>().netId); } }
/// <summary> /// This method should be used for all changes to a ship's health. /// It should only be called on the server. /// Use NetworkInstanceId.Invalid if there is no damage source. /// </summary> /// <param name="amount">Amount to change health by</param> /// <param name="source">ID of the damage/heal source. Can be NetworkInstanceId.Invalid</param> public void ChangeHealth(float amount, NetworkInstanceId source) { if ((health == 0 || currentInvincibleTimer > 0) && amount < 0) { return; //don't register damage taken after death or while invincible } //Todo: add back in this functionality in the Stat System using an event hook for PlayerDamaged if (amount < 0) //only for damage { amount *= defenseStat; // Multiplier effect for defense stat } Player.ActivateEventPlayerDamaged(MultiplayerManager.FindPlayer(GetComponent <NetworkIdentity>().netId), MultiplayerManager.FindPlayer(source), ref amount); //By setting this variable in a serverside context, the OnChangeHealth hook is called on all clients health = Mathf.Clamp(health + amount, 0, 100); if (health == 0) //Tell the server about this kill { MultiplayerManager.GetInstance().PlayerKill(MultiplayerManager.FindPlayer(GetComponent <NetworkIdentity>().netId), source); } }
public void CmdChangeShip(Ship ship) { MultiplayerManager.FindPlayer(GetComponent <NetworkIdentity>().netId).ship = ship; playerShip = (short)ship; RpcChangeShip(ship); }
public void CmdPlayerInit(int connId) { MultiplayerManager.FindPlayer(connId).objectId = GetComponent <NetworkIdentity>().netId; }