private static AttackParams CheckAttackAvailability(IActor actor, IAttackTarget target, ISectorMap map)
        {
            var combatActModule = actor.Person.GetModuleSafe <ICombatActModule>();

            if (combatActModule is null)
            {
                throw new NotSupportedException();
            }

            var inventory = actor.Person.GetModuleSafe <IInventoryModule>();

            var acts = combatActModule.GetCurrentCombatActs();
            var act  = SelectActHelper.SelectBestAct(acts, inventory);

            var isInDistance   = act.CheckDistance(actor.Node, target.Node, map);
            var targetIsOnLine = map.TargetIsOnLine(actor.Node, target.Node);

            var attackParams = new AttackParams
            {
                IsAvailable = isInDistance && targetIsOnLine,
                CombatAct   = act
            };

            return(attackParams);
        }
Ejemplo n.º 2
0
    public void Shot(MoveObject parent, BaseObject target, TagKind tagKind, AttackParams attack)
    {
        if (_shoting)
        {
            return;
        }

        ShotTime = attack.AttackSpeed;

        _shotTime = ShotTime;
        _shoting  = true;

        Bullet.Create(parent, target, tagKind, attack);

        StartCoroutine(DoShot());
    }
Ejemplo n.º 3
0
    void Start()
    {
        playerLayer = LayerMask.NameToLayer("Player");

        UP_ATTACK = new AttackParams(
            new Vector2(0, 1.6f),
            90
            );
        DOWN_ATTACK = new AttackParams(
            new Vector2(0, -1.6f),
            -90,
            true
            );
        FORWARD_ATTACK = new AttackParams(
            new Vector2(1.6f, 0),
            0
            );
    }
Ejemplo n.º 4
0
    protected override void Update()
    {
        base.Update();

        if (!Actor || !_monster || !_monster.Parent)
        {
            return;
        }

        AttackParams attack = null;        //_monster.Parent.Activitie<AttackActivity>().Attack;

        if (_monster.Distance(Actor) > attack.AttackRange)
        {
            _monster.MoveToPosition(Actor.Position);
        }
        else
        {
            _bulletManager.Shot(_monster, Actor, TagKind.Enemy, attack);
            _monster.Stop();
        }
    }
        private AttackParams CheckAttackAvailability(IActor actor, IAttackTarget target)
        {
            if (actor.Person.GetModuleSafe <ICombatActModule>() is null)
            {
                throw new NotSupportedException();
            }

            var inventory = actor.Person.GetModuleSafe <IInventoryModule>();

            var act = SelectActHelper.SelectBestAct(actor.Person.GetModule <ICombatActModule>().CalcCombatActs(), inventory);

            var isInDistance   = act.CheckDistance(actor.Node, target.Node, _map);
            var targetIsOnLine = _map.TargetIsOnLine(actor.Node, target.Node);

            var attackParams = new AttackParams
            {
                IsAvailable = isInDistance && targetIsOnLine,
                TacticalAct = act
            };

            return(attackParams);
        }
Ejemplo n.º 6
0
 public AttackCommand(int minionId, int x, int y)
 {
     CommandName = "attack";
     MinionId    = minionId;
     Params      = new AttackParams(x, y);
 }
Ejemplo n.º 7
0
 private void ApplyAttackParams(AttackParams attack)
 {
     transform.localPosition    = attack.position;
     transform.localEulerAngles = new Vector3(0, 0, attack.rotation);
     weaponSpriteRenderer.flipY = attack.flip;
 }
Ejemplo n.º 8
0
    public static void Create(BaseObject moveObject, BaseObject targetObject, TagKind tag, AttackParams attack)
    {
        GameObject obj = Instantiate(The.GameLogic.BulletPrefab);

        obj.transform.position = moveObject.Position + (targetObject.Position - moveObject.Position).normalized * 0.7f + new Vector3(0, 0.5f, 0);

        Bullet bullet = obj.GetComponent <Bullet>();

        bullet.Target  = targetObject.Position;
        bullet._tag    = tag == TagKind.Enemy ? "monster" : "enemy";
        bullet.tag     = "Bullet";
        bullet._damage = attack.AttackDamage;

        IgnoreTag(bullet.tag, bullet);

        IgnoreTag(tag.ToString(), bullet);
        if (tag == TagKind.Monster)
        {
            IgnoreTag("Cow", bullet);
        }
    }