Ejemplo n.º 1
0
 public Enemy(IAttackBehavior AttackBehavior, IPathFindingBehavior PathFindingBehavior, double HitPoints = 1, double AttackPower = 1)
 {
     this.AttackBehavior      = AttackBehavior;
     this.PathFindingBehavior = PathFindingBehavior;
     this.HitPoints           = HitPoints;
     this.AttackPower         = AttackPower;
 }
Ejemplo n.º 2
0
 public void AddAttack(String key, IAttackBehavior attack)
 {
     if (!GetAttacks().ContainsKey(key))
     {
         _attacks.Add(key, attack);
     }
 }
Ejemplo n.º 3
0
 public blob(string name, int health, int damage, IBehavior behavior, IAttackBehavior attack)
 {
     this.Name     = name;
     this.Health   = health;
     this.Damage   = damage;
     this.Behavior = behavior;
     this.Attack   = attack;
 }
 private void InitAttackBehavior(ScriptableObject attackBehavior)
 {
     if (attackBehavior != null)
     {
         ScriptableObject clone = _resourceFactory.Instantiate(attackBehavior) as ScriptableObject;
         InitThrowingBehaviour(clone);
         IAttackBehavior clonedAttackBehavior = clone as IAttackBehavior;
         clonedAttackBehavior.Inject(_behaviorContext);
         _combatStateMachineContext.AddAttackBehavior(clonedAttackBehavior);
     }
 }
 private void ExecuteAttacking(CharacterCombatStateMachineContext context)
 {
     for (int i = 0; i < context.AttackBehaviors.Count; i++)
     {
         _currentBehavior = context.AttackBehaviors[i];
         if (_currentBehavior != null && _currentBehavior.BehaviorCondition == Status.Success)
         {
             _currentBehavior.Behave();
             break;
         }
     }
 }
Ejemplo n.º 6
0
    public void SetUnit(string className)
    {
        var UnitData = GameManager.Get.GetUnitData(className);

        m_ClassName      = UnitData.m_ClassName;
        gameObject.name += "-" + m_ClassName;

        m_SpriteRenderer        = GetComponent <SpriteRenderer>();
        m_SpriteRenderer.sprite = UnitData.m_CharSprite;

        m_AttackBehavior = Instantiate(UnitData.m_AttackBehav);
        //m_AttackBehavior = UnitData.m_AttackBehav;
        //인스턴싱 안하는것도 방법일수 있지만
        //복잡한 게임 특성상 해당 비헤이비어가 따로 변수를 저장해야하는 케이스가 생길 확률이 높음,
        //그럴 경우 인스턴스가 타 유닛과 공유되면 문제 야기함.
        //전부 파라미터로 받아버리는것도 방법이 될수 있음.
        m_MoveBehavior = Instantiate(UnitData.m_MoveBehav);
    }
