示例#1
0
文件: NPC.cs 项目: johhov/DagOgNatt
        public void Update(Player player)
        {
            if (Global.offset >= 8000 && !Global.day)
            {
                objectOffset -= 2;
            }

            if ((passableAtDay && Global.day) || (passableAtNight && !Global.day))
            {
                passable = true;
            }
            else
            {
                passable = false;
            }

            this.position.X = startingPosition.X - Global.offset + objectOffset;
            if (player.position.X >= position.X - 200)
            {
                if (!player.Dying)
                {
                    player.Die();
                }
            }
        }
示例#2
0
        public void Update(Player player)
        {
            if (player.AtEdge != 0)
            {
                position = new Vector2(-Global.offset * speed, 0);
            }

            playerBoundingBoxLeft = player.boundingBoxLeftEdge;
            playerBoundingBoxRight = player.boundingBoxRightEdge;
        }
示例#3
0
文件: Game1.cs 项目: johhov/DagOgNatt
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            gameState = GameState.Menu;

            //Game objects
            input = new Input();
            player = new Player();

            parallaxLayers = new List<Parallax>();
            for (int i = 0; i < 3; i++)
            {
                parallaxLayers.Add(new Parallax(1, i));
            }

            Global.offset = 0;
            Global.day = true;
            Global.gamestart = 0;
            startScreen = new ScreenObject();
            //startButton = new ScreenObject();
            gate = new Movable(new Vector2(6900, 550), false, true, new Rectangle(0, 0, 100, 50));
            excavator = new Movable(new Vector2(2340, 550), false, true, new Rectangle(0, 0, 0, 0));
            flower = new Flower(new Vector2(6000, 80), false, false, new Rectangle(0, 0, 509, 698));
            monster = new NPC(new Vector2(9000, 300), true, false, new Rectangle(0, 0, 327, 360));
            pulse = new Overlay(0, new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0));
            score = new Scoreboard(new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0));
            numbOne = new Scoreboard(new Vector2(5, 5), new Vector2(0, 0), new Vector2(0, 0));
            wolf = new Movable(new Vector2(5000, 550), true, false, new Rectangle(0, 0, 0, 0));
            doneFlower = new Movable(new Vector2(6000, 80), true, true, new Rectangle(0, 0, 509, 698));
            bridge = new Movable(new Vector2(6500, 0), true, true, new Rectangle(0, 0, 1080, 720));
            bushCan = new Movable(new Vector2(3250, 0), true, true, new Rectangle(0, 0, 3520, 720));

            collidables = new List<Movable>();
            collidables.Add(gate);
            collidables.Add(excavator);
            collidables.Add(wolf);
            collidables.Add(flower);

            //Menu objects
            menuButtons = new List<Button>();
            menuButtons.Add(new Button(new Vector2(0, 0), "Start Game", Keys.Enter));
            menuButtons.Add(new Button(new Vector2(0, 0), "Exit Game", Keys.Escape));

            base.Initialize();//should be bottom
        }