Пример #1
0
def toggle_particles(running):
    global CURRENT_WAYPOINT
    global NEXT_WAYPOINT

    currentPos = fge.GetTransform(CURRENT_WAYPOINT).GetPosition()
    currentParticles = fge.GetParticles(CURRENT_WAYPOINT)
    currentParticles.SetPosition(currentPos[0], currentPos[1], currentPos[2])
    currentParticles.SetRunning(running)

    nextPos = fge.GetTransform(NEXT_WAYPOINT).GetPosition()
    nextParticles = fge.GetParticles(NEXT_WAYPOINT)
    nextParticles.SetPosition(nextPos[0], nextPos[1], nextPos[2])
    nextParticles.SetRunning(running)
Пример #2
0
def on_event(id, event):
    global INPUT_SEQUENCE
    global OUTPUT_ITEMS
    global SEQUENCE_INDEX
    global INTERACTING
    if (event.GetType() == "GeneratorInputEvent"):
        if (event.mGeneratorID == id):
            requiredInput = INPUT_SEQUENCE[SEQUENCE_INDEX]
            if (event.mInputType == requiredInput):
                audio = fge.GetAudio(id)
                audio.Load("I_A.mp3")
                audio.Play()
                audio.Volume(1.0)
                correctInputEvent = fge.GetInputEvent()
                correctInputEvent.mGeneratorID = id
                fge.SendEvent(correctInputEvent, id)
                SEQUENCE_INDEX = SEQUENCE_INDEX + 1
                if (SEQUENCE_INDEX == len(INPUT_SEQUENCE)):
                    particleEmitter = fge.GetParticles(id)
                    particleEmitter.SetRunning(True)
                    outputEvent = fge.GetGeneratorOutputEvent()
                    outputEvent.mGeneratorID = id
                    outputEvent.mPlayerID = event.mPlayerID
                    outputEvent.mOutputs = OUTPUT_ITEMS
                    fge.SendEvent(outputEvent, id)
                    SEQUENCE_INDEX = 0
    if (event.GetType() == "HighlightEvent"):
        INTERACTING = True
Пример #3
0
def on_event(id, event):
    global opName
    global counter
    if (event.GetType() == "ContainerOutputEvent"):
        if (event.mContainerID == id):
            processorContainer = fge.GetCarrier(id)
            items = processorContainer.GetItems()
            items.reverse()
            outputItems = items[:event.mNumItems]
            for itemID in outputItems:
                itemCollider = fge.GetCollider(itemID)
                itemCollider.mIsTrigger = False
                itemBody = fge.GetBody(itemID)
                itemBody.mConstrainX = False
                itemBody.mConstrainY = False
                itemBody.mConstrainZ = False
                processorContainer.RemoveItem(itemID)
                pickupEvent = fge.GetPlayerPickupEvent()
                pickupEvent.mPlayerID = event.mPlayerID
                pickupEvent.mItemID = itemID
                fge.SendEvent(pickupEvent, event.mPlayerID)
                item = fge.GetType(itemID)
                if (item == opName and counter == 0):
                    particleEmitter = fge.GetParticles(id)
                    particleEmitter.SetRunning(True)
                    counter += 1
    if (event.GetType() == "RecipeMatchEvent"):
        if (event.mProcessorID == id):
            processor = fge.GetProcessor(id)
            opName = fge.DecodeResource(event.mOutput)
            counter = 0
Пример #4
0
def on_update(id, dt):
    con = fge.GetController(id)
    player = fge.GetPlayer(id)
    #update the player
    speed = 8.0
    x = y = 0
    rot_num = 0
    rot = 0
    particles = fge.GetParticles(id)
    if(con.IsPressed("up")):
        rot += 180
        rot_num +=1
        y -= speed
    elif(con.IsPressed("down")):
        rot += 0
        rot_num +=1
        y += speed
    if(con.IsPressed("left")):
        if(con.IsPressed("up")):
            rot += 270
        else:
            rot += -90
        rot_num +=1
        x -= speed
    elif(con.IsPressed("right")):
        rot += 90
        rot_num +=1
        x += speed
    if(rot_num >= 1):
        player.Rotate(rot/rot_num)
    if(x!=0 or y != 0):
        playerTransform = fge.GetTransform(id)
        playerPos = playerTransform.GetPosition()
        playerScale = playerTransform.GetScale()
        particles.SetPosition(playerPos[0], playerPos[1], playerPos[2])
        particles.SetRunning(True)
        sprint = con.IsTriggered("Sprint")
        if(sprint):
            x = 2*x
            y = 2*y
        player.Move(x,y,sprint)
    body  =  fge.GetBody(id)
    vel = body.GetVelocity()
    xV = vel[0]
    zV = vel[2]
