Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Audio;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.GamerServices;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Media;
- namespace customtowerdefense
- {
- public class Game1 : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- public SpriteFont font1;
- public Texture2D wall;
- public Vector2 text;
- public bool Editior;
- public Vector2 roadposition;
- MouseState mouse;
- Texture2D cursor;
- public bool wallselected;
- road road;
- KeyboardState keyboardstate;
- Texture2D cursor2;
- player player;
- new Vector2 wallposition;
- KeyboardState keyboardState;
- string[] modes = {"You are in Editor Mode", "You are in player mode" };
- string[] blocks = {"Block: road", "Block: wall" };
- new Vector2 textposition;
- Texture2D roadghost;
- Vector2 ghostposition;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- }
- protected override void Initialize()
- {
- Editior = true;
- this.IsMouseVisible = true;
- road = new road();
- wallselected = false;
- graphics.IsFullScreen = false;
- graphics.ApplyChanges();
- base.Initialize();
- }
- protected override void LoadContent()
- {
- spriteBatch = new SpriteBatch(GraphicsDevice);
- roadghost = Content.Load<Texture2D>("Blocks/roadghost");
- road.load(Content);
- cursor2 = Content.Load<Texture2D>("shooting");
- font1 = Content.Load<SpriteFont>("Spritefont1");
- cursor = Content.Load<Texture2D>("cursor");
- wall = Content.Load<Texture2D>("Blocks/wall");
- }
- protected override void UnloadContent() { }
- protected override void Update(GameTime gameTime)
- {
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- this.Exit();
- keyboardstate = Keyboard.GetState();
- mouse = Mouse.GetState();
- if (keyboardstate.IsKeyDown(Keys.P))
- {
- Editior = false;
- }
- if (mouse.LeftButton == ButtonState.Released)
- {
- ghostposition = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
- }
- road.update();
- base.Update(gameTime);
- }
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.CornflowerBlue);
- spriteBatch.Begin();
- drawmode();
- if (Editior == true)
- {
- road.draw(spriteBatch);
- spriteBatch.Draw(roadghost, new Vector2(mouse.X, mouse.Y), Color.White);
- }
- spriteBatch.End();
- spriteBatch.Begin();
- if (Editior == true)
- {
- spriteBatch.Draw(cursor, ghostposition, Color.White);
- }
- if (!Editior)
- {
- spriteBatch.Draw(cursor2, new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Color.White);
- }
- spriteBatch.End();
- base.Draw(gameTime);
- }
- private void drawmode()
- {
- if (Editior)
- {
- spriteBatch.DrawString(font1, modes[0], new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y), Color.Orange);
- }
- else if (!Editior)
- {
- spriteBatch.DrawString(font1, modes[1], new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y), Color.Orange);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment