Пример #1
0
 private void LateUpdate()
 {
     PlayerLeftText.text   = "Left: " + PlayerLeft.ToString();
     PlayerDangerText.text = "Danger: " + Players.Where(x => !x.MustRemove).Sum(x => x.Count).ToString();
     PlayerDeadText.text   = "Dead: " + PlayerDead.ToString();
     PlayerSafeText.text   = "Safe: " + PlayerSafe.ToString();
 }
Пример #2
0
 internal async Task PlayerLeftNotification(PlayerLeftNotification notification)
 {
     if (PlayerLeft != null)
     {
         await PlayerLeft?.Invoke(notification);
     }
 }
Пример #3
0
 private void UpdateConnectionsList(NetConnection connection, NetConnectionStatus status)
 {
     if (status == NetConnectionStatus.Connected)
     {
         string name = connection.RemoteHailMessage.ReadString();
         Output(name + " @" + connection.RemoteEndPoint + " has connected");
         ConnectionInfo info = new ConnectionInfo {
             Name = name, Connection = connection
         };
         _connectionInfoList.Add(info);
         if (PlayerJoined != null)
         {
             PlayerJoined.Invoke(info, null);
         }
     }
     else if (status == NetConnectionStatus.Disconnected)
     {
         ConnectionInfo info = _connectionInfoList.Find((x) => { return(x.Connection == connection); });
         Output(info.Name + " @" + connection.RemoteEndPoint + " has disconnected");
         _connectionInfoList.Remove(info);
         if (PlayerLeft != null)
         {
             PlayerLeft.Invoke(info, null);
         }
         // _connectionInfoList.RemoveAll((x)=> { return x.Connection == connection;});
     }
 }
Пример #4
0
 public void Delete(int playerID)
 {
     //Destroy(characters[playerID].playerController.transform.gameObject); EDIT
     //characters.RemoveAt(playerID);
     Debug.Log("FINISH HIM");
     PlayerLeft?.Invoke(playerID);
 }
Пример #5
0
 private void When(PlayerLeft @event)
 {
     if (!Players.TryRemove(@event.PlayerId, out var player))
     {
         Console.WriteLine($"player {@event.PlayerId} is already removed");
     }
 }
Пример #6
0
 private void OnTriggerExit(Collider other)
 {
     if (other.GetComponent <PlayerControl>() != null)
     {
         interactionAvailableHint.SetActive(false);
         PlayerLeft?.Invoke();
     }
 }
Пример #7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Type != 0)
            {
                hash ^= Type.GetHashCode();
            }
            if (ActionStartMs != 0L)
            {
                hash ^= ActionStartMs.GetHashCode();
            }
            if (DurationMs != 0)
            {
                hash ^= DurationMs.GetHashCode();
            }
            if (EnergyDelta != 0)
            {
                hash ^= EnergyDelta.GetHashCode();
            }
            if (AttackerIndex != 0)
            {
                hash ^= AttackerIndex.GetHashCode();
            }
            if (TargetIndex != 0)
            {
                hash ^= TargetIndex.GetHashCode();
            }
            if (ActivePokemonId != 0UL)
            {
                hash ^= ActivePokemonId.GetHashCode();
            }
            if (playerJoined_ != null)
            {
                hash ^= PlayerJoined.GetHashCode();
            }
            if (battleResults_ != null)
            {
                hash ^= BattleResults.GetHashCode();
            }
            if (DamageWindowsStartTimestampMs != 0L)
            {
                hash ^= DamageWindowsStartTimestampMs.GetHashCode();
            }
            if (DamageWindowsEndTimestampMs != 0L)
            {
                hash ^= DamageWindowsEndTimestampMs.GetHashCode();
            }
            if (playerLeft_ != null)
            {
                hash ^= PlayerLeft.GetHashCode();
            }
            if (TargetPokemonId != 0UL)
            {
                hash ^= TargetPokemonId.GetHashCode();
            }
            return(hash);
        }
