Exemple #1
0
    IEnumerator DoDragInstruct()
    {
        if (mShapeCategoryWidgetActivePicks.Exists(mDragInstructTarget))
        {
            yield return(new WaitForSeconds(0.1f)); //slight delay to allow UIs to position properly

            if (dragGuide.isActive)
            {
                dragGuide.UpdatePositions(mDragInstructTarget.transform.position, categoryContainer.position);
            }
            else
            {
                dragGuide.Show(false, mDragInstructTarget.transform.position, categoryContainer.position);
            }

            dragInstructGO.SetActive(true);
        }
        else if (mShapeCategoryWidgetActivePlaced.Exists(mDragInstructTarget))
        {
            dragGuide.Hide();

            dragInstructGO.SetActive(false);
        }

        mDragInstructRout = null;
    }
Exemple #2
0
    IEnumerator DoShow(Transform aPt1, Transform aPt2)
    {
        dragGuide.Show(false, aPt1.position, aPt2.position);

        var delay = dragGuide.cursorFadeDelay * 5f + dragGuide.cursorFadeDelay * 2f + dragGuide.cursorMoveDelay;

        yield return(new WaitForSeconds(delay));
    }
Exemple #3
0
    IEnumerator DoHelpDisplay()
    {
        //find the first operand card
        CardWidget card = null;

        while (true)
        {
            if (opsWidget.operation != null && opsWidget.operation.operands.Length > 0)
            {
                card = opsWidget.operandSlots.slots[0].card;
            }

            if (card)
            {
                break;
            }

            yield return(null);
        }

        Vector2 wholePos    = card.numberWidget.wholeRootGO.transform.position;
        Vector2 fractionPos = card.numberWidget.fractionRootGO.transform.position;

        var dragDelay = dragGuideWidget.cursorFadeDelay * 2f + dragGuideWidget.cursorIdleDelay * 5f + dragGuideWidget.cursorMoveDelay;

        var waitDrag = new WaitForSeconds(dragDelay);

        while (true)
        {
            dragGuideWidget.Show(false, wholePos, fractionPos);

            yield return(waitDrag);

            dragGuideWidget.Show(false, fractionPos, wholePos);

            yield return(waitDrag);
        }
    }
Exemple #4
0
    void M8.IModalActive.SetActive(bool aActive)
    {
        if (aActive)
        {
            instructDragGuide.Show(false, instructDragStart.position, instructDragEnd.position);

            //start
            mRout = StartCoroutine(DoActive());
        }
        else
        {
            instructDragGuide.Hide();

            StopRouts();
        }
    }
Exemple #5
0
    void Update()
    {
        if (isVisible && mCardWidget)
        {
            var startPos = mCardWidget.transform.position;
            var endPos   = GetDragEndPos();

            if (dragGuideWidget.isActive)
            {
                dragGuideWidget.UpdatePositions(startPos, endPos);
            }
            else
            {
                dragGuideWidget.Show(false, startPos, endPos);
            }
        }
    }
Exemple #6
0
    IEnumerator DoDragInstruct()
    {
        while (mDragInstructEnabled)
        {
            if (!dragInstructCardDeckWidget)
            {
                break;
            }

            if (dragInstructCardDeckWidget.cards == null)
            {
                yield return(null);

                continue;
            }

            yield return(new WaitForSeconds(0.5f));

            if (!dragInstruct)
            {
                break;
            }

            dragInstruct.Hide(); //allow for reposition

            int opInd   = -1;
            int opCount = Mathf.Min(operandSlots.slots.Length, mOperation.operands.Length);
            for (int i = 0; i < opCount; i++)
            {
                var op = mOperation.operands[i];
                if (op.isEmpty)
                {
                    opInd = i;
                    break;
                }
            }

            if (opInd != -1)
            {
                CardWidget card = null;
                for (int i = 0; i < dragInstructCardDeckWidget.cards.Length; i++)
                {
                    if (dragInstructCardDeckWidget.cards[i])
                    {
                        card = dragInstructCardDeckWidget.cards[i];
                        break;
                    }
                }

                if (card)
                {
                    Vector2 dragStart = card.transform.position;
                    Vector2 dragEnd   = operandSlots.slots[opInd].anchor.position;

                    dragInstruct.Show(false, dragStart, dragEnd);
                    if (dragInstructDialogGO)
                    {
                        dragInstructDialogGO.SetActive(true);
                    }
                }
                else   //no card available
                {
                    if (dragInstructDialogGO)
                    {
                        dragInstructDialogGO.SetActive(false);
                    }
                }
            }
            else   //all operands filled
            {
                if (dragInstructDialogGO)
                {
                    dragInstructDialogGO.SetActive(false);
                }
            }

            mDragInstructSlotUpdated = false;
            while (!mDragInstructSlotUpdated)
            {
                yield return(null);
            }

            yield return(null);
        }

        mDragInstructRout = null;
        DragInstructEnd();
    }
