Beispiel #1
0
        public void ProjectileUpdate()
        {
            Vector3 oldPosition = new Vector3(3, 5, 1);

            PointTargetProjectile arrow = new PointTargetProjectile(
                new Damage(DamageType.Pierce, 25, 0), MovementFactory.CreateParabolicMovement(30, 0.2, new Vector3(0, 2, 0)),
                oldPosition, new Vector3(10, 0, 8));
            arrow.Update(0.4);
            Assert.AreNotEqual<Vector3>(oldPosition, arrow.Position);

            Unit target = new Unit(100, ArmorType.Unarmored, 10, 20, Vector3.zero);
            UnitSeekingProjectile magicMissile = new UnitSeekingProjectile(
                new Damage(DamageType.Magic, 50, 5), MovementFactory.CreateLinear3DMovement(25),
                oldPosition, target);
            magicMissile.Update(0.4);
            Assert.AreNotEqual<Vector3>(oldPosition, magicMissile.Position);

            // Illegal calls

            try {
                arrow.Update(-0.1);
                Assert.Fail("DeltaTime can't be lower than zero");
            } catch (ArgumentException) {
            }
        }
Beispiel #2
0
        public void ProjectileCreation()
        {
            PointTargetProjectile arrow = new PointTargetProjectile(
                new Damage(DamageType.Pierce, 25, 0), MovementFactory.CreateParabolicMovement(30, 20, new Vector3(0, 2, 0)),
                new Vector3(0, 2, 0), new Vector3(10, 0, 8));

            Assert.AreEqual<Damage>(new Damage(DamageType.Pierce, 25, 0), arrow.Damage);
            Movement expectedMovement = MovementFactory.CreateParabolicMovement(30, 20, arrow.Position);
            expectedMovement.SetTarget(new Vector3(10, 0, 8));
            Assert.AreEqual<Movement>(expectedMovement, arrow.Movement);
            Assert.AreEqual<Vector3>(new Vector3(10, 0, 8), arrow.Movement.GetTarget());

            Unit target = new Unit(100, ArmorType.Unarmored, 10, 20, Vector3.zero);
            UnitSeekingProjectile magicMissile = new UnitSeekingProjectile(
                new Damage(DamageType.Magic, 50, 5), MovementFactory.CreateLinear3DMovement(25),
                new Vector3(0, 2, 2), target);

            Assert.AreEqual<Damage>(new Damage(DamageType.Magic, 50, 5), magicMissile.Damage);
            expectedMovement = MovementFactory.CreateLinear3DMovement(25);
            expectedMovement.SetTarget(target.Position);
            Assert.AreEqual<Movement>(MovementFactory.CreateLinear3DMovement(25), magicMissile.Movement);
            Assert.AreEqual<Unit>(target, magicMissile.Target);

            // Illegal calls

            try {
                Projectile damageNull = new PointTargetProjectile(
                    null, MovementFactory.CreateLinear3DMovement(30),
                    new Vector3(0, 2, 0), new Vector3(10, 0, 8));
                Assert.Fail("Damage can't be null");
            } catch (ArgumentException) {
            }
        }