Example #1
0
 public void SubscribeTargeter(ITargeter targeter)
 {
     if (targeter != null)
     {
         subscribedTargeters.Add(targeter);
     }
 }
Example #2
0
 public void RemoveSubscribedTargeter(ITargeter targeter)
 {
     if (targeter != null)
     {
         subscribedTargeters.Remove(targeter);
     }
 }
 public override void Init()
 {
     Targeter = GetComponentInParent <ITargeter>();
     Provider = GetComponentInParent <ITargetProvider>();
     Ranger   = GetComponentInParent <IRanger>();
     UpdateStats();
 }
 public override void OnBulletImpact(Vector2 startPos, IDamagable damagable, ITargeter targeter)
 {
     if (damagable != null)
     {
         damagable.Damage(damage, targeter);
     }
 }
Example #5
0
 public TargetingManager(
     [Inject] ITargeter targeter,
     [Inject] ICursor cursor)
 {
     _targeter = targeter;
     _cursor   = cursor;
     _updating = true;
 }
Example #6
0
        public override void Init()
        {
            _targetProvider = GetComponentInParent <ITargetProvider>();
            _targeter       = GetComponentInParent <ITargeter>();

            _beamStart          = transform.Find("BeamStart");
            _beam               = transform.Find("Beam").GetComponent <LineRenderer>();
            _particleForceField = GetComponentInChildren <ParticleSystemForceField>();
        }
Example #7
0
 protected void AddAspect(ITargeter targeter, List <EffectInstance> effects)
 {
     if (effects.Count == 0 || targeter == null)
     {
         return;
     }
     aspects.Add(new SpellAspect()
     {
         Targeter = targeter, Effects = effects
     });
 }
        private void DeRegisterTargeter(ITargeter targeter)
        {
            targeter.CurrentTarget = null;

            if (!(targeter is Turret && ((Turret)targeter).TurretType == TurretTypes.Planet))
            {
                targeter.PotentialTargets.Clear();
            }

            if (_targetingObjects.ContainsKey(targeter.Id))
            {
                _targetingObjects.Remove(targeter.Id);
            }
        }
    public void TargeterIsUpdated()
    {
        //Arrange
        ITargeter targeter = Substitute.For <ITargeter>();

        Container.Bind <ITargeter>().FromInstance(targeter);
        ICursor cursor = Substitute.For <ICursor>();

        Container.Bind <ICursor>().FromInstance(cursor);
        TargetingManager tMan = Container.Resolve <TargetingManager>();

        //Act
        tMan.Tick();

        //Assert
        targeter.Received(1).AcquireTarget();
    }
Example #10
0
        private void RegisterTargeter(ITargeter targeter)
        {
            if (targeter is DefensiveMine)
            {
                return;
            }

            if (!_targetingObjects.ContainsKey(targeter.Id))
            {
                _targetingObjects.Add(targeter.Id, targeter);

                if (!_suspendTargetSetting)
                {
                    SetPotentialTargets(targeter);
                }
            }
        }
    public void StartTargeting(int casterTeamId, Vector3 initPos, UnitAbility ability, Action <TargetingResultData> targetingResultCallback)
    {
        this.targetingResultCallback = targetingResultCallback;
        currentTargetingType         = ability.TargetingType;
        currentTargetGroup           = ability.TargetGroup;
        targeterInfoGO.SetActive(true);

        switch (ability.TargetingType)
        {
        case TargetingType.Single:
            currentTargeter    = pointTargeter;
            additionalTargeter = null;
            break;

        case TargetingType.Self:
            currentTargeter    = pointTargeter;
            additionalTargeter = null;
            break;

        case TargetingType.Line:
            currentTargeter    = lineTargeter;
            additionalTargeter = basicPointTargeter;
            break;

        case TargetingType.Circle:
            currentTargeter    = circleTargeter;
            additionalTargeter = basicPointTargeter;
            break;

        case TargetingType.All:
        default:
            Debug.Log($"[TargeterMaster] TargeterType unhandled {ability.TargetingType}");
            break;
        }


        currentTargeter?.Setup(casterTeamId, initPos, ability.AbilitySize, ability.TargetGroup);
        additionalTargeter?.Setup(casterTeamId, initPos, 1f, null);

        if (ability.TargetingType != TargetingType.Self)
        {
            inputController.TargetPointer.Any.Enable();
        }
        inputController.TargetPointer.Execute.Enable();
        inputController.TargetPointer.Execute.performed += Execute_performed;
    }
Example #12
0
        /// <summary>
        /// Iterates through _targetableObjects and sets targeter.PotentialTargets appropriately
        /// </summary>
        /// <param name="targeter"></param>
        private void SetPotentialTargets(ITargeter targeter)
        {
            // If landing becomes slow for large numbers of turrets,
            // Reimplement this with single PotentialTurretTargets collection.
            targeter.PotentialTargets.Clear();

            foreach (var pt in _targetableObjects)
            {
                if (pt.Value is CommandCenter)
                {
                    continue;
                }
                else if (!pt.Value.OnSameTeam(targeter))
                {
                    targeter.PotentialTargets.Add(pt.Value.Id, pt.Value);
                }
            }
        }