Пример #8
0
 protected virtual void OnPlayerLeft(RoomPlayerEventArgs e)
 {
     if (Disposed)
     {
         return;
     }
     PlayerLeft?.Invoke(this, e);
     RoomManager.Channel.BroadcastCencored(new RoomChangeRoomInfoAck2Message(GetRoomInfo()));
 }
Пример #9
0
 private void DestroyPlayerView(PlayerLeft playerLeft)
 {
     if (!_playerViews.ContainsKey(playerLeft.PlayerId))
     {
         return;
     }
     Destroy(_playerViews[playerLeft.PlayerId].gameObject);
     _playerViews.Remove(playerLeft.PlayerId);
 }
Пример #10
0
 private void OnClientLeft(ulong steamId, MyChatMemberStateChangeEnum stateChange)
 {
     Players.TryGetValue(steamId, out PlayerViewModel vm);
     if (vm == null)
     {
         vm = new PlayerViewModel(steamId);
     }
     Log.Info($"{vm.Name} ({vm.SteamId}) {(ConnectionState)stateChange}.");
     PlayerLeft?.Invoke(vm);
     Players.Remove(steamId);
 }
Пример #11
0
 private void PlayerDisconnected(long playerId)
 {
     MyAPIGateway.Utilities.InvokeOnGameThread(() =>
     {
         PlayerAuxData aux;
         if (_playerById.TryGetValue(playerId, out aux) && aux.RealPlayer != null)
         {
             PlayerLeft?.Invoke(aux.RealPlayer);
         }
         Refresh();
     });
 }
Пример #12
0
        public void OnPlayerLeft(int peerId)
        {
            _accessesInUse.Remove(peerId);

            _players.TryGetValue(peerId, out var playerPeer);

            if (playerPeer == null)
            {
                return;
            }

            PlayerLeft?.Invoke(playerPeer);
        }
Пример #13
0
 //constructor
 public Player(PyramidPanic game, Vector2 position, float speed)
 {
     this.game = game;
     this.position = position;
     this.texture = this.game.Content.Load<Texture2D>(@"PlayScene\player\Explorer");
     this.rectangle = new Rectangle((int)position.X + 16, (int)position.Y + 16, this.texture.Width / 4, this.texture.Height);
     this.collisionRec = new Rectangle((int)position.X, (int)position.Y, 32, 32);
     this.speed = speed;
     this.playerLeft = new PlayerLeft(this);
     this.playerRight = new PlayerRight(this);
     this.playerDown = new PlayerDown(this);
     this.playerUp = new PlayerUp(this);
     this.playerIdle = new PlayerIdle(this);
     this.state = new PlayerIdle(this,0);
 }
Пример #14
0
    protected virtual void OnPlayerLeft(UnetMsfPlayer player)
    {
        // Remove from lookups
        PlayersByPeerId.Remove(player.PeerId);
        PlayersByUsername.Remove(player.Username);
        PlayersByConnectionId.Remove(player.Connection.connectionId);

        if (PlayerLeft != null)
        {
            PlayerLeft.Invoke(player);
        }

        // Notify controller that the player has left
        Controller.PlayerLeft(player.PeerId);
    }
        private async Task ClientOnPlayerLeft(BigInteger roomId, Address player)
        {
            if (roomId != this.gameState.RoomId)
            {
                return;
            }

            Debug.Log("Player left " + player);
            PlayerLeft?.Invoke(player);
            if (this.client.Address == player)
            {
                return;
            }

            await UpdateGameState();
        }
Пример #16
0
 private void PlayerDisconnected(long playerId)
 {
     MyAPIGateway.Utilities.InvokeOnGameThread(() =>
     {
         PlayerAuxData aux;
         if (_playerById.TryGetValue(playerId, out aux) && aux.RealPlayer != null)
         {
             PlayerLeft?.Invoke(aux.RealPlayer);
         }
         else
         {
             ResearchCore.ResearchCore.LoggerStatic?.Warning(
                 $"Failed to find real player for disconnecting player {playerId}");
         }
         Refresh();
     });
 }
