예제 #1
0
        public override void Update(float dt, AnimationPart part, float animationProgress, AnimationEvent nextEvent)
        {
            float progress = GetProgress(nextEvent, animationProgress);

            part.position.X = interpolation.Apply(position.X, (nextEvent as PositionEvent).position.X, progress);
            part.position.Y = interpolation.Apply(position.Y, (nextEvent as PositionEvent).position.Y, progress);
        }
예제 #2
0
        private void LoadCharacterRig(string name, string[] lines)
        {
            Display = new GCharacter();
            int partnum = Int32.Parse(lines[0]);

            for (int i = 0; i < partnum; i++)
            {
                GPart  part     = new GPart();
                string partName = lines[i * 3 + 1];
                part.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/Character/" + name + "/" + partName + "/Front.png")));
                part.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/Character/" + name + "/" + partName + "/Right.png")));
                part.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/Character/" + name + "/" + partName + "/Back.png")));
                part.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/Character/" + name + "/" + partName + "/Left.png")));
                string[] rotCenterStrings = lines[i * 3 + 2].Split(" ");
                part.RotationCenter = new Vector2f(float.Parse(rotCenterStrings[0]), float.Parse(rotCenterStrings[1]));
                string[] originStrings = lines[i * 3 + 3].Split(" ");
                part.Origin = new Vector3f(float.Parse(originStrings[0]), float.Parse(originStrings[1]), float.Parse(originStrings[1]));
                Display.Parts.Add(part);
            }
            Display.State.ID      = 0;
            Display.State.facing  = 0;
            Display.State.elapsed = Time.Zero;
            int animnum = Int32.Parse(lines[partnum * 3 + 1]);

            for (int i = 0; i < animnum; i++)
            {
                Animation animation = new Animation();
                string    animName  = lines[partnum * 3 + 2 + i];
                string[]  amimLines = File.ReadAllLines("../../../Resources/Graphics/Character/" + name + "/Animations/" + animName + ".txt");
                int       sum       = 0;
                for (int j = 0; j < partnum; j++)
                {
                    AnimationPart part      = new AnimationPart();
                    int           animSteps = Int32.Parse(amimLines[sum++]);
                    for (int k = 0; k < animSteps; k++)
                    {
                        AnimationStep step     = new AnimationStep();
                        string[]      stepInfo = amimLines[sum++].Split(" ");
                        step.Duration = Time.FromSeconds(float.Parse(stepInfo[0]));
                        step.Rotation = float.Parse(stepInfo[1]);
                        part.Steps.Add(step);
                    }
                    animation.Parts.Add(part);
                }

                if (amimLines.Last() == "Y")
                {
                    animation.Repeatable = true;
                }
                else
                {
                    animation.Repeatable = false;
                }
                Display.Animations.Add(animation);
            }
        }
예제 #3
0
 public PEnvironment(string name, Game game)
 {
     Game = game;
     try
     {
         LoadGraphics(name);
     }
     catch (FileNotFoundException fileNotFoundException)
     {
         Console.WriteLine("No graphics setup file for " + name);
         Console.WriteLine("Initializing as default texture");
         GPart defPart = new GPart();
         defPart.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/default.png")));
         GCharacter defCharacter = new GCharacter();
         defCharacter.Parts.Add(defPart);
         AnimationStep defStep = new AnimationStep();
         defStep.Duration = Time.FromSeconds(1f);
         defStep.Rotation = 0;
         AnimationPart defAnimPart = new AnimationPart();
         defAnimPart.Steps.Add(defStep);
         Animation defAnim = new Animation();
         defAnim.Parts.Add(defAnimPart);
         defCharacter.Animations.Add(defAnim);
         Display = defCharacter;
     }
     catch (DirectoryNotFoundException directoryNotFoundException)
     {
         Console.WriteLine("No graphics setup file for " + name);
         Console.WriteLine("Initializing as default texture");
         GPart defPart = new GPart();
         defPart.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/default.png")));
         GCharacter defCharacter = new GCharacter();
         defCharacter.Parts.Add(defPart);
         AnimationStep defStep = new AnimationStep();
         defStep.Duration = Time.FromSeconds(1f);
         defStep.Rotation = 0;
         AnimationPart defAnimPart = new AnimationPart();
         defAnimPart.Steps.Add(defStep);
         Animation defAnim = new Animation();
         defAnim.Parts.Add(defAnimPart);
         defCharacter.Animations.Add(defAnim);
         Display = defCharacter;
     }
 }
예제 #4
0
        public void LoadDefault()
        {
            GPart defPart = new GPart();

            defPart.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/default.png")));
            GCharacter defCharacter = new GCharacter();

            defCharacter.Parts.Add(defPart);
            AnimationStep defStep = new AnimationStep();

            defStep.Duration = Time.FromSeconds(1f);
            defStep.Rotation = 0;
            AnimationPart defAnimPart = new AnimationPart();

            defAnimPart.Steps.Add(defStep);
            Animation defAnim = new Animation();

            defAnim.Parts.Add(defAnimPart);
            defCharacter.Animations.Add(defAnim);
            Display = defCharacter;
        }
예제 #5
0
 public void LoadGraphics(string name)
 {
     try
     {
         GPart part = new GPart();
         part.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/Environment/" + name + "/" +
                                                     name + ".png")));
         GCharacter character = new GCharacter();
         character.Parts.Add(part);
         AnimationStep step = new AnimationStep();
         step.Duration = Time.FromSeconds(1f);
         step.Rotation = 0;
         AnimationPart animPart = new AnimationPart();
         animPart.Steps.Add(step);
         Animation anim = new Animation();
         anim.Parts.Add(animPart);
         character.Animations.Add(anim);
         Display = character;
     }
     catch (LoadingFailedException e)
     {
         Console.WriteLine("No graphics file for " + name);
     }
 }
예제 #6
0
        private void LoadProjectile(string name)
        {
            GPart part = new GPart();

            part.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/Environment/" + name + "/" + "Front.png")));
            part.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/Environment/" + name + "/" + "Right.png")));
            part.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/Environment/" + name + "/" + "Back.png")));
            part.BaseTexture.Add(new Sprite(new Texture("../../../Resources/Graphics/Environment/" + name + "/" + "Left.png")));
            GCharacter character = new GCharacter();

            character.Parts.Add(part);
            AnimationStep step = new AnimationStep();

            step.Duration = Time.FromSeconds(1f);
            step.Rotation = 0;
            AnimationPart animPart = new AnimationPart();

            animPart.Steps.Add(step);
            Animation anim = new Animation();

            anim.Parts.Add(animPart);
            character.Animations.Add(anim);
            Display = character;
        }
예제 #7
0
 public void setAnimationPart(AnimationPart animationPart)
 {
     this.animationPart = animationPart;
     setAnimationInteger("part", (int)animationPart);
 }
예제 #8
0
        public override void Update(float dt, AnimationPart part, float animationProgress, AnimationEvent nextEvent)
        {
            float progress = GetProgress(nextEvent, animationProgress);

            part.rotation = interpolation.Apply(rotation, (nextEvent as RotationEvent).rotation, progress);
        }