Advertisement
Purianite

Untitled

Nov 7th, 2012
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.23 KB | None | 0 0
  1. //This is in the form class:
  2. public static void notifyChange()
  3.         {
  4.         //Error here: "An object reference is required for the non-static field, method, or property
  5.         //'Level_Editor.MapEditor.ChangeIndicator'
  6.             ChangeIndicator.Text = status;
  7.         }
  8.  
  9. //Here's the code in the XNA game that needs to use notifyChange to change the text in the form:
  10. //if the mouse coordinates for the world are actually in the world...
  11.                 if (Camera.WorldRectangle.Contains((int)mouseLoc.X, (int)mouseLoc.Y))
  12.                 {
  13.                     //if the left button is pressed...
  14.                     if (ms.LeftButton == ButtonState.Pressed)
  15.                     {
  16.                         isChanged = true;
  17.                         MapEditor.notifyChange();
  18.                         //Place tile at cell pointed at by the mouse
  19.                         TileMap.SetTileAtCell(
  20.                             TileMap.GetCellByPixelX((int)mouseLoc.X),
  21.                             TileMap.GetCellByPixelY((int)mouseLoc.Y),
  22.                         DrawLayer, DrawTile);
  23.                     }
  24.  
  25.                     //if we pressed the right-mouse button & we have not been holding it down...
  26.                     if ((ms.RightButton == ButtonState.Pressed) &&
  27.                         (lastMouseState.RightButton != ButtonState.Released))
  28.                     {
  29.                         isChanged = true;
  30.                         MapEditor.notifyChange();
  31.                         //if we are also in Code Editing mode...
  32.                         if (EditingCode)
  33.                         {
  34.                             //Set the code value of the selected tile to the current code value
  35.                             // within the editor window
  36.                             TileMap.GetMapSquareAtCell(
  37.                                 TileMap.GetCellByPixelX((int)mouseLoc.X),
  38.                                 TileMap.GetCellByPixelY((int)mouseLoc.Y)
  39.                                 ).CodeValue = CurrentCodeValue;
  40.                         }
  41.                         else
  42.                         {                            
  43.                             //Check the tile chosen upon click then paint the opposite of it
  44.                             if (!painting)
  45.                             {
  46.                                 paintType = !(TileMap.GetMapSquareAtCell(
  47.                                 TileMap.GetCellByPixelX((int)mouseLoc.X),
  48.                                 TileMap.GetCellByPixelY((int)mouseLoc.Y)
  49.                                 ).Passable);
  50.                                 painting = true;
  51.                             }                            
  52.                             if (painting)
  53.                             {
  54.                                 TileMap.GetMapSquareAtCell(
  55.                                 TileMap.GetCellByPixelX((int)mouseLoc.X),
  56.                                 TileMap.GetCellByPixelY((int)mouseLoc.Y)
  57.                                 ).Passable = paintType;
  58.                             }
  59.                         }                        
  60.                     }
  61.  
  62.                     if (ms.RightButton == ButtonState.Released)
  63.                     {
  64.                         painting = false;
  65.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement