예제 #1
0
        private void Update()
        {
            if (targetEnemy == null)
            {
                FindEnemy();
            }
            else
            {
                // 적으로부터의 거리 계산
                float distanceFromEnemy = GetDistanceFromEnemy();

                // 거리에 따른 공격 전략 선택
                if (distanceFromEnemy <= GrapplingDistance)
                {
                    attackStrategy = GrapplingAttack.instance;
                }
                else if (distanceFromEnemy <= PunchDistance)
                {
                    attackStrategy = PunchAttack.instance;
                }
                else if (distanceFromEnemy <= DashDistance)
                {
                    attackStrategy = DashAttack.instance;
                }
                else
                {
                    attackStrategy = StopAttack.instance;
                }

                // 현재 전략을 통해 적 공격
                attackStrategy.Attack(targetEnemy);
            }
        }
예제 #2
0
        /// <summary>
        ///     Class constructor. Initialize weapon values.
        /// </summary>
        /// <param name="weaponType"></param>
        public Weapon(WeaponType weaponType)
        {
            WeaponBuilder weaponBuilder = new WeaponBuilder(weaponType);

            this.weaponType     = weaponType;
            this.Damage         = weaponBuilder.Damage;
            this.Magazine       = weaponBuilder.MagazineSize;
            this.MagazineSize   = weaponBuilder.MagazineSize;
            this.AttackStrategy = weaponBuilder.AttackStrategy;
        }
예제 #3
0
    /*------------------------------------------------------------------*\
    |*							CONSTRUCTOR
    \*------------------------------------------------------------------*/

    public EngagingComponent(Entity entity, IAttackStrategy strategy, float rng, float dmg, float cd, float delay)
    {
        Entity         = entity;
        Range          = rng;
        Damages        = dmg;
        Strategy       = strategy;
        AttackCoolDown = cd;
        AttackDelay    = delay;
        DPS            = (float)Math.Round(Damages / AttackCoolDown, 1);
    }
예제 #4
0
 public Creature(string name, Vector2 worldIndex, MovementType movementType, Stat hitPoints, Stat mana, ITurnStrategy turnStrategy, IDrawStrategy drawStrategy, IDeathStrategy deathStrategy, IAttackStrategy attackStrategy, World world, IRemains remains)
 {
     MovementType = movementType;
     WorldIndex = worldIndex;
     Name = name;
     Health = hitPoints;
     Mana = mana;
     TurnStrategy = turnStrategy;
     DrawStrategy = drawStrategy;
     DeathStrategy = deathStrategy;
     AttackStrategy = attackStrategy;
     _world = world;
     Inventory = new List<IItem>();
     Spells = new List<ISpell>();
     TemporaryEffects = new List<ITemporaryEffect>();
     ViewDistance = new Stat(15);
     Remains = remains;
 }
예제 #5
0
 public Creature(string name, Vector2 worldIndex, MovementType movementType, Stat hitPoints, Stat mana, ITurnStrategy turnStrategy, IDrawStrategy drawStrategy, IDeathStrategy deathStrategy, IAttackStrategy attackStrategy, World world, IRemains remains)
 {
     MovementType     = movementType;
     WorldIndex       = worldIndex;
     Name             = name;
     Health           = hitPoints;
     Mana             = mana;
     TurnStrategy     = turnStrategy;
     DrawStrategy     = drawStrategy;
     DeathStrategy    = deathStrategy;
     AttackStrategy   = attackStrategy;
     _world           = world;
     Inventory        = new List <IItem>();
     Spells           = new List <ISpell>();
     TemporaryEffects = new List <ITemporaryEffect>();
     ViewDistance     = new Stat(15);
     Remains          = remains;
 }
 /// <summary>
 ///     Builder of the weapon.
 /// </summary>
 /// <param name="damage"></param>
 /// <param name="magazineSize"></param>
 /// <param name="attackStrategy"></param>
 private void Builder(int damage, int magazineSize, IAttackStrategy attackStrategy)
 {
     this.Damage         = damage;
     this.MagazineSize   = magazineSize;
     this.AttackStrategy = attackStrategy;
 }
예제 #7
0
 public BraveMan(IAttackStrategy weapon)
 {
     Weapon = weapon;
 }
 public void Attack(ICharacter characterToAttack, IAttackStrategy attackStrategy)
 {
     attackStrategy.Execute(characterToAttack, this);
 }
 public static void SetAttackStrategy(IAttackStrategy strategy)
 {
     _currentAttackStrategy = strategy;
 }
예제 #10
0
 public void SetAttackStrategy(IAttackStrategy attackStrategy)
 {
     this.attackStrategy = attackStrategy;
 }