예제 #1
0
    public void MouseDrag(Vector2 position)
    {
        Vector3      worldPosition = Camera.main.ScreenToWorldPoint(position);
        RaycastHit2D hit           = Physics2D.Raycast(worldPosition, Vector2.zero, Mathf.Infinity, 1 << UILayer);

        if (gameTracker.currentState == GameTracker.STATE_PLAN_PLAYER_1 || gameTracker.currentState == GameTracker.STATE_PLAN_PLAYER_2)
        {
            if (isAnyShipSelected)
            {
                gameTracker.SetShipTargetPosition(selectedShipID, worldPosition);
            }
            else
            {
                if (hit)
                {
                    PlayerShip playerShip = hit.transform.gameObject.GetComponent <PlayerShip>();
                    if (playerShip && playerShip.tag == gameTracker.currentTag)
                    {
                        SelectShip(playerShip.ID);
                    }
                }
            }
        }
    }