Exemplo n.º 1
0
    def destroy(self, object):
        if object.get(NetworkDataCodes.TYPE) == NetworkDataCodes.WALL:
            id = object.get(NetworkDataCodes.ID)
            wall = Global.getGameWall(id)
            wall.destroy()

        if object.get(NetworkDataCodes.TYPE) == NetworkDataCodes.TANK:
            id = object.get(NetworkDataCodes.TANK_ID)
            tank = Global.getGameTank(id)
            tank.destroy()

        if object.get(NetworkDataCodes.TYPE) == NetworkDataCodes.STANDART_BULLET or \
                        object.get(NetworkDataCodes.TYPE) == NetworkDataCodes.HEAVY_BULLET:

            id = object.get(NetworkDataCodes.BULLET_ID)
            position = object.get(NetworkDataCodes.POSITION)
            bullet = Global.getGameBullet(id)
            if not bullet: return

            bullet.destroy(position)
Exemplo n.º 2
0
    def Network(self, data):
        #print('Network Receive', data)

        if data.get('action') == NetworkActions.INIT:
            index = int(data.get('connection_index'))
            type = data.get(NetworkDataCodes.TYPE)
            clan = data.get(NetworkDataCodes.CLAN)

            channel = Global.PullConnsctions[index]

            id = addGamePlayer(type=type, clan=clan, position=(200, 100))

            channel.Send({'action': NetworkActions.INIT, 'id': id})

        if data.get('action') == NetworkActions.TANK_MOVE:
            tank = Global.getGameTank(data.get(NetworkDataCodes.TANK_ID))
            tank.update(data)

        if data.get('action') == NetworkActions.TANK_FIRE:
            self.events.fire(data)

        if data.get('action') == NetworkActions.DAMAGE:
            self.events.damage(data)