Beispiel #1
0
        /// <summary>
        /// Syncs other players that are connected to the server
        /// </summary>
        /// <param name="identifier"></param>
        /// <param name="username"></param>
        /// <param name="?"></param>
        public void SyncPlayer(short identifier, string username, byte team, float posX, float posY,
                               float rot, byte weapon, byte state)
        {
            ClientPlayer player = Players.Find(ply => ply.Identifier == identifier);

            // If the player doesn't currently exist, set up the data and add it to the list
            if (player == null)
            {
                player = new ClientPlayer(username, identifier, driver.Assets);
                player.SetPosition(new Vector2(posX, posY));
                player.SetRotation(rot);
                player.SetCurrentWeapon(WeaponData.ByteToWeapon(weapon));
                player.SetTeam(team);
                player.SetState(state);
                Players.Add(player);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Damages a player
        /// </summary>
        /// <param name="identifier"></param>
        /// <param name="health"></param>
        /// <param name="armor"></param>
        public void Damage(short identifier, int health, int armor)
        {
            ClientPlayer player = Players.Find(ply => ply.Identifier == identifier);

            // Play sound if the player's health isn't the same (they were damaged)
            if (player.Health != health)
            {
                PlaySound(player, "hit2");
            }

            // If they died. Set their state to dead and play a sound
            if (health <= 0)
            {
                player.SetHealth(0);
                player.SetArmor(0);
                player.SetState(ServerClientInterface.DEAD);
                PlaySound(player, "death4");
            }
            else
            {
                player.SetHealth(health);
                player.SetArmor(armor);
            }
        }