Exemplo n.º 1
0
 public static void Cancel(Window window)
 {
     lock (locker) {
         if (Splits.TryGetValue(window, out var split))
         {
             MoveAction.Invoke(window, split.PreviousArea);
             Remove(window);
         }
     }
 }
Exemplo n.º 2
0
 public static void MoveDown(Window window)
 {
     lock (locker) {
         if (!Splits.ContainsKey(window))
         {
             return;
         }
         window.Restore();
         var split = Splits[window];
         split.MoveDown();
         MoveAction.Invoke(window, split.Area);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Функция удаления текущего объекта
        /// </summary>
        public static void Remove()
        {
            if (_currentItem == null)
            {
                return;
            }

            AppendNewAction(ECancelTypes.Remove, _currentItem);
            _currentItem.Remove();
            _currentItem = null;
            _isReDraw    = false;

            _refresh?.Invoke();
            _move?.Invoke();
        }
Exemplo n.º 4
0
 public static void SplitUp(Window window)
 {
     lock (locker) {
         if (!Splits.ContainsKey(window))
         {
             Splits.Add(window, new MonitorSplit(window));
         }
         window.Restore();
         var split = Splits[window];
         split.SplitUp();
         if (split.parts.X == 1 && split.parts.Y == 1)
         {
             Cancel(window);
         }
         else
         {
             MoveAction.Invoke(window, split.Area);
         }
     }
 }
        void Update()
        {
            move         = Vector3.zero;
            freelook     = Vector2.zero;
            menu_move    = Vector2.zero;
            ui_move      = Vector2.zero;
            rotate_cam   = 0f;
            press_action = false;
            press_attack = false;
            press_jump   = false;
            press_craft  = false;

            press_accept    = false;
            press_cancel    = false;
            press_pause     = false;
            press_ui_select = false;
            press_ui_use    = false;
            press_ui_cancel = false;

            Vector2 wasd = Vector2.zero;

            if (Input.GetKey(KeyCode.A))
            {
                wasd += Vector2.left;
            }
            if (Input.GetKey(KeyCode.D))
            {
                wasd += Vector2.right;
            }
            if (Input.GetKey(KeyCode.W))
            {
                wasd += Vector2.up;
            }
            if (Input.GetKey(KeyCode.S))
            {
                wasd += Vector2.down;
            }

            Vector2 arrows = Vector2.zero;

            if (Input.GetKey(KeyCode.LeftArrow))
            {
                arrows += Vector2.left;
            }
            if (Input.GetKey(KeyCode.RightArrow))
            {
                arrows += Vector2.right;
            }
            if (Input.GetKey(KeyCode.UpArrow))
            {
                arrows += Vector2.up;
            }
            if (Input.GetKey(KeyCode.DownArrow))
            {
                arrows += Vector2.down;
            }

            if (Input.GetKey(cam_rotate_left))
            {
                rotate_cam += -1f;
            }
            if (Input.GetKey(cam_rotate_right))
            {
                rotate_cam += 1f;
            }

            if (Input.GetKeyDown(action_key))
            {
                press_action = true;
            }
            if (Input.GetKeyDown(attack_key))
            {
                press_attack = true;
            }
            if (Input.GetKeyDown(jump_key))
            {
                press_jump = true;
            }
            if (Input.GetKeyDown(craft_key))
            {
                press_craft = true;
            }

            if (Input.GetKeyDown(menu_accept))
            {
                press_accept = true;
            }
            if (Input.GetKeyDown(menu_cancel))
            {
                press_cancel = true;
            }
            if (Input.GetKeyDown(menu_pause))
            {
                press_pause = true;
            }

            if (Input.GetKeyDown(ui_select))
            {
                press_ui_select = true;
            }
            if (Input.GetKeyDown(ui_use))
            {
                press_ui_use = true;
            }
            if (Input.GetKeyDown(ui_cancel))
            {
                press_ui_cancel = true;
            }

            Vector2 both = (arrows + wasd);

            move = gamepad_controls ? new Vector3(wasd.x, 0f, wasd.y) : new Vector3(wasd.x, 0f, wasd.y);
            if (gamepad_controls)
            {
                freelook = arrows;
            }

            //Menu / UI
            if (!menu_moved && both.magnitude > 0.5f)
            {
                menu_move  = both;
                menu_moved = true;
            }

            if (both.magnitude < 0.5f)
            {
                menu_moved = false;
            }

            if (!ui_moved && arrows.magnitude > 0.5f)
            {
                ui_move  = arrows;
                ui_moved = true;
            }

            if (arrows.magnitude < 0.5f)
            {
                ui_moved = false;
            }

            //Gamepad
            if (gamepad_linked && gamepad_controls)
            {
                Vector2 gmove = gamepad_move.Invoke();
                move       += new Vector3(gmove.x, 0f, gmove.y);
                freelook   += gamepad_freelook.Invoke();
                rotate_cam += gamepad_camera.Invoke().x;
                ui_move    += gamepad_dpad.Invoke();
                menu_move  += gamepad_menu.Invoke();
                menu_move  += gamepad_dpad.Invoke();

                press_action = press_action || gamepad_action.Invoke();
                press_attack = press_attack || gamepad_attack.Invoke();
                press_jump   = press_jump || gamepad_jump.Invoke();

                press_craft     = press_craft || gamepad_craft.Invoke();
                press_accept    = press_accept || gamepad_accept.Invoke();
                press_cancel    = press_cancel || gamepad_cancel.Invoke();
                press_pause     = press_pause || gamepad_pause.Invoke();
                press_ui_select = press_ui_select || gamepad_accept.Invoke();
                press_ui_use    = press_ui_use || gamepad_use.Invoke();
                press_ui_cancel = press_ui_cancel || gamepad_cancel.Invoke();
            }

            move     = move.normalized * Mathf.Min(move.magnitude, 1f);
            freelook = freelook.normalized * Mathf.Min(freelook.magnitude, 1f);
        }