コード例 #1
0
ファイル: Door.cs プロジェクト: vrobel/mooege
        public override void OnTargeted(Players.Player player, Net.GS.Message.Definitions.World.TargetMessage message)
        {
            World.BroadcastIfRevealed(new PlayAnimationMessage
            {
                ActorID = this.DynamicID,
                Field1 = 5,
                Field2 = 0,
                tAnim = new Net.GS.Message.Fields.PlayAnimationMessageSpec[]
                {
                    new Net.GS.Message.Fields.PlayAnimationMessageSpec()
                    {
                        Duration = 50,
                        AnimationSNO = AnimationSet.TagMapAnimDefault[AnimationSetKeys.Opening],
                        PermutationIndex = 0,
                        Speed = 1
                    }
                }

            }, this);

            World.BroadcastIfRevealed(new SetIdleAnimationMessage
            {
                ActorID = this.DynamicID,
                AnimationSNO = AnimationSetKeys.Open.ID
            }, this);

            this.Attributes[GameAttribute.Gizmo_Has_Been_Operated] = true;
            this.Attributes[GameAttribute.Gizmo_Operator_ACDID] = unchecked((int)player.DynamicID);
            this.Attributes[GameAttribute.Gizmo_State] = 1;
            Attributes.BroadcastChangedIfRevealed();

            base.OnTargeted(player, message);
        }
コード例 #2
0
ファイル: DraughtsGame.cs プロジェクト: sys27/Draughts
        public void StartNew()
        {
            board.CreateBoard();
            currentPlayer = Players.PlayerOne;

            OnBoardChanged();
        }
コード例 #3
0
        private Players ChangeTurn(Players item)
        {
            if (opponent == Opponents.Player)
            {
                foreach (var card in firstPlayerGameCards)
                    card.SetVisible(false);
                foreach (var card in secondPlayerGameCards)
                    card.SetVisible(false);
                skip1.Visible = false;
                skip2.Visible = false;

                if (item == Players.First)
                {
                    MessageBox.Show("Player 2 turn", "Football");
                    foreach (var card in secondPlayerGameCards)
                        card.SetVisible(true);
                    skip2.Visible = true;
                    item = Players.Second;
                }
                else
                {
                    MessageBox.Show("Player 1 turn", "Football");
                    foreach (var card in firstPlayerGameCards)
                        card.SetVisible(true);
                    skip1.Visible = true;
                    item = Players.First;

                }
            }
            else
            {
                item = item == Players.First ? Players.Second : Players.First;
            }
            return item;
        }
コード例 #4
0
		public VisualPlayer(Players.Player player)
		{
			if (player == null)
				return;

			lock (player)
			{
				this.Name = player.Name;
				this.PlayerUniqueId = player.UniqueId;
				this.Phase = player.Phase;
				this.PlayerMode = player.PlayerMode;

				// This sometimes has an Enumeration exception -- can't figure out how to Lock it properly
				try { this.VictoryPoints = player.VictoryPoints; }
				catch { this.VictoryPoints = 0; }

				this.Revealed = player.Revealed;

				Cards.CardCollection discardCards = new Cards.CardCollection();
				for (int i = 0; i < player.DiscardPile.Count - 1; i++)
					discardCards.Add(new Cards.Universal.Dummy());
				if (player.DiscardPile.Count - 1 > 0)
					discardCards.Add(player.DiscardPile.First());
				this.DiscardPile.AddRange(player, discardCards);

				Cards.CardCollection privateCards = new Cards.CardCollection();
				for (int i = 0; i < player.DiscardPile.Count; i++)
					privateCards.Add(new Cards.Universal.Dummy());
				this.DiscardPile.AddRange(player, privateCards);
			}
		}
コード例 #5
0
ファイル: Trigger.cs プロジェクト: vrobel/mooege
        /// <summary>
        /// Reveal Override. For Spawner Gizmos there is no reveal necessary.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Reveal(Players.Player player)
        {
            if (player.RevealedObjects.ContainsKey(this.DynamicID)) return false; // already revealed
            player.RevealedObjects.Add(this.DynamicID, this);
            //Start triggered conversation
            if (this.TriggeredConversation != null)
            {
                StartConversation(this.World, this.TriggeredConversation.Id);
                Logger.Debug("triggered conversation: {0}", this.TriggeredConversation.Id);
            }
            if (this.TriggeredConversation1 != null)
            {
                StartConversation(this.World, this.TriggeredConversation1.Id);
                Logger.Debug("triggered conversation: {0}", this.TriggeredConversation1.Id);
            }
            if (this.TriggeredActor != null)
            {
                //TODO: Verify spawn position?

            }
            if (this.OnActorSpawnedScript != null)
            {
                this.World.Game.Scripts[OnActorSpawnedScript.Id].Execute();
            }

            return true;
        }
コード例 #6
0
ファイル: Jeweler.cs プロジェクト: Velhenn/mooege
 public void OnAddSocket(Players.Player player, Item item)
 {
     // TODO: Animate Jeweler? Who knows. /fasbat
     item.Attributes[GameAttribute.Sockets] += 1;
     // Why this not work? :/
     item.Attributes.SendChangedMessage(player.InGameClient, item.DynamicID);
 }
コード例 #7
0
ファイル: Game.cs プロジェクト: rickhaffey/CSC480
        public void AcceptMove(Players player, int column)
        {
            if (!IsMoveValid(column))
            {
                switch (player)
                {
                    case Players.Black:
                        throw new InvalidMoveException(GameResult.InvalidMoveBlack);
                    case Players.Red:
                        throw new InvalidMoveException(GameResult.InvalidMoveRed);
                    default:
                        throw new Exception("Unexpected player value");
                }
            }

            for (int i = Rows - 1; i >= 0; i--)
            {
                if (_board[i, column] == Players.None)
                {
                    _board[i, column] = player;
                    return;
                }
            }

            throw new Exception("Unable to process player move.");
        }
コード例 #8
0
 public CreatePositionData(List<PiecePosition> pieces,
     Players player_to_move,
     Castle white_castling_options,
     Castle black_castling_options,
     int? capture_en_passant_column,
     ushort fullmove_number,
     ushort halfmove_clock)
 {
     if (pieces == null)
     {
         throw new ArgumentNullException();
     }
     if (capture_en_passant_column.HasValue
         && (capture_en_passant_column < Chessboard.COLUMN_MIN
         || capture_en_passant_column > Chessboard.COLUMN_MAX))
     {
         throw new ArgumentOutOfRangeException();
     }
     m_pieces = pieces;
     m_player_to_move = player_to_move;
     m_white_castling_options = white_castling_options;
     m_black_castling_options = black_castling_options;
     m_capture_en_passant_column = capture_en_passant_column;
     m_fullmove_number = fullmove_number;
     m_halfmove_clock = halfmove_clock;
 }
コード例 #9
0
ファイル: Player.cs プロジェクト: knutdr/Space_defender
 public Player(Texture2D texture, Players playerIndex)
     : base(texture, new WeaponSet(new Laser(GameBase.Textures["Laser"])))
 {
     Position = new Vector2(GameBase.DisplaySetting.Width * 0.5f - (Width * 0.5f), GameBase.DisplaySetting.Height - Height);
     Vector = Vector2.Zero;
     PlayerIndex = playerIndex;
 }
コード例 #10
0
ファイル: GameController.cs プロジェクト: uberspot/Qubez
 /// <summary>
 /// Initializes a new instance of the <see cref="GameController"/> class.
 /// </summary>
 /// <param name="isOnline">if set to <c>true</c> [the game is online].</param>
 /// <param name="names">The names of the players.</param>
 /// <param name="sizeOfBoard">The size of board.</param>
 public GameController(bool isOnline, List<string> names, uint sizeOfBoard)
 {
     IsOnline = isOnline;
     Players = new Players(names, Globals.NumberOfLetters);
     Board = new Board(0, sizeOfBoard);
     Changes = new CircularList<Change>();
     IsFirstTime = true;
 }
コード例 #11
0
ファイル: Player.cs プロジェクト: mrlucas84/XBMCRemoteRT
 public async static Task<JObject> GetProperties(Players player, JArray properties)
 {
     JObject parameters = new JObject(
         new JProperty("playerid", getIdFromPlayers(player)),
         new JProperty("properties", properties));
     JObject responseObject = await ConnectionManager.ExecuteRPCRequest("Player.GetProperties", parameters);
     return (JObject)responseObject["result"];
 }
コード例 #12
0
 public bool IsPieceAt(ChessboardCell cell, out Players player,
     out Exports.Pieces piece)
 {
     int data = m_cells[cell.Value];
     player = (Players)DecodePlayer(data);
     piece = (Exports.Pieces)DecodePiece(data);
     return piece != Exports.Pieces.NoPiece;
 }
コード例 #13
0
        public PlayerInput GetAssignedInput(Players player)
        {
            PlayerInput playerInput;

            if (!assignedInputs.TryGetValue(player, out playerInput))
                Debug.LogError(string.Format("No PlayerInput has been assigned to {0}.", player));

            return playerInput;
        }
コード例 #14
0
ファイル: Players.cs プロジェクト: floatas/SpeedrunComSharp
        public static Players Parse(SpeedrunComClient client, dynamic playersElement)
        {
            var players = new Players();

            players.Value = (int)playersElement.value;
            players.Type = playersElement.type == "exactly" ? PlayersType.Exactly : PlayersType.UpTo;

            return players;
        }
コード例 #15
0
	/**
	 * Runs at load time
	 */
	void Start () {
		playersCollection = Players.S;

		gameController = GameController.S;
		mapsController = MapsController.S;
		networkController = NetworkController.S;
		uiController = UIController.S;
		unitsController = UnitsController.S;
	}
コード例 #16
0
ファイル: Healthwell.cs プロジェクト: n3rus/mooege
        public override void OnTargeted(Players.Player player, Net.GS.Message.Definitions.World.TargetMessage message)
        {
            Logger.Warn("Healthwell has no function, Powers not implemented");

            this.Attributes[GameAttribute.Gizmo_Has_Been_Operated] = true;
            this.Attributes[GameAttribute.Gizmo_Operator_ACDID] = unchecked((int)player.DynamicID);
            this.Attributes[GameAttribute.Gizmo_State] = 1;
            Attributes.BroadcastChangedIfRevealed();
        }
コード例 #17
0
ファイル: PlayerInfo.cs プロジェクト: ZaikMD/ImagineNation
 public static PlayerInfo getPlayer(Players player)
 {
     for (int i = 0; i < m_Players.Count; i++)
     {
         if (m_Players[i].m_Player == player)
             return m_Players[i];
     }
     //error
     return null;
 }
コード例 #18
0
ファイル: Player.cs プロジェクト: wtoscer/XBMCRemoteWP
 public async static Task GoTo(Players player, GoTo goTo)
 {
     if (player == Players.None)
         return;
     int playerId = getIdFromPlayers(player);
     JObject parameters = new JObject(
         new JProperty("playerid", playerId),
         new JProperty("to", goTo.ToString().ToLower()));
     await ConnectionManager.ExecuteRPCRequest("Player.GoTo", parameters);
 }
コード例 #19
0
ファイル: Game.cs プロジェクト: uynguyen/MyCaroProject
 public Game(int mapwidth = 30, int mapheight = 30, Players firstPlayer = Players.X)
 {
     mapWidth = mapwidth;
     mapHeight = mapheight;
     currentPlayer = firstPlayer;
     map = new int[mapHeight, mapWidth];
     SetMap();
     player1 = new Player();
     player2 = new Player();
 }
