std::string cFlyon::Create_Name(void) const { std::string name = "Flyon "; // dup name += _(Get_Direction_Name(m_start_direction).c_str()); if (m_start_image && !m_start_image->m_name.empty()) { name += " " + m_start_image->m_name; } return name; }
xmlpp::Element* cFlyon::Save_To_XML_Node(xmlpp::Element* p_element) { xmlpp::Element* p_node = cEnemy::Save_To_XML_Node(p_element); Add_Property(p_node, "direction", Get_Direction_Name(m_start_direction)); Add_Property(p_node, "image_dir", path_to_utf8(m_img_dir)); Add_Property(p_node, "max_distance", static_cast<int>(m_max_distance)); Add_Property(p_node, "speed", m_speed); return p_node; }
void cRokko :: Set_Direction( const ObjectDirection dir ) { // already set if( m_start_direction == dir ) { return; } // clear old images Clear_Images(); cEnemy::Set_Direction( dir, 1 ); m_name = "Rokko "; m_name += _(Get_Direction_Name(m_start_direction).c_str()); Add_Image( pVideo->Get_Surface( "enemy/rokko/r.png" ) ); if( m_direction == DIR_LEFT ) { Set_Rotation( 0.0f, 180.0f, 0.0f, 1 ); } else if( m_direction == DIR_RIGHT ) { Set_Rotation( 0.0f, 0.0f, 0.0f, 1 ); } else if( m_direction == DIR_UP ) { Set_Rotation( 0.0f, 0.0f, 270.0f, 1 ); } else if( m_direction == DIR_DOWN ) { Set_Rotation( 0.0f, 0.0f, 90.0f, 1 ); } else { printf( "Warning: Unknown Rokko direction %s\n", Get_Direction_Name( dir ).c_str() ); } Update_Distance_rect(); Set_Image_Num( 0, 1 ); }
cRokko::cRokko(XmlAttributes& attributes, cSprite_Manager* sprite_manager) : cEnemy(sprite_manager) { cRokko::Init(); // position Set_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]), true); // direction Set_Direction(Get_Direction_Id(attributes.fetch("direction", Get_Direction_Name(m_start_direction)))); // speed Set_Speed(string_to_float(attributes.fetch("speed", float_to_string(m_speed)))); }
void cWaypoint::Save_To_Stream(ofstream& file) { file << "\t<waypoint>" << std::endl; file << "\t\t<Property name=\"x\" value=\"" << static_cast<int>(m_start_pos_x) << "\" />" << std::endl; file << "\t\t<Property name=\"x\" value=\"" << static_cast<int>(m_start_pos_y) << "\" />" << std::endl; file << "\t\t<Property name=\"type\" value=\"" << static_cast<int>(waypoint_type) << "\" />" << std::endl; file << "\t\t<Property name=\"destination\" value=\"" << destination << "\" />" << std::endl; file << "\t\t<Property name=\"direction_backward\" value=\"" << Get_Direction_Name(direction_backward) << "\" />" << std::endl; file << "\t\t<Property name=\"access\" value=\"" << access_default << "\" />" << std::endl; file << "\t</waypoint>" << std::endl; }
void cEato::Save_To_Stream(ofstream& file) { file << "\t<enemy>" << std::endl; file << "\t\t<Property name=\"type\" value=\"eato\"" << std::endl; file << "\t\t<Property name=\"posx\" value=\"" << static_cast<int>(m_start_pos_x) << "\" />" << std::endl; file << "\t\t<Property name=\"posy\" value=\"" << static_cast<int>(m_start_pos_y) << "\" />" << std::endl; file << "\t\t<Property name=\"image_dir\" value=\"" << m_img_dir << "\" />" << std::endl; file << "\t\t<Property name=\"direction\" value=\"" << Get_Direction_Name(m_start_direction) << "\" />" << std::endl; file << "\t</enemy>" << std::endl; }
void cSpikeball :: Save_To_Stream( ofstream &file ) { // begin enemy file << "\t<enemy>" << std::endl; // name file << "\t\t<Property name=\"type\" value=\"spikeball\" />" << std::endl; // position file << "\t\t<Property name=\"posx\" value=\"" << static_cast<int>(m_start_pos_x) << "\" />" << std::endl; file << "\t\t<Property name=\"posy\" value=\"" << static_cast<int>(m_start_pos_y) << "\" />" << std::endl; // color file << "\t\t<Property name=\"color\" value=\"" << Get_Color_Name( m_color_type ) << "\" />" << std::endl; // direction file << "\t\t<Property name=\"direction\" value=\"" << Get_Direction_Name( m_start_direction ) << "\" />" << std::endl; // end enemy file << "\t</enemy>" << std::endl; }
void cSpikeball :: Editor_Activate( void ) { // get window manager CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); // direction CEGUI::Combobox *combobox = static_cast<CEGUI::Combobox *>(wmgr.createWindow( "TaharezLook/Combobox", "editor_spikeball_direction" )); Editor_Add( UTF8_("Direction"), UTF8_("Starting direction."), combobox, 100, 75 ); combobox->addItem( new CEGUI::ListboxTextItem( "left" ) ); combobox->addItem( new CEGUI::ListboxTextItem( "right" ) ); combobox->setText( Get_Direction_Name( m_start_direction ) ); combobox->subscribeEvent( CEGUI::Combobox::EventListSelectionAccepted, CEGUI::Event::Subscriber( &cSpikeball::Editor_Direction_Select, this ) ); // init Editor_Init(); }
void cRokko :: Save_To_Stream( ofstream &file ) { // begin enemy file << "\t<enemy>" << std::endl; // name file << "\t\t<Property name=\"type\" value=\"rokko\" />" << std::endl; // position file << "\t\t<Property name=\"posx\" value=\"" << static_cast<int>(m_start_pos_x) << "\" />" << std::endl; file << "\t\t<Property name=\"posy\" value=\"" << static_cast<int>(m_start_pos_y) << "\" />" << std::endl; // direction file << "\t\t<Property name=\"direction\" value=\"" << Get_Direction_Name( m_start_direction ) << "\" />" << std::endl; // speed file << "\t\t<Property name=\"speed\" value=\"" << m_speed << "\" />" << std::endl; // end enemy file << "\t</enemy>" << std::endl; }
void cFlyon::Editor_Activate(void) { // get window manager CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton(); // direction CEGUI::Combobox* combobox = static_cast<CEGUI::Combobox*>(wmgr.createWindow("TaharezLook/Combobox", "editor_flyon_direction")); Editor_Add(UTF8_("Direction"), UTF8_("Direction it moves into."), combobox, 100, 110); combobox->addItem(new CEGUI::ListboxTextItem("up")); combobox->addItem(new CEGUI::ListboxTextItem("down")); combobox->addItem(new CEGUI::ListboxTextItem("left")); combobox->addItem(new CEGUI::ListboxTextItem("right")); combobox->setText(Get_Direction_Name(m_start_direction)); combobox->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted, CEGUI::Event::Subscriber(&cFlyon::Editor_Direction_Select, this)); // image dir CEGUI::Editbox* editbox = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox", "editor_flyon_image_dir")); Editor_Add(UTF8_("Image directory"), UTF8_("Directory containing the images"), editbox, 200); editbox->setText(path_to_utf8(m_img_dir).c_str()); editbox->subscribeEvent(CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber(&cFlyon::Editor_Image_Dir_Text_Changed, this)); // max distance editbox = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox", "editor_flyon_max_distance")); Editor_Add(UTF8_("Distance"), _("Movable Distance into its direction"), editbox, 90); editbox->setValidationString("^[+]?\\d*$"); editbox->setText(int_to_string(static_cast<int>(m_max_distance))); editbox->subscribeEvent(CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber(&cFlyon::Editor_Max_Distance_Text_Changed, this)); // speed editbox = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox", "editor_flyon_speed")); Editor_Add(UTF8_("Speed"), UTF8_("Initial speed when jumping out"), editbox, 120); editbox->setValidationString("[+]?[0-9]*\\.?[0-9]*"); editbox->setText(float_to_string(m_speed, 6, 0)); editbox->subscribeEvent(CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber(&cFlyon::Editor_Speed_Text_Changed, this)); // init Editor_Init(); }
cFlyon::cFlyon(XmlAttributes& attributes, cSprite_Manager* sprite_manager) : cEnemy(sprite_manager) { cFlyon::Init(); // position Set_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]), true); // image directory Set_Image_Dir(utf8_to_path(attributes.fetch("image_dir", path_to_utf8(m_img_dir)))); // direction Set_Direction(Get_Direction_Id(attributes.fetch("direction", Get_Direction_Name(m_start_direction)))); // max distance Set_Max_Distance(string_to_int(attributes.fetch("max_distance", int_to_string(m_max_distance)))); // speed Set_Speed(string_to_float(attributes.fetch("speed", float_to_string(m_speed)))); }
void cMovingSprite :: Update_Anti_Stuck( void ) { // collision count cObjectCollisionType *col_list = Collision_Check( &m_col_rect, COLLIDE_ONLY_BLOCKING ); // check collisions for( cObjectCollision_List::iterator itr = col_list->objects.begin(), itr_end = col_list->objects.end(); itr != itr_end; ++itr ) { cObjectCollision *collision = (*itr); cSprite *col_obj = collision->obj; if( collision->m_array == ARRAY_ENEMY || ( collision->m_array == ARRAY_ACTIVE && ( col_obj->m_massive_type == MASS_HALFMASSIVE || col_obj->m_massive_type == MASS_CLIMBABLE ) ) ) { continue; } debug_print( "Anti Stuck detected object %s on %s side\n", col_obj->m_name.c_str(), Get_Direction_Name( collision->direction ).c_str() ); if( collision->direction == DIR_LEFT ) { Col_Move( 1.0f, 0.0f, 0, 1 ); } else if( collision->direction == DIR_RIGHT ) { Col_Move( -1.0f, 0.0f, 0, 1 ); } else if( collision->direction == DIR_UP ) { Col_Move( 0.0f, 1.0f, 0, 1 ); } else if( collision->direction == DIR_DOWN ) { Col_Move( 0.0f, -1.0f, 0, 1 ); } } delete col_list; }