コード例 #1
0
        public IEnumerator highlight_selected_slot([NUnit.Framework.Range(0, 4)] int slotNumber)
        {
            var player     = UniversalTestHelpers.GetPlayer();
            var slotHolder = Object.FindObjectOfType <UIRuneSlotHolder>();

            PlayerInput.Instance.LeftThumbStick.Returns(new Vector2(1.0f, 0.0f));
            yield return(new WaitForSeconds(1.1f));

            var angle = 269.0f - 72.0f * slotNumber;

            if (angle < 0)
            {
                angle = 360 + angle;
            }
            PlayerInput.Instance.GetJoyStickAngle(ControllerType.Left).Returns(angle);
            yield return(new WaitForUpdate());

            for (int index = 0; index < slotHolder.Slots.Length; index++)
            {
                var slot = slotHolder.Slots[index];
                Assert.AreEqual(slotNumber == index, slot.IsHighlited);
            }

            Object.DestroyImmediate(player.gameObject);
            yield return(null);
        }
コード例 #2
0
        public IEnumerator on_slot_selected_selectionSlot_changes()
        {
            var player        = UniversalTestHelpers.GetPlayer();
            var selectionSlot = Object.FindObjectOfType <UIRuneSelectionSlot>();

            PlayerInput.Instance.LeftThumbStick.Returns(new Vector2(1.0f, 0.0f));

            yield return(new WaitForSeconds(1.1f));

            PlayerInput.Instance.GetJoyStickAngle(ControllerType.Left).Returns(268.0f);

            yield return(new WaitForUpdate());

            var icon = selectionSlot.Icon;

            Assert.AreEqual(null, icon);
            PlayerInput.Instance.UIRuneConfirm.Returns(true);

            yield return(null);

            Assert.AreNotEqual(icon, selectionSlot.Icon);
            icon = selectionSlot.Icon;
            PlayerInput.Instance.GetJoyStickAngle(ControllerType.Left).Returns(90.0f);
            PlayerInput.Instance.UIRuneConfirm.Returns(true);

            yield return(null);

            Assert.AreNotEqual(icon, selectionSlot.Icon);

            Object.DestroyImmediate(player.gameObject);
            yield return(null);
        }
コード例 #3
0
        public IEnumerator bomb_rune_explode_on_confirm()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = Object.FindObjectOfType <RuneController>();

            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(1);
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(new WaitForFixedUpdate());

            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            var bomb = Object.FindObjectOfType <Bomb>();

            Assert.NotNull(bomb);
            PlayerInput.Instance.Confirm.Returns(true);
            yield return(new WaitForFixedUpdate());

            //IsRunning
            yield return(new WaitForSeconds(bomb.DestroyDelay + 0.1f));

            bomb = Object.FindObjectOfType <Bomb>();
            Assert.IsNull(bomb);

            Object.DestroyImmediate(player.gameObject);
            yield return(new WaitForUpdate());
        }
コード例 #4
0
        public IEnumerator mangesis_rune_interactable_object_is_moved_when_controller_moves()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = Object.FindObjectOfType <RuneController>();
            var cube           = GameObject.CreatePrimitive(PrimitiveType.Cube);

            cube.transform.position = player.RightHand.transform.position + player.RightHand.transform.forward;
            cube.AddComponent <IRuneInteractable>();
            cube.layer = 8;
            cube.GetComponent <Rigidbody>().useGravity = false;
            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(0);
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(new WaitForFixedUpdate());

            Assert.IsTrue(runeController.CurrentRune.IsActive);
            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            PlayerInput.Instance.Confirm.Returns(true);
            Assert.IsFalse(runeController.CurrentRune.IsRunning);
            yield return(new WaitForSeconds(1.1f)); // Wait for animation

            Assert.IsTrue(runeController.CurrentRune.IsRunning);

            PlayerInput.Instance.RightControllerVelocity.Returns(new Vector3(1.0f, 1.0f, 0.0f));
            yield return(new WaitForSeconds(0.5f));

            Assert.Greater(cube.transform.position.x, 0.5f);
            Assert.Greater(cube.transform.position.y, 0.5f);

            Object.DestroyImmediate(player.gameObject);
            Object.DestroyImmediate(cube);
            yield return(new WaitForUpdate());
        }
