Advertisement
Guest User

PrototypeState::Enter()

a guest
Apr 2nd, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1.  
  2. bool PrototypeState::Enter()
  3. {
  4.     //Few things going on. ServiceLocator is giving and taking new pointers.
  5.     //Game world, BlackBoard and the BehaviorTree are initialized.
  6.  
  7.  
  8.     state_window = ServiceLocator<Window>::get_service(); //this gets a static pointer to my window class.
  9.                                                          // This class holds the sf::window
  10.     game_world = GameWorld::create(); // get a pointer to game_world
  11.     game_world->Initialize();          
  12.     game_world->CreateTankPTR(sf::Vector2f(HALFTILEWIDTH + 1 * TILEWIDTH, HALFTILEHEIGHT + 18 * TILEHEIGHT));
  13.    
  14.     ServiceLocator<GameWorld>::set_service(game_world);
  15.    
  16.     graph = ServiceLocator<Graph>::get_service();
  17.    
  18.     BlackBoard<GameWorld>* black = new BlackBoard<GameWorld>;
  19.     black->Start();
  20.     ServiceLocator<BlackBoard<GameWorld>>::set_service(black);
  21.  
  22.  
  23.     BTree = new bt1::FirstBTFindBase;
  24.     bt1::ConditionArrived<GameWorld>* condition1 = new bt1::ConditionArrived<GameWorld>;
  25.     bt1::ConditionBaseWalkable<GameWorld>* condition2 = new bt1::ConditionBaseWalkable<GameWorld>;
  26.     bt1::ActionFindPathAndGo<GameWorld>* action1 = new bt1::ActionFindPathAndGo<GameWorld>;
  27.     bt1::ActionSetArrived<GameWorld>* action2 = new bt1::ActionSetArrived<GameWorld>;
  28.     BTree->SearchBaseAndGo->addChild(condition1);
  29.     BTree->SearchBaseAndGo->addChild(condition2);
  30.     BTree->SearchBaseAndGo->addChild(action1);
  31.     BTree->SearchBaseAndGo->addChild(action2);
  32.    
  33.     ServiceLocator<bt1::FirstBTFindBase>::set_service(BTree);
  34.  
  35.     return true;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement