Exemplo n.º 1
0
        //TO DO: hard coded right now for 2 lists, generalize this to take any amount
        //of lists that coincides with the number of users in the party
        //NOTE: *** Can be done with use of params[] List<T> then indexing list number in function ***
        public void Comparator(List <string> Stef, List <string> Chris)
        {
            //Creates temporary combined list of songs to be used later in function
            var FullList = new List <string>();

            FullList.AddRange(Stef);
            FullList.AddRange(Chris);

            //Creates list of unmatched items: Target0
            var Target0        = new List <string>();
            var firstNotSecond = Stef.Except(Chris).ToList();
            var secondNotFirst = Chris.Except(Stef).ToList();

            Target0.AddRange(firstNotSecond);
            Target0.AddRange(secondNotFirst);

            var Target1 = FullList.Except(Target0).ToList();

            //List of Songs that match(1) and do not match(0) with 1's being first in the list
            TargetList.AddRange(Target1);
            TargetList.AddRange(Target0);

            var partition = Partition <string>(TargetList, 100);

            //Creates comma separated list of Ids to be used in GetFeatures function
            foreach (var item in partition)
            {
                TargetListIds.Add(string.Join(',', item.Select(e => e)));
            }

            //Adds to List of Target values that corresponds with the order of TargetList
            TargetValues.AddRange(Enumerable.Repeat(1, Target1.Count()));
            TargetValues.AddRange(Enumerable.Repeat(0, Target0.Count()));
        }
Exemplo n.º 2
0
        public void SetTarget(List <Vector2> targetList)
        {
            List <Vector2> TargetList;
            Entity         checkEntity;

            foreach (int sub in Subscribtions)
            {
                checkEntity = EntityManager.GetEntity(sub);
                // determines if subscribed entity is: 1)selected 2) is infact a unit and not something else
                if ((bool)(checkEntity.cBag[DataType.IsSelected]) && (SelectionType)(checkEntity.cBag[DataType.SelectionType]) == SelectionType.Units)
                {
                    TargetList = (List <Vector2>)checkEntity.cBag[DataType.TargetList];
                    TargetList.AddRange(targetList);
                    checkEntity.cBag[DataType.TargetList]  = TargetList;
                    checkEntity.cBag[DataType.IsMoveValid] = true;
                }
            }
        }
Exemplo n.º 3
0
    /// <summary>
    /// Handles all firing events including target aquisition and firing. 
    /// Events are:
    ///     OnStart() :
    ///         Runs once when the firing system first becomes active
    ///     OnUpdate() :
    ///         Runs each frame while the firing system is active
    ///     OnTargetUpdate() : 
    ///         Runs each frame while tracking a target (there is at least one target.)
    ///     OnIdleUpdate() :
    ///         Runs each frame while the firing system is idle (no targets)
    ///     OnFire() :
    ///         Runs when it is time to fire.
    ///     
    /// Counter Behavior Notes:
    ///   * If there are no targets. the counter will keep running up. 
    ///     This means the next target to enter will be fired upon 
    ///     immediatly.
    ///     
    ///   * The counter is always active so if the last target exits, then a 
    ///     new target enters right after that, there may still be a wait.	
    /// </summary>
    private IEnumerator FiringSystem()
    {
        // While (true) because of the timer, we want this to run all the time, not
        //   start and stop based on targets in range
        if (this.initIntervalCountdownAtZero)
            this.fireIntervalCounter = 0;
        else
            this.fireIntervalCounter = this.interval;

        this.targets.Clear();
        this.OnStart();   // EVENT TRIGGER

        while (true)
        {
            // if there is no target, counter++, handle idle behavior, and
            //   try next frame.
            // Will init this.targets for child classes as well.
            this.targets = this.targetTracker.targets;

            if (this.targets.Count != 0)
            {
                // Let the delegate filter a copy of the list just for the OnFire
                //   Test. We still want this.targets to remain as is.
                //   Do this in here to still trigger OnTargetUpdate
                var targetsCopy = new TargetList();
                targetsCopy.AddRange(this.targets);

                if (this.onPreFireDelegates != null)
                    this.onPreFireDelegates(targetsCopy);

                // if all is right, fire
                if (targetsCopy.Count != 0 &&    // Incase of pre-fire delegate changes
                    this.fireIntervalCounter <= 0 &&
                    this.isLockedOnTarget)
                {
                    this.OnFire();
                    this.fireIntervalCounter = this.interval;  // Reset
                }
                else if (this.debugLevel > DEBUG_LEVELS.Off)
                {
                    // Just for debug. Show a gizmo line to each target being tracked
                    //   OnFire() has another color, so keep this here where this
                    //   won't overlay the OnFired line.
                    foreach (Target target in targets)
                        Debug.DrawLine
                        (
                            this.emitter.position,
                            target.transform.position,
                            Color.gray
                        );
                }

                // Update event while tracking a target
                this.OnTargetUpdate(targets);   // EVENT TRIGGER
            }
            else
            {
                // Update event while NOT tracking a target
                this.OnIdleUpdate();   // EVENT TRIGGER
            }

            this.fireIntervalCounter -= Time.deltaTime;

            // Update event no matter what
            this.OnUpdate();   // EVENT TRIGGER

            // Stager calls to get Target (the whole system actually)
            yield return null;
        }
    }
