示例#1
0
def handleLeftClicks(actionList, grid, keys, p, bgGrid):
	if keys[K_LSHIFT]: 
		#new function below, pass grid, p, actionlist) 
		e = findEntity(grid.entityList, p)
		if not e: 
			return 

		if isinstance(grid.entityList[e], entities.MonsterEnergy): 
			grid.entityList.pop(e)
			t = entities.transformingMonster(p)
			grid.entityList.append(t)
			actionList.insert(t, 0)

	elif grid.placeMode == model.GATHERER: 
		removePrevInCell(grid, p)
		newGath = entities.CSCStudent(5, p)
		grid.entityList.append(newGath)
	elif grid.placeMode == model.GENERATOR: 
		removePrevInCell(grid, p)
		newGen = entities.CampusMarket(4, p)
		grid.entityList.append(newGen)
	elif grid.placeMode == model.RESOURCE: 
		removePrevInCell(grid, p)
		newRes = entities.MonsterEnergy(p)
		grid.entityList.append(newRes)
	elif grid.placeMode == model.OBSTACLE: 
		removePrevInCell(grid, p)
		newObs = entities.Obstacle(p)
		grid.entityList.append(newObs)
	#The following two only affect the bgGrid
	elif grid.placeMode == model.EMPTY: 
		model.set_cell(bgGrid, p, model.EMPTY)
	elif grid.placeMode == model.CONCRETE: 
		model.set_cell(bgGrid, p, model.CONCRETE)

	else: 
		newRes = resourceClick(grid, p, grid.entityList)
		grid.entityList += newRes

	print (grid.entityList)
示例#2
0
def load(grid, bgGrid):
	model.emptyGrid(grid)
	model.emptyGrid(bgGrid)
	newList = []

	with open('gaia.sav', 'r') as f:
		for line in f:
			l = line.split()
			if l[0] == 'gatherer':
				p = entities.Point(int(l[1]), int(l[2]))
				resLim = 5
				newEnt = entities.CSCStudent(resLim, p)
				newEnt.rate = int(l[2])*100
				#print('YOU FOUND A GATHERER')

			elif l[0] == 'generator':
				p = entities.Point(int(l[1]), int(l[2]))
				rate = 2
				newEnt = entities.CampusMarket(rate, p)
				#print('YOU FOUND A GENERATOR')

			elif l[0] == 'resource':
				p = entities.Point(int(l[1]), int(l[2]))
				newEnt = entities.MonsterEnergy(p)
				#print('YOU FOUND A RESOURCE')

			elif l[0] == 'obstacle':
				p = entities.Point(int(l[1]), int(l[2]))
				newEnt = entities.Obstacle(p)

			elif l[0] == 'concrete':
				p = entities.Point(int(l[1]), int(l[2]))
				value = 6
				model.set_cell(bgGrid, p, value)

			newList.append(newEnt)
		f.close()
		grid.entityList = newList
		print("You loaded the file!")
示例#3
0
def handleLeftClicks(grid, keys, p, bgGrid):
    if grid.placeMode == model.GATHERER:
        newGath = entities.CSCStudent(5, p)
        grid.entityList.append(newGath)
    elif grid.placeMode == model.GENERATOR:
        newGen = entities.CampusMarket(4, p)
        grid.entityList.append(newGen)
    elif grid.placeMode == model.RESOURCE:
        newRes = entities.MonsterEnergy(p)
        grid.entityList.append(newRes)
    elif grid.placeMode == model.OBSTACLE:
        newObs = entities.Obstacle(p)
        grid.entityList.append(newObs)
    #The following two only affect the bgGrid
    elif grid.placeMode == model.EMPTY:
        model.set_cell(bgGrid, p, model.EMPTY)
    elif grid.placeMode == model.CONCRETE:
        model.set_cell(bgGrid, p, model.CONCRETE)

    else:
        newRes = resourceClick(grid, p, grid.entityList)
        grid.entityList += newRes
