Esempio n. 1
0
 protected void OnTriggerEnter2D(Collider2D collision)
 {
     if (TargetTags.Contains(collision.tag))
     {
         targets.Add(collision);
     }
 }
Esempio n. 2
0
 public override bool Cast()
 {
     if (base.Cast())
     {
         var projectile = Instantiate(ProjectilePrefab, transform.position, transform.rotation);
         projectile.GetComponent <Projectile>().CollisionHandler = (collider) => {
             if (TargetTags.Contains(collider.tag))
             {
                 collider.GetComponent <Unit>().AddEffects(Effects);
             }
         };
         projectile.GetComponent <Projectile>().TargetTags.AddRange(TargetTags);
     }
     return(false);
 }
        public void Match_ShouldUseRoleCasingFromScope_WhenSucessful()
        {
            // Arrange
            var foundTags = new TargetTags(
                environment: "sCoPe-eNvIrOnMeNt",
                role: "sCoPe-rOlE-1",
                project: null,
                space: null,
                tenant: null);

            // Act
            var result = sut.Match(foundTags);

            // Assert
            result.Role.Should().Be("scope-role-1");
        }
        public void Match_ShouldSucceed_IfOptionalTagsAllMatchScope()
        {
            // Arrange
            var foundTags = new TargetTags(
                environment: scopeEnvironment,
                role: scopeRole1,
                project: scopeProject,
                space: scopeSpace,
                tenant: scopeTenant);

            // Act
            var result = sut.Match(foundTags);

            // Assert
            result.IsSuccess.Should().BeTrue();
        }
        public void Match_ShouldMakeOrdinalCaseInsenitiveComparisons()
        {
            // Arrange
            var foundTags = new TargetTags(
                environment: "sCoPe-eNvIrOnMeNt",
                role: "sCoPe-rOlE-1",
                project: "sCoPe-pRoJeCt",
                space: "sCoPe-sPaCe",
                tenant: "sCoPe-tEnAnT");

            // Act
            var result = sut.Match(foundTags);

            // Assert
            result.IsSuccess.Should().BeTrue();
        }
        public void Match_ShouldCaptureMatchingRole_WhenMatchSucceeds()
        {
            // Arrange
            var foundTags = new TargetTags(
                environment: scopeEnvironment,
                role: scopeRole2,
                project: null,
                space: null,
                tenant: null);

            // Act
            var result = sut.Match(foundTags);

            // Assert
            result.Role.Should().Be(scopeRole2);
        }
        public void Match_ShouldSucceed_IfRoleAndEnvironmentTagsMatchAndNoOptionalTagsArePresent()
        {
            // Arrange
            var foundTags = new TargetTags(
                environment: scopeEnvironment,
                role: scopeRole1,
                project: null,
                space: null,
                tenant: null);

            // Act
            var result = sut.Match(foundTags);

            // Assert
            result.IsSuccess.Should().BeTrue();
        }
