Example #1
0
 public MarioLevel(IList<IItem> i, IList<IEnemy> e, IList<IBlock> b, Mario m, Camera c)
 {
     itemList = i;
     enemyList = e;
     blockList = b;
     mario = m;
     camera = c;
     background = new Background(c);
 }
Example #2
0
 public MarioPhysics(Mario m, MarioState s)
 {
     myMario = m;
     State = s;
     xVelocity = 0;
     yVelocity = Constants.marioFallingSpeed;
     jumpCount = 0;
     verticalDirection = VerticalMovingDirection.Falling;
     horizontalDirection = HorizontalMovingDirection.None;
     bounceCounter = 0;
     hitCeiling = false;
     hitGround = true;
 }
Example #3
0
 public OnePlayerLevel(IList<IItem> i, IList<IEnemy> e, IList<IBlock> b, IList<IProjectile> p, Mario m, Camera c, HUD h, SoundEffects s, Blocks.Flagpole f)
 {
     itemList = i;
     enemyList = e;
     blockList = b;
     projectileList = p;
     mario = m;
     camera = c;
     background = new BackgroundOne(c);
     undergroundBackground = new UndergroundBackground(c);
     hud = h;
     sound = s;
     flagpole = f;
     onFlagpole = false;
 }
Example #4
0
 public MarioState(Mario mario, Camera cam)
 {
     //assume that we're starting in a small standing mario state untill the first command comes.
     CurrentSprite = new Sprites.MarioSmallStandingSprite();
     facing = SpriteEffects.None;
     marioIsLarge = false;
     marioHasFire = false;
     marioHasStar = false;
     marioIsInvincible = false;
     invincibleCounter = 0;
     myMario = mario;
     CurrentState = MarioStates.Standing;
     camera = cam;
     hitCounter = Constants.hitTimeout;
     itemCounter = Constants.itemTimeout;
     starDrawCounter = 0;
 }
        private static OnePlayerLevel LoadLevel(StreamReader stream, SoundEffects s)
        {
            List<IEnemy> enemies = new List<IEnemy>();
            List<IBlock> blocks = new List<IBlock>();
            List<IItem> items = new List<IItem>();
            List<IProjectile> projectiles = new List<IProjectile>();
            Mario mario = null;
            Luigi luigi = null;
            Flagpole flagpole = null;
            Camera cam = new Camera();
            HUD hud = new HUD();
            SoundEffects sound = s;

                String tag;

                stream.ReadLine(); //should be <level>
                while ((tag = stream.ReadLine()) != null && !tag.Equals("</level>"))
                {
                    string[] words = tag.Split(' ');
                    int? xpos = null;
                    int? ypos = null;
                    bool isMario = false;
                    bool isLuigi = false;
                    if (words[0].Equals("<mario")) isMario = true;
                    if (words[0].Equals("<luigi")) isLuigi = true;
                    //because type uniquely specifies things anyways, and type is required for non marios, no need to check for the other possibilities here.
                    String type = "";
                    for (int wordsCount = 1; wordsCount < words.Length; wordsCount++)
                    {
                        if (words[wordsCount].Length >= 6)
                        {
                            if(words[wordsCount].Substring(0,5).Equals("type="))
                            {
                                type = words[wordsCount].Substring(5).Trim('"').ToLower();
                            }
                            else if (words[wordsCount].Substring(0, 5).Equals("xpos="))
                            {
                                xpos = Int32.Parse(words[wordsCount].Substring(5).Trim('"'));
                            }
                            else if (words[wordsCount].Substring(0, 5).Equals("ypos="))
                            {
                                ypos = Int32.Parse(words[wordsCount].Substring(5).Trim('"'));
                            }
                        }
                    }
                    if (!xpos.HasValue || !ypos.HasValue) continue; //if we didn't read a position, we can't place it in the world. (if we didn't read a type, then type = "" and it wont get placed in a list anyways)
                    if (isMario)
                    {
                        mario = new Mario(xpos.Value, ypos.Value, cam, sound, projectiles);
                    }
                    else
                    {
                        switch (type.Trim('"'))
                        {
                            case "goomba":
                                enemies.Add(new Goomba(xpos.Value, ypos.Value, cam));
                                break;
                            case "greenkoopa":
                                enemies.Add(new GreenKoopa(xpos.Value, ypos.Value, cam));
                                break;
                            case "redkoopa":
                                enemies.Add(new RedKoopa(xpos.Value, ypos.Value, cam));
                                break;
                            case "piranha":
                                enemies.Add(new Piranha(xpos.Value, ypos.Value, cam));
                                break;

                            case "brick":
                                blocks.Add(new Brick(xpos.Value, ypos.Value, cam, BrickState.bempty));
                                break;
                            case "starbrick":
                                blocks.Add(new Brick(xpos.Value, ypos.Value, cam, BrickState.bstar));
                                break;
                            case "hitqblock":
                                blocks.Add(new Brick(xpos.Value, ypos.Value, cam, BrickState.qempty));
                                break;
                            case "qblock":
                                blocks.Add(new Brick(xpos.Value, ypos.Value, cam, BrickState.qcoin));
                                break;
                            case "qitem":
                                blocks.Add(new Brick(xpos.Value, ypos.Value, cam, BrickState.qitem));
                                break;
                            case "qlife":
                                blocks.Add(new Brick(xpos.Value, ypos.Value, cam, BrickState.qlife));
                                break;
                            case "pipe":
                                blocks.Add(new Pipe(xpos.Value, ypos.Value, cam));
                                break;
                            case "pipe2":
                                blocks.Add(new Pipe2(xpos.Value, ypos.Value, cam));
                                break;
                            case "vpipe":
                                blocks.Add(new VerticalWarpPipe(xpos.Value, ypos.Value, cam));
                                break;
                            case "hpipe":
                                blocks.Add(new HorizontalWarpPipe(xpos.Value, ypos.Value, cam));
                                break;
                            case "roughplatform":
                                blocks.Add(new RoughPlatform(xpos.Value, ypos.Value, cam));
                                break;
                            case "smoothplatform":
                                blocks.Add(new SmoothPlatform(xpos.Value, ypos.Value, cam));
                                break;
                            case "flagpole":
                                flagpole = new Flagpole(xpos.Value, ypos.Value, cam);
                                break;
                            case "castle":
                                blocks.Add(new Castle(xpos.Value, ypos.Value, cam));
                                break;
                            case "greenplatform":
                                blocks.Add(new GreenRoughPlatform(xpos.Value, ypos.Value, cam));
                                break;
                            case "greenbrick":
                                blocks.Add(new GreenBrick(xpos.Value, ypos.Value, cam));
                                break;
                            case "coin":
                                items.Add(new Coin(xpos.Value, ypos.Value, cam));
                                break;
                            case "fireflower":
                                items.Add(new Fireflower(xpos.Value, ypos.Value, cam));
                                break;
                            case "mushroom":
                                items.Add(new Mushroom(xpos.Value, ypos.Value, cam));
                                break;
                            case "oneup":
                                items.Add(new Oneup(xpos.Value, ypos.Value, cam));
                                break;
                            case "star":
                                items.Add(new Star(xpos.Value, ypos.Value, cam));
                                break;
                            default:
                                break;
                        }
                    }
                }
                cam.Init(mario);
                return new OnePlayerLevel(items, enemies, blocks, projectiles, mario, cam, hud, sound, flagpole);
        }
Example #6
0
 //because mario needs camera and camera needs mario, this Init is used to deal with the circular dependency between them.
 public void Init(Mario m)
 {
     mario = m;
 }
Example #7
0
        private int xPos; //camera doesn't need to alter y positions because our camera only pans left-right (actually, only right)

        #endregion Fields

        #region Constructors

        public Camera()
        {
            mario = null;
            xPos = 0;//this should probably actually be tied to the x position mario starts in. 0 works for now, but when we add the return from the secret area, it wont.
        }
Example #8
0
 public void marioEnemyKill(Mario mario)
 {
     if (mario.isInKillSequence())
     {
         marioEnemyKilledCount++;
     }
     else
     {
         marioEnemyKilledCount = 0;
     }
     MarioScore += enemyKilledPoints[marioEnemyKilledCount];
 }