Exemplo n.º 4
0
        /// <summary>
        /// Destroys the projectile on impact and finds objects in range to 
        ///	affect if they share the same tag as target.
        /// </summary>
        public void DetonateProjectile()
        {
            // Prevent being run more than once in a frame where it has already 
            //   been destroyed.
            if (!this.gameObject.activeInHierarchy) return;

            // Build a new list of targets depending on the options used
            var targetList = new TargetList();
            if (this.areaHit)
            {
                // This is turned back off OnDisable() (base class)
                this.perimeter.enabled = true;

                targetList.AddRange(this.targets); // Add all targets in range
            }
            else
            {
                if (this.target != Target.Null)
                    targetList.Add(this.target); // Add projectile target
            }

            if (this.debugLevel > DEBUG_LEVELS.Off)
            {
                string msg = string.Format("Detonating with targets: {0}", targetList);
                Debug.Log(string.Format("Projectile ({0}): {1}", this.name, msg));
            }

            // Create a new list of targets which have this target tracker reference.
            //   This is for output so targets which are handled at all by this Projectile
            //   are stamped with a reference.
            var targetCopies = new TargetList();
            Target target;
            foreach (Target inTarget in targetList)
            {
                if (inTarget == Target.Null)
                    continue;

                // Can't edit a struct in a foreach loop, so need to copy and store
                target = new Target(inTarget);
                target.projectile = this;  // Add reference. null before t
                targetCopies.Add(target);

                switch (this.notifyTargets)
                {
                    case NOTIFY_TARGET_OPTIONS.Direct:
                        target.targetable.OnHit(this.effectsOnTarget, target, this.collider);
                        break;
                }

                // Just for debug. Show a gizmo line when firing
                if (this.debugLevel > DEBUG_LEVELS.Off)
                    Debug.DrawLine
                    (
                        this.xform.position,
                        target.transform.position,
                        Color.red
                    );

            }

            switch (this.notifyTargets)
            {
                case NOTIFY_TARGET_OPTIONS.Direct:
                    this.SpawnDetonatorPrefab(false);
                    break;

                case NOTIFY_TARGET_OPTIONS.PassToDetonator:
                    this.SpawnDetonatorPrefab(true);
                    break;
            }


            // Trigger delegates
            if (this.OnDetonationDelegates != null) this.OnDetonationDelegates(targetCopies);

            // Clean-up in case this instance is used in a pooling system like PoolManager
            this.target = Target.Null;

            InstanceManager.Despawn(this.transform);
        }
