/// <summary>
		/// Parsuje wiadomość.
		/// </summary>
		/// <param name="msg">Wiadomość.</param>
		public PlayerAccepted(Message msg)
		{
			if (msg.Type != (MessageType)GameMessageType.PlayerAccepted)
			{
				throw new InvalidCastException("Cannot convert this message to PlayerAccepted");
			}
			BinarySerializer s = new BinarySerializer(msg.Data);
			this.UserId = s.GetUInt32();
			this.InGame = s.GetBool();

			ushort players = s.GetUInt16();
			this.Players = new List<IPlayerData>();
			for (int i = 0; i < players; i++)
			{
				var player = new Player.PlayerData(s.GetUInt32());
				player.Nick = s.GetString();
				player.InGame = s.GetBool();
				this.Players.Add(player);
			}

			ushort nations = s.GetUInt16();
			this.AvailableNations = new List<string>();
			for (int i = 0; i < nations; i++)
			{
				this.AvailableNations.Add(s.GetString());
			}
		}
Example #2
0
        //Insert Player
        public static void InsertPlayer(Player.PlayerData oPlayer)
        {
            using (IDbConnection oSql = DatabaseHelper.CreateSqlConnection())
            {
                DynamicParameters oParameters = new DynamicParameters();
                oParameters.Add("@in_SleeperId", oPlayer.SleeperId, DbType.Int64, ParameterDirection.Input);
                oParameters.Add("@in_FirstName", oPlayer.FirstName, DbType.String, ParameterDirection.Input);
                oParameters.Add("@in_LastName", oPlayer.LastName, DbType.String, ParameterDirection.Input);
                oParameters.Add("@in_Team", oPlayer.Team, DbType.String, ParameterDirection.Input);
                oParameters.Add("@in_Position", oPlayer.Position, DbType.String, ParameterDirection.Input);

                oSql.Execute("Fantasy_InsertPlayer", oParameters, commandType: CommandType.StoredProcedure);
            }
        }
Example #3
0
        void OnEnable()
        {
            if (boundTo.CheckSlot(managedSlot))
            {
                Destroy(pixelParent);
                pixelParent = new GameObject("Pixel Parent");
                pixelParent.transform.SetParent(transform, false);
                pixelParent.transform.SetAsLastSibling();

                Battle.BattleData data = boundTo.saveSlotContents[managedSlot];
                for (int player = 0; player < 2; player++)
                {
                    Player.PlayerData playerData = player == 0 ? data.attacker : data.defender;
                    float[,,] flag = playerData.flag;
                    Vector2 beginningPos = (player == 0 ? Vector2.one * (pixelSide / 2.0f + 20) : new Vector2((640 - pixelSide / 2.0f) - pixelSide * flag.GetLength(0), pixelSide / 2.0f + 20)) - new Vector2(320, 80);
                    for (int x = 0; x < flag.GetLength(0); x++)
                    {
                        for (int y = 0; y < flag.GetLength(1); y++)
                        {
                            Color      color = new Color(flag[x, y, 0], flag[x, y, 1], flag[x, y, 2]);
                            GameObject pixel = Instantiate(pixelPrefab);
                            pixel.transform.SetParent(pixelParent.transform, false);
                            pixel.transform.localPosition = beginningPos + new Vector2(x, y) * pixelSide;

                            pixel.GetComponent <RawImage>().color = color;
                        }
                    }
                }
                clearButton.gameObject.SetActive(true);
                label.text = usedMessage;
            }
            else
            {
                label.text = emptyMessage;
                clearButton.gameObject.SetActive(false);
            }
        }
Example #4
0
		public PlayerActivityEventArgs(Player.PlayerData pData)
		{
			this.PlayerData = pData;
		}
