Exemplo n.º 1
0
    IEnumerator DoCompactCementation()
    {
        //setup output
        RockSedimentaryData        rockOutput = null;
        List <RockSedimentaryData> rockList   = null;

        switch (mCurMode)
        {
        case SourceMode.Rock:
            var grainType = (GrainSize)(mErosionCount - 1);
            rockList = mClasticOutput[grainType];
            break;

        case SourceMode.Organic:
            var source = mSourceSelects[0];
            rockList = mOrganicOutput[source];
            break;
        }

        mSourceSelects.Clear();

        if (rockList != null)
        {
            rockOutput = rockList[Random.Range(0, rockList.Count)];

            if (GlobalSettings.isUnlimitedResource)
            {
                rockOutput.count = GlobalSettings.unlimitedResourceRock;
            }
            else
            {
                rockOutput.count += inventory.sedimentaryRockCount;
            }
        }
        //

        //setup display
        if (rockOutput)
        {
            if (sedimentaryRockSprite)
            {
                sedimentaryRockSprite.spriteShape = rockOutput.spriteShape;
            }
        }

        M8.SoundPlaylist.instance.Play(soundRain, false);

        //play animation
        if (compactCementAnimator)
        {
            compactCementAnimator.gameObject.SetActive(true);

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

        //clear out previous mode
        switch (mCurMode)
        {
        case SourceMode.Rock:
            erosionSpriteLayer.gameObject.SetActive(false);
            break;

        case SourceMode.Organic:
            //clear out rock layer display
            for (int i = 0; i < sourceSpawners.Length; i++)
            {
                sourceSpawners[i].Reset();
            }
            break;
        }

        mRockResultList.Clear();
        mRockResultList.Add(rockOutput);

        criteria.InvokeUpdate(rockOutput);

        yield return(new WaitForSeconds(compactCementDelay));

        StartCoroutine(DoRockResult());
    }
Exemplo n.º 2
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());
    }