public CSLRenderer(Scene scene, ContentManager Content) { this.scene = scene; curEventID = 0; scene.background.loadTexture(Content); /* foreach (KeyValuePair<String, Actor> curActor in scene.actors) { curActor.Value.loadTexture(Content); } */ fadeTex = Content.Load<Texture2D>(Globals.getValue("LibCSLContentPath") + "Fade"); speechTex = Content.Load<Texture2D>(Globals.getValue("LibCSLContentPath") + "Speech"); font = Content.Load<SpriteFont>(Globals.getValue("LibCSLContentPath") + "Dialogue"); foreach (Event e in scene.events) { foreach (Actions.Action a in e.actions) { if (a.actionType == ActionType.Move) { MoveAction m = a as MoveAction; if (!scene.actors[m.actor].hasAnim(m.animation)) { scene.actors[m.actor].addAnim(m.animation, AnimationMode.Loop, Content, 4); } } } } curEvent = scene.events[curEventID]; done = false; curEvent = scene.events[curEventID]; done = false; }
private void extractEvents(StreamReader file, ref List<Event> events) { bool foundAllEvents = false; string curLine; while (!foundAllEvents) { curLine = file.ReadLine(); if (curLine.StartsWith("Event")) { string id; FinishedID finishedOn; int time; List<LibCSL.Actions.Action> actions; extractEventHeaderFromLine(curLine, out id, out finishedOn, out time); extractActions(file, out actions); Event newEvent = new Event(finishedOn, actions, time); events.Add(newEvent); } else if (curLine.StartsWith("ENDCSL")) { foundAllEvents = true; } } }
public void Update(GameTime gameTime) { lastKState = kState; kState = Keyboard.GetState(); lastGState = gState; gState = GamePad.GetState(PlayerIndex.One); if (!done) { #region Event change code if (curEvent.finishedOn == FinishedID.onAction) { if ((kState.IsKeyDown(Keys.Space) && lastKState.IsKeyUp(Keys.Space)) || (gState.IsButtonDown(Buttons.A) && lastGState.IsButtonUp(Buttons.A))) { curEventID++; if (curEventID == scene.events.Count) { done = true; } else { curEvent = scene.events[curEventID]; } Console.WriteLine("Finished event " + curEventID); } } else { millis += gameTime.ElapsedGameTime.Milliseconds; Console.WriteLine("Millis = " + millis); if (millis >= curEvent.time) { curEventID++; if (curEventID == scene.events.Count) { done = true; } else { curEvent = scene.events[curEventID]; } Console.WriteLine("Finished event " + curEventID); millis = 0; } } #endregion #region Action updates foreach (Actions.Action curAct in curEvent.actions) { if (curAct.actionType == ActionType.Move) { MoveAction move = curAct as MoveAction; Actor act = scene.getActor(move.actor); move.update(ref act, gameTime); } else if (curAct.actionType == ActionType.Fade) { FadeAction fade = curAct as FadeAction; fade.Update(gameTime); } } #endregion foreach (Actor a in scene.actors.Values) { a.Update(gameTime); } } }