/// <summary>
    /// Linear fill method.
    /// </summary>
    private void LinearFill()
    {
        clickPostion = GameplayController.Instance.canvasCamera.ScreenToWorldPoint(Input.mousePosition);

        Vector3 rotation = path.transform.eulerAngles;

        rotation.z -= path.offset;

        Rect rect = TR_CommonUtil.RectTransformToScreenSpace(path.GetComponent <RectTransform> ());

        Vector3 pos1 = Vector3.zero, pos2 = Vector3.zero;

        if (path.type == TR_Path.ShapeType.Horizontal)
        {
            pos1.x = path.transform.position.x - Mathf.Sin(rotation.z * Mathf.Deg2Rad) * rect.width / 2.0f;
            pos1.y = path.transform.position.y - Mathf.Cos(rotation.z * Mathf.Deg2Rad) * rect.width / 2.0f;

            pos2.x = path.transform.position.x + Mathf.Sin(rotation.z * Mathf.Deg2Rad) * rect.width / 2.0f;
            pos2.y = path.transform.position.y + Mathf.Cos(rotation.z * Mathf.Deg2Rad) * rect.width / 2.0f;
        }
        else
        {
            pos1.x = path.transform.position.x - Mathf.Cos(rotation.z * Mathf.Deg2Rad) * rect.height / 2.0f;
            pos1.y = path.transform.position.y - Mathf.Sin(rotation.z * Mathf.Deg2Rad) * rect.height / 2.0f;

            pos2.x = path.transform.position.x + Mathf.Cos(rotation.z * Mathf.Deg2Rad) * rect.height / 2.0f;
            pos2.y = path.transform.position.y + Mathf.Sin(rotation.z * Mathf.Deg2Rad) * rect.height / 2.0f;
        }
        pos1.z = path.transform.position.z;
        pos2.z = path.transform.position.z;

        GameObject obj1 = GameObject.Find("obj1");

        if (obj1 == null)
        {
            obj1 = new GameObject("obj1");
        }

        GameObject obj2 = GameObject.Find("obj2");

        if (obj2 == null)
        {
            obj2 = new GameObject("obj2");
        }
        if (path.flip)
        {
            Vector3 temp = pos2;
            pos2 = pos1;
            pos1 = temp;
        }

        obj1.transform.position = pos1;
        obj2.transform.position = pos2;

        clickPostion.x           = Mathf.Clamp(clickPostion.x, Mathf.Min(pos1.x, pos2.x), Mathf.Max(pos1.x, pos2.x));
        clickPostion.y           = Mathf.Clamp(clickPostion.y, Mathf.Min(pos1.y, pos2.y), Mathf.Max(pos1.y, pos2.y));
        fillAmount               = Vector2.Distance(clickPostion, pos1) / Vector2.Distance(pos1, pos2);
        pathFillImage.fillAmount = fillAmount;
        CheckPathComplete();
    }