コード例 #20
0
ファイル: Player.cs プロジェクト: wtoscer/XBMCRemoteWP
 public async static Task<int> PlayPause(Players player)
 {
     if (player == Players.None)
         return 0;
     int playerId = getIdFromPlayers(player);
     JObject parameters = new JObject(new JProperty("playerid", playerId));
     JObject responseObjet = await ConnectionManager.ExecuteRPCRequest("Player.PlayPause", parameters);
     int speed = (int)responseObjet["result"]["speed"];
     return speed;
 }
コード例 #21
0
 public PiecePosition(Players player, Pieces piece, ChessboardCell cell)
 {
     Debug.Assert(cell.Row >= Chessboard.ROW_MIN
         && cell.Row <= Chessboard.ROW_MAX);
     Debug.Assert(cell.Column >= Chessboard.COLUMN_MIN &&
         cell.Column <= Chessboard.COLUMN_MAX);
     m_player = player;
     m_piece = piece;
     m_cell = cell;
 }
コード例 #22
0
ファイル: TriggerSkill.cs プロジェクト: kissgoodbye/sgs
 protected override void InstallTriggers(Players.Player owner)
 {
     Trace.Assert(!_isTriggerInstalled,
         string.Format("Trigger already installed for skill {0}", this.GetType().FullName));
     foreach (var pair in Triggers)
     {
         pair.Value.Owner = owner;
         Game.CurrentGame.RegisterTrigger(pair.Key, pair.Value);
     }
     _isTriggerInstalled = true;
 }
コード例 #23
0
ファイル: OthelloLibrary.cs プロジェクト: ArthurLaks/Games
 /// <summary>
 /// Returns the opponent of the specified player.
 /// </summary>
 /// <param name="player"></param>
 /// <returns>Black if white was passed and white if black was passed.</returns>
 public static Players Opponent(Players player)
 {
     switch (player) {
     case Players.White:
       return Players.Black;
     case Players.Black:
       return Players.White;
     default:	  //If player equals empty
       throw new ArgumentException("Empty has no opponent", "player");
     }
 }
コード例 #24
0
 protected override void UninstallTriggers(Players.Player owner)
 {
     Trace.Assert(_isTriggerInstalled,
         string.Format("Trigger not installed yet for skill {0}", this.GetType().FullName));
     _isTriggerInstalled = false;
     foreach (var pair in Triggers)
     {
         pair.Value.Owner = null;
         Game.CurrentGame.UnregisterTrigger(pair.Key, pair.Value);
     }
 }
コード例 #25
0
	public void AddScore (Players _player)
	{
		switch (_player)
		{
		case Players.Player2:
			p2Score++;
			break;
		case Players.Player1:
			p1Score++;
			break;
		}
	}
コード例 #26
0
 public ApplicationSettings(MessageQueue messageQueue, SystemEventQueue eventQueue)
 {
     InitializeDirectories();
     SystemMessageQueue = messageQueue;
     SystemEventQueue = eventQueue;
     MapColors = new Dictionary<int, KnownColor>();
     LoadColors();
     Logins = new List<Connection>();
     RegisteredUsers = new RegisteredUsers();
     Players = new Players();
     LoadRegistryAccounts();
 }
コード例 #27
0
ファイル: Controller.cs プロジェクト: Vakulka/Rendzu
 private int GetCurrentPlayerNumber(Players currentPlayer)
 {
     int currentPlayerNumber;
     switch (currentPlayer)
     {
         case Players.A: currentPlayerNumber = 1; break;
         case Players.B: currentPlayerNumber = 2; break;
         case Players.None: currentPlayerNumber = 0; break;
         default: currentPlayerNumber = 0; break;
     }
     return currentPlayerNumber;
 }
コード例 #28
0
ファイル: GamePlay.cs プロジェクト: usedflax/flaxbox
 public static void Start(Players players)
 {
     switch (players)
     {
         case Players.Singleplayer:
             break;
         case Players.Multiplayer:
             break;
         default:
             break;
     }
 }
コード例 #29
0
ファイル: PlayerHelper.cs プロジェクト: eraser85/XBMCRemoteRT
        private static async Task RefreshPlayerProperties(Players player)
        {
            JArray properties = new JArray("time", "totaltime", "speed");
            JObject result = await Player.GetProperties(GlobalVariables.CurrentPlayerState.PlayerType, properties);

            JObject totalTime = (JObject)result["totaltime"];
            GlobalVariables.CurrentPlayerState.TotalTimeSeconds = ((int)totalTime["hours"] * 3600) + ((int)totalTime["minutes"] * 60) + (int)totalTime["seconds"];
            
            JObject time = (JObject)result["time"];
            GlobalVariables.CurrentPlayerState.TimeSeconds = ((int)time["hours"] * 3600) + ((int)time["minutes"] * 60) + (int)time["seconds"];

            GlobalVariables.CurrentPlayerState.Speed = (int)result["speed"];
        }
コード例 #30
0
ファイル: AdminUI.cs プロジェクト: gamemachine/gamemachine
 void IAdminApi.OnPlayerSearch(Players players)
 {
     result.gameObject.SetActive(true);
     foreach (Player player in players.player) {
         GameObject go = GameObject.Instantiate(result.gameObject) as GameObject;
         go.name = player.id;
         go.transform.SetParent(results,false);
         go.transform.Find("Text").GetComponent<Text>().text = player.id;
         Button b = go.transform.GetComponent<Button>();
         AddListener(b, player.id);
     }
     result.gameObject.SetActive(false);
 }
コード例 #31
0
        //PLAY Method
        public override void Play()
        {
            Dealer = new TwentyOneDealer();
            foreach (Player player in Players)
            {
                player.Hand = new List <Card>();
                player.Stay = false;
            }
            Dealer.Hand = new List <Card>();
            Dealer.Stay = false;
            Dealer.Deck = new Deck();
            Dealer.Deck.Shuffle();


            Console.WriteLine("Place your bet!");

            foreach (Player player in Players)
            {
                int  bet             = Convert.ToInt32(Console.ReadLine());
                bool successfullyBet = player.Bet(bet);
                if (!successfullyBet)
                {
                    return;
                }
                Bets[player] = bet;
            }
            for (int i = 0; i < 2; i++)
            {
                Console.WriteLine("Dealing...");
                foreach (Player player in Players)
                {
                    Console.WriteLine("{0}: ", player.Name);
                    Dealer.Deal(player.Hand);
                    if (i == 1)//checking for blackjack
                    {
                        bool blackJack = TwentyOneRules.CheckForBlackJack(player.Hand);
                        if (blackJack)
                        {
                            Console.WriteLine("Blackjack! {0} wins {1}", player.Name, Bets[player]);
                            player.Balance += Convert.ToInt32((Bets[player] * 1.5) + Bets[player]);
                            return;
                        }
                    }
                }
                Console.Write("Dealer: ");
                Dealer.Deal(Dealer.Hand);
                if (i == 1)
                {
                    bool blackjack = TwentyOneRules.CheckForBlackJack(Dealer.Hand);
                    if (blackjack)
                    {
                        Console.WriteLine("Dealer has Blackjack! Everyone Loses!");
                        foreach (KeyValuePair <Player, int> entry in Bets)
                        {
                            Dealer.Balance += entry.Value;
                        }
                        return;
                    }
                }
            }
            foreach (Player player in Players)
            {
                while (!player.Stay)
                {
                    Console.WriteLine("Your cards are: ");
                    foreach (Card card in player.Hand)
                    {
                        Console.WriteLine("{0}", card.ToString());
                    }
                    Console.WriteLine("\n\nHit or Stay?");
                    string answer = Console.ReadLine().ToLower();
                    if (answer == "stay")
                    {
                        player.Stay = true;
                        break;
                    }
                    else if (answer == "hit")
                    {
                        Dealer.Deal(player.Hand);
                    }
                    bool busted = TwentyOneRules.IsBusted(player.Hand);
                    if (busted)
                    {
                        Dealer.Balance += Bets[player];
                        Console.WriteLine("{0} Busted! You lose your bets of {1}. Your balance is now {2}.", player.Name, Bets[player], player.Balance);
                        Console.WriteLine("Do you want to play again?");
                        answer = Console.ReadLine().ToLower();
                        if (answer == "yes" || answer == "yeah" || answer == "yep" || answer == "ya" || answer == "y")
                        {
                            player.isActivelyPlaying = true;
                            return;
                        }
                        else
                        {
                            player.isActivelyPlaying = false;
                            return;
                        }
                    }
                }
            }
            Dealer.isBusted = TwentyOneRules.IsBusted(Dealer.Hand);
            Dealer.Stay     = TwentyOneRules.ShouldDealerStay(Dealer.Hand);
            while (!Dealer.Stay && !Dealer.isBusted)
            {
                Console.WriteLine("Dealer is hitting...");
                Dealer.Deal(Dealer.Hand);
                Dealer.isBusted = TwentyOneRules.IsBusted(Dealer.Hand);
                Dealer.Stay     = TwentyOneRules.ShouldDealerStay(Dealer.Hand);
            }
            if (Dealer.Stay)
            {
                Console.WriteLine("Dealer is staying.");
            }
            if (Dealer.isBusted)
            {
                Console.WriteLine("Dealer is busted!");
                foreach (KeyValuePair <Player, int> entry in Bets)
                {
                    Console.WriteLine("{0} won {1}!", entry.Key.Name, entry.Value);
                    Players.Where(x => x.Name == entry.Key.Name).First().Balance += (entry.Value * 2);
                    Dealer.Balance -= entry.Value;
                }
                return;
            }
            foreach (Player player in Players)
            {
                bool?playerWon = TwentyOneRules.CompareHands(player.Hand, Dealer.Hand);  //bool? allows bool to take a null value as well
                if (playerWon == null)
                {
                    Console.WriteLine("Push! No one wins.");
                    player.Balance += Bets[player];
                }
                else if (playerWon == true)
                {
                    Console.WriteLine("{0} won {1}!", player.Name, Bets[player]);
                    player.Balance += (Bets[player] * 2);
                    Dealer.Balance -= Bets[player];
                }
                else
                {
                    Console.WriteLine("Dealer wins {0}!", Bets[player]);
                    Dealer.Balance += Bets[player];
                }
                Console.WriteLine("Play Again?");
                string answer = Console.ReadLine().ToLower();
                if (answer == "yes" || answer == "yeah" || answer == "yep" || answer == "ya" || answer == "y")
                {
                    player.isActivelyPlaying = true;
                }
                else
                {
                    player.isActivelyPlaying = false;
                }
            }
        }