Exemple #7
0
    protected override IEnumerator Start()
    {
        if (!string.IsNullOrEmpty(musicPath))
        {
            LoLManager.instance.PlaySound(musicPath, true, true);
        }

        yield return(base.Start());

        //spawn player
        mPlayerGO.SetActive(true);
        yield return(new WaitForSeconds(1.5f));

        //

        //first time detail

        //activate force selection
        mForceGroupUIGO.SetActive(true);

        //first time - show drags
        if (isForceDragInstructions)
        {
            yield return(new WaitForSeconds(0.4f));

            dragGuideGO.SetActive(true);

            var item = entitySpawnerGroup.widgets[0];

            Vector2 guideStart = item.transform.position;
            Vector2 guideDest  = Camera.main.WorldToScreenPoint(dragGuideGO.transform.position);

            mDragGuide.Show(false, guideStart, guideDest);

            //wait for item to be spawned
            while (item.activeUnitCount == 0)
            {
                yield return(null);
            }

            //hide guide, show adjust entity guide
            dragGuideGO.SetActive(false);
            mDragGuide.Hide();

            dragEntityGuideGO.SetActive(true);

            yield return(new WaitForSeconds(playGuideGOShowDelay));

            playGuideGO.SetActive(true);
            mPlayGroupUIGO.SetActive(true);

            while (!mPlayerBody.simulated)
            {
                yield return(null);
            }

            //hide guides
            dragEntityGuideGO.SetActive(false);
            playGuideGO.SetActive(false);
        }
        else
        {
            //activate play
            mPlayGroupUIGO.SetActive(true);
        }

        //player watcher
        StartCoroutine(DoPlayer());
    }
