예제 #1
0
 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);
    }
예제 #3
0
파일: Map.cs 프로젝트: jascou/PanzerKontrol
 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);
 }
예제 #4
0
 internal EloFixtureCompetitor(T player, int startRating, int opponentRating, PlayerIdentifier playerNumber, int kFactor)
 {
     Player         = player;
     StartRating    = startRating;
     OpponentRating = opponentRating;
     PlayerNumber   = playerNumber;
     KFactor        = kFactor;
 }
예제 #5
0
 void Start()
 {
     playerIdentifier = GetComponent <PlayerIdentifier>();
     ladderSound      = ladderSoundObject.GetComponent <AudioSource>();
     fpc         = GetComponent <FirstPersonController>();
     rb          = GetComponent <Rigidbody>();
     myPlayerNum = playerIdentifier.myPlayerNum;
 }
예제 #6
0
        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);
        }
예제 #7
0
파일: Map.cs 프로젝트: jascou/PanzerKontrol
        // 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);
        }
예제 #8
0
파일: Access.cs 프로젝트: aiczk/MoApi
        public async UniTask Join(string roomName, PlayerIdentifier playerIdentifier)
        {
            if (isJoin)
            {
                return;
            }

            await accessControlHub.JoinAsync(roomName, playerIdentifier);

            isJoin = true;
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
            }
        }
예제 #11
0
        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);
        }
예제 #12
0
 // 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;
     }
 }
예제 #13
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;
        }
예제 #14
0
 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;
 }
예제 #15
0
파일: Map.cs 프로젝트: jascou/PanzerKontrol
 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);
     }
 }
예제 #16
0
    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);
    }
예제 #17
0
 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;
     }
 }
예제 #18
0
 // 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;
     // }
 }
예제 #19
0
 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);
     }
 }
예제 #20
0
파일: Map.cs 프로젝트: jascou/PanzerKontrol
        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);
            }
        }
예제 #21
0
        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();
        }
예제 #22
0
 // 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;
 }
예제 #23
0
파일: Map.cs 프로젝트: jascou/PanzerKontrol
 public List <Hex> GetInitialDeploymentZone(PlayerIdentifier player)
 {
     return(Hexes.FindAll((Hex x) => x.InitialDeploymentZone != null && x.InitialDeploymentZone.Value == player));
 }
예제 #24
0
파일: Map.cs 프로젝트: jascou/PanzerKontrol
        public bool IsInInitialDeploymentZone(PlayerIdentifier player, Position position)
        {
            Hex hex = GetHex(position);

            return(hex.InitialDeploymentZone != null && hex.InitialDeploymentZone.Value == player);
        }
예제 #25
0
 public List<Hex> GetInitialDeploymentZone(PlayerIdentifier player)
 {
     return Hexes.FindAll((Hex x) => x.InitialDeploymentZone != null && x.InitialDeploymentZone.Value == player);
 }
예제 #26
0
 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;
 }
예제 #27
0
 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;
 }
예제 #28
0
    // 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));
 }
예제 #30
0
 public void Initialize(PlayerIdentifier identifier, PlayerType playerType)
 {
     _playerType = playerType;
     _identifier = identifier;
 }
예제 #31
0
 public PlayerState(Game game, Faction faction, PlayerIdentifier identifier)
 {
     Game       = game;
     Faction    = faction;
     Identifier = identifier;
 }
예제 #32
0
파일: Access.cs 프로젝트: aiczk/MoApi
 void IAccessControlReceiver.Leave(PlayerIdentifier playerIdentifier) => leave.OnNext(playerIdentifier);
예제 #33
0
파일: Access.cs 프로젝트: aiczk/MoApi
 void IAccessControlReceiver.Join(PlayerIdentifier playerIdentifier) => join.OnNext(playerIdentifier);
예제 #34
0
 public bool isPlayers(PlayerIdentifier id)
 {
     return(id == PlayerIdentifier);
 }
 private IToken GetTokenFromPlayer(PlayerIdentifier identifier)
 {
     return _identifiers.FirstOrDefault(v => v.Value == identifier).Key;
 }
예제 #36
0
파일: Map.cs 프로젝트: jascou/PanzerKontrol
 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);
     }
 }
예제 #37
0
 public bool IsInInitialDeploymentZone(PlayerIdentifier player, Position position)
 {
     Hex hex = GetHex(position);
     return hex.InitialDeploymentZone != null && hex.InitialDeploymentZone.Value == player;
 }
예제 #38
0
 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();
     }
 }
예제 #39
0
 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);
     }
 }
예제 #40
0
 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);
     }
 }
예제 #41
0
 public PlayerState(Game game, Faction faction, PlayerIdentifier identifier)
 {
     Game = game;
     Faction = faction;
     Identifier = identifier;
 }