Ejemplo n.º 1
0
        /// <summary>
        /// Notifies a group of players of a player kill
        /// </summary>
        static public void Player_RouteKill(
            IEnumerable <Player> p, CS_VehicleDeath death, Player dead,
            int cash, int points, int personalPoints, int experience)
        {               //Prepare a death packet
            SC_VehicleDeath not = new SC_VehicleDeath();

            not.type = death.type;

            not.playerID  = dead._id;
            not.vehicleID = (dead._occupiedVehicle == null ? dead._id : dead._occupiedVehicle._id);
            not.killerID  = death.killerPlayerID;
            not.positionX = death.positionX;
            not.positionY = death.positionY;
            not.yaw       = dead._state.yaw;

            not.points         = (short)points;
            not.personalCash   = (short)cash;
            not.personalPoints = (short)personalPoints;
            not.personalExp    = (short)experience;

            //Send it to each player
            foreach (Player player in p)
            {
                player._client.sendReliable(not);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new packet based on the typeID and the received content
        /// inside the buffer. The user has to create an own implementation
        /// of this interface.
        /// </summary>
        public PacketBase createPacket(NetworkClient client, ushort typeID, byte[] buffer, int offset, int size)
        {               //Ready our packet base
            PacketBase packet = null;

            size--;

            //Was it a system packet?
            if (buffer[offset++] == 0)
            {
                //Yes, find the appropriate type
                return(createSystemPacket(typeID, buffer, offset, size));
            }

            //So what was the typeid?
            switch (typeID)
            {
            case CS_Login.TypeID:
                packet = new CS_Login(typeID, buffer, offset, size);
                break;

            case CS_ArenaJoin.TypeID:
                packet = new CS_ArenaJoin(typeID, buffer, offset, size);
                break;

            case CS_PlayerJoin.TypeID:
                packet = new CS_PlayerJoin(typeID, buffer, offset, size);
                break;

            case CS_Ready.TypeID:
                packet = new CS_Ready(typeID, buffer, offset, size);
                break;

            case CS_PlayerPickup.TypeID:
                packet = new CS_PlayerPickup(typeID, buffer, offset, size);
                break;

            case CS_PlayerDrop.TypeID:
                packet = new CS_PlayerDrop(typeID, buffer, offset, size);
                break;

            case CS_Chat.TypeID:
                packet = new CS_Chat(typeID, buffer, offset, size);
                break;

            case CS_PlayerUseItem.TypeID:
                packet = new CS_PlayerUseItem(typeID, buffer, offset, size);
                break;

            case CS_Explosion.TypeID:
                packet = new CS_Explosion(typeID, buffer, offset, size);
                break;

            case CS_PlayerUpdate.TypeID:
                packet = new CS_PlayerUpdate(typeID, buffer, offset, size);
                break;

            case CS_Shop.TypeID:
                packet = new CS_Shop(typeID, buffer, offset, size);
                break;

            case CS_ShopSkill.TypeID:
                packet = new CS_ShopSkill(typeID, buffer, offset, size);
                break;

            case CS_PlayerSwitch.TypeID:
                packet = new CS_PlayerSwitch(typeID, buffer, offset, size);
                break;

            case CS_PlayerFlag.TypeID:
                packet = new CS_PlayerFlag(typeID, buffer, offset, size);
                break;

            case CS_RequestUpdate.TypeID:
                packet = new CS_RequestUpdate(typeID, buffer, offset, size);
                break;

            case CS_StartUpdate.TypeID:
                packet = new CS_StartUpdate(typeID, buffer, offset, size);
                break;

            case CS_VehicleDeath.TypeID:
                packet = new CS_VehicleDeath(typeID, buffer, offset, size);
                break;

            case CS_PlayerPortal.TypeID:
                packet = new CS_PlayerPortal(typeID, buffer, offset, size);
                break;

            case CS_AllowSpectator.TypeID:
                packet = new CS_AllowSpectator(typeID, buffer, offset, size);
                break;

            case CS_RequestSpectator.TypeID:
                packet = new CS_RequestSpectator(typeID, buffer, offset, size);
                break;

            case CS_ItemExpired.TypeID:
                packet = new CS_ItemExpired(typeID, buffer, offset, size);
                break;

            case CS_PlayerProduce.TypeID:
                packet = new CS_PlayerProduce(typeID, buffer, offset, size);
                break;

            case CS_SetBanner.TypeID:
                packet = new CS_SetBanner(typeID, buffer, offset, size);
                break;

            case CS_FileSend.TypeID:
                packet = new CS_FileSend(typeID, buffer, offset, size);
                break;

            case CS_Environment.TypeID:
                packet = new CS_Environment(typeID, buffer, offset, size);
                break;

            case CS_Frames.TypeID:
                packet = new CS_Frames(typeID, buffer, offset, size);
                break;

            case CS_ChartRequest.TypeID:
                packet = new CS_ChartRequest(typeID, buffer, offset, size);
                break;

            case CS_SecurityCheck.TypeID:
                packet = new CS_SecurityCheck(typeID, buffer, offset, size);
                break;

            case CS_BallPickup.TypeID:
                packet = new CS_BallPickup(typeID, buffer, offset, size);
                break;

            case CS_BallDrop.TypeID:
                packet = new CS_BallDrop(typeID, buffer, offset, size);
                break;

            case CS_GoalScored.TypeID:
                packet = new CS_GoalScored(typeID, buffer, offset, size);
                break;

            case CS_VehiclePickup.TypeID:
                packet = new CS_VehiclePickup(typeID, buffer, offset, size);
                break;

            case CS_SendBanner.TypeID:
                packet = new CS_SendBanner(typeID, buffer, offset, size);
                break;

            case CS_DamageEvent.TypeID:
                packet = new CS_DamageEvent(typeID, buffer, offset, size);
                break;

            case CS_PlayerZoneDisconnected.TypeID:
                packet = new CS_PlayerZoneDisconnected(typeID, buffer, offset, size);
                break;

            case CS_RegResponse.TypeID:
                packet = new CS_RegResponse(typeID, buffer, offset, size);
                break;

            case CS_Unknown.TypeID:
                packet = new CS_Unknown(typeID, buffer, offset, size);
                break;

            default:
                //An undefined packet.
                packet = new PacketDummy(typeID, buffer, offset, size);
                break;
            }

            return(packet);
        }