Esempio n. 1
0
    def __init__(self):
        dcFileNames = ['../direct.dc']

        # a distributed object of our game.
        self.distributedObject = None
        self.aiDGameObect = None

        ClientRepository.__init__(
            self,
            dcFileNames = dcFileNames,
            threadedNet = True)

        # Set the same port as configured on the server to be able to connect
        # to it
        tcpPort = ConfigVariableInt('server-port', 4400).getValue()

        # Set the IP or hostname of the server we want to connect to
        hostname = ConfigVariableString('server-host', '127.0.0.1').getValue()

        # Build the URL from the server hostname and port. If your server
        # uses another protocol then http you should change it accordingly.
        # Make sure to pass the connectMethod to the  ClientRepository.__init__
        # call too.  Available connection methods are:
        # self.CM_HTTP, self.CM_NET and self.CM_NATIVE
        self.url = URLSpec('http://{}:{}'.format(hostname, tcpPort))

        # Attempt a connection to the server
        self.connect([self.url],
                     successCallback = self.connectSuccess,
                     failureCallback = self.connectFailure)
    def __init__(self, threadedNet = True):
        dcFileNames = ['direct.dc', 'tagger.dc']

        ClientRepository.__init__(self, dcFileNames = dcFileNames,
                                  dcSuffix = 'AI', connectMethod = self.CM_NET,
                                  threadedNet = threadedNet)

        # Need at least 32 bits to receive big picture packets.
        self.setTcpHeaderSize(4)

        # Allow some time for other processes.
        base.setSleep(0.01)

        taskMgr.setupTaskChain('updateCells', numThreads = 1,
                               threadPriority = TPLow, frameSync = True)

        taskMgr.doMethodLater(5, self.__checkPosters, 'checkPosters')

        self.games = []

        tcpPort = base.config.GetInt('server-port', Globals.ServerPort)
        hostname = base.config.GetString('server-host', Globals.ServerHost)
        if not hostname:
            hostname = 'localhost'
        url = URLSpec('g://%s:%s' % (hostname, tcpPort))
        self.connect([url],
                     successCallback = self.connectSuccess,
                     failureCallback = self.connectFailure)
Esempio n. 3
0
    def __init__(self, threadedNet=True):
        dcFileNames = ['direct.dc', 'tagger.dc']

        ClientRepository.__init__(self,
                                  dcFileNames=dcFileNames,
                                  dcSuffix='AI',
                                  connectMethod=self.CM_NET,
                                  threadedNet=threadedNet)

        # Need at least 32 bits to receive big picture packets.
        self.setTcpHeaderSize(4)

        # Allow some time for other processes.
        base.setSleep(0.01)

        taskMgr.setupTaskChain('updateCells',
                               numThreads=1,
                               threadPriority=TPLow,
                               frameSync=True)

        taskMgr.doMethodLater(5, self.__checkPosters, 'checkPosters')

        self.games = []

        tcpPort = base.config.GetInt('server-port', Globals.ServerPort)
        hostname = base.config.GetString('server-host', Globals.ServerHost)
        if not hostname:
            hostname = 'localhost'
        url = URLSpec('g://%s:%s' % (hostname, tcpPort))
        self.connect([url],
                     successCallback=self.connectSuccess,
                     failureCallback=self.connectFailure)