Exemplo n.º 5
0
    /// <summary>
    /// Destroys the projectile on impact and finds objects in range to
    ///	affect if they share the same tag as target.
    /// </summary>
    public void DetonateProjectile()
    {
        // Prevent being run more than once in a frame where it has already
        //   been destroyed.
        if (!this.gameObject.activeInHierarchy)
        {
            return;
        }

        // Build a new list of targets depending on the options used
        var targetList = new TargetList();

        if (this.areaHit)
        {
            // This is turned back off OnDisable() (base class)
            this.perimeter.enabled = true;

            targetList.AddRange(this.targets); // Add all targets in range
        }
        else
        {
            if (this.target != Target.Null)
            {
                targetList.Add(this.target); // Add projectile target
            }
        }

        if (this.debugLevel > DEBUG_LEVELS.Off)
        {
            string msg = string.Format("Detonating with targets: {0}", targetList);
            Debug.Log(string.Format("Projectile ({0}): {1}", this.name, msg));
        }

        // Create a new list of targets which have this target tracker reference.
        //   This is for output so targets which are handled at all by this Projectile
        //   are stamped with a reference.
        var    targetCopies = new TargetList();
        Target target;

        foreach (Target inTarget in targetList)
        {
            if (inTarget == Target.Null)
            {
                continue;
            }

            // Can't edit a struct in a foreach loop, so need to copy and store
            target            = new Target(inTarget);
            target.projectile = this;  // Add reference. null before t
            targetCopies.Add(target);

            switch (this.notifyTargets)
            {
            case NOTIFY_TARGET_OPTIONS.Direct:
                target.targetable.OnHit(this.effectsOnTarget, target, this.collider);
                break;
            }

            // Just for debug. Show a gizmo line when firing
            if (this.debugLevel > DEBUG_LEVELS.Off)
            {
                Debug.DrawLine
                (
                    this.xform.position,
                    target.transform.position,
                    Color.red
                );
            }
        }

        switch (this.notifyTargets)
        {
        case NOTIFY_TARGET_OPTIONS.Direct:
            this.SpawnDetonatorPrefab(false);
            break;

        case NOTIFY_TARGET_OPTIONS.PassToDetonator:
            this.SpawnDetonatorPrefab(true);
            break;
        }


        // Trigger delegates
        if (this.OnDetonationDelegates != null)
        {
            this.OnDetonationDelegates(targetCopies);
        }

        // Clean-up in case this instance is used in a pooling system like PoolManager
        this.target = Target.Null;

        InstanceManager.Despawn(this.transform);
    }
Exemplo n.º 6
0
 public void DetonateProjectile()
 {
     if (!base.gameObject.activeInHierarchy)
     {
         return;
     }
     TargetList targetList = new TargetList();
     if (this.areaHit)
     {
         base.perimeter.enabled = true;
         targetList.AddRange(this.targets);
     }
     else if (this.target != Target.Null)
     {
         targetList.Add(this.target);
     }
     if (this.debugLevel > DEBUG_LEVELS.Off)
     {
         string arg = string.Format("Detonating with targets: {0}", targetList);
         UnityEngine.Debug.Log(string.Format("Projectile ({0}): {1}", base.name, arg));
     }
     TargetList targetList2 = new TargetList();
     Projectile.NOTIFY_TARGET_OPTIONS nOTIFY_TARGET_OPTIONS;
     foreach (Target current in targetList)
     {
         if (!(current == Target.Null))
         {
             Target target = new Target(current);
             target.projectile = this;
             targetList2.Add(target);
             nOTIFY_TARGET_OPTIONS = this.notifyTargets;
             if (nOTIFY_TARGET_OPTIONS == Projectile.NOTIFY_TARGET_OPTIONS.Direct)
             {
                 target.targetable.OnHit(this.effectsOnTarget, target, base.GetComponent<Collider>());
             }
             if (this.debugLevel > DEBUG_LEVELS.Off)
             {
                 UnityEngine.Debug.DrawLine(this.xform.position, target.transform.position, Color.red);
             }
         }
     }
     nOTIFY_TARGET_OPTIONS = this.notifyTargets;
     if (nOTIFY_TARGET_OPTIONS != Projectile.NOTIFY_TARGET_OPTIONS.Direct)
     {
         if (nOTIFY_TARGET_OPTIONS == Projectile.NOTIFY_TARGET_OPTIONS.PassToDetonator)
         {
             this.SpawnDetonatorPrefab(true);
         }
     }
     else
     {
         this.SpawnDetonatorPrefab(false);
     }
     if (this.OnDetonationDelegates != null)
     {
         this.OnDetonationDelegates(targetList2);
     }
     this.target = Target.Null;
     InstanceManager.Despawn(base.transform);
 }