Exemple #8
0
    protected override IEnumerator Start()
    {
        if (!string.IsNullOrEmpty(musicPath))
        {
            LoLManager.instance.PlaySound(musicPath, true, true);
        }

        yield return(base.Start());

        titleAnim.gameObject.SetActive(true);
        yield return(titleAnim.PlayEnterWait());

        yield return(new WaitForSeconds(startDelay));

        motionIllustrationAnim.gameObject.SetActive(true);
        yield return(motionIllustrationAnim.PlayEnterWait());

        introDialog.Play();
        while (introDialog.isPlaying)
        {
            yield return(null);
        }

        yield return(titleAnim.PlayExitWait());

        titleAnim.gameObject.SetActive(false);

        yield return(motionIllustrationAnim.PlayExitWait());

        motionIllustrationAnim.gameObject.SetActive(false);

        //princess
        yield return(DoPrincessDistress());

        //help
        kidnapDialog.Play();
        while (kidnapDialog.isPlaying)
        {
            yield return(null);
        }

        //get block 1 ready
        block1.gameObject.SetActive(true);
        block1.body.simulated = true;

        block1ForceGravityGO.SetActive(true);

        mBlockForceRout = StartCoroutine(DoForceBalance(block1, block1ForceNetGO, block1ForceBalancedGO, block1ForceUnbalancedGO, block1NetForceDirRoot, block1NetForceNoneGO));

        //wait a bit, then pause and describe the gravity
        yield return(new WaitForSeconds(gravityDialogWaitDelay));

        M8.SceneManager.instance.Pause();

        gravityDialog.Play();
        while (gravityDialog.isPlaying)
        {
            yield return(null);
        }

        M8.SceneManager.instance.Resume();

        //wait for block 1 to hit ground
        while (!block1.isGrounded)
        {
            yield return(null);
        }

        //fancy camera shake
        cameraShaker.Shake();

        if (!string.IsNullOrEmpty(blockLandSfxPath))
        {
            LoLManager.instance.PlaySound(blockLandSfxPath, false, false);
        }

        yield return(new WaitForSeconds(1f));

        for (int i = 0; i < block1Wheels.Length; i++)
        {
            var suspension = block1Wheels[i].suspension;
            suspension.frequency       = block1WheelsGroundFreq;
            block1Wheels[i].suspension = suspension;
        }
        //

        yield return(new WaitForSeconds(1f));

        block1ForceGravityGO.SetActive(false);

        //some more dialog
        landDialog.Play();
        while (landDialog.isPlaying)
        {
            yield return(null);
        }

        //show interaction
        interfaceRootGO.SetActive(true);

        //set to only one knight
        var knightSpawner   = (EntitySpawnerWidget)unitSpawnerWidget;
        var lastKnightCount = knightSpawner.entityCount;

        knightSpawner.SetEntityCount(1);

        //game ready
        unitSpawnerWidget.active = true;

        //drag instruction
        yield return(new WaitForSeconds(0.35f));

        mDragGuide.Show(false, unitSpawnerWidget.icon.transform.position, dragGuideTo.position);

        while (knightSpawner.activeUnitCount == 0)
        {
            yield return(null);
        }

        mDragGuide.Hide();
        //

        //wait for block1 to start moving

        //send 1 goblin
        StartCoroutine(DoGoblins());

        //wait for block contact
        while ((block1.collisionFlags & CollisionFlags.CollidedSides) == CollisionFlags.None)
        {
            yield return(null);
        }

        //show knight force
        block1ForceKnightGO.SetActive(true);

        //wait for goblin force display
        while (!block1ForceGoblinGO.activeSelf)
        {
            yield return(null);
        }

        //dialog
        goblinPushDialog.Play();
        while (goblinPushDialog.isPlaying)
        {
            yield return(null);
        }

        //add the rest of knights counter
        knightSpawner.SetEntityCount(lastKnightCount);

        //show drag again
        mDragGuide.Show(false, unitSpawnerWidget.icon.transform.position, dragGuideTo.position);
        mIsDragGuideShown = true;

        //wait for block1 to contact goal
        bool isBlockFinish = false;

        while (!isBlockFinish)
        {
            var blockContacts = block1.collisionData;
            for (int i = 0; i < blockContacts.Count; i++)
            {
                var coll = blockContacts[i].collider;
                if (coll && coll.CompareTag(block1GoalTag))
                {
                    isBlockFinish = true;
                    break;
                }
            }

            yield return(null);
        }

        unitSpawnerWidget.active = false;

        //animation

        //clear out units
        signalUnitsClear.Invoke();

        block1ForceKnightGO.SetActive(false);
        block1ForceGoblinGO.SetActive(false);

        //more dialog
        yield return(new WaitForSeconds(2f));

        //clear out block1 info
        StopCoroutine(mBlockForceRout);
        block1ForceNetGO.SetActive(false);
        block1ForceBalancedGO.SetActive(false);
        block1ForceUnbalancedGO.SetActive(false);
        block1NetForceDirRoot.gameObject.SetActive(false);
        block1NetForceNoneGO.SetActive(false);
        //

        block1FinishDialog.Play();
        while (block1FinishDialog.isPlaying)
        {
            yield return(null);
        }
        //

        //block 2 ready
        block2.gameObject.SetActive(true);
        block2.body.simulated = true;

        block2ForceGravityGO.SetActive(true);

        mBlockForceRout = StartCoroutine(DoForceBalance(block2, block2ForceNetGO, block2ForceBalancedGO, block2ForceUnbalancedGO, block2NetForceDirRoot, block2NetForceNoneGO));

        //wait for block 2 to hit ground
        while (!block2.isGrounded)
        {
            yield return(null);
        }

        //fancy camera shake
        cameraShaker.Shake();

        if (!string.IsNullOrEmpty(blockLandSfxPath))
        {
            LoLManager.instance.PlaySound(blockLandSfxPath, false, false);
        }

        block2ForceGravityGO.SetActive(false);

        block2Dialog.Play();
        while (block2Dialog.isPlaying)
        {
            yield return(null);
        }

        //game ready
        unitSpawnerWidget.active = true;

        //show drag again
        mDragGuide.Show(false, unitSpawnerWidget.icon.transform.position, dragGuideTo.position);
        mIsDragGuideShown = true;

        //wait for knight contact, then show forces
        while ((block2.collisionFlags & CollisionFlags.CollidedSides) == CollisionFlags.None)
        {
            yield return(null);
        }

        block2ForcesGO.SetActive(true);
        //

        //wait for block2 to contact block 1
        isBlockFinish = false;

        while (!isBlockFinish)
        {
            var blockContacts = block2.collisionData;
            for (int i = 0; i < blockContacts.Count; i++)
            {
                var coll = blockContacts[i].collider;
                if (coll == block1.coll)
                {
                    isBlockFinish = true;
                    break;
                }
            }

            yield return(null);
        }

        unitSpawnerWidget.active = false;

        //clear out units
        signalUnitsClear.Invoke();

        StopCoroutine(mBlockForceRout);
        block2ForcesGO.SetActive(false);
        block2ForceNetGO.SetActive(false);
        block2ForceBalancedGO.SetActive(false);
        block2ForceUnbalancedGO.SetActive(false);
        block2NetForceDirRoot.gameObject.SetActive(false);
        block2NetForceNoneGO.SetActive(false);

        //victory
        yield return(new WaitForSeconds(victoryStartDelay));

        victoryGO.SetActive(true);

        yield return(new WaitForSeconds(victoryDelay));

        //next level
        //GameData.instance.Progress();
        M8.UIModal.Manager.instance.ModalCloseAll();
        M8.UIModal.Manager.instance.ModalOpen(victoryModal);
    }