Esempio n. 8
0
    private void Awake()
    {
        if (targetTags == null)
        {
            targetTags = GetComponent <TargetTags>();
        }

        if (targetTags != null)
        {
            var targetList = targetTags.GetTargets();

            if (addPlayerTag && targetList.Contains(Tags.Player) == false)
            {
                targetTags.overridableTargets.Add(Tags.Player);
            }
        }
    }
        public void Match_ShouldFail_IfRoleTagIsMismatched()
        {
            // Arrange
            var foundTags = new TargetTags(
                environment: scopeEnvironment,
                role: "wrong-role",
                project: null,
                space: null,
                tenant: null);

            // Act
            var result = sut.Match(foundTags);

            // Assert
            using (new AssertionScope())
            {
                result.IsSuccess.Should().BeFalse();
                result.FailureReasons.Should().ContainSingle().Which.Should().Be(
                    "Mismatched role tag. Match requires 'octopus-role' tag with value from ['scope-role-1', 'scope-role-2'], but found 'wrong-role'.");
            }
        }
        public void Match_ShouldFail_IfEnvironmentTagIsMissing()
        {
            // Arrange
            var foundTags = new TargetTags(
                environment: null,
                role: scopeRole1,
                project: null,
                space: null,
                tenant: null);

            // Act
            var result = sut.Match(foundTags);

            // Assert
            using (new AssertionScope())
            {
                result.IsSuccess.Should().BeFalse();
                result.FailureReasons.Should().ContainSingle().Which.Should().Be(
                    "Missing environment tag. Match requires 'octopus-environment' tag with value 'scope-environment'.");
            }
        }
        public void Match_ShouldFail_IfMismatchedTenantTagIsPresent()
        {
            // Arrange
            var foundTags = new TargetTags(
                environment: scopeEnvironment,
                role: scopeRole1,
                project: null,
                space: null,
                tenant: "wrong-tenant");

            // Act
            var result = sut.Match(foundTags);

            // Assert
            using (new AssertionScope())
            {
                result.IsSuccess.Should().BeFalse();
                result.FailureReasons.Should().ContainSingle().Which.Should().Be(
                    "Mismatched tenant tag. Optional 'octopus-tenant' tag must match 'scope-tenant' if present, but is 'wrong-tenant'.");
            }
        }
        public void Match_ShouldIncludeAllFailureReasons_IfMultipleReasonsExist()
        {
            // Arrange
            var foundTags = new TargetTags(
                environment: "wrong-environment",
                role: "wrong-role",
                project: "wrong-project",
                space: "wrong-space",
                tenant: "wrong-tenant");

            // Act
            var result = sut.Match(foundTags);

            // Assert
            using (new AssertionScope())
            {
                result.IsSuccess.Should().BeFalse();
                result.FailureReasons.Should().Contain("Mismatched environment tag. Match requires 'octopus-environment' tag with value 'scope-environment', but found 'wrong-environment'.");
                result.FailureReasons.Should().Contain("Mismatched role tag. Match requires 'octopus-role' tag with value from ['scope-role-1', 'scope-role-2'], but found 'wrong-role'.");
                result.FailureReasons.Should().Contain("Mismatched project tag. Optional 'octopus-project' tag must match 'scope-project' if present, but is 'wrong-project'.");
                result.FailureReasons.Should().Contain("Mismatched space tag. Optional 'octopus-space' tag must match 'scope-space' if present, but is 'wrong-space'.");
                result.FailureReasons.Should().Contain("Mismatched tenant tag. Optional 'octopus-tenant' tag must match 'scope-tenant' if present, but is 'wrong-tenant'.");
            }
        }
Esempio n. 13
0
        public virtual void Deserialize(BinaryReader r)
        {
            var numParamCount = r.ReadUInt32();

            // if there are no custom params of any kind,
            // there's just an 0xFFFFFFFF here and the item ends.
            if (numParamCount == NoParamsMarker)
            {
                return;
            }

            for (int i = 0; i < numParamCount; i++)
            {
                NumParams.Add(r.ReadSingle());
            }

            var stringParamCount = r.ReadUInt32();

            for (int i = 0; i < stringParamCount; i++)
            {
                var strLen   = (int)r.ReadUInt64();
                var strBytes = r.ReadBytes(strLen);
                var str      = Encoding.Default.GetString(strBytes);
                StringParams.Add(str);
            }

            var targetTagsCount = r.ReadUInt32();

            for (int i = 0; i < targetTagsCount; i++)
            {
                TargetTags.Add(r.ReadToken());
            }

            TargetRange = r.ReadSingle();
            actionFlags = new FlagField(r.ReadUInt32());
        }
Esempio n. 14
0
 public void SetTargets(TargetTags targets)
 {
     overridableTargets = new List <string>(targets.GetTargets());
 }
