Пример #1
0
        public void update(ref Actor actor, GameTime gameTime)
        {
            actor.curAnim = this.animation;
            millis += gameTime.ElapsedGameTime.Milliseconds;

            if (origPos == Vector2.Zero)
            {
                origPos = actor.coordinate;
            }
            if (millis >= time || (millis == 0 && origPos == Vector2.Zero))
            {
                actor.coordinate = target;
                actor.curAnim = "Idle";
            }
            else
            {
                ratio = (float)(millis) / (float)(time);;
                actor.coordinate = Vector2.Lerp(origPos, target, ratio);
                actor.coordinate.X = (float)((int)(actor.coordinate.X));
                actor.coordinate.Y = (float)((int)(actor.coordinate.Y));
            }
        }
Пример #2
0
        private void extractActorsAndBackground(StreamReader file, out Background background, out List<Actor> actors)
        {
            background = null;
            actors = new List<Actor>();
            string curline;

            #region Find Background Declaration

            bool foundBackgroundDeclaration = false;

            while (!foundBackgroundDeclaration)
            {
                curline = file.ReadLine();

                if (curline.StartsWith("Background"))
                {
                    foundBackgroundDeclaration = true;
                    background = new Background(seperator.seperateWords(curline)[1]);
                }
            }

            #endregion

            #region Find Actor Declarations

            bool foundAllActors = false;
            List<string> actorNames = new List<string>();

            while (!foundAllActors)
            {
                curline = file.ReadLine();

                if (curline.StartsWith("Actor"))
                {
                    List<String> words = seperator.seperateWords(curline);

                    string actorName = words[1];
                    string actorXPos = "";
                    Vector2 curActorPos = Vector2.Zero;
                    string actorYPos = "";

                    actorXPos = words[2];
                    actorXPos = actorXPos.Substring(1, actorXPos.Length - 2);
                    actorYPos = words[3];
                    actorYPos = actorYPos.Substring(0, actorYPos.Length - 1);
                    curActorPos = new Vector2(float.Parse(actorXPos), float.Parse(actorYPos));

                    Actor newActor = new Actor(actorName, null, curActorPos);
                    actors.Add(newActor);
                }

                if (isNextLineNonActor((char)file.Peek())) //Check to see if all the actors are done with.  If so, exit loop
                    foundAllActors = true;

            }

            #endregion
        }