예제 #1
0
        public void Initialize(IMap map, Transform target, EnemyStats stats, IPathFinder pathFinder, AttackResolver attackResolver)
        {
            if (map == null)
            {
                throw new ArgumentNullException(nameof(map));
            }
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (stats == null)
            {
                throw new ArgumentNullException(nameof(stats));
            }
            if (pathFinder == null)
            {
                throw new ArgumentNullException(nameof(pathFinder));
            }
            if (attackResolver == null)
            {
                throw new ArgumentNullException(nameof(attackResolver));
            }

            this.map            = map;
            this.target         = target;
            this.stats          = stats;
            this.pathFinder     = pathFinder;
            this.attackResolver = attackResolver;
        }
예제 #2
0
        void Attack(Transform target)
        {
            IAttackable targetBody = target.GetComponent <IAttackable>();

            if (targetBody == null)
            {
                throw new ArgumentException("Target cannot be attacked.");
            }
            Attack       attack        = BuildAttack();
            Defense      targetDefense = targetBody.GetDefense();
            AttackResult result        = AttackResolver.ResolvePhysicalAttack(attack, targetDefense);

            targetBody.Attack(result);
        }