示例#1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        HealthBoost     healthBoost          = other.gameObject.GetComponent <HealthBoost>();
        Invulnerability invulnerabilityBoost = other.GetComponent <Invulnerability>();

        InteractWithPickUp(healthBoost, invulnerabilityBoost);
    }
示例#2
0
    private void Awake()
    {
        shootingDirection = Direction.RIGHT;
        animator          = GetComponent <Animator>();
        controller        = GetComponent <CharacterController2D>();
        inputManager      = InputManager.GetInstance();
        audioManager      = AudioManager.GetInstance();
        flipper           = GetComponent <Flipper>();
        dying             = false;
        hitReceiver       = GetComponent <EnemyHitReceiver>();
        invuln            = GetComponent <Invulnerability>();
        invulnerableAura  = Instantiate(Resources.Load <GameObject>("Prefabs/Halo"), transform);
        invulnerableAura.SetActive(false);

        // Controller events.
        controller.onControllerCollidedEvent += onControllerCollider;
        controller.onTriggerEnterEvent       += onTriggerEnterEvent;
        controller.onTriggerExitEvent        += onTriggerExitEvent;

        // Object pools.
        var projectile = Instantiate(Resources.Load <GameObject>("Prefabs/CrossProjectile"), transform);

        for (var i = 0; i < 5; i++)
        {
            crossPool[i] = Instantiate(projectile, Vector2.zero, Quaternion.identity).gameObject;
            crossPool[i].SetActive(false);
        }
        deadNunResource = Resources.Load <GameObject>("Prefabs/DeadNun");
    }
示例#3
0
 private void InteractWithInvulnerabilityItem(Invulnerability invulnerabilityBoost)
 {
     isInvulnerable = true;
     invulnerabilityBoost.OnHit();
     invulernablePopUp.SetActive(true);
     AudioSource.PlayClipAtPoint(stimulus, Camera.main.transform.position, sfxVolume);
     invulnerableBar.SetInvulnerabilityMaxValue(resetInvulnerableTimer);
 }
        public void ApplyTo_NullCharacter_Throws()
        {
            // Arrange
            var enchantment = new Invulnerability(false);

            // Act
            TestDelegate applyTo = () => enchantment.ApplyTo(null);

            // Assert
            Assert.Throws <ArgumentNullException>(applyTo);
        }
        public void GetSchools_MiracleUsed()
        {
            // Arrange
            var enchantment = new Invulnerability(true);

            // Act
            var schools = enchantment.GetSchools();

            // Assert
            Assert.That(schools, Is.EquivalentTo(new School[] { School.Abjuration, School.Evocation }));
        }
示例#6
0
    private void InteractWithPickUp(HealthBoost healthBoost, Invulnerability invulnerabilityBoost)
    {
        if (healthBoost)
        {
            InteractWithHealthItem(healthBoost);
        }

        else if (invulnerabilityBoost)
        {
            InteractWithInvulnerabilityItem(invulnerabilityBoost);
        }
    }
示例#7
0
        private Bonus _createBonus(int bId, BonusType type, int bx, int by)
        {
            Bonus b = null;

            switch (type)
            {
            case BonusType.Acceleration:
                b = new Acceleration(bx, by);
                break;

            case BonusType.APBullets:
                b = new APBullets(bx, by);
                break;

            case BonusType.BigAmmo:
                b = new BigAmmo(bx, by);
                break;

            case BonusType.BigMedChest:
                b = new BigMedChest(bx, by);
                break;

            case BonusType.DispenserBonus:
                b = new DispenserBonus(bx, by);
                break;

            case BonusType.Invulnerability:
                b = new Invulnerability(bx, by);
                break;

            case BonusType.MineBonus:
                b = new MineBonus(bx, by);
                break;

            case BonusType.SmallAmmo:
                b = new SmallAmmo(bx, by);
                break;

            case BonusType.SmallMedChest:
                b = new SmallMedChest(bx, by);
                break;

            case BonusType.TurretBonus:
                b = new TurretBonus(bx, by);
                break;

            case BonusType.Unknown:
                throw new ArgumentException("unknown bonus type came from client ");
            }
            b.Id = bId;
            return(b);
        }
        public void Default()
        {
            // Arrange
            var enchantment = new Invulnerability(false);

            // Act


            // Assert
            Assert.AreEqual("Invulnerability", enchantment.Name.Text);
            Assert.AreEqual(18, enchantment.CasterLevel);
            Assert.AreEqual(3, enchantment.SpecialAbilityBonus);
            Assert.AreEqual(0, enchantment.Cost);
        }
        public void ApplyTo_ICharacter_BestowsDR()
        {
            // Arrange
            var damageReductions = Mock.Of <IDamageReductionTracker>();
            var mockCharacter    = new Mock <ICharacter>();

            mockCharacter.Setup(c => c.DamageReduction)
            .Returns(damageReductions);
            var enchantment = new Invulnerability(false);

            // Act
            enchantment.ApplyTo(mockCharacter.Object);

            // Assert
            Mock.Get(damageReductions)
            .Verify(dr => dr.Add(It.Is <Func <byte> >(calc => 5 == calc()),
                                 It.Is <string>(str => "Magic" == str)),
                    "Invulnerability armor enchantment failed to add DR 5/Magic to the ICharacter.");
        }
示例#10
0
 public void Start()
 {
     invuln   = GetComponent <Invulnerability>();
     movement = GetComponent <PlatformerMovement2D>();
 }