public void Partition(int partitionCount, GameObject pieceReference, GameObject original)
    {
        this.outlineRenderers.Clear();
        partitions = getPartitions();

        GameObject     temp;
        SpriteRenderer sprite = original.GetComponent <SpriteRenderer> ();
        Vector2        pos;

        this.original = original.GetComponent <PartitionableObject_v2> ();
        this.AdjustCamera();

        this.partitionPointer = -1;
        float prevPieceX = 0f;

        Debug.Log("<color=yellow>PartitionCount clone is " + partitionCount + "</color>");
        for (int x = 0; x < partitionCount; x++)
        {
            pos = new Vector2(gameObject.transform.position.x, gameObject.transform.position.y);

            temp = Instantiate(original.GetComponent <PartitionableObject_v2>().partitionPiece, pos, Quaternion.identity);
            //			temp.transform.localScale = new Vector2 (original.transform.localScale.x / partitionCount, original.transform.localScale.y);
            //			temp.transform.localScale = new Vector2 (temp.transform.localScale.x-scaleReduction, temp.transform.localScale.y-scaleReduction);
            temp.transform.localScale = new Vector2(original.transform.localScale.x / partitionCount + .5f, gameObject.transform.localScale.y);



            temp.GetComponent <SpriteRenderer> ().sortingLayerName = "Clone Partition";

            temp.SetActive(true);
            temp.name = "partition_" + x;
            temp.tag  = "Partition Instance";
            temp.transform.SetParent(gameObject.transform);

            Bounds cloneBounds = gameObject.GetComponent <SpriteRenderer> ().bounds;

            Vector2 locPos = new Vector2(cloneBounds.center.x - (cloneBounds.extents.x - (cloneBounds.extents.x / partitionCount)) + prevPieceX, cloneBounds.center.y);

            temp.transform.position = locPos;
            temp.AddComponent <RectTransform> ();
            this.GenerateOutline(temp);

            prevPieceX += (cloneBounds.size.x / partitionCount);

            partitions.Add(temp);
            this.highlightPartition(x, false);
        }

//		if (!this.fractionLabel.gameObject.activeInHierarchy)
//			Debug.LogError ("Fraction Label is DISABLED!!!");
//		Debug.Log ("Partition Count: " + partitions.Count);

        this.fractionLabel.Enable();
        this.fractionLabel.UpdateValue(0, partitionCount);
    }
    public GameObject SpawnClone(GameObject parent, Vector2 clonePosition, Color highlightColor, Color disabledColor, float scaleReduction)
    {
        GameObject holder = GameObject.Instantiate(parent, clonePosition, Quaternion.identity);

        holder.GetComponent <PartitionableObject_v2> ().RemoveComponents();
        holder.GetComponentInChildren <ClonePosition> ().RemoveComponents();
        holder.GetComponentInChildren <UnderflowPosition> ().RemoveComponents();
        holder.GetComponentInChildren <OverflowPosition> ().RemoveComponents();
        holder.GetComponentInChildren <ResultsUI> ().RemoveComponents();
        holder.GetComponentInChildren <HintBubbleManager> ().RemoveComponents();

        holder.transform.SetParent(parent.transform);



        SpriteRenderer sprite = holder.GetComponent <SpriteRenderer> ();

//		float opacity = 0.5f;
//		Color color = new Color(sprite.color.r,sprite.color.g,sprite.color.b,opacity);
//		sprite.color = color;

        holder.AddComponent <PartitionedClone_v2> ();

//		holder.GetComponent<PartitionedClone_v2> ().highlightColor = new Color(0.078f, 1f, 0.2f);
        holder.GetComponent <PartitionedClone_v2> ().scaleReduction = scaleReduction;

        PartitionableObject_v2 original = parent.GetComponent <PartitionableObject_v2> ();

        holder.GetComponent <PartitionedClone_v2> ().SetUnderflowPosition(original.GetComponentInChildren <UnderflowPosition>().transform.position);
        holder.GetComponent <PartitionedClone_v2> ().SetOverflowPosition(original.GetComponentInChildren <OverflowPosition>().transform.position);
        holder.GetComponent <PartitionedClone_v2> ().SetOriginalPosition(original.transform.position);
        holder.GetComponent <PartitionedClone_v2> ().SetResultsUI(original.GetComponentInChildren <ResultsUI> ());


        holder.GetComponent <PartitionedClone_v2> ().highlightColor        = original.cloneHighlightColor;
        holder.GetComponent <PartitionedClone_v2> ().disabledColor         = original.GetDisabledColor();
        holder.GetComponent <PartitionedClone_v2> ().highlightOutlineColor = original.cloneHighlightOutlineColor;
        holder.GetComponent <PartitionedClone_v2> ().disabledOutlineColor  = original.GetDisabledOutlineColor();

        holder.GetComponent <PartitionedClone_v2> ().filledColor        = original.GetHighlightColor();
        holder.GetComponent <PartitionedClone_v2> ().filledOutlineColor = original.GetHighlightOutlineColor();
//		holder.GetComponent<PartitionedClone_v2> ().gameObject.GetComponentInChildren<HintBubbleManager> ().RemoveComponents ();
        holder.SetActive(true);

        return(holder);
    }