示例#4
0
def handleLeftClicks(grid, keys, p, bgGrid):
	if grid.placeMode == model.GATHERER: 
		newGath = entities.CSCStudent(5, p)
		grid.entityList.append(newGath)
	elif grid.placeMode == model.GENERATOR: 
		newGen = entities.CampusMarket(4, p)
		grid.entityList.append(newGen)
	elif grid.placeMode == model.RESOURCE: 
		newRes = entities.MonsterEnergy(p)
		grid.entityList.append(newRes)
	elif grid.placeMode == model.OBSTACLE: 
		newObs = entities.Obstacle(p)
		grid.entityList.append(newObs)
	#The following two only affect the bgGrid
	elif grid.placeMode == model.EMPTY: 
		model.set_cell(bgGrid, p, model.EMPTY)
	elif grid.placeMode == model.CONCRETE: 
		model.set_cell(bgGrid, p, model.CONCRETE)

	else: 
		newRes = resourceClick(grid, p, grid.entityList)
		grid.entityList += newRes
示例#5
0
def load(grid, bgGrid):
    model.emptyGrid(grid)
    model.emptyGrid(bgGrid)
    newList = []

    with open('gaia.sav', 'r') as f:
        for line in f:
            l = line.split()
            if l[0] == 'gatherer':
                p = entities.Point(int(l[1]), int(l[2]))
                resLim = 5
                newEnt = entities.CSCStudent(resLim, p)
                newEnt.rate = int(l[2]) * 100
                #print('YOU FOUND A GATHERER')

            elif l[0] == 'generator':
                p = entities.Point(int(l[1]), int(l[2]))
                rate = 2
                newEnt = entities.CampusMarket(rate, p)
                #print('YOU FOUND A GENERATOR')

            elif l[0] == 'resource':
                p = entities.Point(int(l[1]), int(l[2]))
                newEnt = entities.MonsterEnergy(p)
                #print('YOU FOUND A RESOURCE')

            elif l[0] == 'obstacle':
                p = entities.Point(int(l[1]), int(l[2]))
                newEnt = entities.Obstacle(p)

            elif l[0] == 'concrete':
                p = entities.Point(int(l[1]), int(l[2]))
                value = 6
                model.set_cell(bgGrid, p, value)

            newList.append(newEnt)
        f.close()
        grid.entityList = newList
        print("You loaded the file!")
示例#6
0
def determineNewGathererPosition(grid, gatherer, resource):
    #Determines position one grixel toward the CLOSEST resource in both the x and y axis
    #Eventually, will determine the closest resource of a list of resources
    oldx = gatherer.position.x
    oldy = gatherer.position.y
    oldpoint = entities.Point(oldx, oldy)

    if resource.position.x > gatherer.position.x:
        gatherer.position.x += 1
    elif resource.position.x < gatherer.position.x:
        gatherer.position.x -= 1
    if model.get_cell(grid, gatherer.position) == 4:
        gatherer.position.x = oldx

    #Handling Y
    if resource.position.y > gatherer.position.y:
        gatherer.position.y += 1
    elif resource.position.y < gatherer.position.y:
        gatherer.position.y -= 1
    if model.get_cell(grid, gatherer.position) == 4:
        gatherer.position.y = oldy

    if not samePt(gatherer.position, oldpoint):
        model.set_cell(grid, oldpoint, 5)
示例#7
0
def determineNewGathererPosition(grid, gatherer, resource):
	#Determines position one grixel toward the CLOSEST resource in both the x and y axis
	#Eventually, will determine the closest resource of a list of resources
	oldx = gatherer.position.x 
	oldy = gatherer.position.y
	oldpoint = entities.Point(oldx, oldy) 

	if resource.position.x > gatherer.position.x:    
		gatherer.position.x += 1
	elif resource.position.x < gatherer.position.x: 
		gatherer.position.x -= 1
	if model.get_cell(grid, gatherer.position) == 4: 
		gatherer.position.x = oldx
		
	#Handling Y 
	if resource.position.y > gatherer.position.y: 
		gatherer.position.y += 1
	elif resource.position.y < gatherer.position.y: 
		gatherer.position.y -= 1
	if model.get_cell(grid, gatherer.position) == 4: 
		gatherer.position.y = oldy

	if not samePt(gatherer.position, oldpoint): 
		model.set_cell(grid, oldpoint, 5)
示例#8
0
def handleRightClicks(grid, point):
	if not model.get_cell(grid, point) == 0: 
		model.set_cell(grid, point, 0)
		for entity in grid.entityList: 
			if samePt(entity.position, point):
				grid.entityList.remove(entity)
示例#9
0
def handleRightClicks(grid, point):
	if not model.get_cell(grid, point) == 0: 
		model.set_cell(grid, point, 0)
		for entity in grid.entityList: 
			if samePt(entity.position, point):
				grid.entityList.remove(entity)