// force la fin de l'animation de réduction de fenetre public void ForceReduce() { /*if(!this.m_reduced){// on restore la fenetre on lève un event this.BroadcastMessage("OnReducing",this,SendMessageOptions.DontRequireReceiver); }*/ this.m_reduced = true; this.SetButtons(this.m_reduced);// affichage des boutons this.m_state = new WindowAnimationState(this.m_animation,this.m_animationDuration,this.m_display.transform,this.m_buttons,this.CalculateFullTranslation(this.m_animation,this.m_reduced)); // on génère le structure de l'animation this.UpdateAnimation(1); this.m_state = null; }
// Update is called once per frame void Update() { if(this.m_state != null){ // il y a une animation à gérer this.m_state.m_timeLeft -= Time.deltaTime; if(this.m_state.m_timeLeft < 0){ this.m_state.m_timeLeft = 0; } float progress = (this.m_animationDuration - this.m_state.m_timeLeft) / this.m_animationDuration; this.UpdateAnimation(progress); if(this.m_state.m_timeLeft == 0){ // fin de l'animation if(this.m_reduced){ // on envoit les messages de fin d'action this.BroadcastMessage("OnPostReducing",this,SendMessageOptions.DontRequireReceiver); this.m_renderer.Active = false; } else{ this.BroadcastMessage("OnPostRestoring",this,SendMessageOptions.DontRequireReceiver); this.m_renderer.Active = true; } this.m_state = null; } } }
// lance une animation private bool LaunchAnimation(bool reduced) { if(this.m_state != null || this.m_reduced == reduced){ // si l'animation n'est pas autorisée ou si une animation est en cours ou si la fenetre est deja dans l'etat final attendu return false; } if(!this.m_animationAllowed){ if(!reduced){ this.ForceRestore(); } else{ this.ForceReduce(); } return false; } this.m_reduced = reduced; this.SetButtons(this.m_reduced);// affichage des boutons this.m_state = new WindowAnimationState(this.m_animation,this.m_animationDuration,this.m_display.transform,this.m_buttons,this.CalculateFullTranslation(this.m_animation,reduced)); // on génère le structure de l'animation return true; }