예제 #1
0
    private void CheckPowerShapePlacement()
    {
        Vector3 casePos  = transform.position;
        Vector3 mousePos = Input.mousePosition;

        isMouseOnGridCaseTMP = false;

        if (mousePos.x >= casePos.x - rect.width * SharedData.GetScreenRatio() / 2 &&
            mousePos.x <= casePos.x + rect.width * SharedData.GetScreenRatio() / 2 &&
            mousePos.y >= casePos.y - rect.height * SharedData.GetScreenRatio() / 2 &&
            mousePos.y <= casePos.y + rect.height * SharedData.GetScreenRatio() / 2)
        {
            isMouseOnGridCaseTMP = true;

            if (currentPowerShape != null)
            {
                if (currentPowerShape.GetComponent <PowerShape>().NumberOfCollisionWithOtherPowerShapes <= 0 &&
                    currentPowerShape.GetComponent <PowerShape>().NumberOfCollisionWithGridLimits <= 0 &&
                    currentPowerShape.GetComponent <PowerShape>().CanBePlacedOnInventory())
                {
                    currentPowerShape.transform.position = casePos;
                    IsPowerShapeOnCase = true;
                }
                else
                {
                    IsPowerShapeOnCase = false;
                }
            }
        }
        else
        {
            if (currentPowerShape != null)
            {
                IsPowerShapeOnCase = false;
            }
        }
    }