Beispiel #1
0
 /// <summary>
 /// Registers a new ITeamable, if it is not already registered.
 /// Handles registration with TargetingManager if necessary
 /// </summary>
 /// <param name="t"></param>
 public void RegisterObject(ITeamable t)
 {
     if (!_teamableObjects.ContainsKey(t.Id))
     {
         _teamableObjects.Add(t.Id, t);
     }
 }
Beispiel #2
0
 public override void Initialize(GameObject go)
 {
     _transform    = go.transform;
     _movable      = go.GetComponent <IMovable>();
     _attackerable = go.GetComponent <IAttackerable>();
     _teamable     = go.GetComponent <ITeamable>();
 }
Beispiel #3
0
        public void ApplyMagicalShield(GameObject target)
        {
            var cols        = Physics.OverlapSphere(target.transform.position, _damageRadius, (int)LayerMaskHelper.Entity);
            var gos         = Triggers.Trigger.GetGameObjectFromColliders(cols);
            var targetCount = 0;

            foreach (var go in gos)
            {
                if (go == target)
                {
                    continue;
                }

//				if(_teamable == null || teamable == null || teamable.Team == _teamable.Team)
//					continue;

                ITeamable   teamable   = target.GetComponent <ITeamable>();
                IHealthable healthable = target.GetComponent <IHealthable>();

                if (healthable == null)
                {
                    continue;
                }

                targetCount++;

                var damage = new Damage(_damage, DamageType.Magical, _self);
                healthable.TakeDamage(damage);
            }

            //TODO apply damage block
            //Dont have any way to damage block outside of buffs
        }
Beispiel #4
0
        /// <summary>
        /// Deregisters ITeamable t, if it is currently registered
        /// </summary>
        /// <param name="t"></param>
        public void DeRegisterObject(ITeamable t)
        {
            //_targetingManager.DeRegisterObject(t);

            if (_teamableObjects.ContainsKey(t.Id))
            {
                _teamableObjects.Remove(t.Id);
            }
        }
Beispiel #5
0
        public override void Initialize(GameObject go)
        {
            base.Initialize(go);
            Level             = 1;//This ability is 'innate' and starts off being leveled
            _nightmareAbility = go.GetComponent <IAbilitiable>().GetAbility <Nightmare>();
            _attackable       = go.GetComponent <IAttackable>();
            _teamable         = go.GetComponent <ITeamable>();
            _healthable       = go.GetComponent <IHealthable>();
            _proc             = new DynamicProc(0f);

            _attackable.IncomingAttackLanded += IncomingAttackLanded;
        }
Beispiel #6
0
 public override void Initialize(GameObject go)
 {
     base.Initialize(go);
     _necromancyProc = new GradualProc(_skeletonSpawnChance);
     _eventable      = go.GetComponent <IMiscEvent>();
     _teamable       = go.GetComponent <ITeamable>();
     if (_eventable == null)
     {
         throw new MissingModuleException();
     }
     _eventable.KilledEntity += KilledEntityCallback;
 }
Beispiel #7
0
 public AttackTargetTrigger(Actor actor, TriggerHelper <T> helper, ITeamable teamable = default)
 {
     _targets = new List <Actor>();
     Trigger  = helper;
     Actor    = actor;
     Teamable = teamable;
     if (Teamable != null)
     {
         Teamable.TeamChanged += OnMyTeamChanged;
     }
     Trigger.Trigger.Enter += TriggerOnEnter;
     Trigger.Trigger.Exit  += TriggerOnExit;
 }
