Пример #1
0
    IEnumerator DoExtrusiveBack()
    {
        ClearSelection();

        yield return(extrusiveSequence.Exit());

        StartCoroutine(DoProcessSelect(true));
    }
Пример #2
0
    //intrusive process
    IEnumerator DoProcessToIntrusiveProceed()
    {
        ClearSelection();

        yield return(processSequence.Exit());

        //if extrusive is disabled, proceed right away
        //just proceed
        StartCoroutine(DoIntrusiveProceed());

        /*if(!processExtrusiveButton.interactable) {
         *  StartCoroutine(DoIntrusiveProceed());
         * }
         * else {
         *  yield return intrusiveSequence.Enter();
         *
         *  intrusiveProceedButton.Select();
         * }*/
    }
Пример #3
0
    IEnumerator DoRockResult()
    {
        //fill rock list widget
        rockResultWidget.Init(mRockResultList, null);

        yield return(rockResultSequence.Enter());

        //check which rocks have not been seen, display info for each
        for (int i = 0; i < mRockResultList.Count; i++)
        {
            var rock = mRockResultList[i];
            if (!rock.isSeen)
            {
                mRockModalParms[ModalInfo.parmInfoData] = rock;

                M8.ModalManager.main.Open(rock.modal, mRockModalParms);

                while (M8.ModalManager.main.isBusy || M8.ModalManager.main.IsInStack(rock.modal))
                {
                    yield return(null);
                }
            }
        }

        //show complete proceed if criteria is met
        if (criteria.IsComplete(inventory))
        {
            if (completeProceedGO)
            {
                completeProceedGO.SetActive(true);
            }
        }

        //wait for rock continue
        rockResultContinueButton.Select();
        mIsRockResultContinue = false;
        while (!mIsRockResultContinue)
        {
            yield return(null);
        }

        yield return(rockResultSequence.Exit());

        if (compactCementAnimator)
        {
            if (!string.IsNullOrEmpty(compactCementTakeFadeOut))
            {
                yield return(compactCementAnimator.PlayWait(compactCementTakeFadeOut));
            }

            compactCementAnimator.gameObject.SetActive(false);
        }

        StartCoroutine(DoProcessSelect());
    }
Пример #4
0
    IEnumerator DoRockSelect()
    {
        var rockCount = inventory.rocksCount;

        if (rockCount > 0)
        {
            rockSelect.Refresh(true, null);

            yield return(rockSelectSequence.Enter());

            rockSelect.Select();

            mRockSelect = null;
            while (!mRockSelect)
            {
                yield return(null);
            }

            yield return(rockSelectSequence.Exit());

            //fail-safe if no metaOutput
            if (!mRockSelect.metaOutput)
            {
                Debug.LogWarning("Rock does not have a meta output: " + mRockSelect.name);
                StartCoroutine(DoRockSelect());
                yield break;
            }

            //generate rock
            if (mRockSelect.count > 0)
            {
                if (!GlobalSettings.isUnlimitedResource)
                {
                    mRockSelect.count--;
                }
                criteria.InvokeUpdate(mRockSelect);
            }

            if (GlobalSettings.isUnlimitedResource)
            {
                mRockSelect.metaOutput.count = GlobalSettings.unlimitedResourceRock;
            }
            else
            {
                mRockSelect.metaOutput.count++;
            }

            mRockResultList.Clear();
            mRockResultList.Add(mRockSelect.metaOutput);
            //

            //animation

            //rock enter
            rockSpriteShape.spriteShape = mRockSelect.spriteShape;

            rockAnimator.gameObject.SetActive(true);

            yield return(rockAnimator.PlayWait(rockTakeEnter));

            //meta morph enter
            metaMorphAnimator.gameObject.SetActive(true);

            yield return(metaMorphAnimator.PlayWait(metaMorphTakeEnter));

            //rock result play
            M8.SoundPlaylist.instance.Play(soundMorph, false);

            rockResultSpriteShape.spriteShape = mRockSelect.metaOutput.spriteShape;

            rockResultAnimator.gameObject.SetActive(true);

            yield return(rockResultAnimator.PlayWait(rockResultTakeEnter));

            //

            rockAnimator.gameObject.SetActive(false);

            //meta morph leave
            yield return(metaMorphAnimator.PlayWait(metaMorphTakeExit));

            metaMorphAnimator.gameObject.SetActive(false);

            criteria.InvokeUpdate(mRockSelect.metaOutput);

            StartCoroutine(DoRockResult());
        }
        else
        {
            //notify that rocks are needed.
            if (noRocksGO)
            {
                noRocksGO.SetActive(true);
            }

            //exitButton.Select();
        }
    }
