示例#1
0
文件: Mario.cs 项目: kinder112/Yami
        public Mario(SpriteBatch batch, ContentManager manager, Point position, ColissionLayer colission, List<Sprite> staticobjects, List<Sprite> movableobjects)
            : base(batch, manager, "sprites/marios")
        {
            FrameAnimation anim = new FrameAnimation(3, 15, 16, 0, 0);
            anim.FramesPerSecond = 20;
            animations.Add("runright", anim);
            anim = new FrameAnimation(3, 15, 16, 0, 17);
            anim.FramesPerSecond = 20;
            animations.Add("runleft", anim);
            anim = new FrameAnimation(1, 16, 16, 48, 0);
            anim.FramesPerSecond = 20;
            animations.Add("jumpright", anim);
            anim = new FrameAnimation(1, 16, 16, 48, 17);
            anim.FramesPerSecond = 20;
            animations.Add("jumpleft", anim);
            anim = new FrameAnimation(1, 16, 16, 66, 0);
            anim.FramesPerSecond = 20;
            animations.Add("frictionright", anim);
            anim = new FrameAnimation(1, 16, 16, 66, 17);
            anim.FramesPerSecond = 20;
            animations.Add("frictionleft", anim);
            anim.FramesPerSecond = 20;
            anim = new FrameAnimation(1, 16, 16, 80 , 0);
            anim.FramesPerSecond = 20;
            animations.Add("stopright", anim);
            anim = new FrameAnimation(1, 16, 16, 80, 17);
            anim.FramesPerSecond = 20;
            animations.Add("stopleft", anim);
            anim = new FrameAnimation(1, 16, 16, 0, 34);
            anim.FramesPerSecond = 20;
            animations.Add("die", anim);
            anim = new FrameAnimation(1, 16, 16, 16, 34);
            animations.Add("slideright", anim);
            anim = new FrameAnimation(1, 16, 16, 32, 34);
            animations.Add("slideleft", anim);
            //anim = new FrameAnimation(4, 33, 33, 66, 66);
            //animations.Add("swimright", anim);
            //anim = new FrameAnimation(4, 33, 33, 0, 99);
            //animations.Add("swimleft", anim);

            CurrentAnimationName = "stopright";
            this.position = position;
            this.colission = colission;
            this.staticobjects = staticobjects;
            this.movableobjects = movableobjects;

            sounds = new List<SoundEffectInstance>();

            SoundEffect tmp = manager.Load<SoundEffect>("sounds/jump");
            SoundEffectInstance sound = tmp.CreateInstance();
            sounds.Add(sound);
            tmp = manager.Load<SoundEffect>("sounds/death");
            sound = tmp.CreateInstance();
            sounds.Add(sound);
        }
示例#2
0
文件: Powerup.cs 项目: kinder112/Yami
        int type; // 1 - Upshroom 2 - Lvlshroom 3 - Plant 4  - Star

        #endregion Fields

        #region Constructors

        public Powerup(SpriteBatch batch, ContentManager manager, ColissionLayer collision, int type, Point position)
            : base(batch, manager, "sprites/powerups")
        {
            FrameAnimation anim = new FrameAnimation(1, 16, 16, 0, 0);
            anim.FramesPerSecond = 6;
            animations.Add("Lvlshroom", anim);
            anim = new FrameAnimation(1, 16, 16, 16, 0);
            animations.Add("Upshroom", anim);
            anim = new FrameAnimation(4, 16, 16, 0, 16);
            animations.Add("Plant", anim);
            anim = new FrameAnimation(4, 16, 16, 0, 32);
            animations.Add("Star", anim);

            this.collision = collision;
            this.type = type;

            switch (type)
            {
                case 1:
                    CurrentAnimationName = "Upshroom";
                    break;
                case 2:
                    CurrentAnimationName = "Lvlshroom";
                    break;
                case 3:
                    CurrentAnimationName = "Plant";
                    break;
                case 4:
                    CurrentAnimationName = "Star";
                    break;

            }
            this.position = position;
            this.oldpos = position;

            SoundEffect tmp;
            if (type == 4)
                tmp = manager.Load<SoundEffect>("sounds/starman10");
            else if (type == 2)
                tmp = manager.Load<SoundEffect>("sounds/1up");
            else
                tmp = manager.Load<SoundEffect>("sounds/powerup");

            sound1 = tmp.CreateInstance();
        }
示例#3
0
文件: Goomba.cs 项目: kinder112/Yami
        int type = 7; // Goomba

        #endregion Fields

        #region Constructors

        public Goomba(SpriteBatch batch, ContentManager manager, ColissionLayer colission, int type, Point position)
            : base(batch, manager, "sprites/goomba")
        {
            FrameAnimation anim = new FrameAnimation(2, 16, 16, 0, 0);
            anim.FramesPerSecond = 6;
            animations.Add("walk", anim);
            anim = new FrameAnimation(1, 16, 16, 32, 0);
            anim.FramesPerSecond = 1;
            animations.Add("stomp", anim);

            CurrentAnimationName = "walk";
            IsAnimating = true;
            this.position = position;
            this.oldpos = position;
            this.colission = colission;

            SoundEffect tmp = manager.Load<SoundEffect>("sounds/stomp");
            sound1 = tmp.CreateInstance();
        }