コード例 #32
0
ファイル: GameSocket.cs プロジェクト: omansak/playhup
        //Listener Process From Client Data
        private static async void ReadFromClient(ProtocolModel.ConnectionClient connectionClient)
        {
            try
            {
                await Task.Run(async() =>
                {
                    while (connectionClient.Client.Connected)
                    {
                        if (connectionClient.Client.GetStream().DataAvailable)
                        {
                            NetworkStream stream = connectionClient.Client.GetStream();
                            byte[] data          = new byte[1024];
                            string json          = string.Empty;
                            var bytes            = stream.Read(data, 0, data.Length);
                            if (bytes > 0)
                            {
                                json = Encoding.ASCII.GetString(data, 0, bytes);
                            }
                            //Data Processing
                            var token = json.Split(new[] { "\\;omansak;\\" }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (var msgToken in token)
                            {
                                ProtocolModel.Base baseMessage = JsonConvert.DeserializeObject <ProtocolModel.Base>(msgToken);
                                switch (baseMessage.Type)
                                {
                                // Join new player and send current players
                                case ProtocolModel.MessageType.RequestJoin:
                                    {
                                        ProtocolModel.Player player = JsonConvert.DeserializeObject <ProtocolModel.Player>(baseMessage.Data.ToString());
                                        player.Id = connectionClient.Id;
                                        Players.Add(player);
                                        BroadcastPlayers();
                                        RequestSendMessage($"--> {Players.First(i => i.Id == connectionClient.Id).Name} is joined.");
                                        break;
                                    }

                                // Lobby Messages
                                case ProtocolModel.MessageType.LobbyMessage:
                                    {
                                        BroadcastFromServer(json);
                                        break;
                                    }

                                // Start Game
                                case ProtocolModel.MessageType.RequestStart:
                                    {
                                        GameRunning = true;
                                        GenerateShapes();
                                        RequestSendMessage($"--> Game started by {Players.First(i => i.Id == connectionClient.Id).Name} (host)");
                                        break;
                                    }

                                // Game Settings
                                case ProtocolModel.MessageType.RequestGameSettings:
                                    {
                                        BroadcastFromServer(JsonConvert.SerializeObject(new ProtocolModel.Base
                                        {
                                            Type = ProtocolModel.MessageType.RequestGameSettings,
                                            Data = new ProtocolModel.GameSetting
                                            {
                                                GameName  = GameName,
                                                Red       = GameShapeRed.ToString(),
                                                Blue      = GameShapeBlue.ToString(),
                                                Yellow    = GameShapeYellow.ToString(),
                                                Timer     = GameRefreshTime.ToString(),
                                                Win       = GameWinPoint.ToString(),
                                                PanelSize = new Point(GamePanelSizeX, GamePanelSizeY)
                                            }
                                        }));
                                        break;
                                    }

                                // Check coor inside objects
                                case ProtocolModel.MessageType.RequestSendCoor:
                                    {
                                        ProtocolModel.ClickCoor point = JsonConvert.DeserializeObject <ProtocolModel.ClickCoor>(baseMessage.Data.ToString());
                                        for (int j = ShapesPanel.Count - 1; j >= 0; j--)
                                        {
                                            var item = ShapesPanel[j];
                                            if (item.Type == 0)
                                            {
                                                if (ContainsEllipse(point.Coor, item.Point))
                                                {
                                                    ShapesPanel.Remove(item);
                                                    Players.First(i => i.Id == connectionClient.Id).Point += GameShapeRed;
                                                    BroadcastShapes();
                                                    BroadcastPlayers();
                                                    RequestSendMessage($"--> {Players.First(i => i.Id == connectionClient.Id).Name} is gained {GameShapeRed} with Red");
                                                    break;
                                                }
                                            }
                                            if (item.Type == 1)
                                            {
                                                if (ContainsRectangle(point.Coor, item.Point))
                                                {
                                                    ShapesPanel.Remove(item);
                                                    Players.First(i => i.Id == connectionClient.Id).Point += GameShapeBlue;
                                                    BroadcastShapes();
                                                    BroadcastPlayers();
                                                    RequestSendMessage($"--> {Players.First(i => i.Id == connectionClient.Id).Name} is gained {GameShapeBlue} with Blue");
                                                    break;
                                                }
                                            }
                                            if (item.Type == 2)
                                            {
                                                if (ContainsTriangle(point.Coor, item.Point))
                                                {
                                                    ShapesPanel.Remove(item);
                                                    Players.First(i => i.Id == connectionClient.Id).Point += GameShapeYellow;
                                                    BroadcastShapes();
                                                    BroadcastPlayers();
                                                    RequestSendMessage($"--> {Players.First(i => i.Id == connectionClient.Id).Name} is gained {GameShapeYellow} with Yellow");
                                                    break;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        Thread.Sleep(25);
                    }
                });
            }
            finally
            {
                Players.Remove(Players.First(i => i.Id == connectionClient.Id));
                connectionClient.Client.Close();
                BroadcastPlayers();
            }
        }
コード例 #33
0
ファイル: GameSocket.cs プロジェクト: omansak/playhup
 public static void BroadcastWinner()
 {
     if (Players.Any(i => i.Point >= GameWinPoint))
     {
         ShapesPanel.Clear();
         BroadcastShapes();
         RequestSendMessage($"{Players.First(i => i.Point >= GameWinPoint).Name} ({Players.First(i => i.Point >= GameWinPoint).Point}) is Won");
         RequestSendMessage($"Game Finished");
         GameRunning = false;
     }
 }
コード例 #34
0
        private void ServerCommandHandler(int source, List <object> args, string rawCommand)
        {
            if (args != null)
            {
                if (args.Count > 0)
                {
                    if (args[0].ToString().ToLower() == "debug")
                    {
                        DebugMode = !DebugMode;
                        if (source < 1)
                        {
                            Debug.WriteLine($"Debug mode is now set to: {DebugMode}.");
                        }
                        else
                        {
                            Players[source].TriggerEvent("chatMessage", $"vMenu Debug mode is now set to: {DebugMode}.");
                        }
                        return;
                    }
                    else if (args[0].ToString().ToLower() == "unban" && (source < 1))
                    {
                        if (args.Count() > 1 && !string.IsNullOrEmpty(args[1].ToString()))
                        {
                            var uuid      = args[1].ToString().Trim();
                            var bans      = BanManager.GetBanList();
                            var banRecord = bans.Find(b => { return(b.uuid.ToString() == uuid); });
                            if (banRecord != null)
                            {
                                BanManager.RemoveBan(banRecord);
                                Debug.WriteLine("Player has been successfully unbanned.");
                            }
                            else
                            {
                                Debug.WriteLine($"Could not find a banned player with the provided uuid '{uuid}'.");
                            }
                        }
                        else
                        {
                            Debug.WriteLine("You did not specify a player to unban, you must enter the FULL playername. Usage: vmenuserver unban \"playername\"");
                        }
                        return;
                    }
                    else if (args[0].ToString().ToLower() == "weather")
                    {
                        if (args.Count < 2 || string.IsNullOrEmpty(args[1].ToString()))
                        {
                            Debug.WriteLine("[vMenu] Invalid command syntax. Use 'vmenuserver weather <weatherType>' instead.");
                        }
                        else
                        {
                            string wtype = args[1].ToString().ToUpper();
                            if (WeatherTypes.Contains(wtype))
                            {
                                TriggerEvent("vMenu:UpdateServerWeather", wtype, BlackoutEnabled, DynamicWeatherEnabled);
                                Debug.WriteLine($"[vMenu] Weather is now set to: {wtype}");
                            }
                            else if (wtype.ToLower() == "dynamic")
                            {
                                if (args.Count == 3 && !string.IsNullOrEmpty(args[2].ToString()))
                                {
                                    if ((args[2].ToString().ToLower() ?? $"{DynamicWeatherEnabled}") == "true")
                                    {
                                        TriggerEvent("vMenu:UpdateServerWeather", CurrentWeather, BlackoutEnabled, true);
                                        Debug.WriteLine("[vMenu] Dynamic weather is now turned on.");
                                    }
                                    else if ((args[2].ToString().ToLower() ?? $"{DynamicWeatherEnabled}") == "false")
                                    {
                                        TriggerEvent("vMenu:UpdateServerWeather", CurrentWeather, BlackoutEnabled, false);
                                        Debug.WriteLine("[vMenu] Dynamic weather is now turned off.");
                                    }
                                    else
                                    {
                                        Debug.WriteLine("[vMenu] Invalid command usage. Correct syntax: vmenuserver weather dynamic <true|false>");
                                    }
                                }
                                else
                                {
                                    Debug.WriteLine("[vMenu] Invalid command usage. Correct syntax: vmenuserver weather dynamic <true|false>");
                                }
                            }
                            else
                            {
                                Debug.WriteLine("[vMenu] This weather type is not valid!");
                            }
                        }
                    }
                    else if (args[0].ToString().ToLower() == "time")
                    {
                        if (args.Count == 2)
                        {
                            if (args[1].ToString().ToLower() == "freeze")
                            {
                                TriggerEvent("vMenu:UpdateServerTime", CurrentHours, CurrentMinutes, !FreezeTime);
                                Debug.WriteLine($"Time is now {(FreezeTime ? "frozen" : "not frozen")}.");
                            }
                            else
                            {
                                Debug.WriteLine("Invalid syntax. Use: ^5vmenuserver time <freeze|<hour> <minute>>^7 instead.");
                            }
                        }
                        else if (args.Count > 2)
                        {
                            if (int.TryParse(args[1].ToString(), out int hour))
                            {
                                if (int.TryParse(args[2].ToString(), out int minute))
                                {
                                    if (hour >= 0 && hour < 24)
                                    {
                                        if (minute >= 0 && minute < 60)
                                        {
                                            TriggerEvent("vMenu:UpdateServerTime", hour, minute, FreezeTime);
                                            Debug.WriteLine($"Time is now {(hour < 10 ? ("0" + hour.ToString()) : hour.ToString())}:{(minute < 10 ? ("0" + minute.ToString()) : minute.ToString())}.");
                                        }
                                        else
                                        {
                                            Debug.WriteLine("Invalid minute provided. Value must be between 0 and 59.");
                                        }
                                    }
                                    else
                                    {
                                        Debug.WriteLine("Invalid hour provided. Value must be between 0 and 23.");
                                    }
                                }
                                else
                                {
                                    Debug.WriteLine("Invalid syntax. Use: ^5vmenuserver time <freeze|<hour> <minute>>^7 instead.");
                                }
                            }
                            else
                            {
                                Debug.WriteLine("Invalid syntax. Use: ^5vmenuserver time <freeze|<hour> <minute>>^7 instead.");
                            }
                        }
                        else
                        {
                            Debug.WriteLine("Invalid syntax. Use: ^5vmenuserver time <freeze|<hour> <minute>>^7 instead.");
                        }
                    }
                    else if (args[0].ToString().ToLower() == "ban" && source < 1)  // only do this via server console (server id < 1)
                    {
                        if (args.Count > 3)
                        {
                            Player p = null;

                            bool   findByServerId = args[1].ToString().ToLower() == "id";
                            string identifier     = args[2].ToString().ToLower();

                            if (findByServerId)
                            {
                                if (Players.Any(player => player.Handle == identifier))
                                {
                                    p = Players.Single(pl => pl.Handle == identifier);
                                }
                                else
                                {
                                    Debug.WriteLine("[vMenu] Could not find this player, make sure they are online.");
                                    return;
                                }
                            }
                            else
                            {
                                if (Players.Any(player => player.Name.ToLower() == identifier.ToLower()))
                                {
                                    p = Players.Single(pl => pl.Name.ToLower() == identifier.ToLower());
                                }
                                else
                                {
                                    Debug.WriteLine("[vMenu] Could not find this player, make sure they are online.");
                                    return;
                                }
                            }

                            string reason = "Banned by staff for:";
                            args.GetRange(3, args.Count - 3).ForEach(arg => reason += " " + arg);

                            if (p != null)
                            {
                                BanManager.BanRecord ban = new BanManager.BanRecord(
                                    BanManager.GetSafePlayerName(p.Name),
                                    p.Identifiers.ToList(),
                                    new DateTime(3000, 1, 1),
                                    reason,
                                    "Server Console",
                                    new Guid()
                                    );

                                BanManager.AddBan(ban);
                                BanManager.BanLog($"[vMenu] Player {p.Name}^7 has been banned by Server Console for [{reason}].");
                                TriggerEvent("vMenu:BanSuccessful", JsonConvert.SerializeObject(ban).ToString());
                                string timeRemaining = BanManager.GetRemainingTimeMessage(ban.bannedUntil.Subtract(DateTime.Now));
                                p.Drop($"You are banned from this server. Ban time remaining: {timeRemaining}. Banned by: {ban.bannedBy}. Ban reason: {ban.banReason}. Additional information: {vMenuShared.ConfigManager.GetSettingsString(vMenuShared.ConfigManager.Setting.vmenu_default_ban_message_information)}.");
                            }
                            else
                            {
                                Debug.WriteLine("[vMenu] Player not found, could not ban player.");
                            }
                        }
                        else
                        {
                            Debug.WriteLine("[vMenu] Not enough arguments, syntax: ^5vmenuserver ban <id|name> <server id|username> <reason>^7.");
                        }
                    }
                    else if (args[0].ToString().ToLower() == "help")
                    {
                        Debug.WriteLine("Available commands:");
                        Debug.WriteLine("(server console only): vmenuserver ban <id|name> <server id|username> <reason> (player must be online!)");
                        Debug.WriteLine("(server console only): vmenuserver unban <uuid>");
                        Debug.WriteLine("vmenuserver weather <new weather type | dynamic <true | false>>");
                        Debug.WriteLine("vmenuserver time <freeze|<hour> <minute>>");
                        Debug.WriteLine("vmenuserver migrate (This copies all banned players in the bans.json file to the new ban system in vMenu v3.3.0, you only need to do this once)");
                    }
                    else if (args[0].ToString().ToLower() == "migrate" && source < 1)
                    {
                        string file = LoadResourceFile(GetCurrentResourceName(), "bans.json");
                        if (string.IsNullOrEmpty(file) || file == "[]")
                        {
                            Debug.WriteLine("&1[vMenu] [ERROR]^7 No bans.json file found or it's empty.");
                            return;
                        }
                        Debug.WriteLine("^5[vMenu] [INFO]^7 Importing all ban records from the bans.json file into the new storage system. ^3This may take some time...^7");
                        var bans = JsonConvert.DeserializeObject <List <BanManager.BanRecord> >(file);
                        bans.ForEach((br) =>
                        {
                            var record = new BanManager.BanRecord(br.playerName, br.identifiers, br.bannedUntil, br.banReason, br.bannedBy, Guid.NewGuid());
                            BanManager.AddBan(record);
                        });
                        Debug.WriteLine("^2[vMenu] [SUCCESS]^7 All ban records have been imported. You now no longer need the bans.json file.");
                    }
                    else
                    {
                        Debug.WriteLine($"vMenu is currently running version: {Version}. Try ^5vmenuserver help^7 for info.");
                    }
                }
                else
                {
                    Debug.WriteLine($"vMenu is currently running version: {Version}. Try ^5vmenuserver help^7 for info.");
                }
            }
            else
            {
                Debug.WriteLine($"vMenu is currently running version: {Version}. Try ^5vmenuserver help^7 for info.");
            }
        }
コード例 #35
0
    private void Start()
    {
        Director.Instance.EverythingBeginsHere();

        lastPlayerWhoBegan = Players.None;
    }
コード例 #36
0
 //Adds a player to the database
 public ActionResult <Players> PostPlayer([FromBody] Players newPlayer)
 {
     _context.Players.Add(newPlayer);
     _context.SaveChanges();
     return(CreatedAtAction("GetPlayer", new { id = newPlayer.PlayerId }, newPlayer));
 }
コード例 #37
0
 public void SetWinnerResult(Players winnerPlayer)
 {
     winnerIcon.sprite = winnerPlayer.iconSprite == null ? winnerIcon.sprite : winnerPlayer.iconSprite;
     winnerName.text   = winnerPlayer.Name;
 }
コード例 #38
0
ファイル: TicTacToeCore.cs プロジェクト: nfcaspers/csharp
        public TurnResult TestForWin(Coordinates Coords, Players ActivePlayer)
        {
            bool previousOwned = false;

            //Überprüfe horizontale Reihe
            for (int i = 0; i < 3; i++)
            {
                if (Board[Coords.X, i] == ActivePlayer)
                {
                    previousOwned = true;
                }
                else
                {
                    previousOwned = false;
                    break;
                }
            }

            if (previousOwned)
            {
                return(TurnResult.Win);
            }

            //Überprüfe vertikale Reihe
            for (int i = 0; i < 3; i++)
            {
                if (Board[i, Coords.Y] == ActivePlayer)
                {
                    previousOwned = true;
                }
                else
                {
                    previousOwned = false;
                    break;
                }
            }

            if (previousOwned)
            {
                return(TurnResult.Win);
            }

            //Überprüfe diagonale Felder
            if (Board[0, 0] == ActivePlayer &&
                Board[1, 1] == ActivePlayer &&
                Board[2, 2] == ActivePlayer)
            {
                return(TurnResult.Win);
            }
            if (Board[0, 2] == ActivePlayer &&
                Board[1, 1] == ActivePlayer &&
                Board[2, 0] == ActivePlayer)
            {
                return(TurnResult.Win);
            }

            if (Moves == 9)
            {
                return(TurnResult.Draw);
            }

            return(TurnResult.None);
        }
コード例 #39
0
        //public List<TestModel> GetAllTest(string playerID)
        //{
        //    List<TestModel> matches = new List<TestModel>();

        //    using (MySqlConnection connection = CreateConnection())
        //    {
        //        matches = connection.Query<TestModel>("SELECT * FROM matches NATURAL JOIN (SELECT * FROM played_match WHERE player_id = @PlayerID) AS matches_played_by_player", new { PlayerID = playerID }).ToList();
        //    }

        //    return matches;
        //}



        public void InsertRandomData(int amount)
        {
            var personGenerator = new PersonNameGenerator();
            var placeGenerator  = new PlaceNameGenerator();

            intrusiveContext context = null;

            Random rnd = new Random(DateTime.UtcNow.Millisecond);

            int index = 105000;

            try
            {
                context = new intrusiveContext();

                context.ChangeTracker.AutoDetectChangesEnabled = false;

                for (int i = 0; i < amount; i++)
                {
                    Accounts tempAccount = new Accounts()
                    {
                        AccountId    = placeGenerator.GenerateRandomPlaceName() + index.ToString() + personGenerator.GenerateRandomFirstName(),
                        Email        = index.ToString(),
                        PasswordHash = index.ToString()
                    };

                    Players tempPlayer = new Players()
                    {
                        Experience = (uint)rnd.Next(10000001),
                        PlayerId   = tempAccount.AccountId
                    };


                    context.Add(tempAccount);
                    context.Add(tempPlayer);

                    if (i % 100 == 0)
                    {
                        context.SaveChanges();

                        context.Dispose();
                        context = new intrusiveContext();
                        context.ChangeTracker.AutoDetectChangesEnabled = false;
                    }


                    context.SaveChanges();

                    //connection.Query<AccountModel>("select * from accounts");
                    //Console.WriteLine("{0} inserted succesfully!", tempPlayer.PlayerId);
                    index++;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException.Message);
            }
            finally
            {
                if (context != null)
                {
                    context.Dispose();
                }
            }



            //using (MySqlConnection connection = CreateConnection())
            //{
            //    int index = 0;
            //    try
            //    {
            //        connection.Open();

            //        for (int i = 0; i < amount; i++)
            //        {
            //            Accounts tempAccount = new Accounts()
            //            {
            //                AccountId = placeGenerator.GenerateRandomPlaceName() + index.ToString() + personGenerator.GenerateRandomFirstName(),
            //                Email = index.ToString(),
            //                PasswordHash = index.ToString()
            //            };

            //            Players tempPlayer = new Players()
            //            {
            //                Experience = (uint)rnd.Next(10000001),
            //                PlayerId = tempAccount.AccountId
            //            };
            //            connection.Insert(tempAccount);
            //            connection.Insert(tempPlayer);

            //            //connection.Query<AccountModel>("select * from accounts");
            //            Console.WriteLine("{0} inserted succesfully!", tempPlayer.PlayerId);
            //            index++;
            //        }

            //    }
            //    catch (Exception e)
            //    {
            //        Console.WriteLine(e.Message);
            //    }
            //}
            Console.WriteLine("All inserted");
        }
コード例 #40
0
 public void AddPlayer(PlayerInfo player)
 {
     Players.Add(player);
 }
コード例 #41
0
ファイル: GameViewModel.cs プロジェクト: GyPapi/BegVCSharp
 private void player_OnPlayerHasWon(object sender, PlayerEventArgs e)
 {
     // Change the state of all the players. Set the specified player as the winner, and
     // all the others as losers.
     Players.ForEach(x => x.State = (x == e.Player ? PlayerState.Winner : PlayerState.Loser));
 }
コード例 #42
0
 void player_OnPlayerHasWon(object sender, PlayerEventArgs e)
 {
     Players.ForEach(x => x.State = (x == e.Player ? PlayerState.Winner :
                                     PlayerState.Loser));
 }
コード例 #43
0
        private void HandlePlayerOptionsRequest(string sender, string data)
        {
            if (!IsHost)
            {
                return;
            }

            PlayerInfo pInfo = Players.Find(p => p.Name == sender);

            if (pInfo == null)
            {
                return;
            }

            string[] parts = data.Split(ProgramConstants.LAN_DATA_SEPARATOR);

            if (parts.Length != 4)
            {
                return;
            }

            int side  = Conversions.IntFromString(parts[0], -1);
            int color = Conversions.IntFromString(parts[1], -1);
            int start = Conversions.IntFromString(parts[2], -1);
            int team  = Conversions.IntFromString(parts[3], -1);

            if (side < 0 || side > SideCount + RandomSelectorCount)
            {
                return;
            }

            if (color < 0 || color > MPColors.Count)
            {
                return;
            }

            if (Map.CoopInfo != null)
            {
                if (Map.CoopInfo.DisallowedPlayerSides.Contains(side - 1) || side == SideCount + RandomSelectorCount)
                {
                    return;
                }

                if (Map.CoopInfo.DisallowedPlayerColors.Contains(color - 1))
                {
                    return;
                }
            }

            if (start < 0 || start > Map.MaxPlayers)
            {
                return;
            }

            if (team < 0 || team > 4)
            {
                return;
            }

            if (side != pInfo.SideId ||
                start != pInfo.StartingLocation ||
                team != pInfo.TeamId)
            {
                ClearReadyStatuses();
            }

            pInfo.SideId           = side;
            pInfo.ColorId          = color;
            pInfo.StartingLocation = start;
            pInfo.TeamId           = team;

            CopyPlayerDataToUI();
            BroadcastPlayerOptions();
        }
コード例 #44
0
 public Player GetPlayerById(int id)
 {
     return(Players.FirstOrDefault(p => p.Id == id));
 }
コード例 #45
0
        protected override void Update()
        {
            foreach (var b in _bullets)
            {
                b.Position += new Vector(0, -1) * Constants.Weapon.BulletVelocity;
                Asteroid a = CheckCollision(b);
                if (a != null)
                {
                    b.Explode(a.Score);
                    a.Hit(b);
                }
                if (b.Valid)
                {
                    b.Draw();
                }
            }
            _bullets.RemoveAll((b) => !b.Valid);

            foreach (var a in _asteroids)
            {
                a.Position += a.Velocity;
                if (a.Valid)
                {
                    a.Draw();
                }
            }
            _asteroids.RemoveAll((a) => !a.Valid);

            SpawnAsteroids();

            _asteroidRate += Constants.Match.AsteroidRateIncreasePerPlayer * Players.Count;

            foreach (var p in Players)
            {
                if (best == null || p.Score > best.Score)
                {
                    best = p;
                }
                if (secondBest == null || (p.Score < best.Score && p.Score > secondBest.Score))
                {
                    secondBest = p;
                }

                if (p.Dead)
                {
                    continue;
                }
                CheckDeath(p);
                MovePlayer(p);
                Fire(p);
                p.Draw(best, secondBest);
            }

            this.IsCompleted = (Players.Count == 1 && Players[0].Dead) || (Players.Count > 1 && Players.Sum((p) => { return(p.Dead ? 0 : 1); }) <= 1);
        }
コード例 #46
0
 public bool Contains(PokerPlayer player)
 {
     return(Players.Contains(player));
 }
        public override void Play()
        {
            //wipe players who opted out from player list
            List <Player> removalList = new List <Player>();

            removalList = Players.Where(x => !x.IsActive).ToList();
            foreach (Player player in removalList)
            {
                Players.Remove(player);
                Bets.Remove(player);
            }

            if (Players.Count == 0)
            {
                return;
            }


            Dealer = new TwentyOneDealer();
            foreach (Player player in Players)
            {
                player.Hand = new List <Card>();
                player.Stay = false;
            }
            Dealer.Hand = new List <Card>();
            Dealer.Stay = false;
            Dealer.Deck = new Deck();
            Dealer.Deck.Shuffle(3);

            foreach (Player player in Players)
            {
                Console.WriteLine("{0}, you have {1} in the bank.", player.Name, player.Balance);

                bool validAnswer = false;
                int  bet         = 0;
                while (!validAnswer)
                {
                    Console.WriteLine("Place your bet:");
                    validAnswer = int.TryParse(Console.ReadLine(), out bet);
                    if (!validAnswer)
                    {
                        Console.WriteLine("Please enter digits only, no decimals.");
                    }
                }
                if (bet < 0)
                {
                    throw new FraudException();
                }

                bool successfullyBet = player.Bet(bet);
                if (!successfullyBet)
                {
                    return;
                }
                Bets[player] = bet;
            }

            for (int i = 0; i < 2; i++)
            {
                Console.WriteLine("Dealing...");
                foreach (Player player in Players)
                {
                    Console.Write("{0}: ", player.Name);
                    Dealer.Deal(player.Hand);
                    if (i == 1)
                    {
                        bool blackJack = TwentyOneRules.CheckForBlackJack(player.Hand);
                        if (blackJack)
                        {
                            int blackJackPayout = Convert.ToInt32(1.5 * Bets[player]);
                            Console.WriteLine("Blackjack! {0} wins {1}", player.Name, blackJackPayout);
                            player.Balance += Convert.ToInt32(((Bets[player]) * 1.5) + Bets[player]);
                            Console.WriteLine("{0} has a balance of: {1}", player.Name, player.Balance);
                            foreach (Player blackjackplayer in Players)
                            {
                                playAgain(blackjackplayer);
                            }
                            return;
                        }
                    }
                }
                Console.Write("Dealer:");
                Dealer.Deal(Dealer.Hand);
                if (i == 1)
                {
                    bool blackJack = TwentyOneRules.CheckForBlackJack(Dealer.Hand);
                    if (blackJack)
                    {
                        Console.WriteLine("Dealer has Blackjack! Everyone loses...");
                        foreach (KeyValuePair <Player, int> entry in Bets)
                        {
                            Dealer.Balance += entry.Value;
                        }
                        foreach (Player player in Players)
                        {
                            playAgain(player);
                        }
                        return;
                    }
                }
            }
            foreach (Player player in Players)
            {
                while (!player.Stay && player.IsActive && !TwentyOneRules.IsBusted(player.Hand))
                {
                    Console.WriteLine("{0}, your cards are:", player.Name);
                    foreach (Card card in player.Hand)
                    {
                        Console.Write("{0} ", card.ToString());
                    }
                    Console.WriteLine("\nHit or Stay?");
                    string answer = Console.ReadLine().ToLower();
                    if (answer.StartsWith("s"))
                    {
                        player.Stay = true;
                        break;
                    }
                    else if (answer.StartsWith("h"))
                    {
                        Dealer.Deal(player.Hand);
                    }
                    bool busted = TwentyOneRules.IsBusted(player.Hand);
                    if (busted)
                    {
                        Dealer.Balance += Bets[player];
                        Console.WriteLine("{0} busted! Lost bet of {1}, balance is now {2}", player.Name, Bets[player], player.Balance);
                        playAgain(player);
                    }
                }
            }
            Dealer.isBusted = TwentyOneRules.IsBusted(Dealer.Hand);
            Dealer.Stay     = TwentyOneRules.ShouldDealerStay(Dealer.Hand);
            while (!Dealer.Stay && !Dealer.isBusted)
            {
                Console.WriteLine("Dealer hits...");
                Dealer.Deal(Dealer.Hand);
                Dealer.isBusted = TwentyOneRules.IsBusted(Dealer.Hand);
                Dealer.Stay     = TwentyOneRules.ShouldDealerStay(Dealer.Hand);
            }
            if (Dealer.Stay)
            {
                Console.WriteLine("Dealer is staying.");
            }
            if (Dealer.isBusted)
            {
                Console.WriteLine("Dealer busted!");
                foreach (KeyValuePair <Player, int> entry in Bets)
                {
                    Console.WriteLine("{0} won {1}!", entry.Key.Name, entry.Value);
                    Players.Where(x => x.Name == entry.Key.Name).First().Balance += (entry.Value * 2);
                    Dealer.Balance -= entry.Value;
                }
                foreach (Player player in Players)
                {
                    playAgain(player);
                }
                return;
            }
            foreach (Player player in Players)
            {
                if (!TwentyOneRules.IsBusted(player.Hand))
                {
                    bool?playerWon = TwentyOneRules.CompareHands(player.Hand, Dealer.Hand);
                    if (playerWon == null)
                    {
                        Console.WriteLine("Push! No one wins.");
                        player.Balance += Bets[player];
                    }
                    else if (playerWon == true)
                    {
                        Console.WriteLine("{0} won {1}!", player.Name, Bets[player]);
                        player.Balance += (Bets[player] * 2);
                        Console.WriteLine("{0} has a balance of: {1}", player.Name, player.Balance);
                        Dealer.Balance -= Bets[player];
                    }
                    else
                    {
                        Console.WriteLine("Dealer wins {0}.", Bets[player]);
                        Dealer.Balance += Bets[player];
                    }
                    playAgain(player);
                }
                else
                {
                    Console.WriteLine("Dealer wins {0}.", Bets[player]);
                    Dealer.Balance += Bets[player];
                }
            }
            return;
        }
コード例 #48
0
 private void AddOne()
 {
     Players.Add(new Player {
         FirstName = "jan", LastName = "nowak"
     });
 }
コード例 #49
0
 public void Resolve(Players players)
 {
     players.PlayerOne.Lost();
     players.PlayerTwo.Won();
 }
コード例 #50
0
ファイル: MMRViewModel.cs プロジェクト: haomf36/HotsBpHelper
        public void FillMMR(Game game)
        {
            int autoCloseSec = App.CustomConfigurationSettings.MMRAutoCloseTime;

            if (autoCloseSec > 0)
            {
                _eventAggregator.PublishOnUIThread(new InvokeScriptMessage
                {
                    ScriptName = "setAutoCloseSeconds",
                    Args       = new[] { autoCloseSec.ToString() }
                }, "MMRChanel");
            }

            _eventAggregator.PublishOnUIThread(new InvokeScriptMessage
            {
                ScriptName = "setLanguageForMessage",
                Args       = new[] { App.CustomConfigurationSettings.LanguageForMessage }
            }, "MMRChanel");

            // 取得地区ID
            var regionId = ((int)game.Region).ToString();
            // 玩家BattleTags
            var battleTags = string.Join("|", game.Players
                                         .Select(p => p.Tag + "#" + p.SelectedHero));

            Players = game.Players.Select(p => p.Tag).ToList();
            string defaultPlayer = Players.First();

            if (App.CustomConfigurationSettings.PlayerTags.Any(p => Players.Contains(p)))
            {
                defaultPlayer = App.CustomConfigurationSettings.PlayerTags.First(p => Players.Contains(p));
                App.CustomConfigurationSettings.PlayerTags.Remove(defaultPlayer);
                App.CustomConfigurationSettings.PlayerTags.Insert(0, defaultPlayer);
                // for config.ini
                App.NextConfigurationSettings.PlayerTags.Remove(defaultPlayer);
                App.NextConfigurationSettings.PlayerTags.Insert(0, defaultPlayer);
            }
            else if (LastMatchPlayers.Count(p => Players.Contains(p)) == 1)
            {
                defaultPlayer = LastMatchPlayers.First(p => Players.Contains(p));
                App.CustomConfigurationSettings.PlayerTags.Insert(0, defaultPlayer);
                // for config.ini
                App.NextConfigurationSettings.PlayerTags.Insert(0, defaultPlayer);
            }

            int defaultPlayerIndex = Players.IndexOf(defaultPlayer);

            LastMatchPlayers.Clear();
            LastMatchPlayers.AddRange(Players);

            _eventAggregator.PublishOnUIThread(new InvokeScriptMessage
            {
                ScriptName = "setMap",
                Args       = new[] { game.Map }
            }, "MMRChanel");

            _eventAggregator.PublishOnUIThread(new InvokeScriptMessage
            {
                ScriptName = "setPlayers",
                Args       = new[] { regionId, defaultPlayerIndex.ToString(), battleTags }
            }, "MMRChanel");
        }
コード例 #51
0
ファイル: Blackjack.cs プロジェクト: Nurtu/Yuno-nadeko1
        public async Task GameLoop()
        {
            try
            {
                //wait for players to join
                await Task.Delay(20000);

                await locker.WaitAsync();

                try
                {
                    State = GameState.Playing;
                }
                finally
                {
                    locker.Release();
                }
                await PrintState();

                //if no users joined the game, end it
                if (!Players.Any())
                {
                    State = GameState.Ended;
                    var end = GameEnded?.Invoke(this);
                    return;
                }
                //give 1 card to the dealer and 2 to each player
                Dealer.Cards.Add(Deck.Draw());
                foreach (var usr in Players)
                {
                    usr.Cards.Add(Deck.Draw());
                    usr.Cards.Add(Deck.Draw());

                    if (usr.GetHandValue() == 21)
                    {
                        usr.State = User.UserState.Blackjack;
                    }
                }
                //go through all users and ask them what they want to do
                foreach (var usr in Players.Where(x => !x.Done))
                {
                    while (!usr.Done)
                    {
                        _log.Info($"Waiting for {usr.DiscordUser}'s move");
                        await PromptUserMove(usr);
                    }
                }
                await PrintState();

                State = GameState.Ended;
                await Task.Delay(2500);

                _log.Info("Dealer moves");
                await DealerMoves();
                await PrintState();

                var _ = GameEnded?.Invoke(this);
            }
            catch (Exception ex)
            {
                _log.Error("REPORT THE MESSAGE BELOW IN #NadekoLog SERVER PLEASE");
                _log.Warn(ex);
                State = GameState.Ended;
                var _ = GameEnded?.Invoke(this);
            }
        }
コード例 #52
0
ファイル: World.cs プロジェクト: po-omena/NR-CORE
        public virtual void LeaveWorld(Entity entity)
        {
            if (entity is Player)
            {
                Player dummy;
                Players.TryRemove(entity.Id, out dummy);
                PlayersCollision.Remove(entity);

                // if in trade, cancel it...
                if (dummy.tradeTarget != null)
                {
                    dummy.CancelTrade();
                }

                if (dummy.Pet != null)
                {
                    LeaveWorld(dummy.Pet);
                }
            }
            else if (entity is Enemy)
            {
                Enemy dummy;
                Enemies.TryRemove(entity.Id, out dummy);
                EnemiesCollision.Remove(entity);
                if (entity.ObjectDesc.Quest)
                {
                    Quests.TryRemove(entity.Id, out dummy);
                }
            }
            else if (entity is Projectile)
            {
                var p = entity as Projectile;
                Projectiles.TryRemove(new Tuple <int, byte>(p.ProjectileOwner.Self.Id, p.ProjectileId), out p);
            }
            else if (entity is StaticObject)
            {
                StaticObject dummy;
                StaticObjects.TryRemove(entity.Id, out dummy);

                if (entity.ObjectDesc?.BlocksSight == true)
                {
                    if (Blocking == 3)
                    {
                        Sight.UpdateRegion(Map, (int)entity.X, (int)entity.Y);
                    }

                    foreach (var plr in Players.Values
                             .Where(p => MathsUtils.DistSqr(p.X, p.Y, entity.X, entity.Y) < Player.RadiusSqr))
                    {
                        plr.Sight.UpdateCount++;
                    }
                }

                if (entity is Decoy)
                {
                    PlayersCollision.Remove(entity);
                }
                else
                {
                    EnemiesCollision.Remove(entity);
                }
            }
            else if (entity is Pet)
            {
                Pet dummy;
                Pets.TryRemove(entity.Id, out dummy);
                PlayersCollision.Remove(entity);
            }

            entity.Dispose();
        }
コード例 #53
0
 public void AddPlayer(int joystick, Color color)
 {
     Players.Add(new PlayerModel(joystick, color));
 }
コード例 #54
0
 public Player GetPlayerBySteamId(ulong steamId)
 {
     return(Players.FirstOrDefault(o => o.SteamId == steamId));
 }
コード例 #55
0
ファイル: Game.cs プロジェクト: Revenege/Durak
        /// <summary>
        /// AI gameplay logic
        /// </summary>
        /// <param name="AiPlayState"> Wether the AI attacks or defends</param>
        private void AiTurn(char AiPlayState)
        {
            //btnAccept.Enabled = false;
            if (AiPlayState == 'D')
            {
                if (defender.WinStatus == false)
                {
                    //Check if the AI is able to play
                    int playableCards = 0;
                    int selected      = 0;

                    for (int i = 0; i < defender.PlayHand.Count; i++)
                    {
                        if (defender.PlayHand[i] > game.Table.LastPlayed())
                        {
                            playableCards++;
                            selected = i;
                        }
                    }
                    //If they are, defend
                    if (playableCards > 0)
                    {
                        DisplayOutput(defender.Name + " Defends with " + defender.PlayHand[selected].ToString());
                        game.Defend(defender, defender.PlayHand[selected]);
                    }
                    else//Else pick up
                    {
                        DisplayOutput(defender.Name + " Was unable to defend");
                        game.TakeCards(defender);
                        Players.SkipTurn();
                    }

                    //Determine if someone won
                    game.DetermineWinner(attacker);
                    game.DetermineWinner(defender);
                    //Determine if the defender has won. Defender is always an AI
                    if (defender.WinStatus == true)
                    {
                        MessageBox.Show(defender.Name + " is Not the durak");
                    }
                    //Determine if the attacker has won.
                    if (attacker.WinStatus == true)
                    {
                        //If the Defender is an AI, display message. Otherwise, end the game
                        if (attacker.IsAi)
                        {
                            MessageBox.Show(attacker.Name + " is Not the durak");
                        }
                        else
                        {
                            MessageBox.Show("Congratulations, you are not the durak");
                            //this.Close();
                            Application.Exit();
                        }
                    }
                    //End the turn
                    EndTurn();
                }
                else//If the current player has already won
                {
                    //Move to the next defender
                    defender = Players.GetNextPlayer();
                    //If the defender is an AI, recursively call the function
                    if (defender.IsAi)
                    {
                        AiTurn('D');
                    }
                    else//Otherwise, Player defends
                    {
                        //btnAccept.Enabled = true;
                        DisplayOutput("You must Defend");
                        //lblTempOutput.Text = game.ShowHand(defender);
                        playState = 'D';
                    }
                }
            }
            else if (AiPlayState == 'A')//IF the Ai is attacking
            {
                //Check if they've won
                if (attacker.WinStatus == false)
                {
                    //If they haven't won, Play a card at random
                    int attackingCard = seed.Next(0, attacker.PlayHand.Count);
                    DisplayOutput(attacker.Name + " Plays " + attacker.PlayHand[attackingCard].ToString());
                    game.Attack(attacker, attacker.PlayHand[attackingCard]);
                    //advance the turn based on if its an Ai next
                    if (defender.IsAi)
                    {
                        AiTurn('D');
                    }
                    else
                    {
                        playState = 'D';
                        DisplayOutput("You must Defend2");
                        //lblTempOutput.Text = game.ShowHand(defender);
                        //btnAccept.Enabled = true;
                    }
                }
                else
                {
                    //If the attacker has already won, Advance the turn.
                    attacker = Players.GetNextPlayer();
                    defender = Players.PeakNextPlayer();
                    //Advance turn based on if its an Ai next
                    if (attacker.IsAi)
                    {
                        AiTurn('A');
                    }
                    else
                    {
                        //btnAccept.Enabled = true;
                        DisplayOutput("\nIt is now your turn");
                        //lblTempOutput.Text = game.ShowHand(attacker);
                        playState = 'A';
                    }
                }
            }
        }
コード例 #56
0
ファイル: DiceGame.cs プロジェクト: SeungsooKang/DiceGame
 public void SetNextPlayer()
 {
     _activePlayer = _activePlayer == null ? Players[0] : Players[(Players.IndexOf(_activePlayer) + 1) % Players.Count];
 }
コード例 #57
0
    public static void DrawPlayerESP()
    {
        if (LocalPlayer.Entity != null)
        {
            try
            {
                if (BasePlayer.VisiblePlayerList != null)
                {
                    foreach (BasePlayer player in BasePlayer.VisiblePlayerList)
                    {
                        if ((player != null) && (player.health > 0f) && !player.IsLocalPlayer())
                        {
                            Vector3 position     = player.transform.position;
                            Vector3 vector3      = MainCamera.mainCamera.WorldToScreenPoint(position);
                            int     distance     = (int)Vector3.Distance(MainCamera.mainCamera.transform.position, position);
                            Vector3 vector28     = MainCamera.mainCamera.WorldToScreenPoint(position + new Vector3(0f, 1.7f, 0f));
                            Vector3 vector288    = MainCamera.mainCamera.WorldToScreenPoint(position + new Vector3(0f, 1.2f, 0f));
                            Vector3 vector21     = MainCamera.mainCamera.WorldToScreenPoint(position);
                            Vector3 positionBone = player.FindBone("head").transform.position;
                            Vector3 screenPos    = Players.GetScreenPos(positionBone + new Vector3(0f, 0.3f, 0f));
                            float   num4         = Mathf.Abs(vector3.y - screenPos.y);
                            float   width        = num4 / 2f;
                            float   num145       = Mathf.Abs(vector21.y - vector28.y);
                            float   num1455      = Mathf.Abs(vector21.y - vector288.y);
                            if (CFG.Setting.adm)
                            {
                                if (player.IsAlive())
                                {
                                    //  VDraw.DrawLine(new Vector2(Screen.width / 2f, 0f), new Vector2(Position2DUP.x, Screen.height - Position2DUP.y), Color.red);
                                    Rendering.DrawString1(new Vector2(Screen.width / 2, 30f), string.Format("{0} {1}", "Админ ТУТ!!!", player.displayName), new Color32(255, 0, 0, 255), true, 13);
                                }
                            }
                            if (vector3.z > 1f)
                            {
                                int cameradistance = (int)Vector3.Distance(MainCamera.mainCamera.transform.position, position);
                                if (!player.IsSleeping() && player.health > 0f)
                                {
                                    if (cameradistance <= CFG.Setting.sdd)
                                    {
                                        if (CFG.Setting.players && player.userID > 1000000000UL)
                                        {
                                            if (!CFG.Setting.hp && !CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.DrawVerticalHealth(new Vector2(screenPos.x, Screen.height - screenPos.y), width, num4, player.health);
                                            }

                                            if (CFG.Setting.hp && !CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.Health11(screenPos.x, Screen.height - screenPos.y, player.health, 100, 45, 6, 1f);
                                            }

                                            if (CFG.Setting.hp && CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.Health11(screenPos.x, Screen.height - screenPos.y, player.health, 100, 45, 6, 1f);
                                            }

                                            if (!CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y), string.Format("{0} [{1}]", player.displayName, distance), PlayerColor, true, 8);
                                            }

                                            if (CFG.Setting.friendsList.Contains(player.userID) && CFG.Setting.hp)
                                            {
                                                Rendering.Health11(screenPos.x, Screen.height - screenPos.y, player.health, 100, 45, 6, 1f);
                                            }

                                            if (CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y), string.Format((menu.enru ? "Friend [{1}]" : "Друг [{1}]"), player.displayName, distance), Color.green, true, 8);
                                            }
                                        }

                                        if (CFG.Setting.dgdg && player.userID > 1000000000UL)
                                        {
                                            if (!player.IsWounded() && !player.IsDucked() && !CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.CornerBox(new Vector2(vector28.x, Screen.height - vector28.y), num145 / 2.5f, num145, 3f, PlayerColor, false);
                                            }

                                            if (!player.IsWounded() && player.IsDucked() && !CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.CornerBox(new Vector2(vector288.x, Screen.height - vector288.y), num1455 / 2.5f, num1455, 3f, PlayerColor, false);
                                            }

                                            if (player.IsWounded() && !CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.CornerBox(new Vector2(vector288.x, Screen.height - vector288.y), num1455 / 2.5f, num1455, 3f, PlayerColor, false);
                                            }

                                            //      if (player.userID.ToString() == "76561198810444875" || player.userID.ToString() == "76561198974039542")
                                            //   Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y - -10f), string.Format("{0}", "Hostile"), new Color32(255, 0, 0, 255), true, 8);
                                        }

                                        if (vector3.z > 2f && CFG.Setting.boneESP && player.IsAlive() && !CFG.Setting.friendsList.Contains(player.userID) && player.userID > 1000000000UL)
                                        {
                                            Vector3[] bonePositions = player.GetBonePositions();
                                            Vector2[] array         = new Vector2[16];
                                            for (int i = 0; i < bonePositions.Length; i++)
                                            {
                                                Vector2 vector4 = MainCamera.mainCamera.WorldToScreenPoint(bonePositions[i]);
                                                array[i] = new Vector2(vector4.x, Screen.height - vector4.y);
                                            }
                                            Rendering.DrawLine(array[0], array[1], CFG.Setting.skele);
                                            Rendering.DrawLine(array[1], array[2], CFG.Setting.skele);
                                            Rendering.DrawLine(array[2], array[3], CFG.Setting.skele);
                                            Rendering.DrawLine(array[1], array[4], CFG.Setting.skele);
                                            Rendering.DrawLine(array[1], array[7], CFG.Setting.skele);
                                            Rendering.DrawLine(array[4], array[5], CFG.Setting.skele);
                                            Rendering.DrawLine(array[7], array[8], CFG.Setting.skele);
                                            Rendering.DrawLine(array[5], array[6], CFG.Setting.skele);
                                            Rendering.DrawLine(array[8], array[9], CFG.Setting.skele);
                                            Rendering.DrawLine(array[3], array[10], CFG.Setting.skele);
                                            Rendering.DrawLine(array[3], array[13], CFG.Setting.skele);
                                            Rendering.DrawLine(array[10], array[11], CFG.Setting.skele);
                                            Rendering.DrawLine(array[13], array[14], CFG.Setting.skele);
                                            Rendering.DrawLine(array[11], array[12], CFG.Setting.skele);
                                            Rendering.DrawLine(array[14], array[15], CFG.Setting.skele);
                                        }
                                        if (vector3.z > 2f && CFG.Setting.boneESP && player.IsAlive() && CFG.Setting.friendsList.Contains(player.userID) && player.userID > 1000000000UL)
                                        {
                                            Vector3[] bonePositions = player.GetBonePositions();
                                            Vector2[] array         = new Vector2[16];
                                            for (int i = 0; i < bonePositions.Length; i++)
                                            {
                                                Vector2 vector4 = MainCamera.mainCamera.WorldToScreenPoint(bonePositions[i]);
                                                array[i] = new Vector2(vector4.x, Screen.height - vector4.y);
                                            }
                                            Rendering.DrawLine11(array[0], array[1], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[1], array[2], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[2], array[3], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[1], array[4], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[1], array[7], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[4], array[5], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[7], array[8], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[5], array[6], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[8], array[9], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[3], array[10], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[3], array[13], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[10], array[11], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[13], array[14], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[11], array[12], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[14], array[15], CFG.Setting.skele);
                                        }
                                        if (vector3.z > 2f && CFG.Setting.boneESP && player.IsAlive() && player.userID < 1000000000UL && !CFG.Setting.friendsList.Contains(player.userID))
                                        {
                                            Vector3[] bonePositions = player.GetBonePositions();
                                            Vector2[] array         = new Vector2[16];
                                            for (int i = 0; i < bonePositions.Length; i++)
                                            {
                                                Vector2 vector4 = MainCamera.mainCamera.WorldToScreenPoint(bonePositions[i]);
                                                array[i] = new Vector2(vector4.x, Screen.height - vector4.y);
                                            }
                                            Rendering.DrawLine1(array[0], array[1], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[1], array[2], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[2], array[3], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[1], array[4], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[1], array[7], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[4], array[5], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[7], array[8], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[5], array[6], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[8], array[9], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[3], array[10], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[3], array[13], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[10], array[11], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[13], array[14], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[11], array[12], CFG.Setting.skele);
                                            Rendering.DrawLine1(array[14], array[15], CFG.Setting.skele);
                                        }
                                        if (vector3.z > 2f && CFG.Setting.boneESP && player.IsAlive() && player.userID < 1000000000UL && CFG.Setting.friendsList.Contains(player.userID))
                                        {
                                            Vector3[] bonePositions = player.GetBonePositions();
                                            Vector2[] array         = new Vector2[16];
                                            for (int i = 0; i < bonePositions.Length; i++)
                                            {
                                                Vector2 vector4 = MainCamera.mainCamera.WorldToScreenPoint(bonePositions[i]);
                                                array[i] = new Vector2(vector4.x, Screen.height - vector4.y);
                                            }
                                            Rendering.DrawLine11(array[0], array[1], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[1], array[2], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[2], array[3], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[1], array[4], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[1], array[7], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[4], array[5], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[7], array[8], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[5], array[6], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[8], array[9], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[3], array[10], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[3], array[13], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[10], array[11], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[13], array[14], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[11], array[12], CFG.Setting.skele);
                                            Rendering.DrawLine11(array[14], array[15], CFG.Setting.skele);
                                        }
                                        if (CFG.Setting.gggf && player.userID > 1000000000UL)
                                        {
                                            if (!player.IsWounded() && !CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y - -10f), (player.GetHeldEntity() != null) ? (menu.enru ? player.GetHeldEntity().GetItem().info.displayName.english : traah.Translate(player.GetHeldEntity().GetItem().info.displayName.english)) : "", PlayerColor, true, 8);
                                            }

                                            if (player.IsWounded() && !CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y - -10f), string.Format("{0}", (menu.enru ? "Wounded" : "ЛЕЖИТ")), new Color32(255, 0, 0, 255), true, 8);
                                            }

                                            Color32 newColourRange = new Color32((byte)UnityEngine.Random.Range(0, 255), (byte)UnityEngine.Random.Range(0, 255), (byte)UnityEngine.Random.Range(0, 255), 255);

                                            if (player.IsWounded() && CFG.Setting.friendsList.Contains(player.userID))
                                            {
                                                Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y - -10f), string.Format("{0}", (menu.enru ? "WOUNDED F****R" : "ПРИЛЁГ ДАЛБАЁБ")), randomColor, true, 8);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (cameradistance <= CFG.Setting.sdd)
                                    {
                                        if (player.IsSleeping() && CFG.Setting.fdf)
                                        {
                                            Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y), string.Format("{0} [{1}]", player.displayName, distance), new Color32(0, 62, 179, 255), true, 8);
                                        }
                                    }
                                }

                                if (CFG.Setting.vbvc)
                                {
                                    if (cameradistance <= CFG.Setting.sdd && player.userID < 1000000000UL)
                                    {
                                        Rendering.DrawVerticalHealth(new Vector2(screenPos.x, Screen.height - screenPos.y), width, num4, player.health);

                                        Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y), string.Format("{0} [{1}]", "NPC", distance), Color.blue, true, 8);
                                        if (!player.IsWounded() && !CFG.Setting.friendsList.Contains(player.userID))
                                        {
                                            Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y - -10f), (player.GetHeldEntity() != null) ? (menu.enru ? player.GetHeldEntity().GetItem().info.displayName.english : traah.Translate(player.GetHeldEntity().GetItem().info.displayName.english)) : "", PlayerColor, true, 8);
                                        }

                                        if (player.IsWounded() && !CFG.Setting.friendsList.Contains(player.userID))
                                        {
                                            Rendering.DrawString1(new Vector2(vector3.x, Screen.height - vector3.y - -10f), string.Format("{0}", (menu.enru ? "Wounded" : "ЛЕЖИТ")), new Color32(255, 0, 0, 255), true, 8);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (CFG.Setting.gggg)
                    {
                        BasePlayer bb   = null;
                        float      gggg = 999f;
                        if (BasePlayer.VisiblePlayerList != null)
                        {
                            foreach (BasePlayer ffff in BasePlayer.VisiblePlayerList)
                            {
                                {
                                    Vector3 vector = MainCamera.mainCamera.WorldToScreenPoint(ffff.transform.position + new Vector3(0f, 1.7f, 0f));
                                    float   num2   = Mathf.Abs(Vector2.Distance(new Vector2(Screen.width / 2, Screen.height / 2), new Vector2(vector.x, Screen.height - vector.y)));
                                    if (num2 <= CFG.Setting.fov1 && num2 < gggg)
                                    {
                                        gggg = num2;
                                        bb   = ffff;
                                    }
                                }
                            }
                        }
                        if (bb != null && !bb.IsDead() && !bb.IsSleeping() && !bb.IsLocalPlayer() && !CFG.Setting.friendsList.Contains(bb.userID))
                        {
                            int     dist      = (int)Vector3.Distance(MainCamera.mainCamera.transform.position, bb.transform.position);
                            Vector3 vector    = MainCamera.mainCamera.WorldToScreenPoint(bb.transform.position);
                            Vector3 screenPos = Players.GetScreenPos(bb.transform.position);
                            if (screenPos.z > 0f && dist <= CFG.Setting.sdd)
                            {
                                Rendering.DrawString1(new Vector2(screenPos.x, Screen.height - screenPos.y - +15f), string.Format("{0}", (menu.enru ? "TARGET" : "ЦЕЛЬ")), Color.green, true, 8);
                            }
                        }
                    }

                    BasePlayer gg = null;
                    float      rr = 999f;
                    if (BasePlayer.VisiblePlayerList != null)
                    {
                        foreach (BasePlayer ffff in BasePlayer.VisiblePlayerList)
                        {
                            {
                                Vector3 vector = MainCamera.mainCamera.WorldToScreenPoint(ffff.transform.position + new Vector3(0f, 1.7f, 0f));
                                float   num2   = Mathf.Abs(Vector2.Distance(new Vector2(Screen.width / 2, Screen.height / 2), new Vector2(vector.x, Screen.height - vector.y)));
                                if (num2 <= CFG.Setting.fov1 && num2 < rr)
                                {
                                    nameTargetKILL = ffff.displayName;
                                    rr             = num2;
                                    gg             = ffff;
                                }
                            }
                        }
                    }
                    if (gg != null && !gg.IsDead() && !gg.IsSleeping() && !gg.IsLocalPlayer() && !CFG.Setting.friendsList.Contains(gg.userID))
                    {
                        Vector3 positionBone = Players.GetPositionBone(gg.GetModel(), "head");
                        bool    flag6        = !(positionBone == Vector3.zero) || !CFG.Setting.greg;
                        if (flag6)
                        {
                            Vector3 screenPos = Players.GetScreenPos(positionBone + new Vector3(0f, 0f, 0f));
                            bool    flag7     = screenPos.z > 3f && CFG.Setting.greg;
                            if (flag7)
                            {
                                GUI.color = Color.white;
                                draw.DrawString1(new Vector2(Screen.width / 2f, Screen.height / 1.89f), string.Format("<b>[{0}]</b>", nameTargetKILL), Color.green, false, 12, FontStyle.Bold);
                                draw.DrawLine(new Vector2(Screen.width / 2f, Screen.height / 2f), new Vector2(screenPos.x + 0f, Screen.height - screenPos.y + 0f), 1f);
                            }
                        }
                    }


                    BasePlayer basePlayer = null;
                    float      num        = 999f;
                    if (BasePlayer.VisiblePlayerList != null)
                    {
                        foreach (BasePlayer basePlayer2 in BasePlayer.VisiblePlayerList)
                        {
                            {
                                Vector3 vector = MainCamera.mainCamera.WorldToScreenPoint(basePlayer2.transform.position + new Vector3(0f, 1.7f, 0f));
                                float   num2   = Mathf.Abs(Vector2.Distance(new Vector2(Screen.width / 2, Screen.height / 2), new Vector2(vector.x, Screen.height - vector.y)));
                                if (num2 <= CFG.Setting.fov && num2 < num)
                                {
                                    num        = num2;
                                    basePlayer = basePlayer2;
                                }
                            }
                        }
                    }
                    if (basePlayer != null && !basePlayer.IsDead() && !basePlayer.IsSleeping() && !basePlayer.IsLocalPlayer())
                    {
                        Vector3 screenPos = Players.GetScreenPos(basePlayer.transform.position);
                        if (screenPos.z > 0f && CFG.Setting.Cloth)
                        {
                            List <Item> list = new List <Item>();
                            list = basePlayer.inventory.containerWear.itemList;

                            GUI.DrawTexture(new Rect((float)Screen.width - 470, 60f, 200f, 35f + list.Count * 13), HukTexture.mTe2x1);
                            Rendering.DrawString1(new Vector2((float)Screen.width - 370, 70f), (menu.enru ? "[Clothing]" : "[Одежда]"), new Color32(12, 155, 171, 255), true, 10, FontStyle.Bold, 1);
                            for (int i = 0; i < list.Count; i++)
                            {
                                Rendering.DrawString1(new Vector2((float)Screen.width - 370, 70f + (i + 1) * 13), (menu.enru ? list[i].info.displayName.english : traah.Translate(list[i].info.displayName.english)), new Color32(255, 145, 0, 255), true, 10, FontStyle.Bold, 1);
                            }
                        }

                        if (screenPos.z > 0f && menu.tt)
                        {
                            List <Item> list = new List <Item>();
                            list = basePlayer.inventory.containerMain.itemList;
                            for (int i = 0; i < list.Count; i++)
                            {
                                Rendering.DrawString1(new Vector2(Screen.width - 150f, 60f), "Инвентарь", new Color32(12, 155, 171, 255), false, 10, FontStyle.Bold, 1);
                                Rendering.DrawString1(new Vector2((float)Screen.width - 150, 70f + (i + 1) * 16), traah.Translate(list[i].info.displayName.english), Color.green, true, 10, FontStyle.Bold, 1);
                            }
                        }
                        if (screenPos.z > 0f && CFG.Setting.bb)
                        {
                            Item[] array = basePlayer.inventory.AllItems();
                            Rect   rect  = new Rect(Screen.width - 250f, 60f, 200f, 35f + array.Length * 16);
                            GUI.DrawTexture(new Rect(Screen.width - 268f, 60f, 200f, 35f + array.Length * 16), HukTexture.mTex1);
                            if (basePlayer.IsWounded())
                            {
                                Rendering.DrawString1(new Vector2((float)Screen.width - 175, 70f), string.Format("{0}", (menu.enru ? "[Wounded]" : "[ЛЕЖИТ]")), new Color32(255, 0, 0, 255), true, 10, FontStyle.Bold, 1);
                            }
                            Rendering.DrawString1(new Vector2(Screen.width - 240f, 70f), "[" + (int)basePlayer.health + "HP] ", new Color32(45, 186, 2, 255), false, 10, FontStyle.Bold, 1);
                            Rendering.DrawString1(new Vector2(Screen.width - 240f, 60f), basePlayer.displayName, new Color32(12, 155, 171, 255), false, 10, FontStyle.Bold, 1);
                            for (int i = 0; i < array.Length; i++)
                            {
                                Texture2D texture = array[i].info.iconSprite.texture;
                                if (array[i] != null)
                                {
                                    Rendering.DrawString1(new Vector2(Screen.width - 240f, 70f + (i + 1) * 16), "[" + array[i].amount.ToString() + "x] " + (menu.enru ? array[i].info.displayName.english : traah.Translate(array[i].info.displayName.english)), new Color32(255, 255, 255, 255), false, 10, FontStyle.Bold, 1);
                                }
                                GUI.DrawTexture(new Rect(Screen.width - 260f, 70f + (i + 1) * 16f, 16f, 16f), texture);
                            }
                        }
                    }
                    if (CFG.Setting.hot)
                    {
                        BasePlayer ff  = null;
                        float      fff = 999f;
                        if (BasePlayer.VisiblePlayerList != null)
                        {
                            foreach (BasePlayer ffff in BasePlayer.VisiblePlayerList)
                            {
                                {
                                    Vector3 vector = MainCamera.mainCamera.WorldToScreenPoint(ffff.transform.position + new Vector3(0f, 1.7f, 0f));
                                    float   num2   = Mathf.Abs(Vector2.Distance(new Vector2(Screen.width / 2, Screen.height / 2), new Vector2(vector.x, Screen.height - vector.y)));
                                    if (num2 <= CFG.Setting.fov && num2 < fff)
                                    {
                                        fff = num2;
                                        ff  = ffff;
                                    }
                                }
                            }
                        }
                        if (ff != null && !ff.IsDead() && !ff.IsSleeping() && !ff.IsLocalPlayer())
                        {
                            Vector3 f = Players.GetScreenPos(ff.transform.position);

                            int     dist      = (int)Vector3.Distance(MainCamera.mainCamera.transform.position, ff.transform.position);
                            Vector3 vector    = MainCamera.mainCamera.WorldToScreenPoint(ff.transform.position);
                            Vector3 screenPos = Players.GetScreenPos(ff.transform.position);
                            if (screenPos.z > 0f && dist <= CFG.Setting.sdd && !ff.IsWounded())
                            {
                                List <Item> list = new List <Item>();
                                list = ff.inventory.containerBelt.itemList;
                                GUI.DrawTexture(new Rect(screenPos.x, Screen.height - screenPos.y - -22f, - -60f, +(list.Count * 11)), HukTexture.mTex1);
                                GUI.DrawTexture(new Rect(screenPos.x, Screen.height - screenPos.y - -22f, -60f, +(list.Count * 11)), HukTexture.mTex1);
                                for (int i = 0; i < list.Count; i++)
                                {
                                    Rendering.DrawString1(new Vector3(screenPos.x, Screen.height - screenPos.y - -10f + (i + 1) * 10), (menu.enru ? list[i].info.displayName.english : traah.Translate(list[i].info.displayName.english)), new Color32(255, 145, 0, 255), true, 8, FontStyle.Bold, 1);
                                }
                            }
                        }
                    }
                }
            }

            catch (NullReferenceException)
            {
            }
        }
    }
コード例 #58
0
        /// <summary>
        /// Handles the user's click on the "Launch Game" / "I'm Ready" button.
        /// If the local player is the game host, checks if the game can be launched and then
        /// launches the game if it's allowed. If the local player isn't the game host,
        /// sends a ready request.
        /// </summary>
        protected override void BtnLaunchGame_LeftClick(object sender, EventArgs e)
        {
            if (!IsHost)
            {
                RequestReadyStatus();
                return;
            }

            if (!Locked)
            {
                LockGameNotification();
                return;
            }

            List <int> occupiedColorIds = new List <int>();

            foreach (PlayerInfo player in Players)
            {
                if (occupiedColorIds.Contains(player.ColorId) && player.ColorId > 0)
                {
                    SharedColorsNotification();
                    return;
                }

                occupiedColorIds.Add(player.ColorId);
            }

            if (AIPlayers.Count(pInfo => pInfo.SideId == ddPlayerSides[0].Items.Count - 1) > 0)
            {
                AISpectatorsNotification();
                return;
            }

            if (Map.EnforceMaxPlayers)
            {
                foreach (PlayerInfo pInfo in Players)
                {
                    if (pInfo.StartingLocation == 0)
                    {
                        continue;
                    }

                    if (Players.Concat(AIPlayers).ToList().Find(
                            p => p.StartingLocation == pInfo.StartingLocation &&
                            p.Name != pInfo.Name) != null)
                    {
                        SharedStartingLocationNotification();
                        return;
                    }
                }

                for (int aiId = 0; aiId < AIPlayers.Count; aiId++)
                {
                    int startingLocation = AIPlayers[aiId].StartingLocation;

                    if (startingLocation == 0)
                    {
                        continue;
                    }

                    int index = AIPlayers.FindIndex(aip => aip.StartingLocation == startingLocation);

                    if (index > -1 && index != aiId)
                    {
                        SharedStartingLocationNotification();
                        return;
                    }
                }

                int totalPlayerCount = Players.Count(p => p.SideId < ddPlayerSides[0].Items.Count - 1)
                                       + AIPlayers.Count;

                if (totalPlayerCount < Map.MinPlayers)
                {
                    InsufficientPlayersNotification();
                    return;
                }

                if (Map.EnforceMaxPlayers && totalPlayerCount > Map.MaxPlayers)
                {
                    TooManyPlayersNotification();
                    return;
                }
            }

            int iId = 0;

            foreach (PlayerInfo player in Players)
            {
                iId++;

                if (player.Name == ProgramConstants.PLAYERNAME)
                {
                    continue;
                }

                if (!player.Verified)
                {
                    NotVerifiedNotification(iId - 1);
                    return;
                }

                if (!player.Ready)
                {
                    if (player.IsInGame)
                    {
                        StillInGameNotification(iId - 1);
                    }
                    else
                    {
                        GetReadyNotification();
                    }

                    return;
                }
            }

            HostLaunchGame();
        }
コード例 #59
0
        private void HandlePlayerOptionsBroadcast(string data)
        {
            if (IsHost)
            {
                return;
            }

            string[] parts = data.Split(ProgramConstants.LAN_DATA_SEPARATOR);

            int playerCount = parts.Length / 8;

            if (parts.Length != playerCount * 8)
            {
                return;
            }

            PlayerInfo localPlayer = FindLocalPlayer();
            int        oldSideId   = localPlayer == null ? -1 : localPlayer.SideId;

            Players.Clear();
            AIPlayers.Clear();

            for (int i = 0; i < playerCount; i++)
            {
                int baseIndex = i * 8;

                string name        = parts[baseIndex];
                int    side        = Conversions.IntFromString(parts[baseIndex + 1], -1);
                int    color       = Conversions.IntFromString(parts[baseIndex + 2], -1);
                int    start       = Conversions.IntFromString(parts[baseIndex + 3], -1);
                int    team        = Conversions.IntFromString(parts[baseIndex + 4], -1);
                int    readyStatus = Conversions.IntFromString(parts[baseIndex + 5], -1);
                string ipAddress   = parts[baseIndex + 6];
                int    aiLevel     = Conversions.IntFromString(parts[baseIndex + 7], -1);

                if (side < 0 || side > SideCount + RandomSelectorCount)
                {
                    return;
                }

                if (color < 0 || color > MPColors.Count)
                {
                    return;
                }

                if (start < 0 || start > MAX_PLAYER_COUNT)
                {
                    return;
                }

                if (team < 0 || team > 4)
                {
                    return;
                }

                if (ipAddress == "127.0.0.1")
                {
                    ipAddress = hostEndPoint.Address.ToString();
                }

                bool isAi = aiLevel > -1;
                if (aiLevel > 2)
                {
                    return;
                }

                PlayerInfo pInfo;

                if (!isAi)
                {
                    pInfo      = new LANPlayerInfo(encoding);
                    pInfo.Name = name;
                    Players.Add(pInfo);
                }
                else
                {
                    pInfo         = new PlayerInfo();
                    pInfo.Name    = AILevelToName(aiLevel);
                    pInfo.IsAI    = true;
                    pInfo.AILevel = aiLevel;
                    AIPlayers.Add(pInfo);
                }

                pInfo.SideId           = side;
                pInfo.ColorId          = color;
                pInfo.StartingLocation = start;
                pInfo.TeamId           = team;
                pInfo.Ready            = readyStatus > 0;
                pInfo.AutoReady        = readyStatus > 1;
                pInfo.IPAddress        = ipAddress;
            }

            CopyPlayerDataToUI();
            localPlayer = FindLocalPlayer();
            if (localPlayer != null && oldSideId != localPlayer.SideId)
            {
                UpdateDiscordPresence();
            }
        }
コード例 #60
0
        private void InitializePlayer(Player player)
        {
            player.DrawNewHand(GameDeck);

            Players.Add(player);
        }