コード例 #5
0
        public IEnumerator all_slots_are_unhighlight_on_disable()
        {
            var player     = UniversalTestHelpers.GetPlayer();
            var slotHolder = Object.FindObjectOfType <UIRuneSlotHolder>();

            PlayerInput.Instance.LeftThumbStick.Returns(new Vector2(1.0f, 0.0f));
            yield return(new WaitForSeconds(1.1f));

            var angle = 269.0f;

            PlayerInput.Instance.GetJoyStickAngle(ControllerType.Left).Returns(angle);
            yield return(new WaitForUpdate());

            Assert.AreEqual(true, slotHolder.Slots[0].IsHighlited);
            yield return(new WaitForUpdate());

            PlayerInput.Instance.LeftThumbStick.Returns(new Vector2(0.0f, 0.0f));
            yield return(new WaitForUpdate());

            foreach (var slot in slotHolder.Slots)
            {
                Assert.AreEqual(false, slot.IsHighlited);
            }

            Object.DestroyImmediate(player.gameObject);
            yield return(null);
        }
コード例 #6
0
        public IEnumerator cryonis_rune_creates_iceBlock_on_confirm_with_correct_layer()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = Object.FindObjectOfType <RuneController>();
            var plane          = GameObject.CreatePrimitive(PrimitiveType.Quad);

            plane.layer = 10;
            plane.transform.position = player.RightHand.transform.position + player.RightHand.transform.forward * 2;
            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(3);
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);

            yield return(new WaitForFixedUpdate());

            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            var target = GameObject.FindObjectOfType <IceBlockTarget>();

            Assert.IsNotNull(target);
            Assert.IsTrue(target.gameObject.activeSelf);

            PlayerInput.Instance.Confirm.Returns(true);
            yield return(new WaitForSeconds(1.0f));

            PlayerInput.Instance.Confirm.Returns(false);
            var iceblock = GameObject.FindObjectOfType <IceBlock>();

            Assert.IsNotNull(iceblock);


            Object.DestroyImmediate(player.gameObject);
            Object.DestroyImmediate(plane);
            Object.DestroyImmediate(iceblock);
            yield return(new WaitForUpdate());
        }
コード例 #7
0
        public IEnumerator stasis_rune_run_with_interactable_object()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = Object.FindObjectOfType <RuneController>();
            var cube           = GameObject.CreatePrimitive(PrimitiveType.Cube);

            cube.transform.position = player.transform.position + player.transform.forward;
            cube.AddComponent <IRuneInteractable>();
            cube.layer = 8;
            cube.GetComponent <Rigidbody>().useGravity = false;
            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(4);
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(new WaitForFixedUpdate());

            Assert.IsTrue(runeController.CurrentRune.IsActive);
            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            Assert.IsFalse(runeController.CurrentRune.IsRunning);
            PlayerInput.Instance.Confirm.Returns(true);
            yield return(new WaitForFixedUpdate());

            Assert.IsTrue(runeController.CurrentRune.IsRunning);

            Object.DestroyImmediate(player.gameObject);
            Object.DestroyImmediate(cube);
            yield return(new WaitForUpdate());
        }
コード例 #8
0
        public IEnumerator current_rune_starts_null()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = player.GetComponent <RuneController>();

            yield return(new WaitForSeconds(1.0f));

            Assert.Null(runeController.CurrentRune);

            Object.DestroyImmediate(player.gameObject);
            yield return(new WaitForUpdate());
        }
コード例 #9
0
        public IEnumerator amount_of_runes_is_equal_to_amount_of_profiles()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = player.GetComponent <RuneController>();

            yield return(new WaitForSeconds(1.0f));

            Assert.AreEqual(runeController.AmountOfProfiles, runeController.AmountOfRunes);

            Object.DestroyImmediate(player.gameObject);
            yield return(new WaitForUpdate());
        }
コード例 #10
0
        public IEnumerator selected_rune_starts_deactivated()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = player.GetComponent <RuneController>();

            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(0);
            Assert.AreEqual(false, runeController.CurrentRune.IsActive);

            Object.DestroyImmediate(player.gameObject);
            yield return(new WaitForUpdate());
        }