Exemple #9
0
    protected override IEnumerator Start()
    {
        if (!string.IsNullOrEmpty(musicPath))
        {
            LoLManager.instance.PlaySound(musicPath, true, true);
        }

        yield return(base.Start());

        //intro
        yield return(new WaitForSeconds(0.5f));

        introDialog.Play();
        while (introDialog.isPlaying)
        {
            yield return(null);
        }
        //

        //inertia
        inertiaIllustrationAnim.gameObject.SetActive(true);
        yield return(inertiaIllustrationAnim.PlayEnterWait());

        inertiaDialog.Play();
        while (inertiaDialog.isPlaying)
        {
            yield return(null);
        }

        yield return(inertiaIllustrationAnim.PlayExitWait());

        inertiaIllustrationAnim.gameObject.SetActive(false);
        //

        //illustrate
        illustrateGO.SetActive(true);

        illustrateDialog.Play();
        while (illustrateDialog.isPlaying)
        {
            yield return(null);
        }

        illustrateGO.SetActive(false);

        //show left side weight
        itemBody.gameObject.SetActive(true);

        yield return(new WaitForSeconds(treasureDialogStartDelay));

        treasureDialog.Play();
        while (treasureDialog.isPlaying)
        {
            yield return(null);
        }

        //enable play
        SetInteractiveEnabled(true);

        //drag instruction
        dragWeightHelpGO.SetActive(true);

        if (mDragGuide)
        {
            var     cam  = Camera.main;
            Vector2 sPos = cam.WorldToScreenPoint(dragWeightStartAnchor.position);
            Vector2 ePos = cam.WorldToScreenPoint(dragWeightEndAnchor.position);

            mDragGuide.Show(false, sPos, ePos);
            mIsDragGuideShown = true;
        }

        //SetInteractiveEnabled(false);

        //GameData.instance.Progress();
    }