Example #13
0
    public override void OnBulletImpact(Vector2 startPos, IDamagable damagable, ITargeter targeter)
    {
        if (damagable != null)
        {
            Collider2D[] collidedObjects = Physics2D.OverlapCircleAll(startPos, blastRadius, blastLayer);

            for (int i = 0; i < collidedObjects.Length; i++)
            {
                if (collidedObjects[i])
                {
                    IDamagable collidedDamagable = collidedObjects[i].GetComponent <IDamagable>();
                    if (collidedDamagable != null)
                    {
                        collidedDamagable.Damage(damage, targeter);
                    }
                }
            }
        }
    }
Example #14
0
    public void Damage(int damage, ITargeter targeter)
    {
        if (!IsDead())
        {
            hp -= damage;
            hp  = Math.Max(0, hp);

            if (IsDead())
            {
                GameManager.instance.IncreaseKillCount();
                if (targeter != null)
                {
                    targeter.OnTargetKilled();
                }
                WarnAndClearSubscribers();

                gameObject.SetActive(false);

                OnEnemyDeath?.Invoke(this);
            }
        }
    }
Example #15
0
        protected override void InitComponent()
        {
            Stats.GetStat(Stat.Type.Turret_Speed).SetNameAndDesc("Firerate", "The amount of times this weapon can fire per second.");
            Stats.GetStat(Stat.Type.Turret_Strength).SetNameAndDesc("Damage", "The amount of damage this weapon does.");

            Stats.AddStat(new Stat(Stat.Type.Weapon_Precision, "Prisicion", "The prisicion of this weapon, the higher the better.", 0));
            Stats.AddStat(new Stat(Stat.Type.Weapon_ProjectileAmount, "Projectiles", "The amount of projectiles fired by this weapon.", 1));

            Events.AddEvent(Modifiables.Event.Type.OnHit);
            Events.AddEvent(Modifiables.Event.Type.OnFirstHit);
            Events.AddEvent(Modifiables.Event.Type.OnPierce);
            Events.AddEvent(Modifiables.Event.Type.OnLastHit);
            Events.AddEvent(Modifiables.Event.Type.OnAOEHit);
            Events.AddEvent(Modifiables.Event.Type.OnDOTHit);
            Events.AddEvent(Modifiables.Event.Type.OnBeginFire);
            Events.AddEvent(Modifiables.Event.Type.OnFire);
            Events.AddEvent(Modifiables.Event.Type.OnProjectileFired);
            Events.AddEvent(Modifiables.Event.Type.OnProjectileFinished);

            _baseModTags.Add(Mod.Tag.TurretWeapon);

            _weapon   = GetComponentInChildren <Weapon>();
            _targeter = transform.parent.GetComponent <ITargeter>();
        }
Example #16
0
 private void Awake()
 {
     _rayProvider = GetComponent <IRayProvider>();
     _targeter    = GetComponent <ITargeter>();
 }
 public abstract void OnBulletImpact(Vector2 impactPos, IDamagable damagable, ITargeter targeter);
 public AuraAbility(IRequisite inflictedRequisite, ITargeter targeter)
 {
     _inflictedRequisite = inflictedRequisite;
     _targeter           = targeter;
     Id = new RequisiteId(inflictedRequisite.Id + "Aura");
 }
Example #19
0
 public void Initialize(ITargeter user)
 {
     _user = user;
 }
Example #20
0
 private void GetFallSpringMovesRemaining(Board board, AllianceScenario allianceScenario, ITargeter unitTargetCalculator, BoardMove workingBoardMove, HashSet <BoardMove> completedBoardMoves)
 {
     foreach (var kvp in board.OccupiedMapNodes.Where(kvp2 => !workingBoardMove.Sources.Contains(kvp2.Key)))
     {
         List <MapNode> path;
         UnitMove       currentMove;
         if (unitTargetCalculator.TryGetMoveTargetValidateWithBoardMove(board, kvp.Key, allianceScenario, workingBoardMove, out path, out currentMove))
         {
             workingBoardMove.Add(currentMove);
         }
         else
         {
             // uh oh, contradiction
             return;
         }
     }
     completedBoardMoves.Add(workingBoardMove.Clone());
     return;
 }
Example #21
0
 public ProbabilisticFuturesAlgorithm()
 {
     _targeter = new SupplyCenterTargeter();
 }
 /// <summary>
 /// Get reference to the <see cref="_targeter"/>.
 /// </summary>
 private void Awake()
 {
     _targeter = GetComponentInParent <ITargeter>();
 }
 public AutoAttackAbility(HitPoints damage, ITargeter targeter)
 {
     _damage   = damage;
     _targeter = targeter;
 }