Ejemplo n.º 1
0
        private void ProcessMovement()
        {
            var destination = MouseHelper.GetPositionUnderMouse();

            var movementEvent = new MovementEvent(destination);

            movementEventRepository.SetValue(movementEvent);

            SetDirection();
        }
Ejemplo n.º 2
0
        private void ProcessPickup()
        {
            var marker      = MouseHelper.GetComponentOnGameObjectUnderMouse <PickupableItemMarker>();
            var destination = MouseHelper.GetPositionUnderMouse();

            pickupEventRepository.SetValue(new PickupEvent(marker));

            if (PositionHelper.GetDistance(player.position, destination) > config.InteractCriticalDistance)
            {
                ProcessMovement();
            }
        }
Ejemplo n.º 3
0
        private void ProcessSceneTransition()
        {
            var marker      = MouseHelper.GetComponentOnGameObjectUnderMouse <SceneTransferMarker>();
            var destination = MouseHelper.GetPositionUnderMouse();

            interactWithSceneTransferEventRepository.SetValue(new InteractWithSceneTransferEvent(marker));

            if (PositionHelper.GetDistance(player.position, destination) > config.InteractCriticalDistance)
            {
                ProcessMovement();
            }
        }
Ejemplo n.º 4
0
        public override void Update()
        {
            if (MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.PickupableItem) ||
                MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.Npc) ||
                MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.SceneTransfer) ||
                MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.DialogueButton) ||
                MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.FinishDialogueButton))
            {
                cursor = Resources.Load <Texture2D>("pointer");
            }
            else
            {
                cursor = Resources.Load <Texture2D>("normal");
            }

            Cursor.SetCursor(cursor, new Vector2(0, 0), CursorMode.Auto);

            if (Input.GetMouseButtonDown(0))
            {
                if (Input.mousePosition != previousPointClicked && previousClickDateTime - DateTime.UtcNow < TimeSpan.FromMilliseconds(200)) // у нас происходит двойной клик. Для кнопок это критично
                {                                                                                                                            // Поэтому я сохраняю предыдущую точку нажатия и сравниваю её с текущей
                    previousClickDateTime = DateTime.UtcNow;
                    previousPointClicked  = Input.mousePosition;
                    movementEventRepository.RemoveValue();
                    pickupEventRepository.RemoveValue();
                    interactWithNpcEventRepository.RemoveValue();
                    newTextEventRepository.RemoveValue();

                    if (MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.Ground))
                    {
                        ProcessMovement();
                    }

                    if (MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.PickupableItem))
                    {
                        ProcessPickup();
                    }

                    if (MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.Npc))
                    {
                        ProcessNpc();
                    }

                    if (MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.DialogueButton))
                    {
                        ProcessButton();
                    }

                    if (MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.FinishDialogueButton))
                    {
                        ProcessFinishDialogue();
                    }

                    if (MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.SceneTransfer))
                    {
                        ProcessSceneTransition();
                    }
                }
            }

            if (Input.GetMouseButtonDown(1))
            {
                if (MouseHelper.IsMouseAboveObjectWithTag(Constants.Tags.PickupableItem))
                {
                    var marker = MouseHelper.GetComponentOnGameObjectUnderMouse <PickupableItemMarker>();
                    startDialogueEventRepository.SetValue(new StartDialogueEvent(marker.Id, "You"));
                }
            }
        }
Ejemplo n.º 5
0
        private void ProcessButton()
        {
            var button = MouseHelper.GetComponentOnGameObjectUnderMouse <NextReplicaDialogueButtonMarker>();

            newTextEventRepository.SetValue(new NewTextEvent(button.Node));
        }