Ejemplo n.º 1
0
        public static bool IntersectPlayerNPC(Player player, NPC npc)
        {
            Rectangle recA = new Rectangle(Convert.ToInt32(player.Position.X), Convert.ToInt32(player.Position.Y), player.spriteWidth, player.spriteHeight);
            Rectangle recB = new Rectangle(Convert.ToInt32(npc.Position.X), Convert.ToInt32(npc.Position.Y), npc.spriteWidth, npc.spriteHeight);

            return recA.Intersects(recB);
        }
Ejemplo n.º 2
0
        /// <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()
        {
            // TODO: Add your initialization logic here
            Player p1 = new Player();
            p1.spriteWidth = 25;
            p1.spriteHeight = 51;
            p1.spriteIndex = 1;
            characters[0] = p1;

            //Add npc
            NPC n1 = new NPC();
            n1.spriteWidth = 25;
            n1.spriteHeight = 51;
            n1.spriteIndex = 0;
            npcs[0] = n1;

            List<Level> ls = LevelHelper.GetLevels();

            levels = new Dictionary<string, Level>();

            foreach(Level l in ls)
            {
                l.LoadContent(Content);
                levels.Add(l.Name, l);

                if (l.Default)
                    currentLevel = l;
            }

            base.Initialize();
        }