示例#1
0
def handleTicks(grid, actionList, ticks): 
	#the whole action thing
	while not actionList.empty() and actionList.head().ord < ticks:
		action = actionList.pop()

		if isinstance(action.item, entities.CSCStudent): 
			if action.item.move: 
				determineNewGathererPosition(grid, action.item, action.item.aim)
				rescheduleItem(actionList, ticks, action.item, action.item.rate)
			else: 
				gatherAnimation(actionList, action.item, ticks)

		if isinstance(action.item, entities.transformingMonster):
			if action.item.times == 0: 
				action.item.times += 1
				rescheduleItem(actionList, ticks, action.item, action.item.rate)
			elif action.item.times == 1: 
				action.item.times += 1
				rescheduleItem(actionList, ticks, action.item, action.item.rate)
			elif action.item.times >= 2: 
				r = entities.Obstacle(action.item.position)
				grid.entityList.append(r)
				i = grid.entityList.index(action.item)
				grid.entityList.pop(i)

		if isinstance(action.item, entities.CampusMarket): 
			if action.item.times < 3: 
				action.item.times += 1
			else: 
				action.item.times = 0 
			rescheduleItem(actionList, ticks, action.item, action.item.rate)
示例#2
0
def create_obstacle(properties, i_store):
   if len(properties) == OBSTACLE_NUM_PROPERTIES:
      return entities.Obstacle(properties[OBSTACLE_NAME],
         point.Point(int(properties[OBSTACLE_COL]), int(properties[OBSTACLE_ROW])),
         image_store.get_images(i_store, properties[PROPERTY_KEY]))
   else:
      return None
示例#3
0
def create_new_entity(pt, entity_select, i_store):
   name = entity_select + '_' + str(pt.x) + '_' + str(pt.y)
   images = image_store.get_images(i_store, entity_select)
   if entity_select == 'obstacle':
      return entities.Obstacle(name, pt, images)
   elif entity_select == 'miner':
      return entities.MinerNotFull(name, MINER_LIMIT, pt,
         random.randint(MINER_RATE_MIN, MINER_RATE_MAX),
         images, MINER_ANIMATION_RATE)
   elif entity_select == 'vein':
      return entities.Vein(name,
         random.randint(VEIN_RATE_MIN, VEIN_RATE_MAX), pt, images)
   elif entity_select == 'ore':
      return entities.Ore(name, pt, images,
         random.randint(ORE_RATE_MIN, ORE_RATE_MAX))
   elif entity_select == 'blacksmith':
      return entities.Blacksmith(name, pt, images)
   else:
      return None
示例#4
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)
示例#5
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
示例#6
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!")
示例#7
0
def create_obstacle():
    obstacles.append(entities.Obstacle(r.randrange(10, screen_size[1]- 140), 120, screen_size[0]))