示例#1
0
        public void FireShot(Vector2 firePosition, int yDirection, List<Fire> fires)
        {
            var inflatedBounds = bounds;
            inflatedBounds.Inflate(10, 10);
            var fire = new Fire(texture, firePosition, inflatedBounds);
            fire.Velocity = new Vector2(0, yDirection);
            fires.Add(fire);

            soundManager.PlayShotSound();
        }
示例#2
0
        public static Level FromText(string text)
        {
            Level level = new Level();

            level.creationText = text;

            int xOffset = 0;
            int yOffset = 0;

            foreach (char ch in text)
            {
                if ((ch == 'p' || ch == 'P') && level.snowman == null)
                {
                    Snowman snowman = new Snowman();

                    snowman.pos.X = (float)xOffset * 32f;
                    snowman.pos.Y = (float)yOffset * 32f;

                    level.snowman = snowman;
                }
                else if (ch == 'f' || ch == 'F')
                {
                    Fire f = new Fire();
                    f.pos.X = (float)xOffset * 32f;
                    f.pos.Y = (float)yOffset * 32f;

                    level.fires.Add(f);
                }
                else if (ch == 'x' || ch == 'X')
                {
                    Tile tile = new Tile();
                    tile.pos.X = (float)xOffset * 32f;
                    tile.pos.Y = (float)yOffset * 32f;

                    level.tiles.Add(tile);
                }
                else if (ch == 'J')
                {
                    JumpSwitch tile = new JumpSwitch(JumpSwitch.Color.Yellow);
                    tile.pos.X = (float)xOffset * 32f;
                    tile.pos.Y = (float)yOffset * 32f;

                    level.jumpSwitches.Add(tile);
                }
                else if (ch == 'j')
                {
                    JumpSwitch tile = new JumpSwitch(JumpSwitch.Color.Green);
                    tile.pos.X = (float)xOffset * 32f;
                    tile.pos.Y = (float)yOffset * 32f;

                    level.jumpSwitches.Add(tile);
                }
                else if (ch == 'T')
                {
                    TimeSwitch tile = new TimeSwitch(TimeSwitch.Color.Blue);
                    tile.pos.X = (float)xOffset * 32f;
                    tile.pos.Y = (float)yOffset * 32f;

                    level.timeSwitches.Add(tile);
                }
                else if (ch == 't')
                {
                    TimeSwitch tile = new TimeSwitch(TimeSwitch.Color.Red);
                    tile.pos.X = (float)xOffset * 32f;
                    tile.pos.Y = (float)yOffset * 32f;

                    level.timeSwitches.Add(tile);
                }
                else if (ch == 'w')
                {
                    Walker w = new Walker();
                    w.pos.X = (float)xOffset * 32f;
                    w.pos.Y = (float)yOffset * 32f;

                    level.walkers.Add(w);
                }
                else if (ch == 'W')
                {
                    Walker w = new Walker();
                    w.pos.X          = (float)xOffset * 32f;
                    w.pos.Y          = (float)yOffset * 32f;
                    w.isWalkingRight = false;

                    level.walkers.Add(w);
                }
                else if (ch == 'g' || ch == 'G')
                {
                    Vector2 p = new Vector2((float)xOffset * 32f, (float)yOffset * 32f);
                    Ghosty  g = new Ghosty(p);

                    level.ghosties.Add(g);
                }
                else if (ch == 'i' || ch == 'I')
                {
                    IceSpike w = new IceSpike();
                    w.pos.X = (float)xOffset * 32f;
                    w.pos.Y = (float)yOffset * 32f;

                    level.iceSpikes.Add(w);
                }
                else if (ch == 'L')
                {
                    LetterBox w = new LetterBox();
                    w.pos.X = (float)xOffset * 32f;
                    w.pos.Y = (float)yOffset * 32f;

                    level.letterBox = w;
                }
                else if (ch == 'l')
                {
                    Letter w = new Letter();
                    w.pos.X = (float)xOffset * 32f;
                    w.pos.Y = (float)yOffset * 32f;

                    level.letters.Add(w);
                }

                if (ch == '\n')
                {
                    xOffset = 0;
                    yOffset++;
                }
                else
                {
                    xOffset++;
                }
            }

            level.letters = level.letters.OrderBy(a => a.pos.X).ThenBy(a => a.pos.Y).ToList();

            level.deathYCoord = (float)(yOffset + 3) * 32f;
            level.minYPointWs = (float)(yOffset) * 32f;

            return(level);
        }
示例#3
0
 public void RemowePlayerFire(Fire fire)
 {
     PlayerFires.Remove(fire);
 }