Guest User

Untitled

a guest
Nov 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.Xna.Framework;
  5. using Microsoft.Xna.Framework.Audio;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework.GamerServices;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10. using Microsoft.Xna.Framework.Media;
  11.  
  12. namespace customtowerdefense
  13. {
  14. public class Game1 : Microsoft.Xna.Framework.Game
  15. {
  16. GraphicsDeviceManager graphics;
  17. SpriteBatch spriteBatch;
  18. public SpriteFont font1;
  19. public Texture2D wall;
  20. public Vector2 text;
  21. public bool Editior;
  22. public Vector2 roadposition;
  23. MouseState mouse;
  24. Texture2D cursor;
  25. public bool wallselected;
  26. road road;
  27. KeyboardState keyboardstate;
  28. Texture2D cursor2;
  29. player player;
  30. new Vector2 wallposition;
  31. KeyboardState keyboardState;
  32. string[] modes = {"You are in Editor Mode", "You are in player mode" };
  33. string[] blocks = {"Block: road", "Block: wall" };
  34. new Vector2 textposition;
  35. Texture2D roadghost;
  36. Vector2 ghostposition;
  37. public Game1()
  38. {
  39. graphics = new GraphicsDeviceManager(this);
  40. Content.RootDirectory = "Content";
  41. }
  42. protected override void Initialize()
  43. {
  44. Editior = true;
  45. this.IsMouseVisible = true;
  46. road = new road();
  47. wallselected = false;
  48. graphics.IsFullScreen = false;
  49. graphics.ApplyChanges();
  50. base.Initialize();
  51. }
  52. protected override void LoadContent()
  53. {
  54. spriteBatch = new SpriteBatch(GraphicsDevice);
  55. roadghost = Content.Load<Texture2D>("Blocks/roadghost");
  56. road.load(Content);
  57. cursor2 = Content.Load<Texture2D>("shooting");
  58. font1 = Content.Load<SpriteFont>("Spritefont1");
  59. cursor = Content.Load<Texture2D>("cursor");
  60. wall = Content.Load<Texture2D>("Blocks/wall");
  61. }
  62. protected override void UnloadContent() { }
  63. protected override void Update(GameTime gameTime)
  64. {
  65. if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  66. this.Exit();
  67. keyboardstate = Keyboard.GetState();
  68. mouse = Mouse.GetState();
  69. if (keyboardstate.IsKeyDown(Keys.P))
  70. {
  71. Editior = false;
  72. }
  73. if (mouse.LeftButton == ButtonState.Released)
  74. {
  75. ghostposition = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
  76. }
  77. road.update();
  78. base.Update(gameTime);
  79. }
  80. protected override void Draw(GameTime gameTime)
  81. {
  82. GraphicsDevice.Clear(Color.CornflowerBlue);
  83. spriteBatch.Begin();
  84. drawmode();
  85. if (Editior == true)
  86. {
  87. road.draw(spriteBatch);
  88. spriteBatch.Draw(roadghost, new Vector2(mouse.X, mouse.Y), Color.White);
  89. }
  90. spriteBatch.End();
  91. spriteBatch.Begin();
  92. if (Editior == true)
  93. {
  94. spriteBatch.Draw(cursor, ghostposition, Color.White);
  95. }
  96. if (!Editior)
  97. {
  98. spriteBatch.Draw(cursor2, new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Color.White);
  99. }
  100. spriteBatch.End();
  101. base.Draw(gameTime);
  102. }
  103. private void drawmode()
  104. {
  105. if (Editior)
  106. {
  107. spriteBatch.DrawString(font1, modes[0], new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y), Color.Orange);
  108. }
  109. else if (!Editior)
  110. {
  111. spriteBatch.DrawString(font1, modes[1], new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y), Color.Orange);
  112. }
  113. }
  114. }
  115. }
Add Comment
Please, Sign In to add comment