Exemplo n.º 7
0
    /// <summary>
    /// Handles all firing events including target aquisition and firing.
    /// Events are:
    ///     OnStart() :
    ///         Runs once when the firing system first becomes active
    ///     OnUpdate() :
    ///         Runs each frame while the firing system is active
    ///     OnTargetUpdate() :
    ///         Runs each frame while tracking a target (there is at least one target.)
    ///     OnIdleUpdate() :
    ///         Runs each frame while the firing system is idle (no targets)
    ///     OnFire() :
    ///         Runs when it is time to fire.
    ///
    /// Counter Behavior Notes:
    ///   * If there are no targets. the counter will keep running up.
    ///     This means the next target to enter will be fired upon
    ///     immediatly.
    ///
    ///   * The counter is always active so if the last target exits, then a
    ///     new target enters right after that, there may still be a wait.
    /// </summary>
    private IEnumerator FiringSystem()
    {
        // While (true) because of the timer, we want this to run all the time, not
        //   start and stop based on targets in range
        if (this.initIntervalCountdownAtZero)
        {
            this.fireIntervalCounter = 0;
        }
        else
        {
            this.fireIntervalCounter = this.interval;
        }

        this.targets.Clear();
        this.OnStart();   // EVENT TRIGGER

        while (true)
        {
            // if there is no target, counter++, handle idle behavior, and
            //   try next frame.
            // Will init this.targets for child classes as well.
            this.targets = this.targetTracker.targets;

            if (this.targets.Count != 0)
            {
                // Let the delegate filter a copy of the list just for the OnFire
                //   Test. We still want this.targets to remain as is.
                //   Do this in here to still trigger OnTargetUpdate
                var targetsCopy = new TargetList();
                targetsCopy.AddRange(this.targets);

                if (this.onPreFireDelegates != null)
                {
                    this.onPreFireDelegates(targetsCopy);
                }

                // if all is right, fire
                if (targetsCopy.Count != 0 &&    // Incase of pre-fire delegate changes
                    this.fireIntervalCounter <= 0 &&
                    this.isLockedOnTarget)
                {
                    this.OnFire();
                    this.fireIntervalCounter = this.interval;  // Reset
                }
                else if (this.debugLevel > DEBUG_LEVELS.Off)
                {
                    // Just for debug. Show a gizmo line to each target being tracked
                    //   OnFire() has another color, so keep this here where this
                    //   won't overlay the OnFired line.
                    foreach (Target target in targets)
                    {
                        Debug.DrawLine
                        (
                            this.emitter.position,
                            target.transform.position,
                            Color.gray
                        );
                    }
                }

                // Update event while tracking a target
                this.OnTargetUpdate(targets);   // EVENT TRIGGER
            }
            else
            {
                // Update event while NOT tracking a target
                this.OnIdleUpdate();   // EVENT TRIGGER
            }

            this.fireIntervalCounter -= Time.deltaTime;

            // Update event no matter what
            this.OnUpdate();   // EVENT TRIGGER

            // Stager calls to get Target (the whole system actually)
            yield return(null);
        }
    }