Example #3
0
    private IEnumerator NeedleTutorial()
    {
        Debug.Log("Needle tutorial start");

        enableDialogue();         //Tutorial_4_PickedUpNeedle
        while (GameController_v7.Instance.GetDialogueManager().IsDialogueBoxPlaying())
        {
            disablePlayerControls();
            yield return(null);
        }

        GameController_v7.Instance.GetDialogueManager().ShowCG();
        yield return(new WaitForSecondsRealtime(NEEDLE_CG_WAIT));

        GameController_v7.Instance.GetDialogueManager().HideCG();

        enableDialogue();         //this happened cuz sky broke, we need to gather sky fragments
        while (GameController_v7.Instance.GetDialogueManager().IsDialogueBoxPlaying())
        {
            disablePlayerControls();
            yield return(null);
        }

        GameController_v7.Instance.GetDialogueManager().HideCG();

        enableDialogue();         //the sky fragment in the needle is reacting to the box, I think this can fix it, can you make me throw it at the box?
        while (GameController_v7.Instance.GetDialogueManager().IsDialogueBoxPlaying())
        {
            disablePlayerControls();
            yield return(null);
        }

        GameController_v7.Instance.GetDialogueManager().DisplayMessage(DialogueManager_v2.DialogueType.HINT, dialogues, null);

        ToggleMobileUI(true);
        playerController.canMove(true);
        playerAttack.canAttack(true);

        PartitionableObject_v2 tutorialBox = null;

        while (tutorialBox == null)
        {
            tutorialBox             = block.GetComponent <PartitionableObject_v2> ();
            tutorialBox.enableClone = false;
            yield return(null);
        }

        bool tried = false;
        int  index = 0;

        while (!tutorialBox.IsTangible())
        {
            switch (index)
            {
            case 0:
                if (GameController_v7.Instance.GetPauseController().IsPaused())
                {
                    Debug.Log("IS PAUSED ENTERED");
                    enableDialogue();
                    while (GameController_v7.Instance.GetDialogueManager().IsDialogueBoxPlaying())
                    {
                        disablePlayerControls();
                        Debug.Log("DialogueManager IN");
                        yield return(null);
                    }
                    Debug.Log("DialogueManager DONE");
//					GameObject cloneObject = tutorialBox.GetComponentInChildren<PartitionedClone_v2> ().gameObject;

//					if (cloneObject != null) {
////						tutorialBox.GetComponentInChildren<HintBubbleManager> ().RemoveComponents ();
//						if (cloneObject.GetComponentInChildren<HintBubbleManager> () != null) {
//							cloneObject.GetComponentInChildren<HintBubbleManager> ().RemoveComponents ();
//						}
//					}
                    tutorialBox.enableClone = true;
                    enableDialogue();
                    while (GameController_v7.Instance.GetDialogueManager().IsDialogueBoxPlaying())
                    {
                        disablePlayerControls();
                        yield return(null);
                    }

                    //Hint to adjust fill
                    GameController_v7.Instance.GetDialogueManager().DisplayMessage(DialogueManager_v2.DialogueType.HINT, dialogues, null);

                    index = 1;

                    ToggleMobileUI(true);
                    playerAttack.canAttack(true);
                    playerController.canMove(true);
                }
                break;

            case 1:
                if (!GameController_v7.Instance.GetPauseController().IsPaused() && !tutorialBox.IsTangible() && !tutorialBox.IsAnimatingFill() && !tutorialBox.IsFilling())
                {
                    playerController.isInDialogue();
                    GameController_v7.Instance.GetDialogueManager().DisplayMessage(DialogueManager_v2.DialogueType.DIALOGUE, errorDialogue1, null);
                    while (GameController_v7.Instance.GetDialogueManager().IsDialogueBoxPlaying())
                    {
                        disablePlayerControls();
                        yield return(null);
                    }

                    //Error Hint
                    GameController_v7.Instance.GetDialogueManager().DisplayMessage(DialogueManager_v2.DialogueType.HINT, errorHint, null);

                    index = 2;

                    ToggleMobileUI(true);
                    playerAttack.canAttack(true);
                    playerController.canMove(false);
                }
                break;

            case 2:
                if (tried)
                {
                    if (!GameController_v7.Instance.GetPauseController().IsPaused() && !tutorialBox.IsTangible() && !tutorialBox.IsFilling() && !tutorialBox.IsAnimatingFill())
                    {
                        playerController.isInDialogue();
                        GameController_v7.Instance.GetDialogueManager().DisplayMessage(DialogueManager_v2.DialogueType.DIALOGUE, errorDialogue2, null);
                        while (GameController_v7.Instance.GetDialogueManager().IsDialogueBoxPlaying())
                        {
                            disablePlayerControls();
                            yield return(null);
                        }

                        //Error Hint
                        GameController_v7.Instance.GetDialogueManager().DisplayMessage(DialogueManager_v2.DialogueType.HINT, errorHint, null);

                        index++;
                        if (index > 2)
                        {
                            index = 2;
                        }

                        ToggleMobileUI(true);
                        playerAttack.canAttack(true);
                        playerController.canMove(true);

                        tried = false;
                    }
                }
                else if (GameController_v7.Instance.GetPauseController().IsPaused())
                {
                    tried = true;
                }
                break;
            }

            yield return(null);
        }

        StartCoroutine(ContinueNextRoom());
    }