Exemple #10
0
    IEnumerator DoDragIndicator()
    {
        //grab guide
        if (!mDragGuide)
        {
            var go = GameObject.FindGameObjectWithTag(dragIndicatorTag);
            mDragGuide = go.GetComponent <DragToGuideWidget>();
        }

        //grab camera
        var cam = Camera.main;

        //wait for blobs to spawn
        while (blobSpawner.spawnQueueCount > 0 && blobSpawner.CheckAnyBlobActiveState(Blob.State.Spawning))
        {
            yield return(null);
        }

        var blobOp1 = blobSpawner.blobActives[0];
        var blobOp2 = blobSpawner.blobActives[1];
        var blobEq  = blobSpawner.blobActives[2];

        while (!(blobOp1.isConnected && blobOp2.isConnected && blobEq.isConnected))
        {
            if (connectControl.curOp == OperatorType.Divide && blobOp1.isConnected && blobEq.isConnected)
            {
                //special case when dividing
                var blobEqPos  = blobEq.jellySprite.CentralPoint.Body2D.position;
                var blobOp2Pos = blobOp2.jellySprite.CentralPoint.Body2D.position;

                Vector2 blobEqUIPos  = cam.WorldToScreenPoint(blobEqPos);
                Vector2 blobOp2UIPos = cam.WorldToScreenPoint(blobOp2Pos);

                if (mDragGuide.isActive)
                {
                    mDragGuide.UpdatePositions(blobEqUIPos, blobOp2UIPos);
                }
                else
                {
                    mDragGuide.Show(false, blobEqUIPos, blobOp2UIPos);
                }
            }
            else if (!(blobOp1.isConnected && blobOp2.isConnected))
            {
                var blobOp1Pos = blobOp1.jellySprite.CentralPoint.Body2D.position;
                var blobOp2Pos = blobOp2.jellySprite.CentralPoint.Body2D.position;

                Vector2 blobOp1UIPos = cam.WorldToScreenPoint(blobOp1Pos);
                Vector2 blobOp2UIPos = cam.WorldToScreenPoint(blobOp2Pos);

                if (mDragGuide.isActive)
                {
                    mDragGuide.UpdatePositions(blobOp1UIPos, blobOp2UIPos);
                }
                else
                {
                    mDragGuide.Show(false, blobOp1UIPos, blobOp2UIPos);
                }
            }
            //wait for blob 3 to be connected
            else if (!blobEq.isConnected)
            {
                var blobOp2Pos = blobOp2.jellySprite.CentralPoint.Body2D.position;
                var blobEqPos  = blobEq.jellySprite.CentralPoint.Body2D.position;

                Vector2 blobOp2UIPos = cam.WorldToScreenPoint(blobOp2Pos);
                Vector2 blobEqUIPos  = cam.WorldToScreenPoint(blobEqPos);

                if (mDragGuide.isActive)
                {
                    mDragGuide.UpdatePositions(blobOp2UIPos, blobEqUIPos);
                }
                else
                {
                    mDragGuide.Show(false, blobOp2UIPos, blobEqUIPos);
                }
            }

            yield return(null);
        }

        mDragGuide.Hide();

        mDragIndicatorRout = null;
    }
Exemple #11
0
    void Update()
    {
        if (isVisible)
        {
            var gridCtrl  = GridEditController.instance.entityContainer.controller;
            var ghostCtrl = GridEditController.instance.ghostController;

            if (!mCamera)
            {
                mCamera = Camera.main;
            }

            bool    isDragVisible = false;
            Vector3 startPosWorld = Vector3.zero, endPosWorld = Vector3.zero;

            //check if col size is met, show expand from right side
            if (ghostCtrl.cellSize.col < cellSize.col)
            {
                startPosWorld = ghostCtrl.expandCollRight.transform.position;

                GridCell toCell = new GridCell();

                toCell.row = ghostCtrl.cellIndex.row + (ghostCtrl.cellSize.row / 2);
                toCell.col = ghostCtrl.cellIndex.col + cellSize.col - 1;

                var toCellBounds = gridCtrl.GetBoundsFromCell(toCell);
                endPosWorld = gridCtrl.transform.TransformPoint(new Vector3(toCellBounds.center.x, 0f, ghostCtrl.transform.localPosition.z));

                isDragVisible = true;
            }
            //check row, show expand from back side
            else if (ghostCtrl.cellSize.row < cellSize.row)
            {
                startPosWorld = ghostCtrl.expandCollBack.transform.position;

                GridCell toCell = new GridCell();

                toCell.row = ghostCtrl.cellIndex.row - (cellSize.row - ghostCtrl.cellSize.row);
                toCell.col = ghostCtrl.cellIndex.col + (ghostCtrl.cellSize.col / 2);

                var toCellBounds = gridCtrl.GetBoundsFromCell(toCell);
                endPosWorld = gridCtrl.transform.TransformPoint(new Vector3(ghostCtrl.transform.localPosition.x, 0f, toCellBounds.center.z));

                isDragVisible = true;
            }

            if (isDragVisible)
            {
                endPosWorld.y = startPosWorld.y;

                Vector2 dragStart = mCamera.WorldToScreenPoint(startPosWorld);
                Vector2 dragEnd   = mCamera.WorldToScreenPoint(endPosWorld);

                if (!dragGuideWidget.isActive)
                {
                    dragGuideWidget.Show(false, dragStart, dragEnd);
                }
                else
                {
                    dragGuideWidget.UpdatePositions(dragStart, dragEnd);
                }

                confirmExpandGO.SetActive(false);
            }
            else
            {
                dragGuideWidget.Hide();

                confirmExpandGO.SetActive(true);
            }
        }
    }