Пример #5
0
    //

    IEnumerator DoRockResult()
    {
        ClearSelection();

        //fill rock list widget
        rockResultWidget.Init(mRockResultList, null);

        yield return(rockResultSequence.Enter());

        //check which rocks have not been seen, display info for each
        for (int i = 0; i < mRockResultList.Count; i++)
        {
            var rock = mRockResultList[i];
            if (!rock.isSeen)
            {
                mRockModalParms[ModalInfo.parmInfoData] = rock;

                M8.ModalManager.main.Open(rock.modal, mRockModalParms);

                while (M8.ModalManager.main.isBusy || M8.ModalManager.main.IsInStack(rock.modal))
                {
                    yield return(null);
                }
            }
        }

        criteria.signalUpdateIgneous.Invoke();

        //show complete proceed if criteria is met
        if (criteria.IsComplete(inventory))
        {
            if (completeProceedGO)
            {
                completeProceedGO.SetActive(true);
            }
        }

        //wait for rock continue

        exitButton.Select();
        //rockResultContinueButton.Select();

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

        yield return(rockResultSequence.Exit());

        //clear out mode
        switch (mCurMode)
        {
        case Mode.Intrusive:
            //fade out last rock
            if (mIntrusiveRockInd < intrusiveRockDisplays.Length)
            {
                float curTime = 0f;
                while (curTime < intrusiveRockDisplayFadeOutDelay)
                {
                    yield return(null);

                    curTime += Time.deltaTime;

                    float t = Mathf.Clamp01(curTime / intrusiveRockDisplayFadeOutDelay);

                    var clr = intrusiveRockDisplays[mIntrusiveRockInd].spriteShapeColor.color;
                    clr.a = 1f - t;
                    intrusiveRockDisplays[mIntrusiveRockInd].spriteShapeColor.color = clr;
                }

                intrusiveRockDisplays[mIntrusiveRockInd].rootGO.SetActive(false);
            }
            break;

        case Mode.Extrusive:
            if (extrusiveAnimator && !string.IsNullOrEmpty(extrusiveTakeClear))
            {
                yield return(extrusiveAnimator.PlayWait(extrusiveTakeClear));
            }
            break;
        }

        StartCoroutine(DoProcessSelect(false));
    }
