예제 #1
0
Knight::Knight(Window *window, int knight_number, int lives_total):
	window(window),
	hitbox(0, 0, 0, 0),
	decal(nullptr),
	lives(lives_total),
	deaths(0),
	specialpower(0)
{
	roster_result = roster_document.load_file("../Scripts/roster.xml");
	attack_hitboxes.reserve(8);

	alive = true;
	hit = false;
	jumping = false;
	landing = false;
	is_landed = false;
	is_jumping = false;
	out_of_bounds = false;
	
	moves.resize(ANIMATION_MAX);

	
	std::string knight_file = 
		roster_document.child("roster").
		find_child_by_attribute("id", std::to_string(knight_number).c_str()).
		attribute("script").value();

	knight_result = knight_document.load_file(knight_file.c_str());
	
	if (!knight_result) {
		printf("Failed to load knight %s.\n", knight_file.c_str());
		return;
	}

	animations.resize(ANIMATION_MAX);

	// NOTE(juha): This is filled with each combo, pushed to *special_combos 
	//             and cleared before another fill
	SpecialCombo combo;
	
	/* NOTE(juha): example code
	atoi(levelDocument.child("map").attribute("height").value());
	levelDocument.child("map").find_child_by_attribute("name", "Background2").child("data");
	tmp = new Animation(window, "../Graphics/Knights/wizard_knight_run.png", 50, 50, 0, 4, 8);*/
	
	pugi::xml_node tmp_node;
	tmp_node = knight_document.child("knight");
	
	parseSounds(&tmp_node);

	parseEffects(&tmp_node);

	Rectangle tmp_hitbox(0, 0, 0, 0);
	std::vector<Rectangle> tmp_move_hitboxes;

	tmp_node = knight_document.child("knight").child("action");
	parseActions(&tmp_node);
}
예제 #2
0
void xmlLoader::loadCommands(ofPtr<game> gm, ofxXmlSettings &XML, int stage, int pty) {

    int numCmds = XML.getNumTags("COMMAND");

    for(int cmd = 0; cmd < numCmds; cmd++) {

        if(XML.pushTag("COMMAND", cmd)) {

            command t_cmd;

            int numTargets = XML.getNumTags("TARGET");

            for(int tgt = 0; tgt < numTargets; tgt++) {
                t_cmd.targets.push_back(XML.getValue("TARGET", "",tgt));
            }

            int numZTargets = XML.getNumTags("Z_TARGET");

            for(int tgt = 0; tgt < numZTargets; tgt++) {
                t_cmd.zTargets.push_back(XML.getValue("Z_TARGET", "",tgt));
            }

            int numSTargets = XML.getNumTags("S_TARGET");

            for(int tgt = 0; tgt < numSTargets; tgt++) {
                t_cmd.sTargets.push_back(XML.getValue("S_TARGET", "",tgt));
            }

            t_cmd.stage = stage;
            t_cmd.priority = pty;

            if(XML.tagExists("REPEAT"))t_cmd.isRepeatable = XML.getValue("REPEAT", true);
            t_cmd.isSchedulable = XML.getValue("SCHED", false);
            if(XML.tagExists("SCHED_TYPE"))t_cmd.schedType = XML.getValue("SCHED_TYPE", "none");
            if(XML.tagExists("INTERVAL_SECS"))t_cmd.interval_secs = XML.getValue("INTERVAL_SECS", 0.0);
            if(XML.tagExists("TOT_EXECS"))t_cmd.totExecs = XML.getValue("TOT_EXECS", 1);

            parseActions(t_cmd, XML);

            gm->addCommand(t_cmd);

            XML.popTag(); // COMMAND
        }

    }

}
예제 #3
0
void main_loop(Player &player1, Player &player2)
{
  
  srand (time(NULL));
  int random_num;
  std::string weather;
  player1.active = player1.pokemons[0];
  player2.active = player2.pokemons[0];
  
  player1.active_ability = player1.active->getAbility();
  player2.active_ability = player2.active->getAbility();
  field = {false, false, false, false, CLEAR};

  switchin_abilities(player1.active_ability->name);
  switchin_abilitiies(player2.active_ability->name);

  Attack* attack1, attack2;
  int turn;
  bool bypass = false;
  while(!player1.forfeit || !player2.forfeit) //change this conditional to faints instead
    {
      //getPlayers actions here
      parseActions(player1);
      parseActions(player2);
     

      if(player1.action == SWITCH)
	{
	  bypass = false;
	  if(player2.action == FIGHT && player2.using_attack->name == "Pursuit")
	    {
	      applyDamage(player2.active, player1.active, player2.using_attack);
	      bypass = true;
	    }
	  Switch(player1.active, player1.switchTo);
	  active_ability1 = player1.active->getAbility();
	  switching_abilities(player1.active_ability->name);
	  if(bypass)
	    {
	      //skip to next turn
	      continue;
	    }
	}
      if(player2.action == SWITCH)
	{
	  bypass = false;
	  if(player1.action == FIGHT && player1.using_attack->name == "Pursuit")
	    {	       
	      applyDamage(player1.active, player2.active, player1.using_attack);
	      bypass = true;
	    }
	  Switch(player2.active, player2.switchTo);
	  active_ability2 = player2.active->getAbility();
	  switching_abilities(player2.active_ability->name);
	  // REMEMBER to apply spikes damages and shit
	  if(bypass)
	    {
	      //skip to next turn
	      continue;
	    }
	}
      
      //apply damages
      turn = compareSpeed(player1.active, player2.active);
      switch(turn)
      {
      case -1:
	applyDamage(player2.active, player1.active, player2.using_attack);
	checkIsFaint(player1);
	applyDamage(player1.active, player2.active, player1.using_attack);
	checkIsFaint(player2);
	break;

      case 1:
	applyDamage(player1.active, player2.active, player1.using_attack);
	checkIsFaint(player2);
	applyDamage(player2.active, player1.active, player2.using_attack);
	checkIsFaint(player1);
	break;

      case 0:
	random_num = rand()%101;
	if(random_num < 50)
	  {
	    applyDamage(player1.active, player2.active, player1.using_attack);
	    checkIsFaint(player2);
	    applyDamage(player2.active, player1.active, player2.using_attack);
	    checkIsFaint(player1);
	  }
	else
	  {
	    applyDamage(player1.active, player2.active, player1.using_attack);
	    checkIsFaint(player2);
	    applyDamage(player2.active, player1.active, player2.using_attack);
	    checkIsFaint(player1);
	  }
	break;
      }
      
      afterBattleAbility(player1.active_ability->name);
      checkIsFaint(player1);
      checkIsFaint(player2);
      afterBattleAbility(player2.active_ability->name);
      checkIsFaint(player1);
      checkIsFaint(player2);
    }
}
예제 #4
0
 //! Parse End actions
 //! @param[in] actions message list of actions to parse
 //! @param[out] event_actions event based actions pointer
 //! @param[in] eta estimated time of arrival for actions' dispatching point
 inline void
 parseEndActions(const IMC::MessageList<IMC::Message>& actions,
                 EventActions* event_actions, float eta)
 {
   parseActions(actions, event_actions, eta, false);
 }
예제 #5
0
 //! Parse Start actions
 //! @param[in] actions message list of actions to parse
 //! @param[out] event_actions event based actions pointer
 //! @param[in] eta estimated time of arrival for actions' dispatching point
 inline void
 parseStartActions(const IMC::MessageList<IMC::Message>& actions,
                   EventActions* event_actions, float eta)
 {
   parseActions(actions, event_actions, eta, true);
 }
예제 #6
0
CommandLineOptions::CommandLineOptions()
{
    parseActions();
}
예제 #7
0
    void
    PlanConfigParser::parse(Parsers::Config& cfg, IMC::PlanSpecification& plan)
    {
      cfg.get("Plan Configuration", "Plan ID", "", plan.plan_id);

      // Parse plan actions
      std::vector<std::string> plan_start_actions;
      std::vector<std::string> plan_end_actions;

      cfg.get("Plan Configuration", "Start Actions", "", plan_start_actions);
      cfg.get("Plan Configuration", "End Actions", "", plan_end_actions);
      parseActions(cfg, plan_start_actions, plan.start_actions);
      parseActions(cfg, plan_end_actions, plan.end_actions);

      std::vector<std::string> ids;

      cfg.get("Plan Configuration", "Maneuvers", "", ids);

      for (unsigned i = 0; i < ids.size(); i++)
      {
        std::string id = ids[i];

        IMC::PlanManeuver pman;
        pman.maneuver_id = id;

        std::string type;
        cfg.get(id, "Type", "!!unknown!!", type);

#ifdef DUNE_IMC_POPUP
        if (type == "PopUp")
        {
          IMC::PopUp popup;
          parse(cfg, id, popup);
          pman.data.set(popup);
        }
        else
#endif
#ifdef DUNE_IMC_GOTO
          if (type == "Goto")
          {
            IMC::Goto goto_man;
            parse(cfg, id, goto_man);
            pman.data.set(goto_man);
          }
          else
#endif
#ifdef DUNE_IMC_STATIONKEEPING
          if (type == "StationKeeping")
          {
            IMC::StationKeeping sk_man;
            parse(cfg, id, sk_man);
            pman.data.set(sk_man);
          }
          else
#endif
#ifdef DUNE_IMC_IDLEMANEUVER
            if (type == "Idle")
            {
              IMC::IdleManeuver idle;
              parse(cfg, id, idle);
              pman.data.set(idle);
            }
            else
#endif
#ifdef DUNE_IMC_LOITER
              if (type == "Loiter")
              {
                IMC::Loiter loiter;
                parse(cfg, id, loiter);
                pman.data.set(loiter);
              }
              else
#endif
#ifdef DUNE_IMC_FOLLOWPATH
                if (type == "FollowPath")
                {
                  IMC::FollowPath fp;
                  parse(cfg, id, fp);
                  pman.data.set(fp);

                }
                else
#endif
#ifdef DUNE_IMC_ROWS
                  if (type == "Rows")
                  {
                    IMC::Rows r;
                    parse(cfg, id, r);
                    pman.data.set(r);
                    r.toText(std::cerr);
                  }
                  else
#endif
#ifdef DUNE_IMC_ELEMENTALMANEUVER
                    if (type == "ElementalManeuver")
                    {
                      IMC::ElementalManeuver eman;
                      parse(cfg, id, eman);
                      pman.data.set(eman);
                    }
                    else
#endif
#ifdef DUNE_IMC_YOYO
                    if (type == "YoYo")
                    {
                      IMC::YoYo yoyo;
                      parse(cfg, id, yoyo);
                      pman.data.set(yoyo);
                    }
                    else
#endif
#ifdef DUNE_IMC_ELEVATOR
                  if (type == "Elevator")
                  {
                    IMC::Elevator elev;
                    parse(cfg, id, elev);
                    pman.data.set(elev);
                    elev.toText(std::cerr);
                  }
                  else
#endif
#ifdef DUNE_IMC_DUBIN
                      if (type == "Dubin")
                      {
                        IMC::Dubin dub;
                        parse(cfg, id, dub);
                        pman.data.set(dub);
                      }
                      else
#endif
#ifdef DUNE_IMC_COMPASSCALIBRATION
                        if (type == "CompassCalibration")
                        {
                          IMC::CompassCalibration ccalib;
                          parse(cfg, id, ccalib);
                          pman.data.set(ccalib);
                        }
                        else
#endif
                      {
                        DUNE_ERR
                        ("Plan Load", "Unknown or unsupported maneuver type: '" << type << '\'');
                        return;
                      }

        // Parse maneuver actions
        std::vector<std::string> man_start_actions;
        std::vector<std::string> man_end_actions;

        cfg.get(id, "Start Actions", "", man_start_actions);
        cfg.get(id, "End Actions", "", man_end_actions);
        parseActions(cfg, man_start_actions, pman.start_actions);
        parseActions(cfg, man_end_actions, pman.end_actions);

        plan.maneuvers.push_back(pman);

        if (plan.maneuvers.size() == 1)
        {
          plan.start_man_id = id;
        }
        else
        {
          // See maneuver sequence in graph terms
          IMC::PlanTransition ptransition;
          ptransition.source_man = ids[plan.maneuvers.size() - 2];
          ptransition.dest_man = id;
          plan.transitions.push_back(ptransition);
        }
      }
    }