示例#1
0
 public void AreNotApproximatelyEqual_fail()
 {
     AssertionFailure[] failures = Capture(() =>
                                           Assert.AreNotApproximatelyEqual(2.4, 2.5, 0.2));
     Assert.Count(1, failures);
     Assert.AreEqual("2.4", failures[0].LabeledValues[0].FormattedValue.ToString());
     Assert.AreEqual("2.5", failures[0].LabeledValues[1].FormattedValue.ToString());
     Assert.AreEqual("0.2", failures[0].LabeledValues[2].FormattedValue.ToString());
 }
示例#2
0
 public void AreNotApproximatelyEqual_fail_with_custom_message()
 {
     AssertionFailure[] failures = Capture(() =>
                                           Assert.AreNotApproximatelyEqual(2.4, 2.5, 0.2, "{0} message", "custom"));
     Assert.Count(1, failures);
     Assert.AreEqual("2.4", failures[0].LabeledValues[0].FormattedValue.ToString());
     Assert.AreEqual("2.5", failures[0].LabeledValues[1].FormattedValue.ToString());
     Assert.AreEqual("0.2", failures[0].LabeledValues[2].FormattedValue.ToString());
     Assert.AreEqual("custom message", failures[0].Message);
 }
示例#3
0
    void Start()
    {
        canvasScaler = gameObject.GetComponentInParent <CanvasScaler>();
        Assert.IsNotNull(canvasScaler);

        canvasScale = Camera.main.GetComponent <PixelArtCamera>().CanvasScale;
        Assert.AreNotApproximatelyEqual(0.0f, canvasScale);

        PositionHUDElements();
    }
    protected override void OnAwake()
    {
        Assert.IsNotNull(welcomeText);
        Assert.AreNotApproximatelyEqual(0f, welcomeTextTime);

        Assert.IsNotNull(propStand);
        Assert.AreNotApproximatelyEqual(0f, propStandAnimationTime);
        Assert.IsNotNull(propStandAnimationCurve);
        Assert.IsNotNull(fetchTrigger);
        Assert.IsNotNull(fetchText);

        Assert.IsNotNull(returnText);
        Assert.IsNotNull(readyPositionIndicator);

        Assert.IsNotNull(readyText);
        Assert.IsNotNull(startText);
        Assert.AreNotApproximatelyEqual(0f, readyTextTime);
        Assert.AreNotApproximatelyEqual(0f, startTextTime);
        Assert.IsNotNull(progressBar);

        Assert.IsNotNull(healthBarImage);

        Assert.IsNotNull(finishText);
        Assert.AreNotApproximatelyEqual(0f, finishTextTime);

        clubStateInits = new Dictionary <ClubState, Action>()
        {
            { ClubState.IDLE, () => { InitIdle(); } },
            { ClubState.WAITING, () => { InitWaiting(); } },
            { ClubState.READY, () => { InitReady(); } },
            { ClubState.GAME, () => { InitGame(); } },
            { ClubState.RESULT, () => { InitResult(); } }
        };
        clubStateExits = new Dictionary <ClubState, Action>()
        {
            { ClubState.IDLE, () => { ExitIdle(); } },
            { ClubState.WAITING, () => { ExitWaiting(); } },
            { ClubState.READY, () => { ExitReady(); } },
            { ClubState.GAME, () => { ExitGame(); } },
            { ClubState.RESULT, () => { ExitResult(); } }
        };
        propStateInits = new Dictionary <PropState, Action>()
        {
            { PropState.DELIVERING, () => { InitDelivering(); } },
            { PropState.FETCHING, () => { InitFetching(); } },
            { PropState.RETURNING, () => { InitReturning(); } }
        };
        propStateExits = new Dictionary <PropState, Action>()
        {
            { PropState.DELIVERING, () => { ExitDelivering(); } },
            { PropState.FETCHING, () => { ExitFetching(); } },
            { PropState.RETURNING, () => { ExitReturning(); } }
        };
    }
    void Start()
    {
        player = GameObject.Find(PLAYER).transform;
        Assert.IsNotNull(player);

        actualUnitsOnScreen = Camera.main.GetComponent <PixelArtCamera>().VertUnitsOnScreen;
        Assert.AreNotApproximatelyEqual(0.0f, actualUnitsOnScreen);

        horizUnitsOnScreen = savedUnitsOnScreen = actualUnitsOnScreen;

        startingPosition = player.position;

        InvokeRepeating("PeriodicUpdate", 0f, .2f);
    }
    public float damageAnimationTime; //0.5f


    void Awake()
    {
        gameObject.SetActive(true);

        Assert.AreNotEqual(0, health);
        Assert.IsNotNull(healthBarImage);

        Assert.IsNotNull(healthBarSprites);
        Assert.IsNotNull(damageAnimationScript);
        Assert.AreNotApproximatelyEqual(0f, damageAnimationTime);

        healthBarImage.gameObject.SetActive(false);
        damageAnimationScript.enabled = false;
    }
    void Start()
    {
        canvasScaler = gameObject.GetComponentInParent <CanvasScaler>();
        Assert.IsNotNull(canvasScaler);

        canvasScale = Camera.main.GetComponent <PixelArtCamera>().CanvasScale;
        Assert.AreNotApproximatelyEqual(0.0f, canvasScale);

        PositionHUDElements();

        // cache & pause tween sequences.
        (fadeOutInstant = MFX.Fade(textComponent, 0, 0, 0)).Pause();
        (fadeIn = MFX.Fade(textComponent, 1, 0, ITEM_CHANGE_FADE)).Pause();
        (fadeOutHUD = MFX.Fade(textComponent, 0, HUD_FADE_OUT_AFTER, HUD_INITIAL_FADE_LENGTH)).Pause();
    }