Ejemplo n.º 7
0
        public Unit(string name, UnitTypes unitType, Faction side, IMovementBehavior movementBehavior, IAttackBehavior attackBehavior, ITargetBehavior targetBehavior)
        {
            _name = name;
            _experience = 50;
            _resources = 50;

            _side = side;

            _unitType = unitType;

            _movementBehavior = movementBehavior;
            _movementBehavior.Owner = this;

            _attackBehavior = attackBehavior;
            _attackBehavior.Owner = this;

            _targetBehavior = targetBehavior;
            _targetBehavior.Owner = this;

            _unitView = new UnitView(this, unitType);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Инициализирует новый игровой юнит.
 /// </summary>
 /// <param name="player">Игрок, управляющий юнитом.</param>
 /// <param name="_attackBehavior">Поведение атаки юнита.</param>
 /// <param name="_moveBehavior">Поведение передвижения юнита.</param>
 /// <param name="_canStandWithOtherUnitsBehavior">Поведение юнита при нахождении с другими на одной клетке.</param>
 /// <param name="_canMoveBehavior">Поведение юнита при определении, может ли он передвигаться.</param>
 /// <param name="_canAttackBehavior">Поведение юнита при определении, может ли он атаковать.</param>
 /// <param name="maxMoveRange">Дистанция передвижения юнита.</param>
 /// <param name="maxAttackRange">Дистанция атаки юнита.</param>
 /// <param name="hp">Очки здоровья юнита.</param>
 /// <param name="damage">Урон, наносимый юнитом.</param>
 protected PlayableUnit(
     Player player,
     IAttackBehavior _attackBehavior,
     IMoveBehavior _moveBehavior,
     ICanStandWithOtherUnitBehavior _canStandWithOtherUnitsBehavior,
     ICanMoveBehavior _canMoveBehavior,
     ICanAttackBehavior _canAttackBehavior,
     int maxMoveRange,
     int maxAttackRange,
     int hp,
     int damage)
 {
     Player         = player;
     attackBehavior = _attackBehavior;
     moveBehavior   = _moveBehavior;
     canStandWithOtherUnitBehavior = _canStandWithOtherUnitsBehavior;
     canMoveBehavior   = _canMoveBehavior;
     canAttackBehavior = _canAttackBehavior;
     Hp             = hp;
     Damage         = damage;
     MaxMoveRange   = maxMoveRange;
     MaxAttackRange = maxAttackRange;
 }
Ejemplo n.º 9
0
 public SmurfStorm(IDefenceBehavior defence, IAttackBehavior attack, ILaundryBehavior laundry) : base(defence, attack, laundry)
 {
 }
Ejemplo n.º 10
0
 public override void Exit(CharacterCombatStateMachineContext context)
 {
     _currentBehavior.EndBehavior();
     _currentBehavior = null;
 }
Ejemplo n.º 11
0
 public void SetAttackBehavior(IAttackBehavior attack)
 {
     this._attack = attack;
 }
Ejemplo n.º 12
0
 public Knight(IDefenceBehavior defence, IAttackBehavior attack) : base(defence, attack)
 {
 }
Ejemplo n.º 13
0
        public void Initialize()
        {
            CollectedItems = new List<Item>();
            _weapons = new List<Weapon>();

            _weapons.Add(FeatureLoader.GetInstance().GetWeapon(SelectedWeapon));
            _attack = FeatureLoader.GetInstance().GetAttack(AttackName);
            _boost = FeatureLoader.GetInstance().GetBoost(BoostName);
            _weaponIndex = 0;
            _doesDamage = false;
            Hp = 1000;
            _attack.SetPlayer(this);
            _boost.SetPlayer(this);

            SetCurrentWeapon(0);
            SetHp(Hp);
            SetShootTimer();

            this.effects = SpriteEffects.None;
            base.Initialize(true);
        }
Ejemplo n.º 14
0
 public void AddAttackBehavior(IAttackBehavior attackBehavior)
 {
     AttackBehaviors.Add(attackBehavior);
 }
Ejemplo n.º 15
0
 public Queen(IDefenceBehavior defence, IAttackBehavior attack) : base(defence, attack)
 {
 }
Ejemplo n.º 16
0
 // END TESTING METHODS
 public void SetAttack()
 {
     _attack = FeatureLoader.GetInstance().GetAttack(AttackName);
 }
Ejemplo n.º 17
0
 public Troll(IDefenceBehavior defence, IAttackBehavior attack, ILaundryBehavior laundry) : base(defence, attack, laundry)
 {
 }
Ejemplo n.º 18
0
 public Character(string name, int hp, int mp, int strength, int intelligence, int defense, int magicResist, IAttackBehavior attackBehavior)
 {
     Name                = name;
     HP                  = hp;
     MP                  = mp;
     Strength            = strength;
     Intelligence        = intelligence;
     Defense             = defense;
     MagicResist         = magicResist;
     this.attackBehavior = attackBehavior;
 }
Ejemplo n.º 19
0
 public void SetAttack(IAttackBehavior atk)
 {
     _attack = atk;
 }
Ejemplo n.º 20
0
 // We can use an overloaded constructor to pass in
 // behaviors that are not the defaults above
 public EnemyRobot(IAttackBehavior attack, ISpecialAbilityBehavior specialAbility)
 {
     AttackBehavior         = attack;
     SpecialAbilityBehavior = specialAbility;
 }
Ejemplo n.º 21
0
 public SmurfStorm(IDefenceBehavior defence, IAttackBehavior attack) : base(defence, attack)
 {
 }
Ejemplo n.º 22
0
 public Troll(IDefenceBehavior defence, IAttackBehavior attack) : base(defence, attack)
 {
 }
Ejemplo n.º 23
0
 // TESTING METHODS
 public void SetAttack(ThrowAttack throwAttack)
 {
     _attack = throwAttack;
 }