예제 #1
0
    public MouseHandlerInfo GetMouseInfo()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit[] hits = Physics.RaycastAll(ray);
        Dictionary <eInput, bool> leftClick  = GetClickStatus(0);
        Dictionary <eInput, bool> rightClick = GetClickStatus(1);
        float axis = Input.GetAxis("Mouse ScrollWheel");

        if (true || leftClick.ContainsValue(true) || rightClick.ContainsValue(true))
        {
            foreach (RaycastHit hit in hits)
            {
                Clickable clicked = hit.transform.gameObject.GetComponentInParent <Clickable>();

                if (clicked != null)
                {
                    Pos p = clicked.pos;
                    MouseHandlerInfo mhi = new MouseHandlerInfo(p, axis, leftClick, rightClick);
                    return(mhi);
                }
            }
        }
        return(new MouseHandlerInfo(axis));
    }
예제 #2
0
    public InputHandlerInfo GetInput()
    {
        KeyHandlerInfo   khi = GetKeyInfo();
        MouseHandlerInfo mhi = GetMouseInfo();
        InputHandlerInfo ihi = new InputHandlerInfo(khi, mhi);

        return(ihi);
    }
예제 #3
0
    dStructurePlacement GetStructurePlacement(MouseHandlerInfo mhi)
    {
        dStructurePlacement structureToBuild = null;

        if (mhi._pos != null && mhi._left[eInput.Up])
        {
            structureToBuild = _locations[mhi._pos].Click();
        }
        return(structureToBuild);
    }
예제 #4
0
    SelectedData GetSelectedData(MouseHandlerInfo mhi)
    {
        SelectedData sd = null;

        if (mhi._pos != null)
        {
            HomelandsLocation loc = _locations[mhi._pos];
            sd = new SelectedData(loc);
        }
        return(sd);
    }
예제 #5
0
    public MouseHandlerOutput GetMouseHandlerOutput(MouseHandlerInfo mhi)
    {
        dStructurePlacement builtBuilding = GetStructurePlacement(mhi);
        SelectedData        selected      = GetSelectedData(mhi);
        MouseHandlerOutput  mho           = new MouseHandlerOutput();

        mho._structurePlaced = builtBuilding;
        mho._selected        = selected;

        return(mho);
    }
예제 #6
0
    void HandleZoom(MouseHandlerInfo mhi)
    {
        float d = mhi._axis;

        if (d != 0)
        {
            if (d > 0f)
            {
                Camera.main.GetComponent <Camera>().orthographicSize -= 1;
            }
            else if (d < 0f)
            {
                Camera.main.GetComponent <Camera>().orthographicSize += 1;
            }
        }
    }
예제 #7
0
 public InputHandlerInfo(KeyHandlerInfo keyHandlerInfo, MouseHandlerInfo mouseHandlerInfo)
 {
     _keyHandlerInfo   = keyHandlerInfo;
     _mouseHandlerInfo = mouseHandlerInfo;
 }