Ejemplo n.º 1
0
        CompleteAttackCycleThatMisses_AimsFXInAttackToFireAtThePositionCloseToButMissingTheDefenderIfFXisDirectional
            ()
        {
            //arrange
            var attack =
                TestObjectsFactory.AttackUnderTestWithDirectionalFXAndWithCharacterUnderTestWithMockMemoryInstance;
            var attacker = attack.Attacker;
            var defender = TestObjectsFactory.DefenderUnderTestWithMockMemoryInstanceFactoryAndMockDefaultAbilities;

            FXElement fxElement = attack.AnimationElements[0] as FXElement;

            if (fxElement != null)
            {
                File.Create(fxElement.CostumeFilePath).Close();
            }

            //act
            var instructions = attack.StartAttackCycle();

            instructions.Defender  = defender;
            instructions.AttackHit = false;
            instructions.Attacker  = attacker;
            attack.CompleteTheAttackCycle(instructions);

            //assert
            foreach (var animationElement in from element in attack.AnimationElements
                     where element is FXElement && (element as FXElement).IsDirectional
                     select element)
            {
                var      fx   = (FXElement)animationElement;
                string[] para =
                {
                    Path.GetFileNameWithoutExtension(fx.ModifiedCostumeFilePath),
                    $"x={defender.Position.JustMissedPosition.X} y={defender.Position.JustMissedPosition.Y} z={defender.Position.JustMissedPosition.Z}"
                };

                Mock.Get(attacker.Generator).Verify(
                    x => x.GenerateDesktopCommandText(DesktopCommand.LoadCostume, para));
            }
            FXElement o = attack.AnimationElements[0] as FXElement;

            if (o != null)
            {
                File.Delete(o.CostumeFilePath);
            }
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Launchs the FXElement.
    /// </summary>
    /// <param name="i_fxElement">The FXElement to launch.</param>
    public IEnumerator LaunchFXElement(FXElement i_fxElement)
    {
        //Gets the FXTime associated with the FXElement.
        FXTime time = i_fxElement.GetComponent <FXTime>();

        //Gets the time when the sequence was launched.
        float initialTime = Time.realtimeSinceStartup;

        //While FXElement start time hasn't been reached.
        while (Time.realtimeSinceStartup < initialTime + time._start)
        {
            yield return(null);
        }

        //Starts the FX associated with the FXElement.
        yield return(StartCoroutine(i_fxElement.StartFX(time._duration)));
    }
Ejemplo n.º 3
0
        public void AnimateAttackOnTheDesktop_TurnsTheAttackerTowardsTheDesktopAndFiresAtThePositonOfTheDesktop()
        {
            //arrange
            var attack =
                TestObjectsFactory.AttackUnderTestWithDirectionalFXAndWithCharacterUnderTestWithMockMemoryInstance;
            var       attacker  = attack.Attacker;
            FXElement fxElement = attack.AnimationElements[0] as FXElement;

            if (fxElement != null)
            {
                File.Create(fxElement.CostumeFilePath).Close();
            }

            var desktopPosition = TestObjectsFactory.MockPosition;

            //act
            attack.FireAtDesktop(desktopPosition);

            //assert
            foreach (var animationElement in from element in attack.AnimationElements
                     where element is FXElement && (element as FXElement).IsDirectional
                     select element)
            {
                var      fx   = (FXElement)animationElement;
                string[] para =
                {
                    Path.GetFileNameWithoutExtension(fx.ModifiedCostumeFilePath),
                    $"x={desktopPosition.X} y={desktopPosition.Y} z={desktopPosition.Z}"
                };

                Mock.Get(attacker.Generator).Verify(
                    x => x.GenerateDesktopCommandText(DesktopCommand.LoadCostume, para));
            }
            var o = attack.AnimationElements[0] as FXElement;

            if (o != null)
            {
                File.Delete(o.CostumeFilePath);
            }
        }