Пример #17
0
        public void OnPlayerLeft(int peerId)
        {
            _accessesInUse.Remove(peerId);

            IPeer playerPeer;

            _players.TryGetValue(peerId, out playerPeer);

            if (playerPeer == null)
            {
                return;
            }

            if (PlayerLeft != null)
            {
                PlayerLeft.Invoke(playerPeer);
            }
        }
Пример #18
0
    public void notify(GameObject from)
    {
        PlayerLeft?.Invoke(from);
        _prevLevelIndex = GetIndexFromPosition(from.transform.position);

        var positionIndex = GetIndexFromPosition(_properties.character.transform.position);

        if (_levels.ContainsKey(positionIndex))
        {
            var level = _levels[positionIndex];
            ActivateLevels(_prevLevelIndex, positionIndex);
            PlayerEntered?.Invoke(level);
        }
        else
        {
            _checkForCharacter = true;
        }
    }
Пример #19
0
        public override void OnPlayerLeftRoom(Player otherPlayer)
        {
            if (!PhotonNetwork.IsMasterClient)
            {
                return;
            }

            var i = 0;

            for (; i < PlayerNumbering.SortedPlayers.Length; i++)
            {
                if (otherPlayer.ActorNumber == PlayerNumbering.SortedPlayers[i].ActorNumber)
                {
                    break;
                }
            }

            PlayerLeft?.Invoke(i);
        }
Пример #20
0
        public void Update(float deltaTime)
        {
            var currentVehicle = Game.PlayerPed.CurrentVehicle;

            if (!_isInVehicle && !Game.Player.IsDead)
            {
                var vehicleTryingToEnter = Game.PlayerPed.VehicleTryingToEnter;
                if (vehicleTryingToEnter != null && !_isEnteringVehicle)
                {
                    _prevVehicle       = vehicleTryingToEnter;
                    _isEnteringVehicle = true;
                    PlayerEntering?.Invoke(this, vehicleTryingToEnter);
                }
                else if (vehicleTryingToEnter == null && currentVehicle == null && _isEnteringVehicle)
                {
                    _isEnteringVehicle = false;
                    PlayerAbortedEntering?.Invoke(this, _prevVehicle);
                }
                else if (currentVehicle != null)
                {
                    _prevVehicle       = currentVehicle;
                    _isEnteringVehicle = false;
                    _isInVehicle       = true;
                    PlayerEntered?.Invoke(this, currentVehicle);
                }
            }
            else if (_isInVehicle)
            {
                if (currentVehicle == null || Game.Player.IsDead)
                {
                    _isInVehicle = false;
                    PlayerLeft?.Invoke(this, _prevVehicle);
                }
                else if (_prevVehicle != currentVehicle)
                {
                    PlayerLeft?.Invoke(this, _prevVehicle);
                    PlayerEntered?.Invoke(this, currentVehicle);
                    _prevVehicle = currentVehicle;
                }
            }
        }
Пример #21
0
        protected virtual void OnPlayerLeft(RoomPlayerEventArgs e)
        {
            PlayerLeft?.Invoke(this, e);

            RoomDto roomDto = new RoomDto();

            roomDto.RoomId      = (byte)this.Id;
            roomDto.PlayerCount = (byte)this.Players.Count;
            roomDto.PlayerLimit = this.Options.PlayerLimit;
            roomDto.State       = (byte)this.GameRuleManager.GameRule.StateMachine.State;
            roomDto.State2      = (byte)this.GameRuleManager.GameRule.StateMachine.State;
            roomDto.GameRule    = (int)this.Options.GameRule;
            roomDto.Map         = (byte)this.Options.MapID;
            roomDto.WeaponLimit = this.Options.ItemLimit;
            roomDto.Name        = this.Options.Name;
            roomDto.Password    = this.Options.Password;
            roomDto.FMBURNMode  = GetFMBurnModeInfo();
            RoomManager.Channel.Broadcast(new RoomChangeRoomInfoAck2Message(roomDto));
            //RoomManager.Channel.Broadcast(new RoomChangeRoomInfoAckMessage(this.Map<Room, RoomDto>()));
            //RoomManager.Channel.Broadcast(new SUserDataAckMessage(e.Player.Map<Player, UserDataDto>()));
        }
Пример #22
0
        private void OnDataReceived(object sender, string json)
        {
            Parameter parameter = JsonConvert.DeserializeObject <Parameter>(json);

            if (parameter.ActionType == ActionType.UpdateGameboard && UpdateGameboard != null)
            {
                UpdateGameboard.Invoke(this, JsonConvert.DeserializeObject <UpdateGameboardParameter>(json));
            }
            else if (parameter.ActionType == ActionType.JoinRoom && PlayerJoined != null)
            {
                PlayerJoined.Invoke(this, EventArgs.Empty);
            }
            else if (parameter.ActionType == ActionType.LeaveRoom && PlayerLeft != null)
            {
                PlayerLeft.Invoke(this, EventArgs.Empty);
            }
            else if (parameter.ActionType == ActionType.StartGame && GameStarted != null)
            {
                GameStarted.Invoke(this, EventArgs.Empty);
            }
        }
Пример #23
0
        static Server()
        {
            Events.GameLobby.Initialized.Subscribe(data =>
            {
                LobbyInitialized?.Invoke(null, System.EventArgs.Empty);
            });

            Events.ServerToClient.AddClient.Subscribe(data =>
            {
                if (G.Sys.NetworkingManager_.IsOnline_)
                {
                    var eventArgs = new PlayerEventArgs(data.clientName_, data.ready_, (LevelCompatibility)data.status_);
                    PlayerJoined?.Invoke(null, eventArgs);
                }
            });

            Events.ServerToClient.RemovePlayerFromClientList.Subscribe(data =>
            {
                var serverLogicObject = GameObject.Find("GameManager")?.GetComponent <ServerLogic>();
                var clientLogic       = serverLogicObject?.GetType().GetField("clientLogic_", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(serverLogicObject) as ClientLogic;
                var clientInfo        = clientLogic?.GetPlayerInfo(data.playerIndex_);

                if (clientInfo != null)
                {
                    var eventArgs = new PlayerEventArgs(clientInfo.Username_, clientInfo.Ready_, (LevelCompatibility)clientInfo.LevelCompatabilityStatus_);
                    PlayerLeft?.Invoke(null, eventArgs);
                }
            });

            Events.ServerToClient.SetGameMode.Subscribe(data =>
            {
                if (G.Sys.NetworkingManager_.IsOnline_)
                {
                    var eventArgs = new GameModeChangedEventArgs(data.mode_);
                    GameModeChanged?.Invoke(null, eventArgs);
                }
            });
        }
Пример #24
0
        public void Update(float deltaTime)
        {
            if (IsPlayerInside())
            {
                if (_playerWasInside)
                {
                    return;
                }

                _playerWasInside = true;
                PlayerEntered?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                if (!_playerWasInside)
                {
                    return;
                }

                _playerWasInside = false;
                PlayerLeft?.Invoke(this, EventArgs.Empty);
            }
        }
Пример #25
0
        private void talker_SpringEvent(object sender, Talker.SpringEventArgs e)
        {
            try
            {
                switch (e.EventType)
                {
                case Talker.SpringEventType.PLAYER_JOINED:
                    var entry = Context?.GetOrAddPlayer(e.PlayerName);
                    if (entry != null)
                    {
                        entry.IsIngame = true;
                    }
                    PlayerJoined?.Invoke(this, new SpringLogEventArgs(e.PlayerName));
                    break;

                case Talker.SpringEventType.PLAYER_LEFT:
                    entry = Context?.GetOrAddPlayer(e.PlayerName);
                    if (entry != null)
                    {
                        entry.IsIngame = false;
                        entry.QuitTime = (int)DateTime.UtcNow.Subtract(Context.IngameStartTime ?? Context.StartTime).TotalSeconds;
                    }
                    if (e.Param == 0)
                    {
                        PlayerDisconnected?.Invoke(this, new SpringLogEventArgs(e.PlayerName));
                    }
                    PlayerLeft?.Invoke(this, new SpringLogEventArgs(e.PlayerName));
                    break;

                case Talker.SpringEventType.GAME_LUAMSG:
                    HandleSpecialMessages(e);
                    break;

                case Talker.SpringEventType.PLAYER_CHAT:
                    if (e.Param == 255)
                    {
                        HandleSpecialMessages(e);
                    }
                    else
                    {
                        AddToLogs(e);
                    }

                    if ((PlayerSaid != null) && !string.IsNullOrEmpty(e.PlayerName))
                    {
                        SpringChatLocation location = SpringChatLocation.Private;
                        if (((e.Param == Talker.TO_EVERYONE) || (e.Param == Talker.TO_EVERYONE_LEGACY)))
                        {
                            location = SpringChatLocation.Public;
                        }
                        if (e.Param == Talker.TO_ALLIES)
                        {
                            location = SpringChatLocation.Allies;
                        }
                        if (e.Param == Talker.TO_SPECTATORS)
                        {
                            location = SpringChatLocation.Spectators;
                        }
                        PlayerSaid(this, new SpringChatEventArgs(e.PlayerName, e.Text, location));
                    }
                    break;

                case Talker.SpringEventType.PLAYER_DEFEATED:
                    MarkPlayerDead(e.PlayerName, true);
                    if (PlayerLost != null)
                    {
                        PlayerLost(this, new SpringLogEventArgs(e.PlayerName));
                    }
                    break;

                case Talker.SpringEventType.SERVER_GAMEOVER:
                    if (!Context.GameEndedOk)     // server gameover runs multiple times
                    {
                        foreach (var p in Context.ActualPlayers)
                        {
                            if (!p.IsIngame && !p.IsSpectator)
                            {
                                MarkPlayerDead(p.Name, true);
                            }
                            p.IsIngame = false;
                        }

                        // set victory team for all allied with currently alive
                        if (e.winningAllyTeams.Length > 0)
                        {
                            foreach (var ally in e.winningAllyTeams)
                            {
                                foreach (var p in Context.ActualPlayers.Where(x => !x.IsSpectator && (x.AllyNumber == ally)))
                                {
                                    p.IsVictoryTeam = true;
                                }
                            }
                        }
                        else         // Fallback, shouldn't happen
                        {
                            foreach (var p in Context.ActualPlayers.Where(x => !x.IsSpectator && (x.LoseTime == null)))
                            {
                                foreach (var q in Context.ActualPlayers.Where(x => !x.IsSpectator && (x.AllyNumber == p.AllyNumber)))
                                {
                                    q.IsVictoryTeam = true;
                                }
                            }
                        }

                        if (Context.IngameStartTime != null)
                        {
                            Context.GameEndedOk = true;
                            Context.Duration    = (int)DateTime.UtcNow.Subtract(Context.IngameStartTime ?? Context.StartTime).TotalSeconds;

                            GameOver?.Invoke(this, new SpringLogEventArgs(e.PlayerName));
                        }
                        else
                        {
                            Trace.TraceWarning("recieved GAMEOVER before STARTPLAYING!");
                        }

                        Task.Delay(10000).ContinueWith(x => ExitGame());
                    }
                    break;

                case Talker.SpringEventType.PLAYER_READY:
                    if (e.Param == 1)
                    {
                        entry = Context.GetOrAddPlayer(e.PlayerName);
                        if (entry != null)
                        {
                            entry.IsIngameReady = true;
                        }
                    }
                    break;

                case Talker.SpringEventType.SERVER_STARTPLAYING:
                    Context.ReplayName            = e.ReplayFileName;
                    Context.EngineBattleID        = e.GameID;
                    Context.IngameStartTime       = DateTime.UtcNow;
                    Context.PlayersUnreadyOnStart = Context.ActualPlayers.Where(x => !x.IsSpectator && !(x.IsIngameReady && x.IsIngame)).Select(x => x.Name).ToList();
                    foreach (var p in Context.ActualPlayers.Where(x => !x.IsSpectator))
                    {
                        p.IsIngameReady = true;
                    }

                    process.PriorityClass = ProcessPriorityClass.High;

                    BattleStarted(this, Context);
                    break;

                case Talker.SpringEventType.SERVER_QUIT:
                    if (LobbyStartContext != null)
                    {
                        foreach (var p in Context.ActualPlayers)
                        {
                            p.IsIngame = false;
                        }
                    }
                    //if (GameOver != null) GameOver(this, new SpringLogEventArgs(e.PlayerName));
                    break;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error processing spring message:{0}", ex);
            }
        }
 public void MergeFrom(BattleAction other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Type != 0)
     {
         Type = other.Type;
     }
     if (other.ActionStartMs != 0L)
     {
         ActionStartMs = other.ActionStartMs;
     }
     if (other.DurationMs != 0)
     {
         DurationMs = other.DurationMs;
     }
     if (other.EnergyDelta != 0)
     {
         EnergyDelta = other.EnergyDelta;
     }
     if (other.AttackerIndex != 0)
     {
         AttackerIndex = other.AttackerIndex;
     }
     if (other.TargetIndex != 0)
     {
         TargetIndex = other.TargetIndex;
     }
     if (other.ActivePokemonId != 0UL)
     {
         ActivePokemonId = other.ActivePokemonId;
     }
     if (other.playerJoined_ != null)
     {
         if (playerJoined_ == null)
         {
             playerJoined_ = new global::POGOProtos.Data.Battle.BattleParticipant();
         }
         PlayerJoined.MergeFrom(other.PlayerJoined);
     }
     if (other.battleResults_ != null)
     {
         if (battleResults_ == null)
         {
             battleResults_ = new global::POGOProtos.Data.Battle.BattleResults();
         }
         BattleResults.MergeFrom(other.BattleResults);
     }
     if (other.DamageWindowsStartTimestampMs != 0L)
     {
         DamageWindowsStartTimestampMs = other.DamageWindowsStartTimestampMs;
     }
     if (other.DamageWindowsEndTimestampMs != 0L)
     {
         DamageWindowsEndTimestampMs = other.DamageWindowsEndTimestampMs;
     }
     if (other.playerLeft_ != null)
     {
         if (playerLeft_ == null)
         {
             playerLeft_ = new global::POGOProtos.Data.Battle.BattleParticipant();
         }
         PlayerLeft.MergeFrom(other.PlayerLeft);
     }
     if (other.TargetPokemonId != 0UL)
     {
         TargetPokemonId = other.TargetPokemonId;
     }
     if (other.leveledUpFriends_ != null)
     {
         if (leveledUpFriends_ == null)
         {
             leveledUpFriends_ = new global::POGOProtos.Data.Friends.LeveledUpFriends();
         }
         LeveledUpFriends.MergeFrom(other.LeveledUpFriends);
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
Пример #27
0
 protected virtual void OnPlayerLeft(ChannelPlayerLeftEventArgs e)
 {
     PlayerLeft?.Invoke(this, e);
 }
Пример #28
0
 private void OnClientLeft(ulong steamId, ChatMemberStateChangeEnum stateChange)
 {
     _log.Info($"{GetSteamUsername(steamId)} disconnected ({(ConnectionState)stateChange}).");
     PlayerLeft?.Invoke(steamId, (ConnectionState)stateChange);
 }
Пример #29
0
 protected virtual void OnPlayerLeft(RoomPlayerEventArgs e)
 {
     PlayerLeft?.Invoke(this, e);
     RoomManager.Channel.Broadcast(new SChangeGameRoomAckMessage(this.Map <Room, RoomDto>()));
     RoomManager.Channel.Broadcast(new SUserDataAckMessage(e.Player.Map <Player, UserDataDto>()));
 }
Пример #30
0
    private void OnPlayerLeft(PlayerLeft playerLeft)
    {
        Debug.Log("OnPlayerLeft: " + playerLeft.Guid);

        CurrentGame.RemovePlayer(playerLeft.Player);
    }
Пример #31
0
 public void Apply(PlayerLeft e) 
 {
     _players.Remove(e.Player);
 }