public ReplayKeyPoint(Entity[] data, KeyPointType type, int id, ActivePlayer player) { if(data != null) Data = Helper.DeepClone(data); Type = type; Id = id; Player = player; }
public TimerEventArgs(int seconds, int playerSeconds, int opponentSeconds, bool running, ActivePlayer activePlayer) { Seconds = seconds; Running = running; PlayerSeconds = playerSeconds; OpponentSeconds = opponentSeconds; CurrentActivePlayer = activePlayer; }
void Awake() { // Setting up the references. gameController = GameObject.FindGameObjectWithTag("GameController"); player1 = GameObject.FindGameObjectWithTag("Player1"); player2 = GameObject.FindGameObjectWithTag("Player2"); player3 = GameObject.FindGameObjectWithTag("Player3"); activePlayer = gameController.GetComponent<ActivePlayer>(); }
void AddPlayer(string name, NetworkPlayer view, int teamNumber) { ActivePlayer tempPlayer = new ActivePlayer(); tempPlayer.playerName = name; tempPlayer.playerNetwork = view; tempPlayer.isAlive = true; tempPlayer.onTeam = teamNumber; ingamePlayers.Add(tempPlayer); teams[teamNumber] += 1; }
public void TestPokerWithExistingListPlayers() { IPlayer p1 = new ActivePlayer("Player1", poker.Table, 1); IPlayer p2 = new Bot("Player2", poker.Table, 2); IPlayer p3 = new Bot("Player3", poker.Table, 3); IPlayer p4 = new Bot("Player4", poker.Table, 4); IList <IPlayer> players = new IPlayer[] { p1, p2, p3, p4 }.ToList(); poker = new Poker(players); Assert.AreEqual(4, poker.Players.Count); }
protected internal override void Execute(IOnlineConnection Sender) { Owner.SharedWriteBuffer.ClearWriteBuffer(); Owner.SharedWriteBuffer.WriteScript(new StartGameScriptServer()); //Create game and tell client to start it too. foreach (IOnlineConnection ActivePlayer in Owner.DicLocalRoom[RoomID].Room.ListOnlinePlayer) { ActivePlayer.SendWriteBuffer(); } }
public void MulliganDone(ActivePlayer activePlayer) { if (activePlayer.Equals(ActivePlayer.Player)) { _playerMulliganed = true; } else if (activePlayer.Equals(ActivePlayer.Opponent)) { _opponentMulliganed = true; } }
public void HandleZonePositionUpdate(ActivePlayer player, TAG_ZONE zone, int turn) { if (player == ActivePlayer.Player) { _game.Player.UpdateZonePos(zone, turn); } else if (player == ActivePlayer.Opponent) { _game.Opponent.UpdateZonePos(zone, turn); } }
void CammerControl(Direction direction, uint step, bool stop = false, int playerindex = 0) { try { GetPlayer(playerindex); ActivePlayer.CamerControl(direction, step, stop); }catch (Exception ex) { ShowError(ex.Message); } }
// Start is called before the first frame update void Start() { active = GameObject.Instantiate(green, spawn.position, Quaternion.identity); player = ActivePlayer.Green; SetActiveUI((int)player); camera.GetComponent <FollowCamera>().target = active.transform; position = Vector3.zero; rotation = Quaternion.identity; }
public void InventoryClosed() { ActivePlayer.GetComponent <CharacterScript>().InventoryManager.GetComponent <Canvas>().renderMode = RenderMode.ScreenSpaceCamera; InventoryOpen = false; MainCanvasScript.MainCanvas.GetComponent <Canvas>().renderMode = RenderMode.ScreenSpaceOverlay; MainCanvasScript.MainCanvas.GetComponent <CanvasGroup>().interactable = true; ActivePlayer.GetComponent <CharacterScript>().InventoryManager.GetComponent <CanvasGroup>().interactable = false; ActivePlayer.GetComponent <CharacterScript>().InventoryManager.GetComponent <CanvasGroup>().blocksRaycasts = false; }
public void PlayPokemon(PokemonCard pokemon) { if (!pokemon.Owner.Id.Equals(ActivePlayer.Id)) { GameLog.AddMessage($"{NonActivePlayer?.NetworkPlayer?.Name} Tried to play a pokemon on his opponents turn"); return; } ActivePlayer.PlayCard(pokemon); TriggerAbilityOfType(TriggerType.EnterPlay, pokemon); }
public void EndTurn() { ActivePlayer = Players.First(p => p != ActivePlayer); if (ActivePlayer.Mana.Total + Rules.ManaGainPerTurn < 10) { ActivePlayer.Mana.GainTotal(Rules.ManaGainPerTurn); } ActivePlayer.Mana.Refill(); ActivePlayer.DrawCard(); }
public static ActivePlayer CreateActivePlayer(int ID, string ip, string port, string state, int player, int session) { ActivePlayer activePlayer = new ActivePlayer(); activePlayer.Id = ID; activePlayer.Ip = ip; activePlayer.Port = port; activePlayer.State = state; activePlayer.Player = player; activePlayer.Session = session; return(activePlayer); }
public bool checkIfPlayerIsActive(ActivePlayer player) { if (GameType == GameType.SinglePlayer) { if (PlayerOne == player) { return(true); } return(false); } return(true); }
public void StartNewGame() { CameraController.ResetCamera(); CameraController.EnableCam(); State = GameState.Normal; OnEnteredNormalMode(); InitializePlayers(); InitializeInputRecievers(whitePlayer.InputHandler as IInputReader, blackPlayer.InputHandler as IInputReader); Board.ChessGrid.ResetGrid(); ImplementBoardLayout(); ActivePlayer.GenerateAllPossibleMoves(Board.ChessGrid, true, true); }
/// <summary> /// 截图,返回图片存储地址 /// </summary> /// <param name="playerindex">播放器id,1-4,默认为当前选中的</param> /// <returns></returns> public string ScreenShot(int playerindex = 0) { try { GetPlayer(playerindex); return(ActivePlayer.Capture2Image()); }catch (Exception ex) { ShowError(ex.Message); return(""); } }
/// <summary> /// This serves a utility to avoid repeating this calculation on the client. /// </summary> /// <param name="activePlayer"></param> /// <returns></returns> private async Task <int> GetPlayerTotalVps(ActivePlayer activePlayer) { int interchangeabelCounter = 0; if (activePlayer.InterChanageableVPs != null) { foreach (VPType.InterChanageableVP interChanageableVp in activePlayer.InterChanageableVPs) { switch (interChanageableVp) { case VPType.InterChanageableVP.Merchant: interchangeabelCounter++; break; case VPType.InterChanageableVP.LongestRoad: case VPType.InterChanageableVP.MetropolisCloth: case VPType.InterChanageableVP.MetropolisCoin: case VPType.InterChanageableVP.MetropolisPaper: interchangeabelCounter += 2; break; } } } int numberOfVps = interchangeabelCounter + activePlayer.NumOfCities * 2 + activePlayer.NumOfSettlements + activePlayer.SaviorOfCatanVP + activePlayer.SpecialVictoryPoints; if (numberOfVps >= 13) { var config = new ProducerConfig { BootstrapServers = "localhost:9092" }; // If serializers are not specified, default serializers from // `Confluent.Kafka.Serializers` will be automatically used where // available. Note: by default strings are encoded as UTF8. using (IProducer <Null, string> producer = new ProducerBuilder <Null, string>(config).Build()) { try { DeliveryResult <Null, string> directoryResult = await producer.ProduceAsync("player-points", new Message <Null, string> { Value = $"{activePlayer.UserName}" }); _logger?.LogInformation($"Delivered '{directoryResult.Value}' to '{directoryResult.TopicPartitionOffset}'"); } catch (ProduceException <Null, string> ex) { _logger?.LogError("Error producing ", ex); } } } return(numberOfVps); }
/// <summary> /// Set the next player on the list as active. /// </summary> public static void NextPlayer() { activePlayer++; if (activePlayer >= players.Length) { turn++; activePlayer = 0; } ActivePlayer.StartTurn(); }
public void switchActivePlayer() // if the active player is X, sets it to O. If active player is O, sets it to X. { if (activePlayer == ActivePlayer.O) { activePlayer = ActivePlayer.X; return; } else if (activePlayer == ActivePlayer.X) { activePlayer = ActivePlayer.O; } }
private void Withdraw() { decimal amount; string currency; SetAmountAndCurrency(out amount, out currency); try { if (currency != "USD" && currency != "EUR" && currency != "UAH") { throw new NotSupportedException(nameof(currency)); } PaymentService.StartWithdrawal(amount, currency); ActivePlayer.Withdraw(amount, currency); } catch (InvalidOperationException) { throw new InvalidOperationException("There is insufficient funds on your account."); } catch (NotSupportedException) { throw new NotSupportedException("Failed. Invalid currency."); } catch (LimitExceededException) { throw; } catch (PaymentServiceException) { throw; } catch (InsufficientFundsException) { throw; } catch (Exception) { throw; } try { Account.Withdraw(amount, currency); Console.WriteLine("Success!"); } catch (InvalidOperationException) { ActivePlayer.Deposit(amount, currency); throw new InvalidOperationException("There is some problem on the platform side. Please try it later."); } }
public ActivePlayer GetCurrentBattingPlayer() { ActivePlayer playerAtBat = GetTeamAtBat().players.Find(x => x.isAtBat); if (playerAtBat == null) { return(activeTeams[teamAtBat].players[0]); } else { return(playerAtBat); } }
/* Adds player to ActivePlayers table */ public static void AddActivePlayer(Player model, BadmintonContext db) { if (db.ActivePlayers.SingleOrDefault(x => x.PlayerID == model.ID) == null) { ActivePlayer newPlayer = new ActivePlayer(); newPlayer.OnCourt = false; newPlayer.PlayerID = model.ID; newPlayer.Waits = 0; newPlayer.GamesPlayed = 0; db.ActivePlayers.Add(newPlayer); db.SaveChanges(); } }
public ActivePlayer GetCurrentPitchingPlayer() { ActivePlayer pitcher = GetTeamInField().players.Find(x => x.isPitching); if (pitcher == null) { return(GetTeamInField().players[0]); } else { return(pitcher); } }
internal static void TurnStart(ActivePlayer player) { if (!InBgMode("Turn Start")) { return; } int turn = Core.Game.GetTurnNumber(); if (turn == 1) { SetMissingRace(); } }
public void RespawnPlayer(Transform trans) { //Destroy active player string name = ReturnName((int)player); GameObject.Destroy(GameObject.Find(name)); //Instantiate new player active = GameObject.Instantiate(green, trans.position, trans.rotation); camera.GetComponent <FollowCamera>().target = active.transform; player = ActivePlayer.Green; SetActiveUI((int)player); }
private void TestActivePlayer() { ActivePlayer activePlayer = new ActivePlayer(1, 1, 2, "Rezerva"); ActivePlayer activePlayerTwo = new ActivePlayer(2, 2, 2, "Participant"); Debug.Assert(activePlayer.ID == "1.1"); Debug.Assert(activePlayer.numberOfPoints == 2); Debug.Assert(activePlayer.type == "Rezerva"); Debug.Assert(activePlayerTwo.ID == "2.2"); Debug.Assert(activePlayerTwo.numberOfPoints == 2); Debug.Assert(activePlayerTwo.type == "Participant"); }
public void ChangeTurn() { _playerIndex++; if (_playerIndex >= AllPlayers.Length) { _playerIndex = 0; } ActivePlayer.StartTurn(); TurnTimer.Stop(); TurnTimer.Reset(); TurnTimer.StartTimer(); OnTurnChanged(); }
public override void Update(double ElapsedSeconds) { GameTime UpdateTime = new GameTime(TimeSpan.Zero, TimeSpan.FromSeconds(ElapsedSeconds)); if (!IsInit) { if (ListGameScreen.Count == 0) { Load(); Init(); TogglePreview(true); if (ListGameScreen.Count == 0) { foreach (IOnlineConnection ActivePlayer in GameGroup.Room.ListOnlinePlayer) { ActivePlayer.Send(new ServerIsReadyScriptServer()); } } else { IsInit = false; } } else { ListGameScreen[0].Update(UpdateTime); if (!ListGameScreen[0].Alive) { ListGameScreen.RemoveAt(0); } if (ListGameScreen.Count == 0) { foreach (IOnlineConnection ActivePlayer in GameGroup.Room.ListOnlinePlayer) { ActivePlayer.Send(new ServerIsReadyScriptServer()); } IsInit = true; } } } LayerManager.Update(UpdateTime); if (!ListPlayer[ActivePlayerIndex].IsPlayerControlled && ListActionMenuChoice.HasMainPanel) { ListActionMenuChoice.Last().Update(UpdateTime); } }
/* Updates player view model * when a player is assigned to a court */ public static void UpdatePlayerOnCourt(Player player, BadmintonContext context) { var id = player.ID; player.Waits = 0; player.OnCourt = true; player.GamesPlayed++; ActivePlayer updated = context.ActivePlayers.Single(x => x.PlayerID == id); updated.Waits = 0; updated.OnCourt = true; updated.GamesPlayed++; context.SaveChanges(); }
protected override void OnJoinRoomLocal(IOnlineConnection Sender, string RoomID, ClientGroup ActiveGroup) { foreach (IOnlineConnection ActivePlayer in ActiveGroup.Room.ListOnlinePlayer) { if (ActivePlayer == Sender) { continue; } ActivePlayer.Send(new PlayerJoinedScriptServer(ActiveGroup.Room.GetPlayer(Sender))); } Sender.Send(new JoinRoomLocalScriptServer(RoomID, ActiveGroup.CurrentGame)); }
public void HandleEndOfTurn(EventEndOfTurn p_event) { if (m_game_manager == null) { return; } ActivePlayer.CleanUp(); m_current_player = (m_current_player + 1) % m_game_manager.players.Count; this.m_remaining_turns -= 1; if (m_remaining_turns == 0) { Suburbia.Bus.FireEvent(new EventEndOfGame()); } }
protected override void Execute(IOnlineConnection Sender) { Owner.CreateSquare(); foreach (IOnlineConnection ActivePlayer in ActiveGroup.Room.ListOnlinePlayer) { if (ActivePlayer == Sender) { continue; } ActivePlayer.Send(new SendPlayerUpdateScriptServer(Owner.ID, "[]")); } }
public void ProposeKeyPoint(KeyPointType type, int id, ActivePlayer player) { if (ProposedKeyPoint != null) ReplayMaker.Generate(ProposedKeyPoint.Type, ProposedKeyPoint.Id, ProposedKeyPoint.Player, _game); ProposedKeyPoint = new ReplayKeyPoint(null, type, id, player); }
public static ActivePlayer CreateActivePlayer(int ID, string ip, string port, string state, int player, int session) { ActivePlayer activePlayer = new ActivePlayer(); activePlayer.Id = ID; activePlayer.Ip = ip; activePlayer.Port = port; activePlayer.State = state; activePlayer.Player = player; activePlayer.Session = session; return activePlayer; }
public static void TurnStart(ActivePlayer player) { //Dupe Checks for Player if(player == ActivePlayer.Player) { Logger.WriteLine("Player Turn", "RenoTime"); CheckDupes(); } }
public void MulliganDone(ActivePlayer activePlayer) { if(activePlayer.Equals(ActivePlayer.Player)) _playerMulliganed = true; else if(activePlayer.Equals(ActivePlayer.Opponent)) _opponentMulliganed = true; }
public static void Generate(KeyPointType type, int id, ActivePlayer player) { Points.Add(new ReplayKeyPoint(Game.Entities.Values.ToArray(), type, id, player)); }
public static void TurnStart(ActivePlayer player, int turnNumber) { Logger.WriteLine(string.Format("{0}-turn ({1})", player, turnNumber + 1), "GameEventHandler"); //doesn't really matter whose turn it is for now, just restart timer //maybe add timer to player/opponent windows TurnTimer.Instance.SetCurrentPlayer(player); TurnTimer.Instance.Restart(); if(player == ActivePlayer.Player && !Game.IsInMenu) { if(Config.Instance.FlashHsOnTurnStart) User32.FlashHs(); if(Config.Instance.BringHsToForeground) User32.BringHsToForeground(); } GameEvents.OnTurnStart.Execute(player); }
public void ShowDeadMessage(ActivePlayer player) { FContainer callout = new FContainer(); callout.scale = 0.5f; MultiDualLabel fullLabel = new MultiDualLabel(); callout.AddChild(fullLabel); DualLabel colorLabel = new DualLabel(TOFonts.MEDIUM_BOLD,player.player.color.name.ToUpper()); colorLabel.mainLabel.color = player.player.color.color; colorLabel.scale = 4.0f; DualLabel messageLabel = new DualLabel(TOFonts.MEDIUM_BOLD," WAS ELIMINATED!"); callout.AddChild(messageLabel); messageLabel.mainLabel.color = Color.white; messageLabel.scale = 4.0f; //smaller shadow colorLabel.mainLabel.y += 0.5f; messageLabel.mainLabel.y += 0.5f; fullLabel.AddLabel(colorLabel); fullLabel.AddLabel(messageLabel); fullLabel.Align(0.5f); Arena.instance.frontContainer.AddChild(callout); fullLabel.alpha = 0.0f; Go.to(fullLabel, 0.5f, new TweenConfig().alpha(1.0f)); callout.y = Config.HEIGHT/2 - 26.0f; Go.to(callout, 3.0f, new TweenConfig().y(callout.y+5.0f).removeWhenComplete()); Go.to(callout,0.8f,new TweenConfig().setDelay(2.2f).alpha(0.0f)); }
/*private static int runDmgCalc(Card c) { return dmgcards.CalcDamage(c); }*/ private static void TurnStart(ActivePlayer p) { //card is drawn. if (_player == null) { NewGame(); } UpdateData(); }
public async void TurnStart(ActivePlayer player, int turnNumber) { if(!_game.IsMulliganDone) Log.Info("--- Mulligan ---"); if(turnNumber == 0) turnNumber++; _turnQueue.Enqueue(new Tuple<ActivePlayer, int>(player, turnNumber)); while(!_game.IsMulliganDone) await Task.Delay(100); while(_turnQueue.Any()) HandleTurnStart(_turnQueue.Dequeue()); }
public void AddToActivePlayers(ActivePlayer activePlayer) { base.AddObject("ActivePlayers", activePlayer); }
public void SetPlayer(ActivePlayer player) { if(_game == null) { Seconds = 75; Log.Warn("Set timer to 75, game is null"); return; } if(player == ActivePlayer.Player && _game.PlayerEntity != null) Seconds = _game.PlayerEntity.HasTag(GameTag.TIMEOUT) ? _game.PlayerEntity.GetTag(GameTag.TIMEOUT) : double.PositiveInfinity; else if(player == ActivePlayer.Opponent && _game.OpponentEntity != null) Seconds = _game.OpponentEntity.HasTag(GameTag.TIMEOUT) ? _game.OpponentEntity.GetTag(GameTag.TIMEOUT) : double.PositiveInfinity; else { Seconds = 75; Log.Warn("Set timer to 75, both player entities are null"); } }
private void ProposeKeyPoint(KeyPointType type, int id, ActivePlayer player) { if(_proposedKeyPoint != null) ReplayMaker.Generate(_proposedKeyPoint.Type, _proposedKeyPoint.Id, _proposedKeyPoint.Player); _proposedKeyPoint = new ReplayKeyPoint(null, type, id, player); }
// Update the card list on player's turn internal void TurnStart(ActivePlayer player) { if (player == ActivePlayer.Player && Opponent != null) { _list.Show(); var mana = AvailableMana(); var klass = KlassConverter(CoreAPI.Game.Opponent.Class); var cards = HearthDb.Cards.Collectible.Values .Where(c => c.Cost == mana && c.Class == klass) .Select(c => new Card(c)) .OrderBy(c => c.Rarity) .ToList<Card>(); _list.Update(cards); } }
public void SetCurrentPlayer(ActivePlayer activePlayer) { CurrentActivePlayer = activePlayer; }
public void HandleZonePositionUpdate(ActivePlayer player, Entity entity, TAG_ZONE zone, int turn) { if(player == ActivePlayer.Player) _game.Player.UpdateZonePos(entity, zone, turn); else if(player == ActivePlayer.Opponent) _game.Opponent.UpdateZonePos(entity, zone, turn); }
void IGameHandler.TurnStart(ActivePlayer player, int turnNumber) => TurnStart(player, turnNumber);
public async void TurnStart(ActivePlayer player, int turnNumber) { if(!_game.IsMulliganDone) Logger.WriteLine("--- Mulligan ---", "GameEventHandler"); while(!_game.IsMulliganDone) await Task.Delay(100); if(_game.CurrentGameMode == Casual || _game.CurrentGameMode == None) DetectRanks(); Logger.WriteLine($"--- {player} turn {turnNumber + 1} ---", "GameEventHandler"); //doesn't really matter whose turn it is for now, just restart timer //maybe add timer to player/opponent windows TurnTimer.Instance.SetCurrentPlayer(player); TurnTimer.Instance.Restart(); if(player == ActivePlayer.Player && !_game.IsInMenu) { if(Config.Instance.FlashHsOnTurnStart) User32.FlashHs(); if(Config.Instance.BringHsToForeground) User32.BringHsToForeground(); } GameEvents.OnTurnStart.Execute(player); }
private void ChoosePlayer () { firstPlayer = ActivePlayer.Opponent; NewTurn (); }