Guest User

PrototypeState::Enter() version2

a guest
Apr 6th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. bool PrototypeState::Enter()
  2. {
  3.     state_window = ServiceLocator<Window>::get_service();
  4.     game_world = GameWorld::create();
  5.     game_world->Initialize();//this one sets the servicelocator<graph> BEWARE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  6.     game_world->TankStateEnter(sf::Vector2f(HALFTILEWIDTH + 1 * TILEWIDTH, HALFTILEHEIGHT + 18 * TILEHEIGHT), RED);
  7.     game_world->TankStateEnter(sf::Vector2f(HALFTILEWIDTH + 18 * TILEWIDTH, HALFTILEHEIGHT + 1 * TILEHEIGHT), GREEN); //
  8.     //game_world->CreateTankPTR(sf::Vector2f(HALFTILEWIDTH + 1 * TILEWIDTH, HALFTILEHEIGHT + 18 * TILEHEIGHT));
  9.  
  10.     ServiceLocator<GameWorld>::set_service(game_world);
  11.    
  12.     graph = ServiceLocator<Graph>::get_service();//Must call this one after game world initialize() perhaps rethink...
  13.    
  14.     BlackBoard<GameWorld>* black = new BlackBoard<GameWorld>;
  15.     black->Start();
  16.     ServiceLocator<BlackBoard<GameWorld>>::set_service(black);
  17.  
  18.  
  19.     BTree = new bt1::FirstBTFindBase;
  20.     bt1::ConditionArrived<GameWorld>* condition1 = new bt1::ConditionArrived<GameWorld>;
  21.     bt1::ConditionBaseWalkable<GameWorld>* condition2 = new bt1::ConditionBaseWalkable<GameWorld>;
  22.     bt1::ActionFindPathAndGo<GameWorld>* action1 = new bt1::ActionFindPathAndGo<GameWorld>;
  23.     bt1::ActionSetArrived<GameWorld>* action2 = new bt1::ActionSetArrived<GameWorld>;
  24.     BTree->SearchBaseAndGo->addChild(condition1);
  25.     BTree->SearchBaseAndGo->addChild(condition2);
  26.     BTree->SearchBaseAndGo->addChild(action1);
  27.     BTree->SearchBaseAndGo->addChild(action2);
  28.    
  29.     ServiceLocator<bt1::FirstBTFindBase>::set_service(BTree);
  30.  
  31.     return true;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment