Пример #1
0
bool cScorpionState::OnMessage(cGameObject * _entity, const ST_PACKET & _packet)
{
	switch (_packet.msg_type)
	{
	case Msg_Death:
		SetupAnimation(2);
		m_bLive = false;
		m_bAttack = false;
		m_fPassedAnitime = 0.0f;
		return true;
	case Msg_IdleAni:
		SetupAnimation(1);
		m_bLive = true;
		return true;
	case Msg_MoveAni:
		SetupAnimation(6);
		return true;
	case Msg_AttackAni:
		SetupAnimation(0);
		if (m_bAttack)
			return true;
		m_bAttack = true;
		m_fPassedAnitime = 0.0f;
		return true;
	}
	return false;
}
void SceneEditorScreenMain::LoadResources()
{
    new HintManager();
    new PropertyControlCreator();
    
    ControlsFactory::CustomizeScreenBack(this);

    font12 = ControlsFactory::GetFont12();
	font12Color = ControlsFactory::GetColorLight();

    helpDialog = new HelpDialog();
    
    focusedControl = NULL;

    InitializeNodeDialogs();

    Rect fullRect = GetRect();
    settingsDialog = new SettingsDialog(fullRect, this);
    textureTrianglesDialog = new TextureTrianglesDialog();
    materialEditor = new MaterialEditor();
    
    InitControls();
    
    InitializeBodyList();
    SetupAnimation();
}
void SceneEditorScreenMain::AutoSaveLevel(BaseObject *, void *, void *)
{
    time_t now = time(0);
    tm* utcTime = localtime(&now);
    
    String folderPath = EditorSettings::Instance()->GetDataSourcePath() + "Autosave";
    bool folderExcists = FileSystem::Instance()->IsDirectory(folderPath);
    if(!folderExcists)
    {
        FileSystem::Instance()->CreateDirectory(folderPath);
    }

    
    
    String pathToFile = folderPath + Format("/AutoSave_%04d.%02d.%02d_%02d_%02d.sc2",   
                                            utcTime->tm_year + 1900, utcTime->tm_mon + 1, utcTime->tm_mday, 
                                            utcTime->tm_hour, utcTime->tm_min);
    
    BodyItem *iBody = bodies[0];
    Scene * scene = iBody->bodyControl->GetScene();
    SceneFileV2 * file = new SceneFileV2();
    file->EnableDebugLog(false);
    file->SaveScene(pathToFile, scene);
    SafeRelease(file);
    
    SetupAnimation();
}
Пример #4
0
void cDworfMageState::EnterState(cGameObject * _entity)
{
	_entity->GetChrSkinnedMesh()->SetFolderName(MODEL_PATH + "DworfBattleMage");
	_entity->GetChrSkinnedMesh()->Load("DworfBattleMage.X");
	_entity->GetObjSkinnedMesh()->Load(std::string(MODEL_PATH + "hand/left").c_str(), "lefthand.X", _entity->GetChrSkinnedMesh(), "RThumb");

	m_entityID = _entity->GetID();

	m_pOwner = _entity;

	m_pAniController = _entity->GetChrSkinnedMesh()->GetAnimationController();
	m_chrmesh = _entity->GetChrSkinnedMesh();

	float fAttackPeriod = m_chrmesh->GetAnimationPeriod(13);
	packet_setskill = new Packet_SetSkill(VK_RBUTTON, new cBaseShortAttack(_entity,1.0f, fAttackPeriod*0.5f, fAttackPeriod));
	g_pMessageDispatcher->Dispatch(m_entityID, m_entityID, 0.0f, Msg_SetSkill, packet_setskill);

	packet_setskill = new Packet_SetSkill(KeyEnum::SKILL1, new cFirePad(_entity,FLT_MAX));
	g_pMessageDispatcher->Dispatch(m_entityID, m_entityID, 0.0f, Msg_SetSkill, packet_setskill);

	packet_setskill = new Packet_SetSkill(KeyEnum::SKILL2, new cFireHand(_entity, 1.0f,fAttackPeriod*0.7f,fAttackPeriod));
	g_pMessageDispatcher->Dispatch(m_entityID, m_entityID, 0.0f, Msg_SetSkill, packet_setskill);

	SetupAnimation(20);

	
}
Пример #5
0
void PlacesOverlayVScrollBar::StartConnectorAnimation()
{
  if (animation_.CurrentState() == nux::animation::Animation::State::Stopped)
  {
    SetupAnimation(connector_height_, 0, std::min(connector_height_, MAX_CONNECTOR_ANIMATION));

    tweening_connection_ = animation_.updated.connect([this] (int const& update) {
      connector_height_ = update;
      UpdateConnectorTexture();
    });

    animation_.Start();
  }
}
Пример #6
0
void cScorpionState::EnterState(cGameObject * _entity)
{
	m_pOwner = _entity;
	m_pOwner->GetChrSkinnedMesh()->SetFolderName(MODEL_PATH + "scorpion");
	m_pOwner->GetChrSkinnedMesh()->Load("scorpion.X");
	m_entityID = _entity->GetID();

	m_pAniController = _entity->GetChrSkinnedMesh()->GetAnimationController();
	m_chrmesh = _entity->GetChrSkinnedMesh();

	SetupAnimation(1);

	_entity->SetBoundSphere(1, D3DXVECTOR3(0, 0, 0));

	float fAttackPeriod = m_chrmesh->GetAnimationPeriod(0);
	packet_setskill = new Packet_SetSkill(VK_RBUTTON, new cBaseShortAttack(_entity,1.0f, fAttackPeriod*0.5f, fAttackPeriod));
	g_pMessageDispatcher->Dispatch(m_entityID, m_entityID, 0.0f, Msg_SetSkill, packet_setskill);
}
Пример #7
0
void PlacesOverlayVScrollBar::StartScrollAnimation(ScrollDir dir, int stop)
{
  if (animation_.CurrentState() == nux::animation::Animation::State::Stopped)
  {
    SetupAnimation(0, stop, SCROLL_ANIMATION);

    tweening_connection_ = animation_.updated.connect([this, dir] (int const& update) {
      OnScroll(dir, update - delta_update_);
      delta_update_ = update;

      CheckIfThumbIsInsideSlider();
      UpdateConnectorPosition();
      QueueDraw();
    });

    animation_.Start();
  }
}
Пример #8
0
// Constructor
Player::Player( Graphics &Graphic, 
			  float X, 
			  float Y ) :
			  AnimatedSprite( Graphic, 
			  "Content/Sprites/MyChar.png", 
			  0,
			  0,
			  16,
			  16, 
			  X, 
			  Y, 
			  100 ),
			  m_DX( 0 ),
			  m_DY( 0 ),
			  m_Facing( Direction::RIGHT ),
			  bGrounded( false )
{
	Graphic.LoadImage( "Content/Sprites/MyChar.png" );
	SetupAnimation( );
	PlayAnimation( "IdleRight" );
}
Пример #9
0
bool cDworfMageState::OnMessage(cGameObject * _entity, const ST_PACKET & _packet)
{
	//idle20,move34,attack13
	switch (_packet.msg_type)
	{
	case Msg_Respawn:
		m_bLive = true;
		m_bAttack = false;
		return true;
	case Msg_IdleAni:
		SetupAnimation(20);
		m_bAttack = false;
		return true;
	case Msg_MoveAni:
		SetupAnimation(34);
		m_bAttack = false;
		return true;
	case Msg_AttackAni:
		SetupAnimation(13);
		m_bAttack = true;
		m_fPassedAnitime = 0.0f;
		return true;
	case Msg_CastingAni:
		SetupAnimation(17);
		m_bAttack = false;
		return true;
	case Msg_StunAni:
		SetupAnimation(29);
		m_bAttack = false;
		return true;
	case Msg_Death:
		SetupAnimation(32);
		m_bAttack = false;
		m_bLive = false;
		m_fPassedAnitime = 0.0f;
		return true;
	}
	return false;
}
Пример #10
0
//------------------------------------------------------------------------
// Add an animation node from the *.anm file.
// ----------------------------------------------------------------------
// Param -> IN:
//      const char*:    Path to the animation file.
//------------------------------------------------------------------------
HRESULT FlyAnimation::AddAnimNode( const char* cAnimFile )
{
    DWORD dw;
    char cIdentifier[4];
    sChunk chunk;
    bool bLoaded[2];
    sAnimNode animNode;

    FILE* pFile = fopen( cAnimFile,"rb" );
    if( !pFile ) return FLY_FILENOTFOUND;

    // Is the file valid format ?
    cIdentifier[0] = fgetc( pFile );
    cIdentifier[1] = fgetc( pFile );
    cIdentifier[2] = fgetc( pFile );
    cIdentifier[3] = fgetc( pFile );
    fread( &dw,sizeof(DWORD),1,pFile );
    if( strcmp(cIdentifier,"ANM") != 0 || 
        dw != AMD_VERSION(2,0) )
    {
        fclose( pFile );
        return FLY_INVALIDFILE;
    }

    // Start to read the animation file.
    bLoaded[0] = bLoaded[1] = false;

    while( true )
    {
        UINT n;
        bool bEnd = false;
        size_t nLen;

        // Read the chunk head.
        fread( &chunk,sizeof(sChunk),1,pFile );

        switch( chunk.wIdentifier )
        {
        case CHK_ANIMHEADER:
            if( bLoaded[0] )
            {
                fclose( pFile );
                return FLY_INVALIDFILE;
            }

            fread( &nLen,sizeof(size_t),1,pFile );
            animNode.header.sAuthor.resize( nLen,'\0' );
            fread( &animNode.header.sAuthor[0],nLen,1,pFile );
            fread( &nLen,sizeof(size_t),1,pFile );
            animNode.header.sAnimName.resize( nLen,'\0' );
            fread( &animNode.header.sAnimName[0],nLen,1,pFile );
            fread( &animNode.header.nNumJoints,sizeof(UINT),1,pFile );
            fread( &animNode.header.nNumFrames,sizeof(UINT),1,pFile );

            bLoaded[0] = true;
            break;
        case CHK_JOINT:
            if( !bLoaded[0] || bLoaded[1] )
            {
                fclose( pFile );
                return FLY_INVALIDFILE;
            }

            animNode.pJoints = new sJoint[animNode.header.nNumJoints];
            if( !animNode.pJoints )
            {
                fclose( pFile );
                return FLY_OUTOFMEMORY;
            }
            memset( animNode.pJoints,0,sizeof(sJoint)*animNode.header.nNumJoints );

            for( n=0;n<animNode.header.nNumJoints;n++ )
            {
                LPJOINT pJoint = &animNode.pJoints[n];

                // Read the joint_main.
                fread( &nLen,sizeof(size_t),1,pFile );
                pJoint->sName.resize( nLen,'\0' );
                fread( &pJoint->sName[0],nLen,1,pFile );
                fread( &nLen,sizeof(size_t),1,pFile );
                pJoint->sParentName.resize( nLen,'\0' );
                fread( &pJoint->sParentName[0],nLen,1,pFile );
                fread( &pJoint->wNumKF_Position,sizeof(WORD),1,pFile );
                fread( &pJoint->wNumKF_Rotation,sizeof(WORD),1,pFile );

                // Read the keyframe position data.
                pJoint->pKF_Position = new sKeyframe_Pos[pJoint->wNumKF_Position];
                if( !pJoint->pKF_Position )
                {
                    fclose( pFile );
                    return FLY_OUTOFMEMORY;
                }
                fread( pJoint->pKF_Position,sizeof(sKeyframe_Pos),pJoint->wNumKF_Position,pFile );

                // Read the keyframe rotation data.
                pJoint->pKF_Rotation = new sKeyframe_Rot[pJoint->wNumKF_Rotation];
                if( !pJoint->pKF_Rotation )
                {
                    fclose( pFile );
                    return FLY_OUTOFMEMORY;
                }
                fread( pJoint->pKF_Rotation,sizeof(sKeyframe_Rot),pJoint->wNumKF_Rotation,pFile );
            }

            bLoaded[1] = true;
            break;
        case CHK_END:
            bEnd = true;
            break;

        // Unknown file chunk.
        default: fseek( pFile,chunk.nChunkSize,SEEK_CUR );
        }

        if( bEnd ) break;
    }

    // Close the animation file.
    fclose( pFile );

    // 输出骨骼数据
    pFile = fopen( "skeleton.txt","w" );
    for( UINT i=0;i<animNode.header.nNumJoints;i++ )
    {
        fprintf( pFile,"%s            %s\n",animNode.pJoints[i].sName.c_str(),
            animNode.pJoints[i].sParentName.c_str() );
    }
    fclose( pFile );

    // Setup the skeleton system.
    SetupAnimation( &animNode );

    // Add the animation node to the list.
    m_AnimGroup.push_back( animNode );

    // Update the dirty state.
    m_nDirtyState++;

    return FLY_OK;
}
Пример #11
0
void SceneEditorScreenMain::LoadResources()
{
    new ErrorNotifier();
    new HintManager();
    new UNDOManager();
    
    new PropertyControlCreator();
    
    ControlsFactory::CustomizeScreenBack(this);

    font = ControlsFactory::GetFontLight();
    
    //init file system dialog
    fileSystemDialog = new UIFileSystemDialog("~res:/Fonts/MyriadPro-Regular.otf");
    fileSystemDialog->SetDelegate(this);
    
    String path = EditorSettings::Instance()->GetDataSourcePath();
    if(path.length())
    fileSystemDialog->SetCurrentDir(path);
    
    // add line after menu
    Rect fullRect = GetRect();
    AddLineControl(Rect(0, ControlsFactory::BUTTON_HEIGHT, fullRect.dx, LINE_HEIGHT));
    CreateTopMenu();
    
    //
    settingsDialog = new SettingsDialog(fullRect, this);
    UIButton *settingsButton = ControlsFactory::CreateImageButton(Rect(fullRect.dx - ControlsFactory::BUTTON_HEIGHT, 0, ControlsFactory::BUTTON_HEIGHT, ControlsFactory::BUTTON_HEIGHT), "~res:/Gfx/UI/settingsicon");

    settingsButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnSettingsPressed));
    AddControl(settingsButton);
    SafeRelease(settingsButton);
        
    menuPopup = new MenuPopupControl(GetRect(), ControlsFactory::BUTTON_HEIGHT + LINE_HEIGHT);
    menuPopup->SetDelegate(this);
    
    InitializeNodeDialogs();    
    
    textureTrianglesDialog = new TextureTrianglesDialog();
    
    textureConverterDialog = new TextureConverterDialog(fullRect);
    
    materialEditor = new MaterialEditor();
	particlesEditor = new ParticlesEditorControl();
    
    //add line before body
    AddLineControl(Rect(0, BODY_Y_OFFSET, fullRect.dx, LINE_HEIGHT));
    
    //Library
    libraryButton = ControlsFactory::CreateButton(
                                                  Rect(fullRect.dx - ControlsFactory::BUTTON_WIDTH, 
                                                       BODY_Y_OFFSET - ControlsFactory::BUTTON_HEIGHT, 
                                                       ControlsFactory::BUTTON_WIDTH, 
                                                       ControlsFactory::BUTTON_HEIGHT), 
                        LocalizedString(L"panel.library"));
    libraryButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnLibraryPressed));
    AddControl(libraryButton);
    
    int32 libraryWidth = EditorSettings::Instance()->GetRightPanelWidth();
    libraryControl = new LibraryControl(
                            Rect(fullRect.dx - libraryWidth, BODY_Y_OFFSET + 1, libraryWidth, fullRect.dy - BODY_Y_OFFSET - 1)); 
    libraryControl->SetDelegate(this);
    libraryControl->SetPath(path);

    //properties
    propertiesButton = ControlsFactory::CreateButton(
                            Vector2(libraryButton->GetRect().x - ControlsFactory::BUTTON_WIDTH, 
                            BODY_Y_OFFSET - ControlsFactory::BUTTON_HEIGHT), 
                        LocalizedString(L"panel.properties"));
    propertiesButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnPropertiesPressed));
    AddControl(propertiesButton);
    
    
    //scene ingo
    sceneInfoButton = ControlsFactory::CreateButton(
                            Vector2(propertiesButton->GetRect().x - ControlsFactory::BUTTON_WIDTH, 
                            BODY_Y_OFFSET - ControlsFactory::BUTTON_HEIGHT), 
                            LocalizedString(L"panel.sceneinfo"));
    sceneInfoButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnSceneInfoPressed));
    AddControl(sceneInfoButton);
    
    
    sceneGraphButton = ControlsFactory::CreateButton( Vector2(0, BODY_Y_OFFSET - ControlsFactory::BUTTON_HEIGHT), LocalizedString(L"panel.graph.scene"));
    sceneGraphButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnSceneGraphPressed));
    AddControl(sceneGraphButton);
    
    dataGraphButton = ControlsFactory::CreateButton(Vector2(ControlsFactory::BUTTON_WIDTH, BODY_Y_OFFSET - ControlsFactory::BUTTON_HEIGHT), LocalizedString(L"panel.graph.data"));
    dataGraphButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnDataGraphPressed));
    AddControl(dataGraphButton);

	entitiesButton = ControlsFactory::CreateButton(Vector2(ControlsFactory::BUTTON_WIDTH*2, BODY_Y_OFFSET - ControlsFactory::BUTTON_HEIGHT), LocalizedString(L"panel.graph.entities"));
	entitiesButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnEntitiesPressed));
	AddControl(entitiesButton);
    
    InitializeBodyList();
    
    SetupAnimation();
    
    helpDialog = new HelpDialog();
}