private void Start() { _heading = transform.up; PlayerIdentifier = _photonView.InstantiationData[0] as PlayerIdentifier; GameManager.Instance.RegisterPlayer(this); _displayName = GameManager.Instance.GetDisplayNameForPlayer(PlayerIdentifier); }
void OnPlayerJoined(PlayerInput input) { Character c = input.GetComponent <Character>(); if (c) { c.SetPlayerHandler(this); identifier = c.GetComponentInChildren <PlayerIdentifier>(); Vector3 pos = Vector3.zero; //if( noReuse ) { // pos = startPositions[ Random.Range( 0, startPositions.Count - 1 ) ]; // startPositions.Remove( pos ); //} //else { //pos = startPositions[ playerNumber % startPositions.Count ]; pos = startPositions[playerNumber++ % startPositions.Count]; //} input.transform.root.position = pos; } identifier.SetColor(playerNumber); }
bool IsValidIndirectCapture(Hex currentHex, PlayerIdentifier conqueror, List <Hex> capturedRegion, HashSet <Hex> scannedHexes) { foreach (var neighbour in GetNeighbours(currentHex)) { if (scannedHexes.Contains(neighbour)) { // This hex has already been scanned continue; } scannedHexes.Add(neighbour); if (neighbour.Owner == conqueror) { // This hex is already owned by the player continue; } if (neighbour.Unit != null) { // An enemy unit is occupying a hex in this region so it can't be captured return(false); } if (scannedHexes.Count >= GameConstants.IndirectCaptureLimit) { // This hex passed the criteria but the region is already too large to be captured indirectly return(false); } capturedRegion.Add(neighbour); bool isEmptyRegion = IsValidIndirectCapture(neighbour, conqueror, capturedRegion, scannedHexes); if (!isEmptyRegion) { return(false); } } return(true); }
internal EloFixtureCompetitor(T player, int startRating, int opponentRating, PlayerIdentifier playerNumber, int kFactor) { Player = player; StartRating = startRating; OpponentRating = opponentRating; PlayerNumber = playerNumber; KFactor = kFactor; }
void Start() { playerIdentifier = GetComponent <PlayerIdentifier>(); ladderSound = ladderSoundObject.GetComponent <AudioSource>(); fpc = GetComponent <FirstPersonController>(); rb = GetComponent <Rigidbody>(); myPlayerNum = playerIdentifier.myPlayerNum; }
public async Task JoinAsync(string roomName, PlayerIdentifier playerIdentifier) { (room, storage) = await Group.AddAsync(roomName, playerIdentifier); self = playerIdentifier; BroadcastExceptSelf(room).Join(playerIdentifier); Players = storage.AllValues; join.OnNext(roomName); }
// Determines which parts of the map are currently being supplied public HashSet <Hex> GetSupplyMap(PlayerIdentifier identifier) { var output = new HashSet <Hex>(new HexComparer()); foreach (var supplySource in SupplySources[identifier]) { CreatePartialSupplyMap(supplySource, identifier, output); } return(output); }
public async UniTask Join(string roomName, PlayerIdentifier playerIdentifier) { if (isJoin) { return; } await accessControlHub.JoinAsync(roomName, playerIdentifier); isJoin = true; }
ServerClient GetClient(PlayerIdentifier identifier) { ServerClient[] clients = { Owner, Opponent }; ServerClient output = clients.First((ServerClient x) => x.Identifier == identifier); if (output == null) { throw new Exception("Unable to find a client matching a numeric identifier"); } return(output); }
private void ActivateScorePanelsForPlayer(Player localPlayer) { var playersSelectedForPhotonPlayer = GameStartParameters.GetLocallySelectedPlayersFromPlayerProperties(localPlayer.CustomProperties); for (int i = 0; i < playersSelectedForPhotonPlayer.Count; i++) { var identifier = new PlayerIdentifier(localPlayer.ActorNumber, i); var playerType = playersSelectedForPhotonPlayer[i]; ScoreDisplayPanel scoreDisplayPanel = _scoreDisplayPanels[_activatedScorePanels]; scoreDisplayPanel.Initialize(identifier, playerType); } }
public string GetDisplayNameForPlayer(PlayerIdentifier playerIdentifier) { string displayName; if (GameConfiguration.IsLocalMultiplayer) { displayName = $"Player {playerIdentifier.LocalPlayerID + 1}"; } else { displayName = PhotonNetwork.CurrentRoom.Players[playerIdentifier.LocalPlayerID].NickName; } return(displayName); }
// Use this for initialization void Start() { thisPlayerID = thisPlayer.GetComponent <PlayerIdentifier>(); roundScoreText.text = "Your score: " + 0; //if this is player 1. if (thisPlayerID.myPlayerNum == 0) { enemyRoundScoreText.text = PlayerNames.playerOneName + ": " + 0; } //if this is player 2 else { enemyRoundScoreText.text = PlayerNames.playerTwoName + ": " + 0; } }
private IEnumerator SpawnPlayers() { yield return(null); List <PlayerType> localPlayers = GameStartParameters.GetLocallySelectedPlayersFromPlayerProperties(PhotonNetwork.LocalPlayer.CustomProperties); for (int i = 0; i < localPlayers.Count; i++) { PlayerIdentifier playerIdentifier = new PlayerIdentifier(PhotonNetwork.LocalPlayer.ActorNumber, i); PlayerType localPlayer = localPlayers[i]; PhotonNetwork.Instantiate(localPlayer.ToString(), PlayerSpawnPoints.Instance.GetForPlayer(PhotonNetwork.LocalPlayer.ActorNumber - 1).position, Quaternion.identity, 0, new[] { playerIdentifier, }); } _initialized = true; }
public List<Hex> GetIndirectlyCapturedRegion(Hex seed, PlayerIdentifier conqueror) { if (seed.Owner == conqueror) { // This can't be the seed of an empty region as it is already owned by the player return null; } List<Hex> capturedRegion = new List<Hex>(); // Initially only the seed is virtually captured capturedRegion.Add(seed); HashSet<Hex> scannedHexes = new HashSet<Hex>(new HexComparer()); // Perform depth-first search to determine the size of the region if (IsValidIndirectCapture(seed, conqueror, capturedRegion, scannedHexes)) return capturedRegion; else return null; }
void CreatePartialSupplyMap(Hex currentPosition, PlayerIdentifier identifier, HashSet <Hex> suppliedHexes) { foreach (var neighbour in GetNeighbours(currentPosition)) { if (suppliedHexes.Contains(neighbour)) { // We've reached a part of the map that has already been covered by previous searches continue; } if (neighbour.Owner != identifier) { // Only hexes that are owned by the player can be supplied continue; } suppliedHexes.Add(neighbour); CreatePartialSupplyMap(neighbour, identifier, suppliedHexes); } }
private void Start() { // Set the gameobject name. gameObject.name = PlayerIdentifier.ToString("g"); // Set dead to default (false). this.isDead = false; // Set death time this.currentDeathTime = deathTime; // Init character sounds. InitializeCharacterSounds(); // Get an animator reference. playerAnimator = GetComponent <Animator>(); // Init the cam limiter. camLimiter = new LimitToCameraFrustum(this, cameraEdgeDetectionOffset); // Init network. //network = GameObject.FindObjectOfType<PlayerNetCommunicate>(); // Set the owner of the weapon and the ability. if (weapon != null) { weapon.OwnerScript = this; } //Set original health level. originalHealthLevelScale = healthLevel.transform.localScale; // Fire spawn event. OnPlayerSpawn(); if (ability != null) { ability.OwnerScript = this; ability.InputDevice = inputDevice; ability.PlayerActions = playerActions; } playerInput = new PlayerInputHandler(this, playerAnimator); }
void Start() { thisPlayerID = GetComponentInParent <PlayerIdentifier>(); thisPlayer = transform.parent.gameObject; myCam = GetComponent <Camera>(); if (thisPlayerID.myPlayerNum == 0) { myCam.targetDisplay = 0; myCanvas.layer = 8; myCam.cullingMask = ~(1 << LayerMask.NameToLayer("P2_UI")); myDisplayNum = myCam.targetDisplay; } else if (thisPlayerID.myPlayerNum == 1) { myCam.targetDisplay = 1; myCanvas.layer = 9; myCam.cullingMask = ~(1 << LayerMask.NameToLayer("P1_UI")); myDisplayNum = myCam.targetDisplay; } }
// Use this for initialization void Start() { scoreHasBeenIncreased = false; timeManager = GetComponent <PlayerTimeManager>(); myCanvas = timeManager.myCanvas; currentHealth = maxHealth; // Debug.Log(currentHealth); playerIdentifier = GetComponent <PlayerIdentifier>(); // myIndex = playerSwitcher.myIndex; currentHealth = maxHealth; AssignPlayerAndEnemy(); // if(playerIdentifier.myPlayerNum == 0){ // //you are player 1 // myName = PlayerNames.playerOneName; // myEnemy = CurrentPlayerTracker.otherPlayer; // } // if(playerIdentifier.myPlayerNum == 1){ // //you are player 2 // myName = PlayerNames.playerTwoName; // myEnemy = CurrentPlayerTracker.currentPlayer; // } }
void Start() { pickups.AddRange(FindObjectsOfType <Pickup>()); // otherPlayer = GetComponent<StealthPlayerSwitcher>().otherPlayer; maxActionPoints = myActionPoints; playerIdentifier = GetComponent <PlayerIdentifier>(); myCanvasUpdater = myCanvas.GetComponent <PlayerCanvasUpdater>(); firstPersonController = GetComponent <FirstPersonController>(); playerFrozenState = PlayerFrozenState.Frozen; rb = GetComponent <Rigidbody>(); playerSwitcher = GetComponent <StealthPlayerSwitcher>(); if (playerIdentifier.myPlayerNum == 0) { UnFreezeMe(); // Debug.Log("I'm unfrozen! I am player " + playerIdentifier.myPlayerNum); } if (playerIdentifier.myPlayerNum == 1) { FreezeMe(); // Debug.Log("I'm frozen! I am player " + playerIdentifier.myPlayerNum); } }
public List <Hex> GetIndirectlyCapturedRegion(Hex seed, PlayerIdentifier conqueror) { if (seed.Owner == conqueror) { // This can't be the seed of an empty region as it is already owned by the player return(null); } List <Hex> capturedRegion = new List <Hex>(); // Initially only the seed is virtually captured capturedRegion.Add(seed); HashSet <Hex> scannedHexes = new HashSet <Hex>(new HexComparer()); // Perform depth-first search to determine the size of the region if (IsValidIndirectCapture(seed, conqueror, capturedRegion, scannedHexes)) { return(capturedRegion); } else { return(null); } }
private void CreatePlayers() { foreach (var playerConfig in _scenario.Configuration.PlayerConfiguration) { var player = new Player() { Game = _game, Id = playerConfig.Id, }; _context.InstancePlayers.Add(player); if (playerConfig.Identifiers.TryGetValue(Identifiers.SUGAR, out var sugarId)) { var sugarIdentifier = new PlayerIdentifier() { GameId = player.GameId, PlayerId = player.Id, IdentifierType = Identifiers.SUGAR, Identifier = sugarId, }; _context.InstancePlayerIdentifiers.Add(sugarIdentifier); } if (playerConfig.Identifiers.TryGetValue(Identifiers.RAGE_CLASS, out var rageClassId)) { var sugarIdentifier = new PlayerIdentifier() { GameId = player.GameId, PlayerId = player.Id, IdentifierType = Identifiers.RAGE_CLASS, Identifier = rageClassId, }; _context.InstancePlayerIdentifiers.Add(sugarIdentifier); } } _context.SaveChanges(); }
// Determines which parts of the map are currently being supplied public HashSet<Hex> GetSupplyMap(PlayerIdentifier identifier) { var output = new HashSet<Hex>(new HexComparer()); foreach (var supplySource in SupplySources[identifier]) CreatePartialSupplyMap(supplySource, identifier, output); return output; }
public List <Hex> GetInitialDeploymentZone(PlayerIdentifier player) { return(Hexes.FindAll((Hex x) => x.InitialDeploymentZone != null && x.InitialDeploymentZone.Value == player)); }
public bool IsInInitialDeploymentZone(PlayerIdentifier player, Position position) { Hex hex = GetHex(position); return(hex.InitialDeploymentZone != null && hex.InitialDeploymentZone.Value == player); }
public List<Hex> GetInitialDeploymentZone(PlayerIdentifier player) { return Hexes.FindAll((Hex x) => x.InitialDeploymentZone != null && x.InitialDeploymentZone.Value == player); }
ServerClient GetClient(PlayerIdentifier identifier) { ServerClient[] clients = { Owner, Opponent }; ServerClient output = clients.First((ServerClient x) => x.Identifier == identifier); if (output == null) throw new Exception("Unable to find a client matching a numeric identifier"); return output; }
bool IsValidIndirectCapture(Hex currentHex, PlayerIdentifier conqueror, List<Hex> capturedRegion, HashSet<Hex> scannedHexes) { foreach (var neighbour in GetNeighbours(currentHex)) { if (scannedHexes.Contains(neighbour)) { // This hex has already been scanned continue; } scannedHexes.Add(neighbour); if (neighbour.Owner == conqueror) { // This hex is already owned by the player continue; } if (neighbour.Unit != null) { // An enemy unit is occupying a hex in this region so it can't be captured return false; } if (scannedHexes.Count >= GameConstants.IndirectCaptureLimit) { // This hex passed the criteria but the region is already too large to be captured indirectly return false; } capturedRegion.Add(neighbour); bool isEmptyRegion = IsValidIndirectCapture(neighbour, conqueror, capturedRegion, scannedHexes); if (!isEmptyRegion) return false; } return true; }
// public int myPlayerIndex; // Use this for initialization void Awake() { playerIdentifier = GetComponent <PlayerIdentifier>(); timeManager = GetComponent <PlayerTimeManager>(); // otherPlayer = GameObject.FindGameObjectWithTag("Player"); }
public static Task <Player> GetPlayerAsync(this IRealmRoyaleApiClient operations, string player, PlayerIdentifier identifier, CancellationToken cancellationToken = default) { return(operations.GetPlayerAsync(player, ((int)identifier).ToString(), cancellationToken)); }
public void Initialize(PlayerIdentifier identifier, PlayerType playerType) { _playerType = playerType; _identifier = identifier; }
public PlayerState(Game game, Faction faction, PlayerIdentifier identifier) { Game = game; Faction = faction; Identifier = identifier; }
void IAccessControlReceiver.Leave(PlayerIdentifier playerIdentifier) => leave.OnNext(playerIdentifier);
void IAccessControlReceiver.Join(PlayerIdentifier playerIdentifier) => join.OnNext(playerIdentifier);
public bool isPlayers(PlayerIdentifier id) { return(id == PlayerIdentifier); }
private IToken GetTokenFromPlayer(PlayerIdentifier identifier) { return _identifiers.FirstOrDefault(v => v.Value == identifier).Key; }
void CreateMovementMap(Unit unit, Hex currentHex, Path currentPath, PlayerIdentifier owner, Dictionary <Position, Path> map) { for (int i = 0; i < HexOffsets.Length; i++) { RiverEdge riverEdge = currentHex.RiverEdges[i]; Position offset = HexOffsets[i]; Position neighbourPosition = currentHex.Position + offset; Hex neighbourHex = GetHex(neighbourPosition); if (neighbourHex == null) { // This hex is not part of the map, skip it continue; } if (neighbourHex.Unit != null && neighbourHex.Unit.Owner.Identifier != owner) { // This hex is already occupied by an enemy unit, skip it continue; } int terrainMovementPoints = neighbourHex.GetTerrainMovementPoints(); int movementPointsLost; if (riverEdge != null && !riverEdge.IsBridge) { // It's a move across a river without a bridge // This is only possible under special circumstances // The unit must have its full movement points and it will lose all of them after the crossing int maximumMovementPoints = unit.Stats.Movement.Value; if (currentPath.MovementPointsLeft < maximumMovementPoints) { // The unit had already moved so it can't cross the river continue; } if (currentPath.MovementPointsLeft < terrainMovementPoints) { // This is an extraordinarily rare case but it means that the unit can't cross the river because it couldn't enter the target terrain type, even if the river wasn't there continue; } movementPointsLost = maximumMovementPoints; } else { // It's either a regular move without a river or a move across a bridge movementPointsLost = terrainMovementPoints; } int newMovementPoints = currentPath.MovementPointsLeft - movementPointsLost; if (newMovementPoints < 0) { // The unit doesn't have enough movement points left to enter this hex continue; } Path previousPath; if (map.TryGetValue(neighbourPosition, out previousPath)) { // This neighbouring hex was already analysed by a previous recursive call to this function, check if we can even improve on what it calculated if (previousPath.MovementPointsLeft <= newMovementPoints) { // The solution is inferior or just as good, skip it continue; } } // Create or update the entry in the movement map Path newPath = new Path(currentPath, neighbourHex, newMovementPoints); map[neighbourPosition] = newPath; CreateMovementMap(unit, neighbourHex, newPath, owner, map); } }
public bool IsInInitialDeploymentZone(PlayerIdentifier player, Position position) { Hex hex = GetHex(position); return hex.InitialDeploymentZone != null && hex.InitialDeploymentZone.Value == player; }
private static string GetButtonCode(PlayerIdentifier player) { switch (player) { case PlayerIdentifier.Player1: return Player1Button; case PlayerIdentifier.Player2: return Player2Button; case PlayerIdentifier.Player3: return Player3Button; case PlayerIdentifier.Player4: return Player4Button; default: throw new ArgumentOutOfRangeException(); } }
void CreateMovementMap(Unit unit, Hex currentHex, Path currentPath, PlayerIdentifier owner, Dictionary<Position, Path> map) { for(int i = 0; i < HexOffsets.Length; i++) { RiverEdge riverEdge = currentHex.RiverEdges[i]; Position offset = HexOffsets[i]; Position neighbourPosition = currentHex.Position + offset; Hex neighbourHex = GetHex(neighbourPosition); if (neighbourHex == null) { // This hex is not part of the map, skip it continue; } if (neighbourHex.Unit != null && neighbourHex.Unit.Owner.Identifier != owner) { // This hex is already occupied by an enemy unit, skip it continue; } int terrainMovementPoints = neighbourHex.GetTerrainMovementPoints(); int movementPointsLost; if (riverEdge != null && !riverEdge.IsBridge) { // It's a move across a river without a bridge // This is only possible under special circumstances // The unit must have its full movement points and it will lose all of them after the crossing int maximumMovementPoints = unit.Stats.Movement.Value; if (currentPath.MovementPointsLeft < maximumMovementPoints) { // The unit had already moved so it can't cross the river continue; } if (currentPath.MovementPointsLeft < terrainMovementPoints) { // This is an extraordinarily rare case but it means that the unit can't cross the river because it couldn't enter the target terrain type, even if the river wasn't there continue; } movementPointsLost = maximumMovementPoints; } else { // It's either a regular move without a river or a move across a bridge movementPointsLost = terrainMovementPoints; } int newMovementPoints = currentPath.MovementPointsLeft - movementPointsLost; if (newMovementPoints < 0) { // The unit doesn't have enough movement points left to enter this hex continue; } Path previousPath; if (map.TryGetValue(neighbourPosition, out previousPath)) { // This neighbouring hex was already analysed by a previous recursive call to this function, check if we can even improve on what it calculated if (previousPath.MovementPointsLeft <= newMovementPoints) { // The solution is inferior or just as good, skip it continue; } } // Create or update the entry in the movement map Path newPath = new Path(currentPath, neighbourHex, newMovementPoints); map[neighbourPosition] = newPath; CreateMovementMap(unit, neighbourHex, newPath, owner, map); } }
void CreatePartialSupplyMap(Hex currentPosition, PlayerIdentifier identifier, HashSet<Hex> suppliedHexes) { foreach (var neighbour in GetNeighbours(currentPosition)) { if (suppliedHexes.Contains(neighbour)) { // We've reached a part of the map that has already been covered by previous searches continue; } if (neighbour.Owner != identifier) { // Only hexes that are owned by the player can be supplied continue; } suppliedHexes.Add(neighbour); CreatePartialSupplyMap(neighbour, identifier, suppliedHexes); } }