//I want some sort of control over adding stuff to the two lists. //This is because I am a CONTROL freak. public void add_cue(Cue cue) { ViewPanel vp = cue as ViewPanel; Comic c = cue as Comic; //EndCue ec = cue as EndCue; if (vp != null) { //Increment the region's X value by the previous comic widths vp.panel_region.X += sum_prev_comic_width(); } else if (c != null) { comics.Add(c); c.x = sum_prev_comic_width(); comic_num++; return; } //else if (ec != null) //{ // //truncate_cues(ec.fire_at); //} if (cue.fire_at == 0) { currently_displayed.Add(cue); } else { all_scene_objects.Add(cue); } }
public void Draw(SpriteBatch spriteBatch, SpriteFont font, Texture2D SubtitleLayover) { foreach (Cue cue in currently_displayed) { if (cue.type == CueType.ViewPanel) { ViewPanel vp = cue as ViewPanel; Comic begins_in = rect_begins_in(vp.panel_region); Rectangle source = vp.panel_region; source.X -= begins_in.x; spriteBatch.Draw(begins_in.texture, scale_rect(source), source, Color.White); } else if (cue.type == CueType.Transition) { Transition t = cue as Transition; Comic begins_in = rect_begins_in(t.trans_rect); Rectangle source = t.trans_rect; source.X -= begins_in.x; spriteBatch.Draw(begins_in.texture, scale_rect(source), source, Color.White); } else if (cue.type == CueType.Graphic) { Graphic graphic = (Graphic)cue; spriteBatch.Draw(graphic.texture, graphic.position, graphic.bound, Color.White); } else if (cue.type == CueType.Text) { Text text = (Text)cue; int y = (int)text.pos[0].Y; spriteBatch.Draw(SubtitleLayover, new Rectangle(0, y, 1280, 720 - y), Color.Black); for (int i = 0; i < text.lines.Count; i++) { string s = text.lines[i]; Vector2 pos = text.pos[i]; spriteBatch.DrawString(Fonts.SubtitleFont, s, pos, Color.Orange); } } if (cue.type == CueType.Fade) { Fade f = cue as Fade; spriteBatch.Draw(white_dot, new Rectangle(0, 0, 1280, 720), Color.Black * f.alpha_val); //spriteBatch.Draw(white_dot, new Rectangle(0, 0, 400, 400), Color.Red); //Console.WriteLine(f.alpha_val.ToString()); } } }
private ViewPanel next_vp() { foreach (Cue c in current_cutscene.all_scene_objects) { ViewPanel vp = c as ViewPanel; if (vp != null) { return(vp); } } return(null); }
public void Update(GameTime gameTime) { //CutScene cs = game_state.current_cs; CutScene cs = current_cutscene; List <Cue> aso = cs.all_scene_objects; List <Cue> cdo = cs.currently_displayed; bool ending = false; time += stop_watch.ElapsedMilliseconds - prev_time; prev_time = stop_watch.ElapsedMilliseconds; //1. Look for Cues that can be added to currently displayed objects for (int i = 0; i < aso.Count; i++) { Cue cue = aso[i]; if (time > cue.fire_at) { cdo.Add(cue); aso.Remove(cue); cdo.Sort(); if (cue.type == CueType.End) { ending = true; } } } //2. Remove expired Cues from currently displayed objects for (int i = 0; i < cdo.Count; i++) { Cue cue = cdo[i]; if (time > cue.remove_at && cue.type != CueType.Sound) { cdo.Remove(cue); } } //3. Look for the current comic and update any transitions foreach (Cue cue in cdo) { if (cue.type == CueType.Fade) { Fade f = (Fade)cue; f.Update(time); } if (cue.type == CueType.Transition) { Transition t = cue as Transition; float percentage = ((float)time - (float)t.fire_at) / ((float)t.remove_at - (float)t.fire_at); t.calc_trans_rect(percentage); } } //4. Play sounds and then remove them for (int i = 0; i < cdo.Count; i++) { Cue cue = cdo[i]; if (cue.type == CueType.Sound) { Sound s = cue as Sound; Globals.soundBank.PlayCue(s.name); cdo.Remove(s); } } //5. Check if we have reached the end of the CutScene if (Controls.pressed_once(Keys.Enter) || Controls.pressed_once(Buttons.B) || ending) { Globals.StopEffects(); Game1.current_state = cs.return_state; Game1.chat_state.dialogue_options = cs.dialogue_options; //game_state.state = cs.return_state; //game_state.dialogue_options = cs.dialogue_options; cdo.Clear(); aso.Clear(); stop_watch.Reset(); prev_time = 0; } //6. Skip to the next panel or the next audio cue if ((Controls.pressed_once(Keys.Space) || Controls.pressed_once(Buttons.A) || Controls.clicked_once()) && cs.skippable) { ViewPanel vp = next_vp(); if (vp != null) { Globals.StopEffects(); time = vp.fire_at; } else { Sound s = next_sound(); if (s != null) { Globals.StopEffects(); time = s.fire_at; } else { stop_watch.Reset(); prev_time = 0; Globals.StopEffects(); Game1.current_state = cs.return_state; Game1.chat_state.dialogue_options = cs.dialogue_options; //game_state.state = cs.return_state; //game_state.dialogue_options = cs.dialogue_options; cdo.Clear(); aso.Clear(); } } } }