Esempio n. 15
0
        /// <summary>
        /// Use to set the targeting on various components before making active
        /// </summary>
        /// <remarks>
        /// Called per spell when pooling is disabled however when pooling is enabled
        /// a master instance is created for cloning of each spell and the targeting is only set once
        /// </remarks>
        /// <param name="MasterInstance"></param>
        /// <param name="Target"></param>
        /// <param name="SlotID"></param>
        public static void SetComponentTagsSlotsAndLayers(ref GameObject MasterInstance, SpawnTarget Target, int SlotID)
        {
            // grab target tag list
            string[]  TargetTags;
            LayerMask TargetLayers;

            string[]  InverseTargetTags;
            LayerMask InverseTargetLayers;

            switch (Target)
            {
            case SpawnTarget.Friend:
                TargetTags          = targetingTagsFriend;
                TargetLayers        = targetingLayerMaskFriend;
                InverseTargetTags   = targetingTagsEnemy;
                InverseTargetLayers = targetingLayerMaskEnemy;
                break;

            case SpawnTarget.Enemy:
                TargetTags          = targetingTagsEnemy;
                TargetLayers        = targetingLayerMaskEnemy;
                InverseTargetTags   = targetingTagsFriend;
                InverseTargetLayers = targetingLayerMaskFriend;
                break;

            default:
                InverseTargetTags   = TargetTags = targetingTagsAll;
                InverseTargetLayers = TargetLayers = targetingLayerMaskAll;
                break;
            }


            // set magic projectile target, tags, layers
            MagicProjectile[] allmProjectile = MasterInstance.GetComponentsInChildren <MagicProjectile>();
            foreach (MagicProjectile mProjectile in allmProjectile)
            {
                mProjectile.Target      = Target;
                mProjectile.iPoolSlotID = SlotID + 1;
                switch (Target)
                {
                case SpawnTarget.Friend:
                    mProjectile.HeatSeekTags   = targetingTagsFriend;
                    mProjectile.HeatSeekLayers = targetingLayerMaskFriend;
                    break;

                case SpawnTarget.Enemy:
                    mProjectile.HeatSeekTags   = targetingTagsEnemy;
                    mProjectile.HeatSeekLayers = targetingLayerMaskEnemy;
                    break;

                default:
                    mProjectile.HeatSeekTags   = targetingTagsAll;
                    mProjectile.HeatSeekLayers = targetingLayerMaskAll;
                    break;
                }
            }

            // target and slot for teleport
            MagicTeleport mt = MasterInstance.GetComponentInChildren <MagicTeleport>();

            if (mt)
            {
                mt.Target       = Target;
                mt.PoolSlotID   = SlotID + 1;
                mt.TargetLayers = TargetLayers;
                mt.TargetTags   = TargetTags;
            }

#if !VANILLA
            // vobjectdamage  target tags
            vObjectDamage[] allVDamage = MasterInstance.GetComponentsInChildren <vObjectDamage>();
            foreach (vObjectDamage vd in allVDamage)
            {
                vd.tags = TargetTags.ToList();
            }
#endif

            // targeting for physics
            MagicProjectilePhysics[] allmPhysics = MasterInstance.GetComponentsInChildren <MagicProjectilePhysics>();
            foreach (MagicProjectilePhysics mpp in allmPhysics)
            {
                mpp.TargetLayers = Target;
            }

            // and heal
            MagicHeal[] allHeal = MasterInstance.GetComponentsInChildren <MagicHeal>();
            foreach (MagicHeal mh in allHeal)
            {
                mh.HealTargetLayers = InverseTargetLayers;
                mh.HealTargetTags   = InverseTargetTags;
            }


            // same for magic damage
            MagicObjectDamage[] allmDamage = MasterInstance.GetComponentsInChildren <MagicObjectDamage>();
            foreach (MagicObjectDamage md in allmDamage)
            {
                md.AOETarget = Target;
            }

            // slot for DestroyAndSpawn
            DestroyGameObjectAndSpawn[] allmDOS = MasterInstance.GetComponentsInChildren <DestroyGameObjectAndSpawn>();
            foreach (DestroyGameObjectAndSpawn dos in allmDOS)
            {
                dos.iPoolSlotID = SlotID + 1;
                dos.Target      = Target;
            }

            // slot for DestroyAndSpawn
            DelayedSpawn[] allmDS = MasterInstance.GetComponentsInChildren <DelayedSpawn>();
            foreach (DelayedSpawn ds in allmDS)
            {
                ds.iPoolSlotID = SlotID + 1;
            }

            // same for collectible
            CollectableItem[] allmCI = MasterInstance.GetComponentsInChildren <CollectableItem>();
            foreach (CollectableItem ci in allmCI)
            {
                ci.iPoolSlotID = SlotID + 1;
            }
        }