Пример #6
0
    IEnumerator DoIntrusiveProceed()
    {
        ClearSelection();

        coolingSlider.normalizedValue = 0f;

        yield return(intrusiveSequence.Exit());

        //initialize display
        intrusiveRockDisplays[0].Init(true);
        for (int i = 1; i < intrusiveRockDisplays.Length; i++)
        {
            intrusiveRockDisplays[i].Init(false);
        }

        //change mode
        yield return(DoMode(Mode.Intrusive));

        //do intrusive fill
        M8.SoundPlaylist.instance.Play(soundMagmaRise, false);

        if (intrusiveAnimator && !string.IsNullOrEmpty(intrusiveTakeFill))
        {
            yield return(intrusiveAnimator.PlayWait(intrusiveTakeFill));
        }

        //initial state
        coolingGlowGO.SetActive(false);
        coolingStopButton.interactable = false;

        //check if we have seen the instruction

        /*bool isInstructionSeen = false;
         * if(M8.SceneState.instance.global.GetValue("magmaCoolerIntrusiveInstructionSeen") == 1)
         *  isInstructionSeen = true;
         * else
         *  M8.SceneState.instance.global.SetValue("magmaCoolerIntrusiveInstructionSeen", 1, false);
         *
         * if(coolingInstructionGO) coolingInstructionGO.SetActive(!isInstructionSeen);*/

        //cooling
        yield return(coolingSequence.Enter());

        yield return(new WaitForSeconds(1f));

        mIntrusiveRockInd = 0;

        int   intrusiveRockInd = 0;
        float curTime          = 0f;
        float curPauseTime     = 0f;
        float coolingSegment   = 1.0f / intrusiveRocks.Length;

        //next rock
        intrusiveRockDisplays[1].rootGO.SetActive(true);

        //do cooling and fill animation
        mIsCoolingStop = false;
        while (!mIsCoolingStop && intrusiveRockInd < intrusiveRocks.Length)
        {
            if (curTime < coolingDelay)
            {
                curTime += Time.deltaTime;
                float t = Mathf.Clamp01(curTime / coolingDelay);
                coolingSlider.normalizedValue = (intrusiveRockInd + t) * coolingSegment;

                //apply alpha to rock display
                int nextRockInd = mIntrusiveRockInd + 1;

                var clr = intrusiveRockDisplays[nextRockInd].spriteShapeColor.color;
                clr.a = t;
                intrusiveRockDisplays[nextRockInd].spriteShapeColor.color = clr;
                //

                //ready to stop
                if (t >= 1f)
                {
                    M8.SoundPlaylist.instance.Play(soundCoolingEnd, false);

                    if (coolingFX)
                    {
                        coolingFX.Play();
                    }

                    intrusiveRockDisplays[mIntrusiveRockInd].rootGO.SetActive(false);
                    mIntrusiveRockInd++;

                    coolingGlowGO.SetActive(true);

                    coolingStopButton.interactable = true;
                    coolingStopButton.Select();
                }
            }
            else if (curPauseTime < coolingSegmentDelay)
            {
                curPauseTime += Time.deltaTime;
            }
            else
            {
                curTime      = 0f;
                curPauseTime = 0f;
                intrusiveRockInd++;

                if (mIntrusiveRockInd + 1 < intrusiveRockDisplays.Length)
                {
                    intrusiveRockDisplays[mIntrusiveRockInd + 1].rootGO.SetActive(true);
                }

                coolingStopButton.interactable = false;
            }

            yield return(null);
        }

        yield return(coolingSequence.Exit());

        //

        //generate rock
        mRockResultList.Clear();

        if (isIntrusiveGiveAllRocks)  //just give all the rocks, sigh...
        {
            for (int i = 0; i < intrusiveRocks.Length; i++)
            {
                var rock = intrusiveRocks[i];

                if (GlobalSettings.isUnlimitedResource)
                {
                    if (rock.count <= 0)
                    {
                        rock.count = GlobalSettings.unlimitedResourceRock;
                    }

                    mRockResultList.Add(rock);
                }
                else
                {
                    rock.count += inventory.igneousOutput;

                    var magmaCount = inventory.magma.count - inventory.igneousOutput;
                    if (magmaCount < 0)
                    {
                        magmaCount = 0;
                    }
                    inventory.magma.count = magmaCount;

                    mRockResultList.Add(rock);

                    if (magmaCount == 0)
                    {
                        break;
                    }
                }
            }
        }
        else
        {
            if (intrusiveRockInd >= intrusiveRocks.Length)
            {
                intrusiveRockInd = intrusiveRocks.Length - 1;
            }

            var rock = intrusiveRocks[intrusiveRockInd];
            rock.count += inventory.igneousOutput;

            var magmaCount = inventory.magma.count - inventory.igneousOutput;
            if (magmaCount < 0)
            {
                magmaCount = 0;
            }
            inventory.magma.count = magmaCount;

            mRockResultList.Add(rock);
        }
        //

        //show rock result
        StartCoroutine(DoRockResult());
    }
