示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(1)) // Right click, move the unit
        {
            target   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            target.z = this.gameObject.transform.position.z;
            MoveObject();
        }
        else if (Input.GetMouseButtonDown(0)) // Left click, determine if its a selection or deselection
        {
            Vector3 mousePos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2 mousePos2d = new Vector2(mousePos.x, mousePos.y);

            RaycastHit2D hit = Physics2D.Raycast(mousePos2d, Vector2.zero);


            if (hit.collider == null || !(hit.collider.tag == "PlayerUnit" || hit.collider.tag == "Building" || hit.collider.tag == "GameButton"))
            {
                //Debug.Log(hit.collider.ToString());
                SelectionHandler.ClearActiveSelections();
                SelectionHandler.ClearSelections();
                SelectionHandler.SelectedObjects.Clear();

                UiManager.isBuildingDisplay = false;
                UiManager.isUnitDisplay     = false;

                //BuildingManager.DeselectCurrentBuilding();
            }
        }
    }
示例#2
0
    private void OnMouseDown()
    {
        SelectionHandler.ClearActiveSelections();

        this.activeSelection = true; // This will be important to display an interface options pertaining to a specific unit when it's selected
        ToggleSprite();
        ShowUnitStats();
        PrintSelectedObjects();
    }