Esempio n. 1
0
 static void UpdateTooltip(Slider slider)
 {
     sliderTooltip.Content = slider.Value < 1.1 ? Math.Round(slider.Value * 100) + "%" : slider.Value.ToString();
     var pos = CursorUtility.GetScreenPosition();
     sliderTooltip.HorizontalOffset = pos.X + 22;
     sliderTooltip.VerticalOffset = pos.Y + 22;
     slider.ToolTip = sliderTooltip;
 }
Esempio n. 2
0
        private void HandleDrag(SceneView scene, Vector2 mousePosition)
        {
            var result = CursorUtility.GetWorldPointFromMouse(scene, mousePosition);

            if (!result.IsSuccess || result.GridCornerPosition == cursorGridPos)
            {
                return;
            }

            cursorGridPos = result.GridCornerPosition;
            RecalculateWalls();
        }
Esempio n. 3
0
        private void StartDragging(SceneView scene, Vector2 mousePosition)
        {
            var result = CursorUtility.GetWorldPointFromMouse(scene, mousePosition);

            if (!result.IsSuccess)
            {
                return;
            }
            wallStart      = result.GridCornerPosition;
            wallEnd        = wallStart;
            isDraggingWall = true;
            wallResolver.CacheExistingWalls();
        }
Esempio n. 4
0
 /// <summary>
 /// 全局按键捕捉,记录按下“Ctrl + K”键时的鼠标位置
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if (((e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) &&
         (e.Key == Key.T))
     {
         int x;
         int y;
         CursorUtility.GetCursorPosition(out x, out y);
         model.Events.Add(new ScreenEvent(model.Events.Count + 1,
                                          EventType.MOUSE_EVENT, ActionType.LEFT_MOUSE_CLICK,
                                          1000, 1, new Point(x, y)));
     }
 }
Esempio n. 5
0
 private void OnCellHovered(Vector2Int?cellPos)
 {
     if (cellPos == null) // Out of bounds
     {
         CursorUtility.SetCursor(normalCursor);
         HideHighlight();
     }
     else if (_isVisible == false || animate == false) // inside bounds but was hidden previously
     {
         CursorUtility.SetCursor(pointerCursor);
         ShowHighlight(cellPos.Value);
     }
     else
     {
         TransitionHighlight(cellPos.Value);  // inside bounds -> inside bounds
     }
 }
Esempio n. 6
0
 private void PositionCursor(SceneView scene, Vector2 mousePosition)
 {
     if (wallCursor == null)
     {
         return;
     }
     if (isDraggingWall)
     {
         wallCursor.position = wallEnd;
     }
     else
     {
         var result = CursorUtility.GetWorldPointFromMouse(scene, mousePosition);
         if (!result.IsSuccess)
         {
             return;
         }
         wallCursor.position = result.GridCornerPosition;
     }
 }
Esempio n. 7
0
        private void PositionDoor(SceneView scene, Vector2 mousePosition)
        {
            var result = CursorUtility.GetWorldPointFromMouse(scene, mousePosition);

            if (!result.IsSuccess)
            {
                return;
            }

            door.position = result.GridEdgePosition;

            if (result.Direction == Directions.Horizontal)
            {
                door.eulerAngles = Vector3.zero;
            }
            else
            {
                door.eulerAngles = new Vector3(0f, -90f, 0f);
            }

            CheckOverlappingWalls(result);
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //  Console.WriteLine(SteamFriends.GetPersonaName());


            base.Initialize();
            initiateActions();

            ResolutionUtility.bMouseIsVisible = this.IsMouseVisible;
            hitboxHelp       = Content.Load <Texture2D>(@"Graphics\HitBoxHelp");
            selectionTexture = Content.Load <Texture2D>(@"Graphics\MainMenu\TestRectangle");
            mapBorderHelp    = Content.Load <Texture2D>(@"Graphics\Tiles\Basic\BorderTest");
            WhiteTex         = Content.Load <Texture2D>(@"White");
            scenes.Insert((int)(Screens.MainMenu), new MainMenu());
            scenes.Insert((int)(Screens.MainGameStart), new NewGameScene());
            scenes.Insert((int)(Screens.MainGameContinue), new ContinueGameScene());
            scenes.Insert((int)(Screens.OWGame), new OWGame());
            scenes.Insert((int)(Screens.BGame), new MainGame());
            scenes.Insert((int)(Screens.Options), new Options());
            scenes.Insert((int)(Screens.ExitGame), new Scene());
            scenes.Insert((int)(Screens.Editor), new Editor());


            CursorUtility.Initialize(this);
            MainGUI.Initialize(this);


            if (!bRunEditMode)
            {
                scenes[SceneUtility.currentScene].Initialize(this);
            }



            graphics.PreferMultiSampling       = true;
            graphics.PreferredBackBufferWidth  = this.GraphicsDevice.DisplayMode.Width;
            graphics.PreferredBackBufferHeight = this.GraphicsDevice.DisplayMode.Height;
            //   this.Window.Position = new Point(100, 100);
            //graphics.IsFullScreen = true;
            this.IsMouseVisible = false;
            graphics.ApplyChanges();
            LoadAssets();
            this.Window.AllowUserResizing = false;
            //Window.IsBorderless = true;
            Window.AllowAltF4 = true;
            //Window.Location = Point.Zero;
            //900,506
            ResolutionUtility.WindowSizeBeforeFullScreen = new Vector2(1366, 768);
            ResolutionUtility.AdjustResolution(1366, 768, graphics);
            gameRender  = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            gameRender  = new RenderTarget2D(GraphicsDevice, 1366, 768);
            UIRender    = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            monitorSize = new Vector2(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
            Console.WriteLine("Primary Monitor Size: " + monitorSize);

            EditorFileWriter.LoadSaveSettings();
            startScreen = new StartScreen();
#if !DEBUG
            // GameProcessor.Launch();
#endif
            // GameProcessor.Launch();
        }