コード例 #11
0
        public IEnumerator give_an_index_in_bounds_makes_current_rune_not_null()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = player.GetComponent <RuneController>();

            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(0);
            Assert.NotNull(runeController.CurrentRune);

            Object.DestroyImmediate(player.gameObject);
            yield return(new WaitForUpdate());
        }
コード例 #12
0
        public IEnumerator stasis_rune_gets_activated()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = Object.FindObjectOfType <RuneController>();

            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(4);
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(new WaitForFixedUpdate());

            Assert.IsTrue(runeController.CurrentRune.IsActive);

            Object.DestroyImmediate(player.gameObject);
            yield return(new WaitForUpdate());
        }
コード例 #13
0
        public IEnumerator all_slots_are_unhighlight_on_enable()
        {
            var player     = UniversalTestHelpers.GetPlayer();
            var slotHolder = Object.FindObjectOfType <UIRuneSlotHolder>();

            PlayerInput.Instance.LeftThumbStick.Returns(new Vector2(1.0f, 0.0f));
            for (int index = 0; index < slotHolder.Slots.Length; index++)
            {
                var slot = slotHolder.Slots[index];
                Assert.AreEqual(false, slot.IsHighlited);
            }
            yield return(new WaitForUpdate());

            Object.DestroyImmediate(player.gameObject);
            yield return(null);
        }
コード例 #14
0
        public IEnumerator active_rune_is_not_running()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = player.GetComponent <RuneController>();

            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(0);
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(null);

            Assert.AreEqual(false, runeController.CurrentRune.IsRunning);

            Object.DestroyImmediate(player.gameObject);
            yield return(new WaitForUpdate());
        }
コード例 #15
0
        public IEnumerator selectedIcon_cant_change_when_rune_is_active()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = player.GetComponent <RuneController>();
            var selectionSlot  = Object.FindObjectOfType <UIRuneSelectionSlot>();

            PlayerInput.Instance.LeftThumbStick.Returns(new Vector2(1.0f, 0.0f));
            //Activate menu
            yield return(new WaitForSeconds(1.1f));

            PlayerInput.Instance.GetJoyStickAngle(ControllerType.Left).Returns(268.0f);
            //Set joystick to rune angle
            yield return(new WaitForUpdate());

            var icon = selectionSlot.Icon;

            Assert.AreEqual(null, icon);
            PlayerInput.Instance.UIRuneConfirm.Returns(true);
            //Select rune
            yield return(null);

            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            //Click rune activation button
            yield return(null);

            Assert.IsTrue(runeController.CurrentRune.IsActive);
            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            //Release rune activation button
            yield return(null);

            Assert.AreNotEqual(icon, selectionSlot.Icon);
            //Check selection slot is not the same as previous one in this case it was null
            icon = selectionSlot.Icon;
            PlayerInput.Instance.GetJoyStickAngle(ControllerType.Left).Returns(90.0f);
            PlayerInput.Instance.UIRuneConfirm.Returns(true);
            //Set joystick angle to another rune and select rune

            yield return(null);

            Assert.AreEqual(icon, selectionSlot.Icon);
            //Check that icon was not selected because rune is active.

            Object.DestroyImmediate(player.gameObject);
            yield return(null);
        }
コード例 #16
0
        public IEnumerator cant_interact_with_menu_until_animation_is_done()
        {
            var player     = UniversalTestHelpers.GetPlayer();
            var slotHolder = Object.FindObjectOfType <UIRuneSlotHolder>();

            Assert.AreEqual(false, slotHolder.IsActive);
            PlayerInput.Instance.LeftThumbStick.Returns(new Vector2(1.0f, 0.0f));
            Assert.AreEqual(false, slotHolder.IsActive);
            yield return(new WaitForSeconds(0.6f));

            Assert.AreEqual(false, slotHolder.IsActive);
            yield return(new WaitForSeconds(0.6f));

            Assert.AreEqual(true, slotHolder.IsActive);

            Object.DestroyImmediate(player.gameObject);
            yield return(null);
        }
コード例 #17
0
        public IEnumerator bomb_rune_creates_a_bomb_on_activated()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = Object.FindObjectOfType <RuneController>();

            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(1);
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(new WaitForFixedUpdate());

            var bomb = Object.FindObjectOfType <Bomb>();

            Assert.NotNull(bomb);

            Object.DestroyImmediate(player.gameObject);
            Object.DestroyImmediate(bomb);
            yield return(new WaitForUpdate());
        }