Esempio n. 4
0
    def __init__(self):
        """ The AI Repository usually lives on a server and is responsible for
        server side logic that will handle game objects """

        # List of all dc files that are of interest to this AI Repository
        dcFileNames = ['../direct.dc', 'sample.dc']

        # Initialize the repository.  We pass it the dc files and as this is an
        # AI repository the dcSuffix AI.  This will make sure any later calls to
        # createDistributedObject will use the correct version.
        # The connectMethod
        ClientRepository.__init__(self,
                                  dcFileNames=dcFileNames,
                                  dcSuffix='AI',
                                  threadedNet=True)

        # Set the same port as configured on the server to be able to connect
        # to it
        tcpPort = ConfigVariableInt('server-port', 4400).getValue()

        # Set the IP or hostname of the server we want to connect to
        hostname = ConfigVariableString('server-host', '127.0.0.1').getValue()

        # Build the URL from the server hostname and port. If your server
        # doesn't use http you should change it accordingly. Make sure to pass
        # the connectMethod to the  ClientRepository.__init__ call too.
        # Available connection methods are:
        # self.CM_HTTP, self.CM_NET and self.CM_NATIVE
        url = URLSpec('http://{}:{}'.format(hostname, tcpPort))

        # Attempt a connection to the server
        self.connect([url],
                     successCallback=self.connectSuccess,
                     failureCallback=self.connectFailure)
    def __init__(self):
        dcFileNames = ['direct.dc', 'net.dc']
        
        ClientRepository.__init__(self, dcFileNames = dcFileNames,
                                  dcSuffix = 'AI')

        tcpPort = base.config.GetInt('server-port', 4400)
        url = URLSpec('http://127.0.0.1:%s' % (tcpPort))
        self.connect([url],
                     successCallback = self.connectSuccess,
                     failureCallback = self.connectFailure)
Esempio n. 6
0
    def __init__(self):
        dcFileNames = ['distributed/direct.dc', 'distributed/net.dc']

        ClientRepository.__init__(self, dcFileNames = dcFileNames,
                                  dcSuffix = 'AI')

        tcpPort = base.config.GetInt('server-port', 4400)
        url = URLSpec('http://127.0.0.1:%s' % (tcpPort))
        self.connect([url],
                     successCallback = self.connectSuccess,
                     failureCallback = self.connectFailure)
 def __init__(self):
     base.cr = ClientRepository(
         dcFileNames=['phase_3/etc/direct.dc', 'phase_3/etc/toon.dc'],
         dcSuffix='AI')
     base.cr.connect([url],
                     successCallback=self.connectSuccess,
                     failureCallback=self.connectFailure)
     base.cTrav = CollisionTraverser()
     self.skeleton = 0
     if base.config.GetBool('want-suits', True):
         base.accept("SpawnSuit", self.createSuit)
     self.activeInvasion = False
     self.invasionSize = 0
     self.difficulty = ""
     self.title = DirectLabel(text="Server Menu",
                              pos=(-0.05, -0.1, -0.1),
                              scale=0.1,
                              relief=None,
                              text_fg=(1, 1, 1, 1),
                              parent=base.a2dTopRight,
                              text_align=TextNode.ARight)
     self.Suits = []
     base.pathNodes = []
     self.SuitCount = 0
     self.automaticSuits = 0
     self.hoodUtil = HoodUtil(base.cr)
     self.tournament = SuitTournament()
     self.lastChoice = None
     self.zoneAllocator = UniqueIdAllocator(50, 500)
Esempio n. 8
0
    def __init__(self):
        print("SETUP AI REPOSITORY")
        dcFileNames = ["interfaces/direct.dc", "interfaces/gameRoom.dc", "interfaces/chat.dc"]

        ClientRepository.__init__(
            self,
            dcFileNames = dcFileNames,
            dcSuffix = 'AI',
            threadedNet = True)

        hostname = base.serverHost.getValue()
        print("CONNECT TO:", hostname)
        url = URLSpec('http://{}'.format(hostname))
        self.connect([url],
                     successCallback = self.connectSuccess,
                     failureCallback = self.connectFailure)
    def __init__(self, readyCommand, readyCommandArgs, failedCommand,
                 failedCommandArgs):
        dcFileNames = [
            "interfaces/direct.dc", "interfaces/gameRoom.dc",
            "interfaces/chat.dc"
        ]
        ClientRepository.__init__(self,
                                  dcFileNames=dcFileNames,
                                  threadedNet=True)

        self.roomManager = None
        self.readyCommand = readyCommand
        self.readyCommandArgs = readyCommandArgs
        self.failedCommand = failedCommand
        self.failedCommandArgs = failedCommandArgs

        hostname = base.serverHost.getValue()
        self.url = URLSpec('http://{}'.format(hostname))
        self.connect([self.url],
                     successCallback=self.connectSuccess,
                     failureCallback=self.connectFailure)
