Пример #1
0
        public ConstructionMenu(Vector2 renderPosition, ContentManager Content, inventory playerInvIn, MapLoader currMapIn, Player currPlayerIn)
        {
            location = renderPosition;

            List<Tuple<resource.resourceTypes, int>> spikeResources = new List<Tuple<resource.resourceTypes, int>>();
            spikeResources.Add(new Tuple<resource.resourceTypes, int>(resource.resourceTypes.Wood, 1));
            items.Add(new constructionItem(resource.resourceTypes.Spike, spikeResources, true, false, true));

            List<Tuple<resource.resourceTypes, int>> spikePitResources = new List<Tuple<resource.resourceTypes, int>>();
            spikePitResources.Add(new Tuple<resource.resourceTypes, int>(resource.resourceTypes.Spike, 5));
            items.Add(new constructionItem(resource.resourceTypes.SpikePit, spikePitResources, false, true));

            List<Tuple<resource.resourceTypes, int>> treeResources = new List<Tuple<resource.resourceTypes, int>>();
            treeResources.Add(new Tuple<resource.resourceTypes, int>(resource.resourceTypes.Acorn, 1));
            items.Add(new constructionItem(resource.resourceTypes.Tree, treeResources, false, true));

            background = Content.Load<Texture2D>("InventoryBackground");
            itemSlot = Content.Load<Texture2D>("inventorySquare");
            selectedItemSlot = Content.Load<Texture2D>("selectedInventorySquare");
            inventoryDialog = Content.Load<Texture2D>("inventoryDialogBox");

            Spike = Content.Load<Texture2D>("woodenStake");
            SpikePit = Content.Load<Texture2D>("spikepitTile");
            Tree = Content.Load<Texture2D>("treeIcon");

            font = Content.Load<SpriteFont>("SpriteFont1");

            playerInv = playerInvIn;
            currMap = currMapIn;
            currPlayer = currPlayerIn;
        }
Пример #2
0
        public void moveTowardsPlayer(Player thePlayer, Vector2 Viewport)
        {
            Vector2 preModifiedPlayerLoc = thePlayer.getCurrentPos();
            Vector2 playerLoc = new Vector2(preModifiedPlayerLoc.X + Viewport.X, preModifiedPlayerLoc.Y + Viewport.Y);

            if (playerLoc.X < zombieLoc.X)
            {
                zombieLoc.X -= moveSpeed;
            }
            else if (playerLoc.X > zombieLoc.X)
            {
                zombieLoc.X += moveSpeed;
            }

            if (playerLoc.Y < zombieLoc.Y)
            {
                zombieLoc.Y -= moveSpeed;
            }
            else if (playerLoc.Y > zombieLoc.Y)
            {
                zombieLoc.Y += moveSpeed;
            }

            //zombies get excited by food and groan.
            if ((playerLoc.X >= zombieLoc.X - 100) && (playerLoc.X <= zombieLoc.X + 100) &&
                (playerLoc.Y >= zombieLoc.Y - 100) && (playerLoc.Y <= zombieLoc.Y + 100))
            {
                if (thePlayer.getIsDead())
                {
                    groanInstance.Stop();
                }
                else if (groanInstance.State == SoundState.Stopped)
                {
                    groanInstance.Volume = 0.50f;
                    //groanInstance.IsLooped = false;
                    groanInstance.Play();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            worldMap.loadContent(Content, graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferWidth);
            worldMap.loadMap("content/worldMap.txt");

            currentMap = worldMap;

            currentPlayer = new Player(Content);

            zombies.Add(new Zombie(Content, new Vector2(450, 450)));

            font = Content.Load<SpriteFont>("SpriteFont1");

            soundOhNo = Content.Load<SoundEffect>("ohNo");
            soundOhNoInstance = soundOhNo.CreateInstance();

            conMenu = new ConstructionMenu(new Vector2(0, 0), Content, currentPlayer.getInventory(), currentMap, currentPlayer);

            //inv.addToInventory(resource.resourceTypes.Hatchet, 1);

            // TODO: use this.Content to load your game content here
        }