public void Update() { if (m_scene_state != DrawableState.Finished) { if (m_currUnit.m_sprite.Draw_State == DrawableState.Finished) { m_played_sound = false; if (m_animQ.Count == 0) // Ran out of animations to perform, reset stuff { m_currUnit.m_sprite.Reset(); // So it wont stay finished for the next time around m_scene_state = DrawableState.Finished; return; } else // On to the next animation { float x, y; x = m_currUnit.m_sprite.X_Pos; y = m_currUnit.m_sprite.Y_Pos; m_currUnit.m_sprite.Reset(); // So it wont stay finished for the next time around m_currUnit = m_animQ.Dequeue(); m_currUnit.m_sprite.X_Pos = x; m_currUnit.m_sprite.Y_Pos = y; } } if (!m_played_sound && m_currUnit.m_sound != null) { m_currUnit.m_sound.Play(); m_played_sound = true; } // Update current Animation m_currUnit.m_sprite.Update(); } }
public void Update() { if (m_manager_state != DrawableState.Finished) { if (m_currScene == null) { m_currScene = m_sceneQ.Dequeue(); // Grab the first animation m_curr_scene_num = 0; } else if (m_currScene.Scene_State == DrawableState.Finished) { if (m_sceneQ.Count == 0) // Ran out of scenes to perform, reset stuff { m_currScene.ResetScene(); // So it wont stay finished for the next time around m_manager_state = DrawableState.Finished; m_currScene = null; m_curr_scene_num = -1; return; } else // On to the next animation { m_curr_scene_num++; m_currScene.ResetScene(); // So it wont stay finished for the next time around m_currScene = m_sceneQ.Dequeue(); } } // Update current Animation m_currScene.Update(); } }
public void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { this.otherScreenHasFocus = otherScreenHasFocus; if (this._isExiting) { this._drawableState = Painting.DrawableState.TransitionOff; if (!this.UpdateTransition(gameTime, this.transitionOffTime, 1)) { this.drawableScreen.RemoveDrawable(this); } } else if (coveredByOtherScreen) { if (this.UpdateTransition(gameTime, this.transitionOffTime, 1)) { this._drawableState = Painting.DrawableState.TransitionOff; } else { this._drawableState = Painting.DrawableState.Hidden; } } else if (this.UpdateTransition(gameTime, this.transitionOnTime, -1)) { this._drawableState = Painting.DrawableState.TransitionOn; } else { this._drawableState = Painting.DrawableState.Active; } Update(gameTime); }
private static LinkedList <Drawable> GetDrawableWithState(Canvas canvas, DrawableState state) { var drawables = new LinkedList <Drawable>(); foreach (var drawable in canvas.Drawables) { if (drawable.State == state) { drawables.AddLast(drawable); } } return(drawables); }
public void Update() { bool finished = true; for (int i = 0; i < m_num; i++) { if (m_clouds[i].m_cloud.Draw_State == DrawableState.Active) { finished = false; break; } } if (finished) { m_state = DrawableState.Finished; } if (m_state != DrawableState.Finished) { int tnum = 0; for (int i = 0; i < m_num / 2; i++, tnum++) { m_clouds[i].m_cloud.Update(); m_clouds[i].m_collision_rect = new Rectangle((int)m_clouds[i].m_cloud.X_Pos + m_textures[tnum].Width / 4, (int)m_clouds[i].m_cloud.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData(new Rectangle((int)m_clouds[i].m_cloud.X_Pos, (int)m_clouds[i].m_cloud.Y_Pos, m_clouds[i].m_coldata.m_rect.Width, m_clouds[i].m_coldata.m_rect.Height), m_clouds[i].m_coldata.m_color_data, m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } tnum = 0; for (int i = m_num / 2; i < m_num; i++, tnum++) { m_clouds[i].m_cloud.Update(); m_clouds[i].m_collision_rect = new Rectangle((int)m_clouds[i].m_cloud.X_Pos + m_textures[tnum].Width / 4, (int)m_clouds[i].m_cloud.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData(new Rectangle((int)m_clouds[i].m_cloud.X_Pos, (int)m_clouds[i].m_cloud.Y_Pos, m_clouds[i].m_coldata.m_rect.Width, m_clouds[i].m_coldata.m_rect.Height), m_clouds[i].m_coldata.m_color_data, m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } } }
/// <summary> /// Constructs the token sprite based on the individual /// components. This is the "view" part of a token. /// </summary> public TokenSprite( Display display, Token token) { this.display = display; this.token = token; // Create the tile typeSprite = token.TypeSpriteName; tileDrawable = Game.Theme.DrawableFactory.Create(typeSprite); // Create the letter valueSprite = token.ValueSpriteName; letterDrawable = Game.Theme.DrawableFactory.Create(valueSprite); letterState = new DrawableState(); // Create the selected selectedDrawable = Game.Theme.DrawableFactory.Create("selected"); selectedState = new DrawableState(); // Randomize it Randomize(); }
public virtual void Reset() { m_state = DrawableState.Active; m_effects = SpriteEffects.None; }
public void SetDrawableState(DrawableState state) { _drawableState = state; }
public void Reset() { Sprite temp; int tnum = 0; if (m_player == 0) { for (int i = 0; i < m_num/2; i++, tnum++) { temp = new Sprite(); temp.Texture = m_textures[tnum]; temp.X_Pos = (float)HelperUtils.GetRandomNumber(-412 - HelperUtils.SafeBoundary.X, HelperUtils.SafeBoundary.X + -m_textures[tnum].Width); temp.Y_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.Y, HelperUtils.SafeBoundary.Y + 200); m_clouds[i] = new Cloud(); m_clouds[i].m_used = false; m_clouds[i].m_cloud = new LinearXYMover(temp, 2*HelperUtils.SafeBoundary.X + 1024, (int)temp.Y_Pos, 1.0f); m_clouds[i].m_collision_rect = new Rectangle((int)temp.X_Pos + m_textures[tnum].Width / 4, (int)temp.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData((int)temp.X_Pos, (int)temp.Y_Pos, m_textures[tnum], new Rectangle(0, 0, m_textures[tnum].Width, m_textures[tnum].Height), m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } tnum = 0; for (int i = m_num/2; i < m_num; i++, tnum++) { temp = new Sprite(); temp.Texture = m_textures[tnum]; temp.X_Pos = (float)HelperUtils.GetRandomNumber(-412 - HelperUtils.SafeBoundary.X, HelperUtils.SafeBoundary.X + -m_textures[tnum].Width); temp.Y_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.Y, HelperUtils.SafeBoundary.Y + 200); m_clouds[i] = new Cloud(); m_clouds[i].m_used = false; m_clouds[i].m_cloud = new LinearXYMover(temp, 2*HelperUtils.SafeBoundary.X + 1024, (int)temp.Y_Pos, 1.0f); m_clouds[i].m_collision_rect = new Rectangle((int)temp.X_Pos + m_textures[tnum].Width / 4, (int)temp.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData((int)temp.X_Pos, (int)temp.Y_Pos, m_textures[tnum], new Rectangle(0, 0, m_textures[tnum].Width, m_textures[tnum].Height), m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } } else if (m_player == 1) { for (int i = 0; i < m_num / 2; i++, tnum++) { temp = new Sprite(); temp.Texture = m_textures[tnum]; temp.X_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.X + 1024, HelperUtils.SafeBoundary.X + 1024 + 412); temp.Y_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.Y, HelperUtils.SafeBoundary.Y + 200); m_clouds[i] = new Cloud(); m_clouds[i].m_used = false; m_clouds[i].m_cloud = new LinearXYMover(temp, -m_textures[tnum].Width - 2*HelperUtils.SafeBoundary.X, (int)temp.Y_Pos, 1.0f); m_clouds[i].m_collision_rect = new Rectangle((int)temp.X_Pos + m_textures[tnum].Width / 4, (int)temp.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData((int)temp.X_Pos, (int)temp.Y_Pos, m_textures[tnum], new Rectangle(0, 0, m_textures[tnum].Width, m_textures[tnum].Height), m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } tnum = 0; for (int i = m_num / 2; i < m_num; i++, tnum++) { temp = new Sprite(); temp.Texture = m_textures[tnum]; temp.X_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.X + 1024, HelperUtils.SafeBoundary.X + 1024 + 412); temp.Y_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.Y, HelperUtils.SafeBoundary.Y + 200); m_clouds[i] = new Cloud(); m_clouds[i].m_used = false; m_clouds[i].m_cloud = new LinearXYMover(temp, -m_textures[tnum].Width - 2*HelperUtils.SafeBoundary.X, (int)temp.Y_Pos, 1.0f); m_clouds[i].m_collision_rect = new Rectangle((int)temp.X_Pos + m_textures[tnum].Width / 4, (int)temp.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData((int)temp.X_Pos, (int)temp.Y_Pos, m_textures[tnum], new Rectangle(0, 0, m_textures[tnum].Width, m_textures[tnum].Height), m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } } m_state = DrawableState.Active; }
public void Update() { bool finished = true; for (int i = 0; i < m_num; i++) { if (m_clouds[i].m_cloud.Draw_State == DrawableState.Active) { finished = false; break; } } if (finished) { m_state = DrawableState.Finished; } if (m_state != DrawableState.Finished) { int tnum = 0; for (int i = 0; i < m_num/2; i++, tnum++) { m_clouds[i].m_cloud.Update(); m_clouds[i].m_collision_rect = new Rectangle((int)m_clouds[i].m_cloud.X_Pos + m_textures[tnum].Width / 4, (int)m_clouds[i].m_cloud.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData(new Rectangle((int)m_clouds[i].m_cloud.X_Pos, (int)m_clouds[i].m_cloud.Y_Pos, m_clouds[i].m_coldata.m_rect.Width, m_clouds[i].m_coldata.m_rect.Height), m_clouds[i].m_coldata.m_color_data, m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } tnum = 0; for (int i = m_num/2; i < m_num; i++, tnum++) { m_clouds[i].m_cloud.Update(); m_clouds[i].m_collision_rect = new Rectangle((int)m_clouds[i].m_cloud.X_Pos + m_textures[tnum].Width / 4, (int)m_clouds[i].m_cloud.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData(new Rectangle((int)m_clouds[i].m_cloud.X_Pos, (int)m_clouds[i].m_cloud.Y_Pos, m_clouds[i].m_coldata.m_rect.Width, m_clouds[i].m_coldata.m_rect.Height), m_clouds[i].m_coldata.m_color_data, m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } } }
public void Reset() { Sprite temp; int tnum = 0; if (m_player == 0) { for (int i = 0; i < m_num / 2; i++, tnum++) { temp = new Sprite(); temp.Texture = m_textures[tnum]; temp.X_Pos = (float)HelperUtils.GetRandomNumber(-412 - HelperUtils.SafeBoundary.X, HelperUtils.SafeBoundary.X + -m_textures[tnum].Width); temp.Y_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.Y, HelperUtils.SafeBoundary.Y + 200); m_clouds[i] = new Cloud(); m_clouds[i].m_used = false; m_clouds[i].m_cloud = new LinearXYMover(temp, 2 * HelperUtils.SafeBoundary.X + 1024, (int)temp.Y_Pos, 1.0f); m_clouds[i].m_collision_rect = new Rectangle((int)temp.X_Pos + m_textures[tnum].Width / 4, (int)temp.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData((int)temp.X_Pos, (int)temp.Y_Pos, m_textures[tnum], new Rectangle(0, 0, m_textures[tnum].Width, m_textures[tnum].Height), m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } tnum = 0; for (int i = m_num / 2; i < m_num; i++, tnum++) { temp = new Sprite(); temp.Texture = m_textures[tnum]; temp.X_Pos = (float)HelperUtils.GetRandomNumber(-412 - HelperUtils.SafeBoundary.X, HelperUtils.SafeBoundary.X + -m_textures[tnum].Width); temp.Y_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.Y, HelperUtils.SafeBoundary.Y + 200); m_clouds[i] = new Cloud(); m_clouds[i].m_used = false; m_clouds[i].m_cloud = new LinearXYMover(temp, 2 * HelperUtils.SafeBoundary.X + 1024, (int)temp.Y_Pos, 1.0f); m_clouds[i].m_collision_rect = new Rectangle((int)temp.X_Pos + m_textures[tnum].Width / 4, (int)temp.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData((int)temp.X_Pos, (int)temp.Y_Pos, m_textures[tnum], new Rectangle(0, 0, m_textures[tnum].Width, m_textures[tnum].Height), m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } } else if (m_player == 1) { for (int i = 0; i < m_num / 2; i++, tnum++) { temp = new Sprite(); temp.Texture = m_textures[tnum]; temp.X_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.X + 1024, HelperUtils.SafeBoundary.X + 1024 + 412); temp.Y_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.Y, HelperUtils.SafeBoundary.Y + 200); m_clouds[i] = new Cloud(); m_clouds[i].m_used = false; m_clouds[i].m_cloud = new LinearXYMover(temp, -m_textures[tnum].Width - 2 * HelperUtils.SafeBoundary.X, (int)temp.Y_Pos, 1.0f); m_clouds[i].m_collision_rect = new Rectangle((int)temp.X_Pos + m_textures[tnum].Width / 4, (int)temp.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData((int)temp.X_Pos, (int)temp.Y_Pos, m_textures[tnum], new Rectangle(0, 0, m_textures[tnum].Width, m_textures[tnum].Height), m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } tnum = 0; for (int i = m_num / 2; i < m_num; i++, tnum++) { temp = new Sprite(); temp.Texture = m_textures[tnum]; temp.X_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.X + 1024, HelperUtils.SafeBoundary.X + 1024 + 412); temp.Y_Pos = (float)HelperUtils.GetRandomNumber(HelperUtils.SafeBoundary.Y, HelperUtils.SafeBoundary.Y + 200); m_clouds[i] = new Cloud(); m_clouds[i].m_used = false; m_clouds[i].m_cloud = new LinearXYMover(temp, -m_textures[tnum].Width - 2 * HelperUtils.SafeBoundary.X, (int)temp.Y_Pos, 1.0f); m_clouds[i].m_collision_rect = new Rectangle((int)temp.X_Pos + m_textures[tnum].Width / 4, (int)temp.Y_Pos + m_textures[tnum].Height / 2, m_textures[tnum].Width / 2, 4); m_clouds[i].m_coldata = new CollisionData((int)temp.X_Pos, (int)temp.Y_Pos, m_textures[tnum], new Rectangle(0, 0, m_textures[tnum].Width, m_textures[tnum].Height), m_clouds[i].m_cloud.Origin, m_clouds[i].m_cloud.Scale, m_clouds[i].m_cloud.Rotation, m_clouds[i].m_cloud.Effects); } } m_state = DrawableState.Active; }