Esempio n. 10
0
 def __init__(self):
     self.process = 'client'
     __builtin__.game = self
     
     base.cr = ClientRepository(['phase_3/etc/direct.dc', 'phase_3/etc/toon.dc'])
     base.cr.isShowingPlayerIds = None
     base.shadowTrav = CollisionTraverser()
     base.cTrav = CollisionTraverser()
     
     # Let's enable particles.
     base.enableParticles()
     
     # Let's set our AntialiasAttrib level.
     render.setAntialias(AntialiasAttrib.MMultisample)
Esempio n. 11
0
    def __init__(self):
        base.tcr = self
        self.cr = ClientRepository(
            dcFileNames=['phase_3/etc/direct.dc', 'phase_3/etc/toon.dc'])
        self.ttls = ToontownLoadingScreen()
        self.ttcm = ToontownConnectionManager(self.cr)
        base.accept("enterPickAToon", self.callPickAToon)
        base.accept("quitCreateAToon", self.callPickAToon)
        base.accept("toonCreated", self.callNamePicker)
        base.accept("nameConfirmed", self.saveToonInfo)
        base.accept("playGame", self.playGame)
        base.accept("PandaPaused", base.disableAllAudio)
        base.accept("PandaRestarted", base.enableAllAudio)
        base.accept("SysMsg", self.createSystemMessage)

        self.callToontownLoad()
Esempio n. 12
0
from lib.coginvasion.dna.DNAParser import *
import __builtin__


class game:
    process = 'client'


__builtin__.game = game()
from lib.coginvasion.toon import ParticleLoader, Toon
from lib.coginvasion.hood.DistributedGagShop import DistributedGagShop
from direct.gui.DirectGui import *
from direct.interval.IntervalGlobal import *
from lib.coginvasion.globals import CIGlobals

base.cr = ClientRepository(['astron/direct.dc'])
base.cr.isShowingPlayerIds = False
base.cTrav = CollisionTraverser()

vfs = VirtualFileSystem.getGlobalPtr()
vfs.mount(Filename("phase_0.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_3.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_3.5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_4.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_5.5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_6.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_7.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_8.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_9.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_10.mf"), ".", VirtualFileSystem.MFReadOnly)
Esempio n. 13
0
 def __init__(self):
     # list of all needed .dc files
     dcFileNames = ['distributed/direct.dc', 'distributed/net.dc']
     # initialise the client repository on this
     # machine with the dc filenames
     ClientRepository.__init__(self, dcFileNames = dcFileNames)
Esempio n. 14
0
# Created by:  blach (5Aug15)

from panda3d.core import *

loadPrcFile('config/Confauto.prc')
loadPrcFile('config/config_client.prc')

from direct.showbase.ShowBaseWide import ShowBase

base = ShowBase()
base.cTrav = CollisionTraverser()
base.shadowTrav = CollisionTraverser()

from direct.distributed.ClientRepository import ClientRepository

cr = ClientRepository([])
cr.isShowingPlayerIds = False

from direct.interval.IntervalGlobal import *
from lib.coginvasion.globals import CIGlobals
from lib.coginvasion.toon import Toon
from lib.coginvasion.hood.TTCHood import TTCHood


def makeToon(dna=None, name=None):
    toon = Toon.Toon(cr)
    if not dna:
        toon.setDNAStrand(toon.dnaStrand)
    else:
        toon.setDNAStrand(dna)
    if name:
Esempio n. 15
0
 def __init__(self):
     # list of all needed .dc files
     dcFileNames = ['distributed/direct.dc', 'distributed/net.dc']
     # initialise the client repository on this
     # machine with the dc filenames
     ClientRepository.__init__(self, dcFileNames=dcFileNames)
