fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Input;
  8. using Microsoft.Xna.Framework.Graphics;
  9.  
  10. namespace BehaviourDemoPort
  11. {
  12. enum EditMode
  13. {
  14. Select,
  15. Move,
  16. }
  17.  
  18. class SceneEditor
  19. {
  20. EditMode editMode;
  21.  
  22. public SceneEditor()
  23. {
  24. Keys[] allKeys = (Keys[])Enum.GetValues(typeof(Keys));
  25. foreach (var key in allKeys)
  26. KeyboardInput.AddKey(key);
  27.  
  28. KeyboardInput.KeyRelease += new KeyHandler(KeyboardInput_KeyRelease);
  29.  
  30. MouseInput.MouseMove += new MouseMoveHandler(MouseInput_MouseMove);
  31. MouseInput.MouseDown += new MouseClickHandler(MouseInput_MouseDown);
  32. MouseInput.MouseUp += new MouseClickHandler(MouseInput_MouseUp);
  33. }
  34.  
  35. void KeyboardInput_KeyRelease(Keys key, KeyboardState keyState)
  36. {
  37. if (key == Keys.Q)
  38. {
  39. this.editMode = EditMode.Select;
  40. }
  41. else if (key == Keys.W)
  42. {
  43. this.editMode = EditMode.Move;
  44. }
  45. else if (key == Keys.Delete)
  46. {
  47. foreach (var actor in Actor.Selection)
  48. {
  49. actor.Delete();
  50. }
  51. Actor.Selection.Clear();
  52. }
  53. else if (key == Keys.C && Actor.Selection.Count >= 2)
  54. {
  55. for (int i = 1; i < Actor.Selection.Count; i++)
  56. {
  57. Node nodeA = Actor.Selection[i - 1] as Node;
  58. Node nodeB = Actor.Selection[i] as Node;
  59.  
  60. if (nodeA != null & nodeB != null)
  61. nodeA.BidiConnect(nodeB);
  62. }
  63. }
  64. else if (key == Keys.X && Actor.Selection.Count >= 2)
  65. {
  66. for (int i = 1; i < Actor.Selection.Count; i++)
  67. {
  68. Node nodeA = Actor.Selection[i - 1] as Node;
  69. Node nodeB = Actor.Selection[i] as Node;
  70.  
  71. if (nodeA != null & nodeB != null)
  72. nodeA.BidiDisconnect(nodeB);
  73. }
  74. }
  75. }
  76.  
  77. void MouseInput_MouseMove(Vector2 position, Vector2 movement)
  78. {
  79. if (this.editMode == EditMode.Move && MouseInput.IsLeftButtonDown)
  80. {
  81. foreach (var actor in Actor.Selection)
  82. {
  83. actor.Position += movement;
  84. }
  85. }
  86. }
  87.  
  88. void MouseInput_MouseDown(Vector2 position)
  89. {
  90. if (KeyboardInput.IsShiftDown)
  91. {
  92. Node node = new Node();
  93. node.Position = position;
  94. Node lastNode = Actor.LastSelected as Node;
  95. if (lastNode != null)
  96. {
  97. node.BidiConnect(lastNode);
  98. }
  99.  
  100. Actor.Selection.Clear();
  101. node.Select();
  102.  
  103. return;
  104. }
  105.  
  106. Actor actor = GetActorAt(position);
  107. if (actor != null)
  108. {
  109. if (!actor.IsSelected && !KeyboardInput.IsControlDown)
  110. Actor.Selection.Clear();
  111. if (KeyboardInput.IsControlDown)
  112. actor.ToggleSelect();
  113. else
  114. actor.Select();
  115. }
  116. else if (!KeyboardInput.IsControlDown)
  117. Actor.Selection.Clear();
  118. }
  119.  
  120. void MouseInput_MouseUp(Vector2 position)
  121. {
  122. if (Actor.Selection.Count > 0 && !KeyboardInput.IsControlDown)
  123. {
  124. Actor.Selection.Clear();
  125.  
  126. Actor actor = GetActorAt(position);
  127. if (actor != null)
  128. actor.Select();
  129. }
  130. }
  131.  
  132. Actor GetActorAt(Vector2 position)
  133. {
  134. for (int i = Actor.Actors.Count -1; i >= 0; i--)
  135. {
  136. Actor actor = Actor.Actors[i];
  137. if (Vector2.Distance(actor.Position, position) < actor.Radius)
  138. {
  139. return actor;
  140. }
  141. }
  142. return null;
  143. }
  144.  
  145.  
  146. public void Draw(SpriteBatch SpriteBatch)
  147. {
  148. string text = String.Format("mode: {0}", this.editMode);
  149. SpriteBatch.DrawString(Style.FontLarge, text, new Vector2(10, 10), Color.White);
  150. }
  151. }
  152. }
  153.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(6,17): error CS0234: The type or namespace name `Xna' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?
prog.cs(7,17): error CS0234: The type or namespace name `Xna' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?
prog.cs(8,17): error CS0234: The type or namespace name `Xna' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?
prog.cs(35,49): error CS0246: The type or namespace name `KeyboardState' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(77,35): error CS0246: The type or namespace name `Vector2' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(77,53): error CS0246: The type or namespace name `Vector2' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(88,35): error CS0246: The type or namespace name `Vector2' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(120,33): error CS0246: The type or namespace name `Vector2' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(132,9): error CS0246: The type or namespace name `Actor' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(146,26): error CS0246: The type or namespace name `SpriteBatch' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(6,17): error CS0234: The type or namespace name `Xna' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?
prog.cs(7,17): error CS0234: The type or namespace name `Xna' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?
prog.cs(8,17): error CS0234: The type or namespace name `Xna' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?
Compilation failed: 13 error(s), 0 warnings
stdout
Standard output is empty