public override void OnEvent(PlayerReady evnt) { if (!evnt.Entity.IsOwner && evnt.Entity == _entity) { SetVoicelines(evnt.CharacterIndex); } }
// BOLT public override void OnEvent(PlayerReady evnt) { if (!evnt.Entity.IsOwner && evnt.Entity == _entity) { SetKart(evnt.KartIndex); } }
// BOLT public override void OnEvent(PlayerReady evnt) { if (!PlayerScoreEntries.ContainsKey(evnt.PlayerID)) { CreateEntryForPlayer(evnt.PlayerID, evnt.Nickname, evnt.Team.ToTeam()); } }
public Error TryGetPlayerReady(string gameId, int slot, out PlayerReady playerReady) { playerReady = new PlayerReady { UserId = "Placeholder", Ready = slot % 2 == 0 }; return(gameId == "test" ? Error.Codes.E01GameNotFound : Error.Codes.E00NoError); }
// BOLT public override void OnEvent(PlayerReady evnt) { if (_gameSettings.Gamemode == Constants.Gamemodes.FFA && evnt.FromSelf) { SetupFFAColors(); } }
protected override void UpdateAfterSim(int tick) { if (!Ready && MyAPIGateway.Session.Player != null) { Ready = true; SetUpdateMethods(UpdateFlags.UPDATE_AFTER_SIM, false); PlayerReady?.Invoke(); } }
protected override void ServerOnPlayerReady(int clientId) { Players[clientId] = Kernel.Get <BasePlayer>(); Players[clientId].Init(clientId, false); SendMotd(clientId); SendSettings(clientId); PlayerReady?.Invoke(Players[clientId]); }
public Error TryGetPlayerReady(string gameId, int slot, out PlayerReady playerReady) { var err = ludoService.GetPlayerReady(gameId, slot, out UserReady ur); playerReady = err == Error.Codes.E00NoError ? new PlayerReady { UserId = ur.UserId, Ready = ur.IsReady } : default; return(err); }
private void SendReadyMessage() { var connectionHandler = ConnectionHandler.Instance; var playerReadyMessage = new PlayerReady(); var wrapperMessage = new WrapperMessage { PlayerReady = playerReadyMessage }; connectionHandler.SendWebsocketMessage(wrapperMessage); }
// BOLT SPECIFIC EVENTS public override void OnEvent(PlayerReady evnt) { if (!AllPlayersStats.ContainsKey(evnt.PlayerID)) { CreateEntryForPlayerID(evnt.PlayerID, evnt.Nickname, evnt.Team.ToTeam()); } else { Debug.Log("Could not add the player stats entry since it already exists."); } }
[HttpPatch(ROUTE_slotStr)] public IActionResult Patch( [FromRoute] string gameId, [FromRoute] string slotStr, [FromBody] PlayerReady playerReady) { if (!TryParse(slotStr, out int slot)) { return(BadRequest()); } var err = slotUser.TrySetSlotReady(gameId, slot, playerReady); return(NoContentOrNotFoundOrConflict(err)); }
void FireReadyEvent(object sender, ToggleEventArgs e) { if (e.State == ToggleEventArgs.STATE.UP) { if (PlayerNotReady != null) { PlayerNotReady.Invoke(this, EventArgs.Empty); } } else { if (PlayerReady != null) { PlayerReady.Invoke(this, EventArgs.Empty); } } }
void Start() { //Don't allow pause GameControl.instance.pause_infoscreen = true; info = GetComponent <MinigameInfo> (); ui = GetComponent <MinigameUI> (); playerReadyScript = ui.minigameUI.GetComponentInChildren <PlayerReady> (); //Find players first to avoid error GameControl.instance.FindPlayers(); //activate the ui on startup //with the correct game being played ui.UpdateMinigameUI(GetCurrentMinigame()); ui.ShowMinigameUI(); }
protected override void NetMsgReady(Chunk packet, UnPacker unPacker, int clientId) { if (!packet.Flags.HasFlag(SendFlags.Vital)) { return; } if (Clients[clientId].State != ServerClientState.Connecting) { return; } Console.Print(OutputLevel.AddInfo, "server", $"player is ready. ClientId={clientId} addr={NetworkServer.ClientEndPoint(clientId)}"); Clients[clientId].State = ServerClientState.Ready; PlayerReady?.Invoke(clientId); var msg = new MsgPacker((int)NetworkMessages.ServerConnectionReady, true); SendMsg(msg, MsgFlags.Vital | MsgFlags.Flush, clientId); }
// PRIVATE private void InstantiateKart(Vector3 spawnPosition, Quaternion spawnRotation, Team team, RoomProtocolToken roomProtocolToken) { GameObject myKart; if (roomProtocolToken != null) { myKart = BoltNetwork.Instantiate(BoltPrefabs.Kart, roomProtocolToken); } else { Debug.LogError("RoomToken not set."); myKart = BoltNetwork.Instantiate(BoltPrefabs.Kart); } _playerSettings.ColorSettings = _gameSettings.TeamsListSettings.GetSettings(team); myKart.GetComponentInChildren <Health.Health>().SetInvincibilityForXSeconds(_playerSettings.InvicibilityOnSpawnDuration); myKart.transform.position = spawnPosition; myKart.transform.rotation = spawnRotation; PlayerInfo.Me = myKart.GetComponent <PlayerInfo>(); myKart.GetComponent <PlayerInfo>().Nickname = _playerSettings.Nickname; myKart.GetComponent <PlayerInfo>().OwnerID = SWMatchmaking.GetMyBoltId(); myKart.GetComponent <PlayerInfo>().Team = team; myKart.GetComponent <BoltEntity>().GetState <IKartState>().Team = (int)team; myKart.GetComponent <BoltEntity>().GetState <IKartState>().OwnerID = SWMatchmaking.GetMyBoltId(); PlayerReady playerReadyEvent = PlayerReady.Create(); playerReadyEvent.Nickname = _playerSettings.Nickname; playerReadyEvent.PlayerID = SWMatchmaking.GetMyBoltId(); playerReadyEvent.Team = (int)team; playerReadyEvent.KartIndex = _playerSettings.KartIndex; playerReadyEvent.CharacterIndex = _playerSettings.CharacterIndex; playerReadyEvent.Entity = myKart.GetComponent <BoltEntity>(); playerReadyEvent.Send(); }
// BOLT public override void OnEvent(PlayerReady evnt) { if (!evnt.FromSelf) { if (evnt.Entity == _kartEntity) // This is the new spawned kart { Nickname = evnt.Nickname; Team = evnt.Team.ToTeam(); OwnerID = evnt.PlayerID; } else if (evnt.Entity != _kartEntity && _kartEntity.IsOwner) // This is my kart, I send my info to the new player { PlayerInfoEvent playerInfoEvent = PlayerInfoEvent.Create(); // We target the new player playerInfoEvent.TargetPlayerID = evnt.PlayerID; playerInfoEvent.Nickname = Nickname; playerInfoEvent.Team = (int)Team; playerInfoEvent.PlayerID = OwnerID; playerInfoEvent.KartIndex = _playerSettings.KartIndex; playerInfoEvent.CharacterIndex = _playerSettings.CharacterIndex; playerInfoEvent.KartEntity = _kartEntity; playerInfoEvent.Send(); } } }
void IInitializable.Initialize() { PlayerReady.Invoke(this); }
public void SetShip(long playerid, Place[] coordinates) { if (!players.ContainsKey(playerid) || players[playerid].IsReady) { throw new PlayerStatusException("User not in game or he's ready"); } var field = players[playerid].Field; if (coordinates.Length == 0) { throw new ArgumentException("Coordinates length must be more then 1"); } if (coordinates.Length != 1) { bool isrow = false; var row = coordinates[0].Row; var column = coordinates[0].ColumnInt; List <Place> sorted = null; if (row == coordinates[1].Row) { isrow = true; sorted = coordinates.OrderBy(c => c.Row).ToList(); } else if (column == coordinates[1].ColumnInt) { sorted = coordinates.OrderBy(c => c.ColumnInt).ToList(); } else { throw new ArgumentException("Incorrect coordinates"); } for (var i = 1; i < sorted.Count; i++) { if (sorted[i].Row != row && sorted[i].ColumnInt != column) { throw new ArgumentException("Incorrect coordinates"); } if ((isrow && sorted[i].ColumnInt - sorted[i - 1].ColumnInt != 1) || (!isrow && sorted[i].Row - sorted[i - 1].Row != 1)) { throw new ArgumentException("Incorrect coordinates"); } if (!CanPlaceShip(field, sorted[i])) { throw new ArgumentException("Can't place ship here"); } } } else { if (!CanPlaceShip(field, coordinates[0])) { throw new ArgumentException("Can't place ship here"); } } if (coordinates.Length > 4) { throw new ArgumentException("Ship is too large"); } if (players[playerid].ShipsAvailableCount[coordinates.Length] == 0) { throw new ShipNotAvailableException("This type of ship isn't available"); } players[playerid].ShipsAvailableCount[coordinates.Length]--; foreach (var place in coordinates) { field[place.Row, place.ColumnInt] = FieldPoint.Ship; } if (players[playerid].ShipsAvailableCount.All(s => s.Value == 0)) { players[playerid].IsReady = true; var enemyready = players[playerid].Enemy.IsReady; PlayerReady?.Invoke(this, new PlayerReadyEventArgs() { IsEnemyReady = enemyready, PlayerId = playerid }); if (enemyready) { GameStarted?.Invoke(this, new GameEventArgs() { FirstPlayerId = players[playerid].Enemy.Id, SecondPlayerId = playerid }); } else { players[playerid].IsPlayerStroke = true; } } }
public Error TrySetSlotReady(string gameId, int slot, PlayerReady pr) => ludoService.SetSlotReady(gameId, slot, new UserReady(pr.UserId, pr.Ready));
public void OnPlayerReady(PlayerReady playerReady) { throw new NotImplementedException(); }