Esempio n. 16
0
    def __init__(self, playerName=None, threadedNet=True):
        dcFileNames = ["direct.dc", "tagger.dc"]

        ClientRepository.__init__(self, dcFileNames=dcFileNames, connectMethod=self.CM_NET, threadedNet=threadedNet)

        base.transitions.FadeModelName = "models/fade"

        # Need at least 32 bits to receive big picture packets.
        self.setTcpHeaderSize(4)

        # Allow some time for other processes.  This also allows time
        # each frame for the network thread to run.
        base.setSleep(0.01)

        # If we're using OpenGL, we can enable shaders.  (DirectX
        # shader support is still kind of spotty, even for simple
        # shaders like these.)
        if base.pipe and base.pipe.getInterfaceName() == "OpenGL":
            Globals.EnableShaders = True

        self.gotMusic = False
        self.__getMusic()

        # For the browse button.
        self.posterDefaultDir = Filename.getHomeDirectory().toOsSpecific()

        # Load a fun font to be the default text font.
        labelFont = loader.loadFont("models/amsterdam.ttf", okMissing=True)
        if labelFont:
            # Make a fuzzy halo behind the font so it looks kind of
            # airbrushy
            labelFont.setOutline(VBase4(0, 0, 0, 1), 2.0, 0.9)
            TextNode.setDefaultFont(labelFont)

        base.disableMouse()
        if base.mouseWatcher:
            mb = ModifierButtons()
            mb.addButton(KeyboardButton.control())
            base.mouseWatcher.node().setModifierButtons(mb)
            base.buttonThrowers[0].node().setModifierButtons(mb)
        taskMgr.setupTaskChain("loadPoster", numThreads=4, threadPriority=TPLow)
        # taskMgr.setupTaskChain('net', numThreads = 1, threadPriority = TPLow, frameSync = True)

        # Set up a text property called "tag" that renders using the
        # tag font, in white, with a shadow.  This is used for
        # rendering the art-painting awards at the end of the round.
        tpMgr = TextPropertiesManager.getGlobalPtr()
        tp = TextProperties()
        tagFont = loader.loadFont("models/one8seven.ttf", okMissing=True)
        if tagFont:
            tp.setFont(tagFont)
        tp.setTextColor(1, 1, 1, 1)
        tp.setShadow(0.05, 0.05)
        tp.setTextScale(1.5)
        tpMgr.setProperties("tag", tp)

        # If we're running from the web, get the gameInfo block from
        # the HTML tokens.
        self.gameInfo = None
        if base.appRunner:
            gameInfoName = base.appRunner.getToken("gameInfo")
            if gameInfoName:
                self.gameInfo = base.appRunner.evalScript(gameInfoName, needsResponse=True)

            # Expose the changePoster() method.
            base.appRunner.main.changePoster = self.changePoster

        print "self.gameInfo = %s" % (self.gameInfo)

        # Also be prepared to update the web form with the table of
        # players and the local player's score.
        self.playerTable = None
        self.scoreTable = None
        if base.appRunner and base.appRunner.dom:
            self.playerTable = base.appRunner.dom.document.getElementById("playerTable")
            self.scoreTable = base.appRunner.dom.document.getElementById("scoreTable")
        print "self.playerTable = %s, scoreTable = %s" % (self.playerTable, self.scoreTable)

        self.playerList = PlayerList(self.playerTable)
        self.onscreenScoreLeft = None

        # When we join a game, we'll prefer to join *this* game.
        self.nextGameId = 0
        self.chooseGameTask = None
        self.allGames = []

        # No game, no avatar (yet).
        self.robot = None
        self.game = None
        self.player = None
        self.av = None
        self.avCell = None
        self.paintThing = None

        self.keyMap = {}
        for key in Globals.ControlKeys:
            self.keyMap[key] = False

        self.dlnp = render.attachNewNode(DirectionalLight("dlnp"))
        self.dlnp.node().setColor((0.8, 0.8, 0.8, 1))
        render.setLight(self.dlnp)
        self.alnp = render.attachNewNode(AmbientLight("alnp"))
        self.alnp.node().setColor((0.2, 0.2, 0.2, 1))
        render.setLight(self.alnp)

        if base.camera:
            self.dlnp.reparentTo(base.camera)

        # Set up the poster FSM to switch the poster modes.
        self.posterFSM = PosterFSM(base.appRunner)

        # A node to hold all avatars.
        self.avRoot = render.attachNewNode("avRoot")

        # The root of the maze.
        self.mazeRoot = render.attachNewNode("maze")
        if Globals.EnableShaders:
            # self.mazeRoot.setShaderAuto()
            s = loader.loadShader("models/nopaint_normal.sha")
            self.mazeRoot.setShader(s)
            self.mazeRoot.setShaderInput("alight0", self.alnp)
            self.mazeRoot.setShaderInput("dlight0", self.dlnp)

        # Initial poster data.
        self.posterData = ("", 0)
        cvar = ConfigVariableFilename("tag-poster", "")
        filename = cvar.getValue()
        if filename:
            self.readTagPoster(filename)

        # Choose a bright paint color.
        h = random.random()
        s = random.random() * 0.3 + 0.7
        v = random.random() * 0.3 + 0.7
        self.playerColor = self.hsv2rgb(h, s, v)

        # Get the player's name.
        name = playerName
        if not name:
            name = getattr(self.gameInfo, "name", None)
        if not name:
            name = base.config.GetString("player-name", "")

        if name:
            # Use the provided name.
            self.playerName = name
            self.startConnect()

        else:
            # Prompt the user.

            # Start with the wall model in the background.
            wall = loader.loadModel("models/wall")
            wall.reparentTo(base.camera)
            wall.setPos(0, 5, -2.5)
            wall.setScale(10)
            if Globals.EnableShaders:
                wall.setShaderAuto()
            self.nameWall = wall

            c = self.playerColor
            self.nameLabel = DirectLabel(
                text="Enter your street name:",
                text_align=TextNode.ALeft,
                text_fg=(c[0], c[1], c[2], 1),
                text_shadow=(0, 0, 0, 1),
                pos=(-0.9, 0, 0.45),
                relief=None,
                scale=0.2,
            )
            tagFont = loader.loadFont("models/one8seven.ttf")

            cardModel = loader.loadModel("models/nametag_card")
            cardTex = cardModel.findTexture("*")
            self.nameEntry = DirectEntry(
                pos=(-0.9, 0, 0.1),
                focus=True,
                relief=DGG.TEXTUREBORDER,
                frameColor=(c[0], c[1], c[2], 0.6),
                frameTexture=cardTex,
                borderWidth=(0.2, 0.2),
                pad=(0.0, -0.2),
                borderUvWidth=(0.1, 0.1),
                text_font=tagFont,
                width=12,
                scale=0.15,
                command=self.enteredName,
            )

            self.nameButton = DirectButton(
                text="Enter game",
                frameColor=(c[0], c[1], c[2], 1),
                scale=0.15,
                pos=(0, 0, -0.5),
                relief=DGG.RAISED,
                borderWidth=(0.05, 0.05),
                pad=(0.8, 0.3),
                command=self.enteredName,
            )