示例#4
0
文件: Map.cs 项目: kinder112/Yami
        public Map(SpriteBatch batch, ContentManager manager, string world, string filename)
        {
            this.manager = manager;
            this.batch = batch;
            teleports = new List<Globals.Teleport>();
            sounds = new List<SoundEffectInstance>();
            staticobjects = new List<Sprite>();
            moveableobjects = new List<Sprite>();
            bool readingtStart = false;
            bool readingSounds = false;
            bool readingBackground = false;
            bool readingColission = false;
            bool readingObjects = false;
            bool readingFlag = false;
            bool readingTeleports = false;

            using (StreamReader reader = new StreamReader("Content/worlds/"+world+"/"+filename))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine().Trim();

                    if (string.IsNullOrEmpty(line))
                        continue;
                    if(line.Contains("[START]"))
                    {
                        readingtStart = true;
                        readingSounds = false;
                        readingBackground = false;
                        readingColission = false;
                        readingObjects = false;
                        readingFlag = false;
                        readingTeleports = false;
                    }
                    else if (line.Contains("[FLAG]"))
                    {
                        readingtStart = false;
                        readingSounds = true;
                        readingBackground = false;
                        readingColission = false;
                        readingObjects = false;
                        readingFlag = true;
                        readingTeleports = false;
                    }
                    else if (line.Contains("[TELEPORTS]"))
                    {
                        readingtStart = false;
                        readingSounds = false;
                        readingBackground = false;
                        readingColission = false;
                        readingObjects = false;
                        readingFlag = false;
                        readingTeleports = true;
                    }
                    else if (line.Contains("[SOUNDS]"))
                    {
                        readingtStart = false;
                        readingSounds = true;
                        readingBackground = false;
                        readingColission = false;
                        readingObjects = false;
                        readingFlag = false;
                        readingTeleports = false;
                    }
                    else if (line.Contains("[BACKGROUND]"))
                    {
                        readingtStart = false;
                        readingSounds = false;
                        readingBackground = true;
                        readingColission = false;
                        readingObjects = false;
                        readingFlag = false;
                        readingTeleports = false;
                    }
                    else if (line.Contains("[COLISSION]"))
                    {
                        readingtStart = false;
                        readingSounds = false;
                        readingBackground = false;
                        readingColission = true;
                        readingObjects = false;
                        readingFlag = false;
                        readingTeleports = false;
                    }
                    else if (line.Contains("[OBJECTS]"))
                    {
                        readingtStart = false;
                        readingSounds = false;
                        readingBackground = false;
                        readingColission = false;
                        readingObjects = true;
                        readingFlag = false;
                        readingTeleports = false;
                    }

                    else if (readingtStart)
                    {
                        string[] tmp = line.Split(' ');
                        start = new Point(int.Parse(tmp[0]), int.Parse(tmp[1]));
                    }
                    else if (readingFlag)
                    {
                        flagexists = true;
                        string[] tmp = line.Split(' ');
                        flagposition = new Point(int.Parse(tmp[0]), int.Parse(tmp[1]));
                        flagpositionbackup = new Point(int.Parse(tmp[0]), int.Parse(tmp[1]));
                    }
                    else if (readingTeleports)
                    {

                        string[] tmp = line.Split(' ');
                        Globals.Teleport tmp2 = new Globals.Teleport(int.Parse(tmp[0]),
                                                                        int.Parse(tmp[1]),
                                                                        int.Parse(tmp[2]),
                                                                        new Point(int.Parse(tmp[3]), int.Parse(tmp[4])));
                        teleports.Add(tmp2);
                    }
                    else if (readingSounds)
                    {
                        SoundEffect tmp = manager.Load<SoundEffect>("sounds/"+line);
                        SoundEffectInstance sound = tmp.CreateInstance();
                        sounds.Add(sound);
                    }
                    else if (readingBackground)
                    {
                        background = manager.Load<Texture2D>("worlds/" + world + "/" + line);
                    }
                    else if (readingColission)
                    {
                        colission = ColissionLayer.FromFile("worlds/" + world + "/" + line);
                    }
                    else if (readingObjects)
                    {
                        ObjectsLayer tmp = ObjectsLayer.FromFile("worlds/" + world + "/" + line);

                        for (int x = 0; x < tmp.width; x++)
                        {
                            for (int y = 0; y < tmp.height; y++)
                            {
                                if (tmp.GetCellIndex(x, y) == 0)
                                    continue;
                                if (tmp.GetCellIndex(x, y) > 0 && tmp.GetCellIndex(x, y) < 5)
                                {
                                    Box tmp3 = new Box(batch, manager, tmp.GetCellIndex(x, y), new Point(Globals.ConvertCellToX(x), Globals.ConvertCellToY(y)));
                                    staticobjects.Add(tmp3);
                                }
                                else if (tmp.GetCellIndex(x, y) > 4 && tmp.GetCellIndex(x, y) < 7)
                                {
                                    Brick tmp3 = new Brick(batch, manager, tmp.GetCellIndex(x, y), new Point(Globals.ConvertCellToX(x), Globals.ConvertCellToY(y)));
                                    staticobjects.Add(tmp3);
                                }
                                else if (tmp.GetCellIndex(x, y) == 7)
                                {
                                    Goomba tmp3 = new Goomba(batch, manager, colission, tmp.GetCellIndex(x, y), new Point(Globals.ConvertCellToX(x), Globals.ConvertCellToY(y)));
                                    moveableobjects.Add(tmp3);
                                }
                                else if (tmp.GetCellIndex(x, y) == 8)
                                {
                                    Coin tmp3 = new Coin(batch, manager, tmp.GetCellIndex(x, y), new Point(Globals.ConvertCellToX(x), Globals.ConvertCellToY(y)));
                                    moveableobjects.Add(tmp3);
                                }

                            }
                        }

                    }

                }
            }

            flag = manager.Load<Texture2D>("images/flag");
            size = new Point(this.background.Width, this.background.Height);
            camera = new Camera(size.X, size.Y);
            mario = new Mario(batch, manager, start, colission, staticobjects, moveableobjects);
        }