Beispiel #8
0
        /// <summary>
        /// Returns true if any of the teams in teams1 are contained in teams2
        /// </summary>
        /// <param name="teams1"></param>
        /// <param name="teams2"></param>
        /// <returns></returns>
        public bool AreAllied(ITeamable t1, ITeamable t2)
        {
            HashSet <int> teams1 = t1.GetTeamIDs();
            HashSet <int> teams2 = t2.GetTeamIDs();

            foreach (int id in teams1)
            {
                if (teams2.Contains(id))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #9
0
        public Attackerable(Actor actor, ITeamable teamable = default) : base(actor)
        {
            _teamable = teamable;

            var helper = TriggerUtility.CreateTrigger <SphereCollider>(Actor, AttackerableTrigger);

            _trigger            = new AttackTargetTrigger <SphereCollider>(Actor, helper, _teamable);
            _attackCooldown     = new DurationTimer(0f, true);
            _damage             = new ModifiedValueBoilerplate <IAttackDamageModifier>(modifier => modifier.AttackDamage);
            _range              = new ModifiedValueBoilerplate <IAttackRangeModifier>(modifier => modifier.AttackRange);
            _attacksPerInterval =
                new ModifiedValueBoilerplate <IAttacksPerIntervalModifier>(modifier => modifier.AttacksPerInterval);
            _interval = new ModifiedValueBoilerplate <IAttackIntervalModifier>(modifier => modifier.AttackInterval);
        }
Beispiel #10
0
        void Start()
        {
            var actor = GetComponent <Actor>();

            _teamable = actor.GetModule <ITeamable>();
            if (_teamable != null)
            {
                _teamable.TeamChanged += TeamableOnChanged;
                if (_teamable.Team != null)
                {
                    Apply(_teamable.Team.GetTint());
                }
            }
        }
Beispiel #11
0
 //For turrets
 private static bool OnSameTeam(this Turret turret, ITeamable t)
 {
     if (t is Turret && ((Turret)t).TurretType == TurretTypes.Planet)
     {
         return(true);//Currently only allow allied turrets on planets. Before changing this, make sure turrets on the server are changed to send team information first.
     }
     else if (t is Structure)
     {
         return(true);
     }
     else
     {
         return(t.Teams.Overlaps(turret.Teams));
     }
 }
Beispiel #12
0
        public void ApplyInfusion(GameObject target)
        {
            var cols = Physics.OverlapSphere(target.transform.position, _manaStealSearchRadius, (int)LayerMaskHelper.Entity);
            var gos  = Triggers.Trigger.GetGameObjectFromColliders(cols);

            ITeamable   teamable   = target.GetComponent <ITeamable>();
            IMagicable  magicable  = target.GetComponent <IMagicable>();
            IHealthable healthable = target.GetComponent <IHealthable>();

            var totalManaStolen = 0f;

            foreach (var go in gos)
            {
                if (go == target)
                {
                    continue;
                }

                if (_teamable == null || teamable == null || teamable.Team == _teamable.Team)
                {
                    continue;
                }

                var enemyMagicable = go.GetComponent <IMagicable>();

                if (enemyMagicable == null)
                {
                    continue;
                }

                var enemyManaPoints = enemyMagicable.ManaPoints;
                var stolen          = Mathf.Min(enemyManaPoints, _manaSteal);
                enemyMagicable.ModifyMana(-stolen, _self);

                totalManaStolen += stolen;
            }

            magicable.ModifyMana(totalManaStolen, _self);
            // //If allied, dont deal damage
            // if(_teamable != null && teamable != null && _teamable.Team == teamable.Team)
            // return;

            var damage = new Damage(totalManaStolen, DamageType.Magical, _self);

            healthable.TakeDamage(damage);
        }
Beispiel #13
0
 public static bool OnSameTeam(this ITeamable t1, ITeamable t2)
 {
     if (t1 == t2)
     {
         return(true);
     }
     else if (t1 is Turret)
     {
         return(((Turret)t1).OnSameTeam(t2));
     }
     else if (t2 is Turret)
     {
         return(((Turret)t2).OnSameTeam(t1));
     }
     else
     {
         return(t1.Teams.Overlaps(t2.Teams)); //WARNING: Overlaps is an O(n) function. If projectile collisions are causing slowdown, consider revising team system
     }
 }
Beispiel #14
0
 public static TeamableChecker AllyOnly(ITeamable teamable) => new TeamableChecker(teamable, TeamRelationFlag.Ally);
Beispiel #15
0
 public override void Initialize(GameObject go)
 {
     _self      = go;
     _teamable  = go.GetComponent <ITeamable>();
     _magicable = go.GetComponent <IMagicable>();
 }
Beispiel #16
0
        public Aggroable(Actor actor, ITeamable teamable = default) : base(actor)
        {
            var helper = TriggerUtility.CreateTrigger <SphereCollider>(actor, TriggerName);

            _triggerLogic = new AttackTargetTrigger <SphereCollider>(Actor, helper, teamable);
        }
Beispiel #17
0
 public static bool SameTeam(this ITeamable teamable, ITeamable other, bool defaultResult = false) => teamable == other || ((teamable != null && other != null) ? teamable.Team == other.Team : defaultResult);
Beispiel #18
0
 /// <summary>
 /// Check if other is neutral to teamable.
 /// </summary>
 /// <param name="teamable">This teamable.</param>
 /// <param name="other">The other teamable.</param>
 /// <returns>True if other is neutral to teamable.</returns>
 public static bool IsNeutral(this ITeamable teamable, ITeamable other) => teamable.IsRelation(other, TeamRelation.Neutral);
Beispiel #19
0
 /// <summary>
 /// Check if other is an ally of teamable.
 /// </summary>
 /// <param name="teamable">This teamable.</param>
 /// <param name="other">The other teamable.</param>
 /// <returns>True if other is an ally of teamable.</returns>
 public static bool IsAlly(this ITeamable teamable, ITeamable other) => teamable.IsRelation(other, TeamRelation.Ally);
Beispiel #20
0
 /// <summary>
 /// Check if other and teamable are both enemies.
 /// </summary>
 /// <param name="teamable">This teamable.</param>
 /// <param name="other">The other teamable.</param>
 /// <returns>True if both other and teamable are enemies.</returns>
 public static bool IsEnemySymetric(this ITeamable teamable, ITeamable other) => teamable.IsEnemy(other) && teamable.IsRelationSymetric(other);
Beispiel #21
0
 /// <summary>
 /// Check if other and teamable are both neutral.
 /// </summary>
 /// <param name="teamable">This teamable.</param>
 /// <param name="other">The other teamable.</param>
 /// <returns>True if both other and teamable are neutral.</returns>
 public static bool IsNeutralSymetric(this ITeamable teamable, ITeamable other) => teamable.IsNeutral(other) && teamable.IsRelationSymetric(other);
Beispiel #22
0
        public bool IsAllowed(ITeamable otherTeamable)
        {
            var relation = _teamable.GetRelation(otherTeamable);

            return(IsAllowed(relation));
        }
Beispiel #23
0
 public TeamableChecker(ITeamable teamable, TeamRelationFlag allowed = default)
 {
     _teamable = teamable;
     Allowed   = allowed;
 }
Beispiel #24
0
 /// <summary>
 /// Check if the provided relation is the relation from other to teamable.
 /// </summary>
 /// <param name="teamable">This teamable.</param>
 /// <param name="other">The other teamable.</param>
 /// <param name="relation">The relation to check.</param>
 /// <returns>True if the relation between the two is the same as the one provided.</returns>
 public static bool IsRelation(this ITeamable teamable, ITeamable other, TeamRelation relation) => teamable.GetRelation(other) == relation;
Beispiel #25
0
 /// <summary>
 /// Checks If teamable and other have the same relation.
 /// </summary>
 /// <param name="teamable">This teamable.</param>
 /// <param name="other">The other teamable.</param>
 /// <returns>True if they have the same relation.</returns>
 public static bool IsRelationSymetric(this ITeamable teamable, ITeamable other) => teamable.GetRelation(other) == other.GetRelation(teamable);
Beispiel #26
0
 public static TeamableChecker NonAllyOnly(ITeamable teamable) => new TeamableChecker(teamable, TeamRelationFlag.Enemy | TeamRelationFlag.Neutral);
Beispiel #27
0
 /// <summary>
 /// Check if other is an enemy of teamable.
 /// </summary>
 /// <param name="teamable">This teamable.</param>
 /// <param name="other">The other teamable.</param>
 /// <returns>True if other is an enemy of teamable.</returns>
 public static bool IsEnemy(this ITeamable teamable, ITeamable other) => teamable.IsRelation(other, TeamRelation.Enemy);