Esempio n. 17
0
 def __init__(self):
     ClientRepository.__init__(self, dcFileNames=[], dcSuffix='AI')
     PORT = base.config.GetInt('server-port', 6668)
     self.connect([URLSpec('http://localhost:%s' % PORT)],
                   successCallback=self.connectSuccess,
                   failureCallback=self.connectFailure)
    def __init__(self, playerName = None, threadedNet = True):
        dcFileNames = ['direct.dc', 'tagger.dc']
        
        ClientRepository.__init__(self, dcFileNames = dcFileNames,
                                  connectMethod = self.CM_NET,
                                  threadedNet = threadedNet)

        base.transitions.FadeModelName = 'models/fade'
        
        # Need at least 32 bits to receive big picture packets.
        self.setTcpHeaderSize(4)

        # Allow some time for other processes.  This also allows time
        # each frame for the network thread to run.
        base.setSleep(0.01)

        # If we're using OpenGL, we can enable shaders.  (DirectX
        # shader support is still kind of spotty, even for simple
        # shaders like these.)
        if base.pipe and base.pipe.getInterfaceName() == 'OpenGL':
            Globals.EnableShaders = True

        self.gotMusic = False
        self.__getMusic()
        
        # For the browse button.
        self.posterDefaultDir = Filename.getHomeDirectory().toOsSpecific()

        # Load a fun font to be the default text font.
        labelFont = loader.loadFont('models/amsterdam.ttf', okMissing = True)
        if labelFont:
            # Make a fuzzy halo behind the font so it looks kind of
            # airbrushy
            labelFont.setOutline(VBase4(0, 0, 0, 1), 2.0, 0.9)
            TextNode.setDefaultFont(labelFont)

        base.disableMouse()
        if base.mouseWatcher:
            mb = ModifierButtons()
            mb.addButton(KeyboardButton.control())
            base.mouseWatcher.node().setModifierButtons(mb)
            base.buttonThrowers[0].node().setModifierButtons(mb)
        taskMgr.setupTaskChain('loadPoster', numThreads = 4,
                               threadPriority = TPLow)
        #taskMgr.setupTaskChain('net', numThreads = 1, threadPriority = TPLow, frameSync = True)

        # Set up a text property called "tag" that renders using the
        # tag font, in white, with a shadow.  This is used for
        # rendering the art-painting awards at the end of the round.
        tpMgr = TextPropertiesManager.getGlobalPtr()
        tp = TextProperties()
        tagFont = loader.loadFont('models/one8seven.ttf', okMissing = True)
        if tagFont:
            tp.setFont(tagFont)
        tp.setTextColor(1, 1, 1, 1)
        tp.setShadow(0.05, 0.05)
        tp.setTextScale(1.5)
        tpMgr.setProperties('tag', tp)

        # If we're running from the web, get the gameInfo block from
        # the HTML tokens.
        self.gameInfo = None
        if base.appRunner:
            gameInfoName = base.appRunner.getToken('gameInfo')
            if gameInfoName:
                self.gameInfo = base.appRunner.evalScript(gameInfoName, needsResponse = True)

            # Expose the changePoster() method.
            base.appRunner.main.changePoster = self.changePoster

        print "self.gameInfo = %s" % (self.gameInfo)

        # Also be prepared to update the web form with the table of
        # players and the local player's score.
        self.playerTable = None
        self.scoreTable = None
        if base.appRunner and base.appRunner.dom:
            self.playerTable = base.appRunner.dom.document.getElementById('playerTable')
            self.scoreTable = base.appRunner.dom.document.getElementById('scoreTable')
        print "self.playerTable = %s, scoreTable = %s" % (self.playerTable, self.scoreTable)

        self.playerList = PlayerList(self.playerTable)
        self.onscreenScoreLeft = None

        # When we join a game, we'll prefer to join *this* game.
        self.nextGameId = 0
        self.chooseGameTask = None
        self.allGames = []

        # No game, no avatar (yet).
        self.robot = None
        self.game = None
        self.player = None
        self.av = None
        self.avCell = None
        self.paintThing = None

        self.keyMap = {}
        for key in Globals.ControlKeys:
            self.keyMap[key] = False

        self.dlnp = render.attachNewNode(DirectionalLight('dlnp'))
        self.dlnp.node().setColor((0.8, 0.8, 0.8, 1))
        render.setLight(self.dlnp)
        self.alnp = render.attachNewNode(AmbientLight('alnp'))
        self.alnp.node().setColor((0.2, 0.2, 0.2, 1))
        render.setLight(self.alnp)

        if base.camera:
            self.dlnp.reparentTo(base.camera)

        # Set up the poster FSM to switch the poster modes.
        self.posterFSM = PosterFSM(base.appRunner)

        # A node to hold all avatars.
        self.avRoot = render.attachNewNode('avRoot')

        # The root of the maze.
        self.mazeRoot = render.attachNewNode('maze')
        if Globals.EnableShaders:
            #self.mazeRoot.setShaderAuto()
            s = loader.loadShader('models/nopaint_normal.sha')
            self.mazeRoot.setShader(s)
            self.mazeRoot.setShaderInput('alight0', self.alnp)
            self.mazeRoot.setShaderInput('dlight0', self.dlnp)

        # Initial poster data.
        self.posterData = ('', 0)
        cvar = ConfigVariableFilename('tag-poster', '')
        filename = cvar.getValue()
        if filename:
            self.readTagPoster(filename)

        # Choose a bright paint color.
        h = random.random()
        s = random.random() * 0.3 + 0.7
        v = random.random() * 0.3 + 0.7
        self.playerColor = self.hsv2rgb(h, s, v)

        # Get the player's name.
        name = playerName
        if not name:
            name = getattr(self.gameInfo, 'name', None)
        if not name:
            name = base.config.GetString('player-name', '')
            
        if name:
            # Use the provided name.
            self.playerName = name
            self.startConnect()

        else:
            # Prompt the user.

            # Start with the wall model in the background.
            wall = loader.loadModel('models/wall')
            wall.reparentTo(base.camera)
            wall.setPos(0, 5, -2.5)
            wall.setScale(10)
            if Globals.EnableShaders:
                wall.setShaderAuto()
            self.nameWall = wall

            c = self.playerColor
            self.nameLabel = DirectLabel(
                text = 'Enter your street name:',
                text_align = TextNode.ALeft,
                text_fg = (c[0], c[1], c[2], 1),
                text_shadow = (0, 0, 0, 1),
                pos = (-0.9, 0, 0.45),
                relief = None,
                scale = 0.2)
            tagFont = loader.loadFont('models/one8seven.ttf')

            cardModel = loader.loadModel('models/nametag_card')
            cardTex = cardModel.findTexture('*')
            self.nameEntry = DirectEntry(
                pos = (-0.9, 0, 0.1),
                focus = True,
                relief = DGG.TEXTUREBORDER,
                frameColor = (c[0], c[1], c[2], 0.6),
                frameTexture = cardTex,
                borderWidth = (0.2, 0.2),
                pad = (0.0, -0.2),
                borderUvWidth = (0.1, 0.1),
                text_font = tagFont,
                width = 12, scale = 0.15,
                command = self.enteredName)

            self.nameButton = DirectButton(
                text = 'Enter game',
                frameColor = (c[0], c[1], c[2], 1),
                scale = 0.15,
                pos = (0, 0, -0.5),
                relief = DGG.RAISED,
                borderWidth = (0.05, 0.05),
                pad = (0.8, 0.3),
                command = self.enteredName)