示例#8
0
    protected void BaseStart()
    {
        cam = Camera.main.GetComponent <Camera>();
        Assert.IsNotNull(cam);

        resolutionMultiplier = Camera.main.GetComponent <PixelArtCamera>().FinalUnitSize;
        Assert.AreNotApproximatelyEqual(0.0f, resolutionMultiplier);

        // cache & pause tween sequences.
        (fadeInHUD = MFX.Fade(spriteRenderer, 1, HUD_FADE_IN_AFTER, HUD_INITIAL_FADE_LENGTH)).Pause();
        (fadeOutHUD = MFX.Fade(spriteRenderer, 0, HUD_FADE_OUT_AFTER, HUD_INITIAL_FADE_LENGTH)).Pause();
        (fadeOutInstant = MFX.Fade(spriteRenderer, 0, 0, 0)).Pause();

        PositionHUDElements();
        spriteRenderer.enabled = true;
        FadeIn();
    }
示例#9
0
    protected void BaseStart()
    {
        canvasScaler = gameObject.GetComponentInParent <CanvasScaler>();
        Assert.IsNotNull(canvasScaler);

        canvasScale = Camera.main.GetComponent <PixelArtCamera>().CanvasScale;
        Assert.AreNotApproximatelyEqual(0.0f, canvasScale);

        resolutionMultiplier = Camera.main.GetComponent <PixelArtCamera>().FinalUnitSize;
        Assert.AreNotApproximatelyEqual(0.0f, resolutionMultiplier);

        cam = Camera.main.GetComponent <Camera>();
        Assert.IsNotNull(cam);

        PositionHUDElements();
        text.enabled = true;

        // cache & pause tween sequences.
        (fadeOutInstant = MFX.Fade(text, 0, 0, 0)).Pause();
        (fadeIn = MFX.Fade(text, 1, HUD_FADE_IN_AFTER, HUD_INITIAL_FADE_LENGTH)).Pause();
        (fadeOutHUD = MFX.Fade(text, 0, HUD_FADE_OUT_AFTER, HUD_INITIAL_FADE_LENGTH)).Pause();
    }
