Пример #1
0
FadeManager::~FadeManager()
{
    a_target = nullptr;
    if(a_parallelAnimations.animationCount()) //If it's not 0 (false), then there's something
        clearGroup(Parallel);
    if(a_sequentialAnimations.animationCount())
        clearGroup(Sequential);
    if(!a_effectContainer) //if pointer not null
        delete a_effectContainer;
    else
        a_effectContainer = nullptr;
}
Пример #2
0
/*
  Clears a group of stones from the board

  param player: color of the group
  param x, y: coordinates of a stone within the group
*/
void GoBoard::clearGroup( Player player, int x, int y ) 
{
  //clear the current node
  grid[x][y]->setPlayer( EMPTY );

  //array's for the orthogonal neighbors
  int xnew[4] = { x-1, x, x+1, x };
  int ynew[4] = { y, y-1, y, y+1 };

  //iterate through each neighbor
  for( int i = 0; i < 4; i++ )
    {

      //make sure we don't go outside the board
      if( isOnBoard( xnew[i],ynew[i] ))
	{
	  //make sure the stone is of the correct player
	  if( grid[xnew[i]][ynew[i]]->isPlayer( player ))
	    {
	      //clear the stone and any stones of the same player attached to it
	      clearGroup( player, xnew[i], ynew[i] );
	    }
	}
    }
}
Пример #3
0
void KviConfigurationFile::clearKey(const QString & szKey)
{
	m_bDirty = true;
	KviConfigurationFileGroup * p_group = getCurrentGroup();
	p_group->remove(szKey);
	if(p_group->count() == 0)clearGroup(m_szGroup);
}
    void CoCheckersExperiment::processIndividualPostHoc(shared_ptr<NEAT::GeneticIndividual> individual)
    {
        clearGroup();
        addIndividualToGroup(individual);
        shared_ptr<GeneticGeneration> dummy;
        CheckersExperiment::processGroup(dummy);

        individual->setUserData(toString(individual->getFitness()));
        cout << "INDIVIDUAL FITNESS: " << individual->getFitness() << endl;
    }
void TreeCollisionGroupManager::clearGroups(core::objectmodel::BaseContext* /*scene*/)
{
	for (std::set<simulation::Node::SPtr>::iterator it = groupSet.begin(); it!=groupSet.end(); ++it)
	{
        simulation::tree::GNode::SPtr group = sofa::core::objectmodel::SPtr_dynamic_cast<simulation::tree::GNode>(*it);
        if (group) clearGroup(group->getParents(), group);
	}

	groupSet.clear();
	groups.clear();
}
Пример #6
0
 void clearGroup(const std::string &groupName)
 {
    clearGroup(current_fig, groupName);
 }
Пример #7
0
ContactListNestedGroup::~ContactListNestedGroup()
{
	clearGroup();
}
Пример #8
0
/**
 * load
 */