Esempio n. 19
0
    def __init__(self):
        dcFileNames = ['direct.dc', 'net.dc']

        ClientRepository.__init__(self, dcFileNames=dcFileNames)
Esempio n. 20
0
 def __init__(self):
     dcFileNames = ['direct.dc', 'net.dc']
     
     ClientRepository.__init__(self, dcFileNames = dcFileNames)
from direct.particles.ParticleEffect import ParticleEffect
from lib.coginvasion.globals import CIGlobals
from lib.coginvasion.cog.Suit import Suit
from direct.interval.IntervalGlobal import *
from lib.coginvasion.cog.DistributedSuit import DistributedSuit
from direct.distributed.ClientRepository import ClientRepository
from lib.coginvasion.toon.Toon import Toon
from lib.coginvasion.toon import NameTag, ToonDNA, ToonHead
from direct.directutil import Mopath
from direct.showbase.Audio3DManager import Audio3DManager
from direct.showutil.Rope import Rope
import glob

base.enableParticles()

base.cr = ClientRepository([])
base.cr.isShowingPlayerIds = False
base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)

vfs = VirtualFileSystem.getGlobalPtr()
vfs.mount(Filename("phase_0.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_3.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_3.5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_4.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_5.5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_6.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_7.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_8.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_9.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_10.mf"), ".", VirtualFileSystem.MFReadOnly)
Esempio n. 22
0
base = CIBase()
render.setAntialias(AntialiasAttrib.MMultisample)
render.show()

sm.doSunriseFor(sunrise=SHOWBASE_POSTINIT)

base.initStuff()

if metadata.USE_LIGHTING:
    render.setShaderAuto()
else:
    render.clearShader()

from direct.distributed.ClientRepository import ClientRepository
base.cr = ClientRepository(['phase_3/etc/direct.dc', 'phase_3/etc/toon.dc'])
base.cr.isShowingPlayerIds = None
base.cr.doIdAllocator = UniqueIdAllocator(0, 999)


def isChristmas():
    return 0


base.cr.isChristmas = isChristmas

from src.coginvasion.base.CIAudio3DManager import CIAudio3DManager
base.audio3d = CIAudio3DManager(base.sfxManagerList[0], camera)
base.audio3d.setDistanceFactor(25)
base.audio3d.setDropOffFactor(0.025)