示例#10
0
 /// <summary>Assert.AreNotApproximatelyEqual</summary>
 public static void IsNotApproximatelyEqual(this float actual, float expected, float tolerance, string message = "")
 {
     Assert.AreNotApproximatelyEqual(expected, actual, tolerance, message);
 }
示例#11
0
 public void AreNotApproximatelyEqual_simple_test()
 {
     Assert.AreNotApproximatelyEqual(2.4, 2.5, 0.05);
 }
示例#12
0
        private void Update()
        {
            Quaternion viewRotation = Quaternion.identity;

            //If we are playing and there is a valid ghost
            if (playing)
            {
                float      playTime         = Time.time - startPlayTime;
                Vector3    lastTickPos      = Vector3.zero;
                Vector3    nextTickPos      = Vector3.zero;
                Quaternion lastTickRot      = new Quaternion();
                Quaternion nextTickRot      = new Quaternion();
                float      crouchPercentage = 0f;
                float      framePercentage  = -1f;

                //Go through all frames
                bool found = false;
                for (int i = 0; i + 1 < tickList.Count; i++)
                {
                    float nextFrameSeconds = (float)new TimeSpan(tickList[i + 1].Time).TotalSeconds;
                    if (nextFrameSeconds >= playTime)
                    {
                        var lastTickTime = (float)new TimeSpan(tickList[i].Time).TotalSeconds;
                        lastTickPos = tickList[i].Position;
                        lastTickRot = tickList[i].Rotation;

                        float nextTickTime = nextFrameSeconds;
                        nextTickPos = tickList[i].Position;
                        nextTickRot = tickList[i].Rotation;

                        framePercentage = (nextTickTime - lastTickTime) / (playTime - lastTickTime);

                        float crouchedLastFrame = tickList[i].Crouched ? 1f : 0f;
                        float crouchedNextFrame = tickList[i + 1].Crouched ? 1f : 0f;
                        crouchPercentage = Mathf.Lerp(crouchedLastFrame, crouchedNextFrame, framePercentage);

                        found = true;
                        break;
                    }
                }

                //If demo is running set player position
                if (found)
                {
                    Assert.AreNotApproximatelyEqual(framePercentage, -1f, "Frame percentage was not set!");

                    Quaternion editedLastRot = Quaternion.Euler(lastTickRot.eulerAngles.x, lastTickRot.eulerAngles.y, 0f);
                    Quaternion editedNextRot = Quaternion.Euler(lastTickRot.eulerAngles.x, nextTickRot.eulerAngles.y, 0f);
                    viewRotation = Quaternion.Lerp(editedLastRot, editedNextRot, framePercentage);

                    transform.position   = Vector3.Lerp(lastTickPos, nextTickPos, framePercentage) + new Vector3(0f, crouchPercentage * -0.5f, 0f);
                    transform.localScale = new Vector3(1f, 1f - 0.5f * crouchPercentage, 1f);
                }
                else
                {
                    playing = false;
                    if (looping)
                    {
                        ResetDemo();
                    }
                    else
                    {
                        StopDemoPlayback();
                    }
                }
            }

            if (!topView)
            {
                ghostCam.transform.position = transform.position + (viewRotation * firstPersonCamOffset);
                ghostCam.transform.rotation = viewRotation;
            }
        }
示例#13
0
 public static void ShouldNotApproximatelyEqual <T>(this T actual, T expected, T delta)
 {
     Assert.AreNotApproximatelyEqual(expected, actual, delta);
 }
示例#14
0
 public static void MustNotBeApproximatelyEqual(this float actual, float expected, float tolerance)
 {
     Assert.AreNotApproximatelyEqual(expected, actual, tolerance);
 }
示例#15
0
 public static void MustNotBeApproximatelyEqual(this float actual, float expected, string message)
 {
     Assert.AreNotApproximatelyEqual(expected, actual, message);
 }