Пример #7
0
    IEnumerator DoErosion()
    {
        if (erosionGrainText)
        {
            erosionGrainText.text = string.Format("{0}: ----", M8.Localize.Get(erosionGrainSizeTitleTextRef));
        }

        yield return(rockErosionSequence.Enter());

        erosionFinishButton.interactable = false;

        if (erosionAnimator)
        {
            if (!string.IsNullOrEmpty(erosionTakeEnter))
            {
                erosionAnimator.ResetTake(erosionTakeEnter);
            }

            erosionAnimator.gameObject.SetActive(true);
        }

        mErosionCount    = 0;
        mIsErosionFinish = false;

        while (true)
        {
            erosionButton.interactable = true;
            erosionButton.Select();

            //wait for a click
            mIsErosionClicked = false;
            while (!mIsErosionClicked && !mIsErosionFinish)
            {
                yield return(null);
            }

            if (mIsErosionFinish)
            {
                break;
            }

            erosionButton.interactable = false;

            mErosionCount++;

            //do erosion enter
            if (erosionAnimator && !string.IsNullOrEmpty(erosionTakeEnter))
            {
                yield return(erosionAnimator.PlayWait(erosionTakeEnter));
            }

            //apply erosion level
            int erosionInd = mErosionCount - 1;

            erosionSpriteLayer.spriteShape = erosionSpriteShapes[erosionInd];

            if (erosionInd == 0)
            {
                //clear out rock layer display
                for (int i = 0; i < sourceSpawners.Length; i++)
                {
                    sourceSpawners[i].Reset();
                }

                erosionSpriteLayer.gameObject.SetActive(true);
            }
            //

            //change text
            if (erosionGrainText)
            {
                var grainType = (GrainSize)(mErosionCount - 1);
                erosionGrainText.text = string.Format("{0}: {1}", M8.Localize.Get(erosionGrainSizeTitleTextRef), M8.Localize.Get(RockSedimentaryData.GetGrainSizeTextRef(grainType)));
            }

            yield return(new WaitForSeconds(erosionDelay));

            //erosion exit
            if (erosionAnimator && !string.IsNullOrEmpty(erosionTakeExit))
            {
                yield return(erosionAnimator.PlayWait(erosionTakeExit));
            }

            if (mErosionCount > 0) //ready to proceed
            {
                erosionFinishButton.interactable = true;
            }

            if (mErosionCount == erosionCapacity)
            {
                break;
            }
        }

        if (erosionAnimator)
        {
            erosionAnimator.gameObject.SetActive(false);
        }

        erosionButton.interactable = false;

        //finish needs to be pressed?
        if (!mIsErosionFinish)
        {
            erosionFinishButton.Select();
            erosionFinishButton.interactable = true;

            while (!mIsErosionFinish)
            {
                yield return(null);
            }
        }

        erosionFinishButton.interactable = false;

        yield return(rockErosionSequence.Exit());

        StartCoroutine(DoCompactCementation());
    }
Пример #8
0
    IEnumerator DoSourceSelect()
    {
        ClearSelection();

        yield return(processSequence.Exit());

        int sourceSelectCount;

        //setup source select widget
        switch (mCurMode)
        {
        case SourceMode.Rock:
            sourceSelectCount            = inventory.sedimentaryRockCount;
            sourceSelect.inventoryFilter = rockFilter;
            break;

        case SourceMode.Organic:
            sourceSelectCount            = 1;
            sourceSelect.inventoryFilter = organicFilter;
            break;

        default:     //fail-safe
            sourceSelectCount = 0;
            break;
        }

        sourceSelect.Refresh(true, null);
        //

        yield return(sourceSequence.Enter());

        sourceSelect.Select();

        if (mSourceSelects != null)
        {
            mSourceSelects.Clear();
        }
        else
        {
            mSourceSelects = new List <InfoData>();
        }

        //wait for source to be selected
        while (mSourceSelects.Count < sourceSelectCount)
        {
            yield return(null);
        }

        ClearSelection();

        yield return(sourceSequence.Exit());

        //wait for rock spawn to be finish and all rocks asleep
        yield return(DoSourceSpawnWait());

        yield return(new WaitForSeconds(sourcePostDelay));

        switch (mCurMode)
        {
        case SourceMode.Rock:
            StartCoroutine(DoErosion());
            break;

        case SourceMode.Organic:
            StartCoroutine(DoCompactCementation());
            break;

        default:     //fail-safe
            StartCoroutine(DoProcessSelect());
            break;
        }
    }