コード例 #18
0
        public IEnumerator occupied_amount_of_slots_is_the_same_as_runes_created()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var slotHolder     = Object.FindObjectOfType <UIRuneSlotHolder>();
            var runeController = Object.FindObjectOfType <RuneController>();

            yield return(new WaitForEndOfFrame());

            var index = slotHolder.FindOpenSlot();

            if (index.HasValue)
            {
                Assert.AreEqual(runeController.AmountOfRunes, index.Value);
            }
            else
            {
                Assert.AreEqual(runeController.AmountOfRunes, slotHolder.AmountOfSlots);
            }

            Object.DestroyImmediate(player.gameObject);
            yield return(null);
        }
コード例 #19
0
        public IEnumerator stasis_rune_doesnt_run_with_normal_object_()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = Object.FindObjectOfType <RuneController>();
            var cube           = GameObject.CreatePrimitive(PrimitiveType.Cube);

            cube.transform.position = player.transform.position + player.transform.forward;
            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(0);
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(new WaitForFixedUpdate());

            Assert.IsTrue(runeController.CurrentRune.IsActive);
            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            PlayerInput.Instance.Confirm.Returns(true);
            yield return(new WaitForFixedUpdate());

            Assert.IsFalse(runeController.CurrentRune.IsRunning);

            Object.DestroyImmediate(player.gameObject);
            Object.DestroyImmediate(cube);
            yield return(new WaitForUpdate());
        }
コード例 #20
0
        public IEnumerator cryonis_rune_reuses_iceBlock_on_confirm_with_correct_layer_for_time_number_4()
        {
            var player         = UniversalTestHelpers.GetPlayer();
            var runeController = Object.FindObjectOfType <RuneController>();
            var plane          = GameObject.CreatePrimitive(PrimitiveType.Quad);

            plane.layer = 10;
            plane.transform.position   = player.RightHand.transform.position + player.RightHand.transform.forward * 2;
            plane.transform.localScale = new Vector3(10.0f, 10.0f, 10.0f);
            yield return(new WaitForSeconds(1.0f));

            runeController.SelectRune(3);
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);

            yield return(new WaitForFixedUpdate());

            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            var target = GameObject.FindObjectOfType <IceBlockTarget>();

            Assert.IsNotNull(target);
            Assert.IsTrue(target.gameObject.activeSelf);

            PlayerInput.Instance.Confirm.Returns(true);
            yield return(new WaitForSeconds(1.0f));

            PlayerInput.Instance.Confirm.Returns(false);
            var iceblock = GameObject.FindObjectOfType <IceBlock>(); //First ice block spwan

            Assert.IsNotNull(iceblock);

            player.transform.position += Vector3.up * 1.5f;
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(new WaitForFixedUpdate());

            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            PlayerInput.Instance.Confirm.Returns(true); //Second ice block spawn
            yield return(new WaitForSeconds(1.0f));

            PlayerInput.Instance.Confirm.Returns(false);

            player.transform.position += Vector3.up * 1.5f;
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(new WaitForFixedUpdate());

            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            PlayerInput.Instance.Confirm.Returns(true); //Third ice block spwan
            yield return(new WaitForSeconds(1.0f));

            PlayerInput.Instance.Confirm.Returns(false);

            player.transform.position += Vector3.up * 1.5f;
            PlayerInput.Instance.ToggleRuneActivation.Returns(true);
            yield return(new WaitForFixedUpdate());

            PlayerInput.Instance.ToggleRuneActivation.Returns(false);
            PlayerInput.Instance.Confirm.Returns(true); //Fourth ice block spwan
            yield return(new WaitForSeconds(1.0f));

            PlayerInput.Instance.Confirm.Returns(false);
            var iceblocks = GameObject.FindObjectsOfType <IceBlock>();

            Assert.AreEqual(3, iceblocks.Length);

            Object.DestroyImmediate(player.gameObject);
            Object.DestroyImmediate(plane);
            for (int i = 0; i < iceblocks.Length; i++)
            {
                Object.DestroyImmediate(iceblocks[i]);
            }
            yield return(new WaitForUpdate());
        }