Пример #5
0
def on_update(id, dt):
    ob = fge.GetObserver(id)
    gameInt = int(ob.GetValue("game"))
    container = fge.GetCarrier(id)
    if (len(container.GetItems("Game")) > 0):
        requestFilledEvent = fge.GetRequestFilledEvent()
        requestFilledEvent.mContainerID = id
        requestFilledEvent.mRequestedGame = gameInt
        fge.BroadcastEvent(requestFilledEvent)
        containerOutputEvent = fge.GetContainerOutputEvent()
        containerOutputEvent.mContainerID = id
        containerOutputEvent.mPlayerID = -1
        containerOutputEvent.mNumItems = 1
        containerOutputEvent.mItemTypes = ["Game"]
        fge.SendEvent(containerOutputEvent, id)
        particleEmitter = fge.GetParticles(id)
        particleEmitter.SetRunning(True)
        #containerPosition = fge.GetTransform(id).GetPosition()
        #particleEmitter.SetPosition(containerPosition[0], containerPosition[1], containerPosition[2])
        audio = fge.GetAudio(id)
        audio.Load("ModuleDeliver01.mp3")
        audio.Play()
        audio.Volume(0.2)
Пример #6
0
def on_update(id, dt):
    con = fge.GetController(id)
    player = fge.GetPlayer(id)
    #update the player
    speed = 8.0
    x = y = 0
    rot_num = 0
    rot = 0
    particles = fge.GetParticles(id)
    if (con.IsPressed("up")):
        rot += 180
        rot_num += 1
        y -= speed
    elif (con.IsPressed("down")):
        rot += 0
        rot_num += 1
        y += speed
    if (con.IsPressed("left")):
        if (con.IsPressed("up")):
            rot += 270
        else:
            rot += -90
        rot_num += 1
        x -= speed
    elif (con.IsPressed("right")):
        rot += 90
        rot_num += 1
        x += speed
    if (rot_num >= 1):
        player.Rotate(rot / rot_num)
    if (x != 0 or y != 0):
        playerTransform = fge.GetTransform(id)
        playerPos = playerTransform.GetPosition()
        playerScale = playerTransform.GetScale()
        #particles.SetPosition(playerPos[0], playerPos[1], playerPos[2])
        particles.SetRunning(True)
        sprint = con.IsTriggered("Sprint")
        if (sprint):
            x = 2 * x
            y = 2 * y
        player.Move(x, y, sprint)
    else:
        particles.SetRunning(False)
    playerHands = fge.GetCarrier(id)
    heldItems = playerHands.GetItems()
    lenHeldItems = len(heldItems)
    pickupAreaIDs = fge.GetChildren(id, "SearchArea")
    for pickupAreaID in pickupAreaIDs:
        pickupArea = fge.GetAreaSearch(pickupAreaID)
        foundIDs = pickupArea.GetFound()
        for foundID in foundIDs:
            foundType = fge.GetType(foundID)
            if (lenHeldItems == 0):
                if (foundType == "Processor"):
                    container = fge.GetCarrier(foundID)
                    processor = fge.GetProcessor(foundID)
                    if (len(container.GetItems()) > 0
                            and not processor.IsWorking()):
                        if (con.IsTriggered("Interact")):
                            containerOutputEvent = fge.GetContainerOutputEvent(
                            )
                            containerOutputEvent.mPlayerID = id
                            containerOutputEvent.mContainerID = foundID
                            containerOutputEvent.mNumItems = 1
                            fge.SendEvent(containerOutputEvent, foundID)
                        else:
                            containerModel = fge.GetModel(foundID)
                            if containerModel is not None:
                                containerModel.Highlight()
                        break
                if (foundType == "Block"):
                    container = fge.GetCarrier(foundID)
                    if (len(container.GetItems()) > 0):
                        if (con.IsTriggered("Interact")):
                            containerOutputEvent = fge.GetContainerOutputEvent(
                            )
                            containerOutputEvent.mPlayerID = id
                            containerOutputEvent.mContainerID = foundID
                            containerOutputEvent.mNumItems = 1
                            fge.SendEvent(containerOutputEvent, foundID)
                        else:
                            containerModel = fge.GetModel(foundID)
                            if containerModel is not None:
                                containerModel.Highlight()
                        break
                elif (foundType == "Container"):
                    continue
                elif (foundType == "Generator"):
                    inputType = ""
                    if (con.IsTriggered("Interact")):
                        inputType = "Interact"
                    if (con.IsTriggered("Sprint")):
                        inputType = "Sprint"
                    if (con.IsTriggered("action3")):
                        inputType = "action3"
                    if (con.IsTriggered("action4")):
                        inputType = "action4"
                    if (inputType != ""):
                        generatorInputEvent = fge.GetGeneratorInputEvent()
                        generatorInputEvent.mGeneratorID = foundID
                        generatorInputEvent.mPlayerID = id
                        generatorInputEvent.mInputType = inputType
                        fge.SendEvent(generatorInputEvent, foundID)
                    else:
                        highlightEvent = fge.GetHighlightEvent()
                        fge.SendEvent(highlightEvent, foundID)
                        itemModel = fge.GetModel(foundID)
                        if itemModel is not None:
                            itemModel.Highlight()
                    break
                elif (foundType == "GridCell"):
                    container = fge.GetCarrier(foundID)
                    if (len(container.GetItems()) > 0):
                        if (con.IsTriggered("Interact")):
                            containerOutputEvent = fge.GetContainerOutputEvent(
                            )
                            containerOutputEvent.mPlayerID = id
                            containerOutputEvent.mContainerID = foundID
                            containerOutputEvent.mNumItems = 1
                            fge.SendEvent(containerOutputEvent, foundID)
                        else:
                            containerModel = fge.GetModel(foundID)
                            if containerModel is not None:
                                containerModel.Highlight()
                        break
                elif (not fge.HasParent(foundID)
                      or fge.GetType(fge.GetParentID(foundID)) == "Platform"):
                    if (con.IsTriggered("Interact")):
                        pickupEvent = fge.GetPlayerPickupEvent()
                        pickupEvent.mPlayerID = id
                        pickupEvent.mItemID = foundID
                        fge.SendEvent(pickupEvent, id)
                    else:
                        itemModel = fge.GetModel(foundID)
                        if itemModel is not None:
                            itemModel.Highlight()
                    break
            else:
                if (fge.GetType(heldItems[0]) != "Game"):
                    if (foundType == "Processor"):
                        processor = fge.GetProcessor(foundID)
                        processorContainter = fge.GetCarrier(foundID)
                        if (processor.GetMaxInput() > len(
                                processorContainter.GetItems())):
                            if (con.IsTriggered("Interact")):
                                containerInputEvent = fge.GetContainerInputEvent(
                                )
                                containerInputEvent.mPlayerID = id
                                containerInputEvent.mContainerID = foundID
                                containerInputEvent.mNumItems = 1
                                fge.SendEvent(containerInputEvent, foundID)
                            else:
                                processorModel = fge.GetModel(foundID)
                                if processorModel is not None:
                                    processorModel.Highlight()
                            break
                    if (foundType == "Block"):
                        container = fge.GetCarrier(foundID)
                        block = fge.GetBlock(foundID)
                        if (1 > len(container.GetItems())
                                and block.CanInput()):
                            if (con.IsTriggered("Interact")):
                                containerInputEvent = fge.GetContainerInputEvent(
                                )
                                containerInputEvent.mPlayerID = id
                                containerInputEvent.mContainerID = foundID
                                containerInputEvent.mNumItems = 1
                                fge.SendEvent(containerInputEvent, foundID)
                            else:
                                processorModel = fge.GetModel(foundID)
                                if processorModel is not None:
                                    processorModel.Highlight()
                        break
                    if (foundType == "GridCell"):
                        cellContainter = fge.GetCarrier(foundID)
                        if (1 > len(cellContainter.GetItems())):
                            if (con.IsTriggered("Interact")):
                                containerInputEvent = fge.GetContainerInputEvent(
                                )
                                containerInputEvent.mPlayerID = id
                                containerInputEvent.mContainerID = foundID
                                containerInputEvent.mNumItems = 1
                                fge.SendEvent(containerInputEvent, foundID)
                            else:
                                cellModel = fge.GetModel(foundID)
                                if cellModel is not None:
                                    cellModel.Highlight()
                            break
                else:
                    if (foundType == "Container"):
                        if (con.IsTriggered("Interact")):
                            containerInputEvent = fge.GetContainerInputEvent()
                            containerInputEvent.mPlayerID = id
                            containerInputEvent.mContainerID = foundID
                            containerInputEvent.mNumItems = 1
                            fge.SendEvent(containerInputEvent, foundID)
                        else:
                            processorModel = fge.GetModel(foundID)
                            if processorModel is not None:
                                processorModel.Highlight()
                        break
        if (len(foundIDs) == 0 and lenHeldItems > 0
                and fge.GetType(heldItems[0]) != "Game"
                and con.IsTriggered("Interact")):
            dropEvent = fge.GetPlayerDropEvent()
            dropEvent.mPlayerID = id
            fge.SendEvent(dropEvent, id)
    body = fge.GetBody(id)
    vel = body.GetVelocity()
    xV = vel[0]
    zV = vel[2]