Example #5
0
        /// <summary>
        /// Constructor for the WorldViewScreen
        /// </summary>
        public WorldViewScreen(Game game, ScreenElement previousScreenElement) :
            base(previousScreenElement, game.GraphicsDevice)
        {
            this.content = game.Content;
            this.game    = game;

            // Set seed to build world with
            int mapSeed = 123;

            Noise.Simplex.Seed(mapSeed);

            // Load graphics resources/assets
            boxRenderer = new BoundingBoxRenderer(graphicsDevice);

            voxelEffect   = content.Load <Effect>("Effects/voxel");
            skydomeEffect = content.Load <Effect>("Effects/skydome");

            // Load initial data for the voxel sprite
            VoxelCache voxelCache = new VoxelCache(mapSeed, 32, 128);

            playerSprite = new VoxelSprite(graphicsDevice);
            playerSprite.Load(voxelCache, "chr_knight");

            // Attempt to load player save data
            gameData = new GameData();

            if (gameData.LoadGame(mapSeed))
            {
                player = new Player(playerSprite.Mesh, gameData.Player);
            }
            else
            {
                Player.PlayerData data = new Player.PlayerData()
                {
                    position    = new Vector3(200, 50, -20),
                    orientation = 0
                };
                player = new Player(playerSprite.Mesh, data);
            }

            // Set up voxel chunks and skydome
            chunkManager = new ChunkManager(graphicsDevice, 123);
            chunkManager.Initialize(graphicsDevice, player.playerData.position);
            skydome = new Skydome(graphicsDevice, content);

            // Set up cameras
            playerCamera  = new PlayerCamera(Vector3.Zero, Vector2.Zero);
            skydomeCamera = new PlayerCamera(Vector3.Zero, Vector2.Zero);

            InitializeGraphicsResources();

            // Set debug info
            debugStats = new DebugStats
            {
                vertexCount = this.vertexCount,
                cameraPos   = this.playerCamera.position,
                chunksAdded = this.chunkManager.ChunksAdded
            };

            // Testing console commands
            GUI.EntitySpawner spawner = new GUI.EntitySpawner();
            console.Command("test");

            // Set some non-standard effect parameters here
            Color skyColor = new Color(0.091f, 0.622f, 0.976f);

            voxelEffect.Parameters["skyColor"].SetValue(skyColor.ToVector3());
            voxelEffect.Parameters["skyTexture"].SetValue(skydome.Skymap);
            voxelEffect.Parameters["toggleColors"].SetValue(toggleColors);

            // Manage resources that need to be reset when graphics device is lost
            game.GraphicsDevice.DeviceReset += new EventHandler <EventArgs>(OnDeviceReset);

            // Add children screen with these stats
            children.Add(new ScreenElements.DebugViewScreen(this, content, graphicsDevice, debugStats, game));
        }
		/// <summary>
		/// Obsługa nowych i rozłączonych klientów.
		/// </summary>
		private void ProcessClients(double delta)
		{
			this.Server.Clients.RWLock.EnterUpgradeableReadLock();
			for (int i = 0; i < this.Server.Clients.Count; i++)
			{
				var client = this.Server.Clients[i];
				if (client.Status != ClientStatus.Ok && client.Status != ClientStatus.Welcome)
				{
					this.Server.Clients.RemoveAt(i--);
					if (client.UserData != null) //Zabezpiecza przed ewentualnym rozłączeniem się użytkownika przed
					{
						if (this.InGame && (client.UserData as Player.PlayerData).InGame)
						{
							//TODO: zakończenie gry
						}

						this.Server.Clients.SendToAll(new Messages.PlayerDisconnected(
							(client.UserData as IPlayerData).UserId, (DisconnectionReason)client.Status
							).ToMessage());
					}
				}
				else if (client.UserData == null && client.Messages.Contains((MessageType)GameMessageType.PlayersFirstConfiguration))
				{
					//Rozpakowanie pierwszej wiadomości
					var msg = new Messages.PlayersFirstConfiguration(client.Messages.GetFirst((MessageType)GameMessageType.PlayersFirstConfiguration));
					var userData = new Player.PlayerData(this.NextUserId++);
					userData.InGame = false;
					userData.Nick = msg.Nick;
					userData.Nation = this.UserData.Nations[0];

					List<string> availableNations = new List<string>();
					foreach (var item in msg.Nations)
					{
						int nationIdx = this.UserData.Nations.FindIndex(n => n.Name.ToLower() == item.Key.ToLower());
						if (this.UserData.NationsCheckSums[nationIdx].SequenceEqual(item.Value))
						{
							availableNations.Add(item.Key);
						}
					}

					var accepted = new Messages.PlayerAccepted(userData.UserId, false, availableNations);
					for (int j = 0; j < this.Server.Clients.Count; j++)
					{
						if (this.Server.Clients[j].UserData != null)
						{
							accepted.Players.Add(this.Server.Clients[j].UserData as IPlayerData);
						}
					}
					client.Send(accepted.ToMessage());
					this.Server.Clients.SendToAll(new Messages.PlayerConnected(userData.UserId, userData.Nick).ToMessage(),
						c => c != client);
					client.UserData = userData;
				}
			}
			this.Server.Clients.RWLock.ExitUpgradeableReadLock();
		}
Example #7
0
 public PlayerActivityEventArgs(Player.PlayerData pData)
 {
     this.PlayerData = pData;
 }