示例#1
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     string name = Microsoft.VisualBasic.Interaction.InputBox("Name: ");
     Directory.CreateDirectory("data/animations/" + name);
     Animation tmpAnimation = new Animation() { BasePath = name };
     File.WriteAllText("data/animations/" + name + "/data.xml", tmpAnimation.ToXml());
     RefreshItems();
 }
示例#2
0
        public override void LoadXmlDoc(System.Xml.XmlDocument x)
        {
            foreach (XmlNode n in x.DocumentElement.ChildNodes)
            {
                string val = n.InnerText;
                switch (n.Name)
                {
                    case "animations":
                        foreach (XmlNode a in n.ChildNodes)
                        {
                            Animation tmpAnim = new Animation(Helpers.NodeToDoc(a));
                            Animations[tmpAnim.Name] = tmpAnim;
                        }

                        break;
                }
            }
        }
示例#3
0
文件: Actor.cs 项目: JimmJamm/SqEng
        protected override void onTick()
        {
            Velocity += Acceleration * (float)Execution.MSPF;

            float a = 0.0005f;
            float div = 1.1f;

            if (@Type == ActorType.MainCharacter)
            {

                if (Velocity.X > speedlimit)
                    Velocity.X = speedlimit;
                if (Velocity.X < -speedlimit)
                    Velocity.X = -speedlimit;

                if (Velocity.Y > speedlimit)
                    Velocity.Y = speedlimit;
                if (Velocity.Y < -speedlimit)
                    Velocity.Y = -speedlimit;
            }

            LastPosition = new Vector2f(Position.X, Position.Y);
            Position += Velocity * (float)Execution.MSPF;
            DeltaPosition = new Vector2f(Position.X - LastPosition.X, Position.Y - LastPosition.Y);

            @Animation.Tick();
            switch (@Type)
            {
                case ActorType.Rock:
                    if (Collision.CollidingWith(StaticResources.State.MainCharacter.Collision))
                    {
                        StaticResources.State.MainCharacter.GoBack();
                    }
                    break;
                case ActorType.MainCharacter:
                    if (Velocity.X >= 0)
                    {
                        Frame.MakeUnflipped();
                    }
                    else if (Velocity.X <= 0)
                    {
                        Frame.MakeFlipped();
                    }

                    if (Keyboard.IsKeyPressed(Keyboard.Key.W))
                        Acceleration.Y = -a;
                    else if (Keyboard.IsKeyPressed(Keyboard.Key.S))
                        Acceleration.Y = a;
                    else
                    {
                        Acceleration.Y = 0;
                        Velocity.Y /= div;
                    }

                    if (Keyboard.IsKeyPressed(Keyboard.Key.D))
                        Acceleration.X = a;
                    else if (Keyboard.IsKeyPressed(Keyboard.Key.A))
                        Acceleration.X = -a;
                    else
                    {
                        Acceleration.X = 0;
                        Velocity.X /= div;
                    }

                    if (Seq != null)
                    {
                        switch (Seq.Seq)
                        {
                            case Sequences.Default:
                                Animation = Animations.Idle;
                                break;
                            case Sequences.Spin:
                                Animation = Animations.Spinny;
                                break;
                        }
                    }
                    else
                    {
                        Animation = Animations.Idle;
                    }

                    break;
                case ActorType.Shark:

                    if (Collision.CollidingWith(StaticResources.State.MainCharacter.Collision))
                    {
                        if (StaticResources.State.MainCharacter.Seq != null)
                        {
                            if (StaticResources.State.MainCharacter.Seq.Seq == Sequences.Spin)
                            {
                                Seq = null;
                                Velocity = new Vector2f(0.8f, -0.8f);
                                SharkHit = true;
                                return;
                            }
                        }
                        if (!SharkHit)
                        {
                            System.Windows.Forms.MessageBox.Show("You died!");
                            Environment.Exit(0);
                            StaticResources.State.MainCharacter.GoBack();
                        }
                    }

                    if (!SharkHit)
                    {
                        if (Seq == null)
                        {
                            if (Velocity.X >= 0)
                            {
                                Velocity.X = -0.1f;
                                Seq = new Sequence(Sequences.SharkLeft, 3000, 0);
                            }
                            else
                            {
                                Velocity.X = 0.1f;
                                Seq = new Sequence(Sequences.SharkRight, 3000, 0);
                            }
                        }

                        if (Velocity.X <= 0)
                        {
                            Sprite.Scale = new Vector2f(1.0f, 1.0f);
                        }
                        else if (Velocity.X >= 0)
                        {
                            Sprite.Scale = new Vector2f(-1.0f, 1.0f);
                        }
                    }
                    else
                    {
                        Sprite.Scale = new Vector2f(Sprite.Scale.X / 2, Sprite.Scale.Y / 2);
                    }
                    break;
                case ActorType.Taffy:
                    if (!Hidden && Collision.CollidingWith(StaticResources.State.MainCharacter.Collision))
                    {
                        StaticResources.State.Candies++;
                        Hidden = true;
                        Sound.Play("player/powerup" + Helpers.Rnd.Next(1, 3), 50);
                        //System.Windows.Forms.MessageBox.Show("aaa");
                    }
                    break;
            }

            Sprite.Position = new Vector2f(Position.X, Position.Y);
        }
示例#4
0
 public AnimationEditor(string path)
 {
     Animation = new Animation(path);
     InitializeComponent();
 }
示例#5
0
文件: Actor.cs 项目: JimmJamm/SqEng
        public override void LoadXmlDoc(System.Xml.XmlDocument x)
        {
            foreach (XmlNode n in x.DocumentElement.ChildNodes)
            {

                string val = n.InnerText.Trim();

                //System.Windows.Forms.MessageBox.Show(n.Name + " : " + val);

                switch (n.Name)
                {
                    case "animation":
                        Animation = new Animation.Animation(Helpers.NodeToDoc(n));
                        break;
                    case "type":
                        switch (val)
                        {
                            case "maincharacter":
                                @Type = ActorType.MainCharacter;
                                break;
                            case "shark":
                                @Type = ActorType.Shark;
                                break;
                            case "taffy":
                                @Type = ActorType.Taffy;
                                break;
                            case "rock":
                                @Type = ActorType.Rock;
                                break;
                        }
                        break;
                    case "x":
                        Position.X = Convert.ToSingle(val);
                        break;
                    case "y":
                        Position.Y = Convert.ToSingle(val);
                        break;
                }
            }
        }