Esempio n. 2
0
    /// <summary>
    /// Set the numbers status.
    /// </summary>
    /// <param name="status">the status value.</param>
    public void SetNumbersStatus(bool status)
    {
        Color            tempColor = Color.white;
        List <Transform> numbers   = TR_CommonUtil.FindChildrenByTag(transform.Find("Numbers"), "Number");

        foreach (Transform number in numbers)
        {
            if (number == null)
            {
                continue;
            }
            if (status)
            {
                EnableStartCollider();
//				number.GetComponent<Animator>().SetBool("Select",true);
                tempColor.a = 1;
            }
            else
            {
                DisableStartCollider();
//				number.GetComponent<Animator>().SetBool("Select",false);
                tempColor.a = 0.3f;
            }
            number.GetComponent <Image> ().color = tempColor;
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Release the coroutine.
    /// </summary>
    /// <returns>The coroutine.</returns>
    private IEnumerator ReleaseCoroutine()
    {
        Image image = TR_CommonUtil.FindChildByTag(transform, "Fill").GetComponent <Image> ();

        while (image.fillAmount > 0)
        {
            image.fillAmount -= 0.02f;
            yield return(new WaitForSeconds(0.005f));
        }
    }
Esempio n. 4
0
    /// <summary>
    /// Set the numbers visibility.
    /// </summary>
    /// <param name="visible">visibility value.</param>
    public void SetNumbersVisibility(bool visible)
    {
        List <Transform> numbers = TR_CommonUtil.FindChildrenByTag(transform.Find("Numbers").transform, "Number");

        foreach (Transform number in numbers)
        {
            if (number != null)
            {
                number.gameObject.SetActive(visible);
            }
        }
    }
 /// <summary>
 /// On the start hit collider event.
 /// </summary>
 /// <param name="hit2d">Hit2d.</param>
 private void OnStartHitCollider(RaycastHit2D hit2d)
 {
     path          = hit2d.transform.GetComponentInParent <TR_Path> ();
     pathFillImage = TR_CommonUtil.FindChildByTag(path.transform, "Fill").GetComponent <Image> ();
     if (path.completed || !shape.IsCurrentPath(path))
     {
         ReleasePath();
     }
     else
     {
         path.StopAllCoroutines();
         TR_CommonUtil.FindChildByTag(path.transform, "Fill").GetComponent <Image> ().color = currentPencilColor;
     }
 }
Esempio n. 6
0
    //public Group group;//the group reference

    /// <summary>
    /// Create a pointer.
    /// </summary>
    /// <param name="groupIndex">Group index.</param>
    /// <param name="levelsGroup">Levels group.</param>
    /// <param name="pointerPrefab">Pointer prefab.</param>
    /// <param name="pointersParent">Pointers parent.</param>
    public static void CreatePointer(int groupIndex, GameObject levelsGroup, GameObject pointerPrefab, Transform pointersParent)
    {
        if (levelsGroup == null || pointerPrefab == null || pointersParent == null)
        {
            return;
        }

        //Create Slider Pointer
        GameObject pointer = Instantiate(pointerPrefab, Vector3.zero, Quaternion.identity) as GameObject;

        pointer.transform.SetParent(pointersParent);
        pointer.name = "Pointer-" + TR_CommonUtil.IntToString(groupIndex + 1);
        pointer.transform.localScale = Vector3.one;
        pointer.GetComponent <RectTransform>().offsetMax = Vector2.zero;
        pointer.GetComponent <RectTransform>().offsetMin = Vector2.zero;
        //pointer.GetComponent<Pointer> ().group = levelsGroup.GetComponent<Group> ();
        //pointer.GetComponent<Button> ().onClick.AddListener (() => GameObject.FindObjectOfType<UIEvents> ().PointerButtonEvent (pointer.GetComponent<Pointer> ()));
    }
    /// <summary>
    /// On shape completed event.
    /// </summary>
    private void OnShapeComplete()
    {
        DisableHand();
        brightEffect.GetComponent <ParticleEmitter> ().emit = false;

        Animator shapeAnimator = shape.GetComponent <Animator> ();

        shapeAnimator.SetBool(shape.name, false);
        shapeAnimator.SetTrigger("Completed");

//		DataManager.SaveShapeStars (TableShape.selectedShape.ID, CommonUtil.GetTableShapeStars (GameObject.FindObjectOfType<Progress> ().starsNumber));
//		if (TableShape.selectedShape .ID + 1 <= ShapesManager.instance.shapes.Count) {
//			DataManager.SaveShapeLockedStatus (TableShape.selectedShape.ID + 1, false);
//		}
        List <Transform> paths = TR_CommonUtil.FindChildrenByTag(shape.transform.Find("Paths"), "Path");

        /*
         * int from, to;
         * string [] slices;
         * foreach (Transform p in paths) {
         *              slices = p.name.Split ('-');
         *              from = int.Parse (slices [1]);
         *              to = int.Parse (slices [2]);
         * //				DataManager.SaveShapePathColor (TableShape.selectedShape.ID, from, to, CommonUtil.FindChildByTag (p, "Fill").GetComponent<Image> ().color);
         * }
         */
//		timer.Stop ();
//		Area.Show ();
        winDialog.Show();
//		GameObject.Find ("NextButton").GetComponent<Animator> ().SetTrigger ("Select");
//		completeEffect.emit = true;
//			CommonUtil.PlayOneShotClipAt (completedSFX, Vector3.zero, effectsAudioSource.volume);
//			AudioController.Instance.PlaySound (completedSFX);

        Invoke("HideWinDialog", 1.0f);
        if (onComplete != null)
        {
//			shape.hide ();
            //onComplete ();
        }
//		Invoke("CreateShape", 1.5f);
    }