Пример #1
0
    protected virtual void MultiSelect()
    {
        player.userInput.Deselect();
        SelectBox.Disable();
        Vector3 groundClickedPosition = WorldTouchPoint(Camera.main.ScreenToWorldPoint(clickedPosition));
        Vector3 groundMousePosition   = WorldTouchPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition));
        float   distance = Mathf.Abs(groundMousePosition.x - groundClickedPosition.x);
        float   xMin     = Mathf.Min(groundMousePosition.x, groundClickedPosition.x);
        float   zMin     = Mathf.Min(groundMousePosition.z, groundClickedPosition.z);
        float   zMax     = Mathf.Max(groundMousePosition.z, groundClickedPosition.z);
        List <MobileWorldObject> mobileWoList = new List <MobileWorldObject> ();

        RaycastHit[] hits = Physics.CapsuleCastAll(new Vector3(xMin, 0f, zMin), new Vector3(xMin, 0f, zMax), 0.1f, Vector3.right, distance, LayerMask.GetMask(new string[] { player.species.ToString() }));
        foreach (RaycastHit hit in hits)
        {
            MobileWorldObject mobileWO = hit.collider.gameObject.GetComponent <MobileWorldObject> ();
            if (mobileWO && mobileWO as SentryMob == null)
            {
                mobileWoList.Add(mobileWO);
            }
        }
        foreach (MobileWorldObject mobileWO in mobileWoList)
        {
            mobileWO.SelectTap(player);
            player.userInput.SelectedObjects.Add(mobileWO as WorldObject);
        }
        if (mobileWoList.Count == 1)
        {
            player.userInput.OpenPanel(mobileWoList[0].buttons);
        }
    }
Пример #2
0
    protected override void MultiSelect()
    {
        DeselectAll();
        SelectBox.Disable();
        Vector3 groundClickedPosition = WorldTouchPoint(Camera.main.ScreenToWorldPoint(clickedPosition));
        Vector3 groundMousePosition   = WorldTouchPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition));
        float   distance = Mathf.Abs(groundMousePosition.x - groundClickedPosition.x);
        float   xMin     = Mathf.Min(groundMousePosition.x, groundClickedPosition.x);
        float   zMin     = Mathf.Min(groundMousePosition.z, groundClickedPosition.z);
        float   zMax     = Mathf.Max(groundMousePosition.z, groundClickedPosition.z);

        RaycastHit[] hits = Physics.CapsuleCastAll(new Vector3(xMin, 0f, zMin), new Vector3(xMin, 0f, zMax), 0.1f, Vector3.right, distance, LayerMask.GetMask(new string[] { player.species.ToString() }));
        foreach (RaycastHit hit in hits)
        {
            Unit unit = hit.collider.gameObject.GetComponent <Unit> ();
            if (unit)
            {
                SelectWorldOject(unit as WorldObject);
            }
        }
    }
Пример #3
0
 public virtual void HandleInput()
 {
     // TODO rewrite this function, the logic sucks
     player.userInput.touchTime += Time.deltaTime;
     if (!Input.GetMouseButton(0))
     {
         if (Input.GetMouseButtonUp(0) && GameManager.FingerInBounds(Input.mousePosition) && player.userInput.NotOnOpenPanel() && player.userInput.touchTime > 0.1f)
         {
             if (!SelectBox.isActive)
             {
                 ClickSelect();
             }
             else
             {
                 MultiSelect();
             }
         }
         MoveCamera();
         if (SelectBox.isActive)
         {
             SelectBox.Disable();
         }
     }
     else if (GameManager.FingerInBounds(Input.mousePosition) && player.userInput.NotOnOpenPanel())
     {
         if (Input.GetMouseButtonDown(0))
         {
             clickedPosition = Input.mousePosition;
         }
         else if ((Input.mousePosition - clickedPosition).sqrMagnitude > 100f)
         {
             AdjustSelectionBox();
         }
     }
     if (Input.GetAxis("Mouse ScrollWheel") != 0f)
     {
         ZoomCamera(Input.GetAxis("Mouse ScrollWheel"));
     }
 }
Пример #4
0
 public override void HandleInput()
 {
     if (!Input.GetMouseButton(0))
     {
         if (Input.GetMouseButtonUp(0))
         {
             if (!SelectBox.isActive)
             {
                 ClickSelect();
             }
             else
             {
                 MultiSelect();
             }
         }
         MoveCamera();
         if (SelectBox.isActive)
         {
             SelectBox.Disable();
         }
     }
     else if (GameManager.FingerInBounds(Input.mousePosition))
     {
         if (Input.GetMouseButtonDown(0))
         {
             clickedPosition = Input.mousePosition;
         }
         else if ((Input.mousePosition - clickedPosition).sqrMagnitude > 100f)
         {
             AdjustSelectionBox();
         }
     }
     if (Input.GetAxis("Mouse ScrollWheel") != 0f)
     {
         ZoomCamera(Input.GetAxis("Mouse ScrollWheel"));
     }
 }