int MapIso::load(string filename) {
	FileParser infile;
	string val;
	string cur_layer;
	string data_format;
  
	clearEvents();
  
	event_count = 0;
	bool collider_set = false;
  
	if (infile.open(PATH_DATA + "maps/" + filename)) {
		while (infile.next()) {
			if (infile.new_section) {
				data_format = "dec"; // default
				
				if (enemy_awaiting_queue) {
					enemies.push(new_enemy);
					enemy_awaiting_queue = false;
				}
				if (npc_awaiting_queue) {
					npcs.push(new_npc);
					npc_awaiting_queue = false;
				}
				if (group_awaiting_queue){
					push_enemy_group(new_group);
					group_awaiting_queue = false;
				}
				
				// for sections that are stored in collections, add a new object here
				if (infile.section == "enemy") {
					clearEnemy(new_enemy);
					enemy_awaiting_queue = true;
				}
				else if (infile.section == "enemygroup") {
					clearGroup(new_group);
					group_awaiting_queue = true;
				}
				else if (infile.section == "npc") {
					clearNPC(new_npc);
					npc_awaiting_queue = true;
				}
				else if (infile.section == "event") {
					event_count++;
				}
				
			}
			if (infile.section == "header") {
				if (infile.key == "title") {
					this->title = infile.val;
				}
				else if (infile.key == "width") {
					this->w = atoi(infile.val.c_str());
				}
				else if (infile.key == "height") {
					this->h = atoi(infile.val.c_str());
				}
				else if (infile.key == "tileset") {
					this->tileset = infile.val;
				}
				else if (infile.key == "music") {
					if (this->music_filename == infile.val) {
						this->new_music = false;
					}
					else {
						this->music_filename = infile.val;
						this->new_music = true;
					}
				}
				else if (infile.key == "spawnpoint") {
					spawn.x = atoi(infile.nextValue().c_str()) * UNITS_PER_TILE + UNITS_PER_TILE/2;
					spawn.y = atoi(infile.nextValue().c_str()) * UNITS_PER_TILE + UNITS_PER_TILE/2;
					spawn_dir = atoi(infile.nextValue().c_str());
				}
			}
			else if (infile.section == "layer") {
				if (infile.key == "id") {
					cur_layer = infile.val;
				}
				else if (infile.key == "format") {
					data_format = infile.val;
				}
				else if (infile.key == "data") {
					// layer map data handled as a special case

					// The next h lines must contain layer data.  TODO: err
					if (data_format == "hex") {
						for (int j=0; j<h; j++) {
							val = infile.getRawLine() + ',';
							for (int i=0; i<w; i++) {
								if (cur_layer == "background") background[i][j] = eatFirstHex(val, ',');
								else if (cur_layer == "object") object[i][j] = eatFirstHex(val, ',');
								else if (cur_layer == "collision") collision[i][j] = eatFirstHex(val, ',');
							}
						}
					}
					else if (data_format == "dec") {
						for (int j=0; j<h; j++) {
							val = infile.getRawLine() + ',';
							for (int i=0; i<w; i++) {
								if (cur_layer == "background") background[i][j] = eatFirstInt(val, ',');
								else if (cur_layer == "object") object[i][j] = eatFirstInt(val, ',');
								else if (cur_layer == "collision") collision[i][j] = eatFirstInt(val, ',');
							}
						}
					}
					if ((cur_layer == "collision") && !collider_set) {
						collider.setmap(collision);
						collider.map_size.x = w;
						collider.map_size.y = h;
					}
				}
			}
			else if (infile.section == "enemy") {
				if (infile.key == "type") {
					new_enemy.type = infile.val;
				}
				else if (infile.key == "spawnpoint") {
					new_enemy.pos.x = atoi(infile.nextValue().c_str()) * UNITS_PER_TILE + UNITS_PER_TILE/2;
					new_enemy.pos.y = atoi(infile.nextValue().c_str()) * UNITS_PER_TILE + UNITS_PER_TILE/2;
					new_enemy.direction = atoi(infile.nextValue().c_str());
				}
			}
			else if (infile.section == "enemygroup") {
				if (infile.key == "category") {
					new_group.category = infile.val;
				}
				else if (infile.key == "level") {
					new_group.levelmin = atoi(infile.nextValue().c_str());
					new_group.levelmax = atoi(infile.nextValue().c_str());
				}
				else if (infile.key == "area") {
					new_group.pos.x = atoi(infile.nextValue().c_str());
					new_group.pos.y = atoi(infile.nextValue().c_str());
					new_group.area.x = atoi(infile.nextValue().c_str());
					new_group.area.y = atoi(infile.nextValue().c_str());
				}
				else if (infile.key == "number") {
					new_group.numbermin = atoi(infile.nextValue().c_str());
					new_group.numbermax = atoi(infile.nextValue().c_str());
				}
			}
			else if (infile.section == "npc") {
				if (infile.key == "id") {
					new_npc.id = infile.val;
				}
				else if (infile.key == "position") {
					new_npc.pos.x = atoi(infile.nextValue().c_str()) * UNITS_PER_TILE + UNITS_PER_TILE/2;
					new_npc.pos.y = atoi(infile.nextValue().c_str()) * UNITS_PER_TILE + UNITS_PER_TILE/2;
				}
			}
			else if (infile.section == "event") {
				if (infile.key == "type") {
					events[event_count-1].type = infile.val;
				}
				else if (infile.key == "location") {
					events[event_count-1].location.x = atoi(infile.nextValue().c_str());
					events[event_count-1].location.y = atoi(infile.nextValue().c_str());
					events[event_count-1].location.w = atoi(infile.nextValue().c_str());
					events[event_count-1].location.h = atoi(infile.nextValue().c_str());
				}
				else if (infile.key == "hotspot") {
					events[event_count-1].hotspot.x = atoi(infile.nextValue().c_str());
					events[event_count-1].hotspot.y = atoi(infile.nextValue().c_str());
					events[event_count-1].hotspot.w = atoi(infile.nextValue().c_str());
					events[event_count-1].hotspot.h = atoi(infile.nextValue().c_str());
				}
				else if (infile.key == "tooltip") {
					events[event_count-1].tooltip = infile.val;
				}
				else if (infile.key == "power_path") {
					events[event_count-1].power_src.x = atoi(infile.nextValue().c_str());
					events[event_count-1].power_src.y = atoi(infile.nextValue().c_str());
					string dest = infile.nextValue();
					if (dest == "hero") {
						events[event_count-1].targetHero = true;
					}
					else {
						events[event_count-1].power_dest.x = atoi(dest.c_str());
						events[event_count-1].power_dest.y = atoi(infile.nextValue().c_str());
					}
				}
				else if (infile.key == "power_damage") {
					events[event_count-1].damagemin = atoi(infile.nextValue().c_str());
					events[event_count-1].damagemax = atoi(infile.nextValue().c_str());
				}
				else if (infile.key == "power_cooldown") {
					events[event_count-1].power_cooldown = atoi(infile.val.c_str());
				}
				else {
					// new event component
					Event_Component *e = &events[event_count-1].components[events[event_count-1].comp_num];
					e->type = infile.key;
					
					if (infile.key == "intermap") {
						e->s = infile.nextValue();
						e->x = atoi(infile.nextValue().c_str());
						e->y = atoi(infile.nextValue().c_str());
					}
					else if (infile.key == "mapmod") {
						e->s = infile.nextValue();
						e->x = atoi(infile.nextValue().c_str());
						e->y = atoi(infile.nextValue().c_str());
						e->z = atoi(infile.nextValue().c_str());
					}
					else if (infile.key == "soundfx") {
						e->s = infile.val;
					}
					else if (infile.key == "loot") {
						e->s = infile.nextValue();
						e->x = atoi(infile.nextValue().c_str()) * UNITS_PER_TILE + UNITS_PER_TILE/2;
						e->y = atoi(infile.nextValue().c_str()) * UNITS_PER_TILE + UNITS_PER_TILE/2;
						e->z = atoi(infile.nextValue().c_str());
					}
					else if (infile.key == "msg") {
						e->s = infile.val;
					}
					else if (infile.key == "shakycam") {
						e->x = atoi(infile.val.c_str());
					}
					else if (infile.key == "requires_status") {
						e->s = infile.val;
					}
					else if (infile.key == "requires_not") {
						e->s = infile.val;
					}
					else if (infile.key == "requires_item") {
						e->x = atoi(infile.val.c_str());
					}
					else if (infile.key == "set_status") {
						e->s = infile.val;
					}
					else if (infile.key == "unset_status") {
						e->s = infile.val;
					}
					else if (infile.key == "remove_item") {
						e->x = atoi(infile.val.c_str());
					}
					else if (infile.key == "reward_xp") {
						e->x = atoi(infile.val.c_str());
					}
					else if (infile.key == "power") {
						e->x = atoi(infile.val.c_str());
					}
					
					events[event_count-1].comp_num++;
				}
			}
		}

		infile.close();
		
		// reached end of file.  Handle any final sections.
		if (enemy_awaiting_queue) {
			enemies.push(new_enemy);
			enemy_awaiting_queue = false;
		}
		if (npc_awaiting_queue) {
			npcs.push(new_npc);
			npc_awaiting_queue = false;
		}
		if (group_awaiting_queue){
			push_enemy_group(new_group);
			group_awaiting_queue = false;
		}
	}


	
	if (this->new_music) {
		loadMusic();
		this->new_music = false;
	}
	tset.load(this->tileset);

	return 0;
}
Пример #9
0
/*
  core function, drives all action on the board each turn

  param player: the player whose turn needs to be executed

  param x,y: coordinates of the stone to be placed
             (note, should be validated with isValidMove() before
	     step is called.
   
  return int: a signal to show the turn has completed succesfully
*/
int GoBoard::step( Player player, int x, int y ) 
{
  Player currPlayer = player;
  Player Enemy;
  Stone *currStone;
  bool KOflag1 = false;
  Group playerGroup;
 
  std::string playerName;

  //establish the opposing player for reference
  if( currPlayer == BLACK ) 
    {
      Enemy = WHITE;
    } 
  else 
    {
      Enemy = BLACK;
    }
 
  //get the stone at x, y
  currStone = grid[x][y];
  
  //set the piece to its new player
  currStone->setPlayer( currPlayer ); 

  //test and possibly kill enemies
  KOflag1 = effectEnemies( Enemy, x, y ); //set the Ko flag to the output

  //initialize the attributes of the group for the current player
  playerGroup.size = 0;
  playerGroup.liberties = 0;
  playerGroup.player = currPlayer;
  playerGroup.owner = (Player)EMPTY;
  //call to determine the attributes
  playerGroup = getGroup( x, y, playerGroup );

  //Debug message to see if the liberties, size, and owner are counted correctly
  //std::cout<<"Size: "<<playerGroup.size<<" Liberties: "<<playerGroup.liberties<<" Player: "<<playerGroup.player<<" Owner: "<<playerGroup.owner<<std::endl;


  //test if player killed themselves
  if( playerGroup.liberties == 0 )
    {
      clearGroup( currPlayer, x, y );
    }

  //Determine if there is not a KO
  if( playerGroup.liberties != 1 || playerGroup.size != 1 || !KOflag1 )
    {
      //The KO positions are set when an enemy is killed,
      //if a KO is not possible then the positions need to be reset 
      //to an unreachable position -1,-1 before the step finishes
      koPosX = -1;
      koPosY = -1;
    }
  
  
  //clear all our Counted marks
  clearMarks();

  //return to signal that the player made a move
  return 1;  
}
Пример #10
0
/*
  Probes adjecent stones and determines if any neighbor groups
  no longer have liberties

  param enemy: the color of the opponents stones
  param x, y: coordinates of the newly placed stone

  return Bool, KOflag, returns true if a state of KO may be possible
  this flag, combined with the flag in the main step function, determines
  if there is in fact a KO state.
*/
bool GoBoard::effectEnemies( Player enemy, int x, int y ) 
{
 
  
  //flags to see if a state of KO may be possible
  int killSize = 0; //size of last gorup killed, used to test for KO, and scoring
  int numKilled = 0; //groups killed, used to test for KO

  //create a group to be reused to test all enemies
  Group enemyGroup;
  enemyGroup.player = enemy;
  enemyGroup.owner = (Player)EMPTY;
  enemyGroup.size = 0;
  enemyGroup.liberties = 0;
  

  //array's to represent orthogonal neighbors
  int xnew[4] = { x-1, x, x+1, x };
  int ynew[4] = { y, y-1, y, y+1 };

  //iterate through each neighbor
  for( int i = 0; i < 4; i++ )
    {
      //make sure we don't go outside the board
      if( isOnBoard( xnew[i], ynew[i] ))
	{
	  
	  //see if the stone is an enemy and has NOT been counted yet
	  if( grid[xnew[i]][ynew[i]]->isPlayer( enemy ) && 
	      !grid[xnew[i]][ynew[i]]->isCounted() )
	    {
	      enemyGroup.size = 0;
	      enemyGroup.liberties = 0;
	      enemyGroup = getGroup( xnew[i], ynew[i], enemyGroup );
	      if( enemyGroup.liberties == 0 ) 
		{
		  //set the killSize when a group is killed
		  killSize = enemyGroup.size;

		  numKilled += 1;
		  
		  //sets the KO position temporarily
		  //will be cleared in the step function if
		  //a ko is not present
		  koPosX = xnew[i];
		  koPosY = ynew[i];
		  
		  switch( enemyGroup.player )
		    {
		    case(WHITE):
		      {
			blackPrisoners += killSize;
			break;
		      }
		    case(BLACK):
		      {
			whitePrisoners += killSize;
			break;
		      }
		    default:
		      {
			break;
		      }
		    }
		  clearGroup( enemy, xnew[i], ynew[i] );
		}
	    }
	}
    }

  //if a single group of size 1 is killed then we need to return that a
  //KO may be possible depending on the size of the player group
  if( numKilled == 1 && killSize == 1)
    {
      return true;
    }
  else
    {
      return false;
    }
}
Пример #11
0
ContactListGroup::~ContactListGroup()
{
	clearGroup();
}