예제 #1
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.button == PointerEventData.InputButton.Right && GameUnitService.GetSelectedUnits().Any())
     {
         var target = Instantiate(TargetPositionObject);
         target.transform.position = eventData.pointerCurrentRaycast.worldPosition;
         if (InputService.IsPressingAlt())
         {
             var     selectedUnits = GameUnitService.GetSelectedUnits();
             Vector3 lastWaypoint  = selectedUnits.First().WayPoints.Any()
     ? selectedUnits.First().WayPoints.Peek()
     : selectedUnits.First().transform.position;
             var formation = _formationService.GetFomation(target.transform, selectedUnits, lastWaypoint, FormationType.Lines);
             foreach (var waypoints in formation)
             {
                 waypoints.Value.AddWayPoint(waypoints.Key, InputService.IsPressingShift());
             }
         }
         else
         {
             if (GameUnitService.GetSelectedUnits().Any())
             {
                 var formation = _formationService.GetFomation(target.transform, GameUnitService.GetSelectedUnits(), GameUnitService.GetSelectedUnits().First().transform.position, FormationType.Lines);
                 foreach (var waypoints in formation)
                 {
                     waypoints.Value.CmdMoveAndReset(waypoints.Key);
                 }
             }
         }
         Destroy(target);
     }
 }
예제 #2
0
        private void UpdateGroupingCheck()
        {
            if (InputService.IsPressingCtrl())
            {
                foreach (var group in KeyBindingsService.GroupList)
                {
                    if (Input.GetKey(group))
                    {
                        CreateGroup(group.ToString().Replace("Keypad", string.Empty));
                    }
                }
            }

            foreach (var group in KeyBindingsService.GroupList)
            {
                if (Input.GetKey(group))
                {
                    foreach (var unit in AllUnits)
                    {
                        unit.OnDeselect(new BaseEventData(EventSystem.current));
                    }

                    foreach (var unit in GameUnitService.GetSelectedUnits(group.ToString()
                                                                          .Replace("Keypad", string.Empty)))
                    {
                        unit.OnSelect(new BaseEventData(EventSystem.current));
                    }
                }
            }
        }
예제 #3
0
 public void OnEndDrag(PointerEventData eventData)
 {
     SelectionBoxImage.gameObject.SetActive(false);
     foreach (var unit in GameUnitService.GetAllUnits())
     {
         if (_selectionRect.Contains(_camera.WorldToScreenPoint(unit.transform.position)))
         {
             unit.GetComponent <BaseUnitController>().OnSelect(eventData);
         }
     }
 }
예제 #4
0
        private void CreateGroup(string group)
        {
            foreach (var unit in GameUnitService.GetSelectedUnits(group))
            {
                unit.OnDeselect(new BaseEventData(EventSystem.current));
            }

            foreach (var unit in GameUnitService.GetSelectedUnits())
            {
                unit.Group = group;
            }
        }