示例#1
0
    IEnumerator DoLaunch(M8.EntityBase cannonEnt)
    {
        var unitForceApply = cannonEnt.GetComponent <UnitStateForceApply>();

        while (!unitForceApply.unit.physicsEnabled)
        {
            yield return(null);
        }

        graphControl.tracer.body = unitForceApply.unit.body;
        graphControl.tracer.Record();

        //wait for cannon to end
        while (unitForceApply.unit.physicsEnabled)
        {
            yield return(null);
        }

        cameraShaker.Shake();

        graphControl.tracer.Stop();

        GraphPopulate(true);

        launchReadyGO.SetActive(true);
        cannonLaunch.interactable = true;

        if (mIsShowGraphReminder)
        {
            graphReminderGO.SetActive(true);
            mIsShowGraphReminder = false;
        }
    }
示例#2
0
    IEnumerator DoKnightPush(M8.EntityBase cannonEnt)
    {
        //apply wheel info on ent

        //wait for push
        var unitForceApply = cannonEnt.GetComponent <UnitStateForceApply>();

        ApplyCurrentWheelInfoToUnit(unitForceApply.unit);

        while (!unitForceApply.unit.physicsEnabled)
        {
            yield return(null);
        }

        graphControl.tracer.body = unitForceApply.unit.body;
        graphControl.tracer.Record();

        //push
        knightAnimator.Play(knightTakePush);

        knightWheelSpriteRender.gameObject.SetActive(false);

        Vector2 wheelOfs = knightRoot.position - knightWheelSpriteRender.transform.position;

        while (unitForceApply.isPlaying)
        {
            knightRoot.position = unitForceApply.unit.position + wheelOfs;

            var animScale = Mathf.Max(knightAnimatePushScaleMin, Mathf.Abs(unitForceApply.unit.body.velocity.x / knightAnimatePushSpeedRef));
            knightAnimator.animScale = animScale;

            yield return(null);
        }

        knightAnimator.animScale = 1.0f;
        //

        //victory thing

        //move back
        knightAnimator.Play(knightTakeMove);
        knightSpriteRender.flipX = true;

        Vector2 startPos = knightRoot.position;
        Vector2 endPos   = knightReturnPoint.position;

        float curTime = 0f;

        while (curTime < knightReturnDelay)
        {
            curTime += Time.deltaTime;

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

            knightRoot.position = Vector2.Lerp(startPos, endPos, t);

            yield return(null);
        }
        //

        knightSpriteRender.flipX = false;

        //wait for tracer to finish
        while (graphControl.tracer.isRecording)
        {
            yield return(null);
        }

        GraphPopulate(!mIsKnightLocked);

        //next wheel type
        if (mCurWheelInfoIndex < wheelInfos.Length - 1)
        {
            mCurWheelInfoIndex++;
        }
        else
        {
            mCurWheelInfoIndex = 0;
        }

        if (!mIsKnightLocked)
        {
            ApplyCurrentWheelInfoDisplay();
            cannonAnimator.Play(cannonTakeEnter);
            while (cannonAnimator.isPlaying)
            {
                yield return(null);
            }

            cannonLaunch.interactable = true;
        }
    }