Esempio n. 1
0
 private bool Move()
 {
     if (!Physics.Raycast(GetMouseRay(), out var info))
     {
         return(false);
     }
     if (!Input.GetMouseButton(0))
     {
         return(true);
     }
     _scheduler.StartAction(_mover);
     _mover.StartMoving(info.point, 1f);
     return(true);
 }
Esempio n. 2
0
        public void Attack(ActionScheduler scheduler, PlayerCursor cursor)
        {
            float timePerAttack = 1 / stats.GetStat(Stat.AttackSpeed);

            if (Time.time < lastAttackTime + timePerAttack)
            {
                return;
            }
            if (!scheduler.StartAction(this, false))
            {
                return;
            }
            if (!stamina.UseStamina(currentWeapon.baseItem.staminaUse))
            {
                return;
            }



            lastAttackTime = Time.time;
            animator.ResetTrigger("cancelAttack");
            animator.SetTrigger("attack");

            if (currentWeapon)
            {
                currentWeapon.hitArea.AdjustDirection(cursor.Position - transform.position);
            }
            currentWeapon.DamageAreaLockState(true);
        }
Esempio n. 3
0
        public void Attack(GameObject combatTarget)
        {
            target = combatTarget.transform;
            _scheduler.StartAction(this);

            print("I'm attacking: " + combatTarget.name);
        }
Esempio n. 4
0
        public override bool Use(GameObject user)
        {
            Mana mana = user.GetComponent <Mana>();

            if (mana.GetManaPoints() < manaCost)
            {
                return(false);
            }

            CooldownStore cooldownStore = user.GetComponent <CooldownStore>();

            if (cooldownStore.GetTimeRemaining(this) > 0)
            {
                return(false);
            }

            AbilityData data = new AbilityData(user);

            ActionScheduler actionScheduler = user.GetComponent <ActionScheduler>();

            actionScheduler.StartAction(data);

            targetingStrategy.StartTargeting(data, () => TargetAcquired(data));

            return(true);
        }
Esempio n. 5
0
        public Mover StartMovement(Vector3 destination, float speedFraction)
        {
            m_ActionScheduler.StartAction(this);
            MoveTo(destination, speedFraction);

            return(this);
        }
Esempio n. 6
0
 public void StartMoveAction(Vector3 destination)
 {
     if (!scheduler.StartAction(this, false))
     {
         return;
     }
     MoveTo(destination);
 }
Esempio n. 7
0
 public void SetInteractionTarget(IInteraction target)
 {
     if (!scheduler.StartAction(this, false))
     {
         return;
     }
     interactionTarget = target;
 }
Esempio n. 8
0
        //distinction between action start and just calling move to.
        public void StartMoveAction(Vector3 destination)
        {
            _actionScheduler.StartAction(this);

            //deselecting whatever target we have and then moving

            MoveTo(destination);
        }
Esempio n. 9
0
        //Tells scheduler to start movement
        public void StartMoveAction(Vector3 destination)
        {
            //Schedule action
            m_ActionScheduler.StartAction(this);

            //Move to destination
            MoveTo(destination);
        }
Esempio n. 10
0
 public void Attack(GameObject combatTarget)
 {
     if (combatTarget == null)
     {
         return;
     }
     _actionScheduler.StartAction(this);
     this._target = combatTarget.GetComponent <Health>();
 }
Esempio n. 11
0
        ///////////////////////////// PUBLIC METHODS ////////////////////////////////////////////

        /// <summary>
        /// Attacks the target
        /// </summary>
        /// <param name="combatTarget"></param>
        public void Attack(GameObject combatTarget)
        {
            //Schedule attack action
            m_ActionScheduler.StartAction(this);

            //Set combat target
            m_Target = combatTarget.GetComponent <Health>();
            //Debug.Log("Attacking: " + combatTarget.name);
        }
Esempio n. 12
0
 public void Attack(GameObject combatTarget)
 {
     target = combatTarget.GetComponent <Animal>();
     if (target)
     {
         actionScheduler.StartAction(this);
         attackQueued = true;
     }
 }
Esempio n. 13
0
        public void StartMoveAction(Vector3 destination)
        {
            if (MouseData.tempItemBeingDragged != null)
            {
                return;
            }

            _actionScheduler.StartAction(this);
            MoveTo(destination);
        }
Esempio n. 14
0
        public void Attack(GameObject combatTarget)
        {
            _scheduler.StartAction(this);

            _target = combatTarget.GetComponent <Health>();

            if (_target)
            {
                _mover.MoveToLocation(_target.transform.position);
            }
        }
Esempio n. 15
0
        public void CastAbility(KeyCode key, LayerMask collisionLayer)
        {
            AbilityCooldownDisplay abilitySlot = abilitySlots[key];

            if (abilitySlot.ability == null)
            {
                return;
            }
            if (!abilitySlot.CooldownReady())
            {
                return;
            }

            castedAbility = abilitySlot.ability;
            Vector3 lookPoint = PlayerInfo.GetPlayerCursor().Position;

            //prepare cast and check if its valid
            abilitySlot.ability.PrepareCast(lookPoint, gameObject, castPosition, collisionLayer);
            if (!abilitySlot.ability.CastIsValid(gameObject))
            {
                return;
            }

            //cast and set cooldown
            if (!scheduler.StartAction(this, true))
            {
                return;
            }
            abilitySlot.SetCooldown();
            if (abilitySlot.ability.shouldRotate)
            {
                RotateCharacter(lookPoint);
            }
            if (abilitySlot.ability.castImmediately)
            {
                abilitySlot.ability.CastAction();
            }

            if (abilitySlot.ability.animationClip == null)
            {
                FinishedCast();
                return;
            }

            //handle animation
            animator.SetTrigger("cast");
            animator.SetTrigger("cast" + abilitySlot.index);

            /* ability cast is triggert by animation event CastAction() */
        }
Esempio n. 16
0
        private void AttackBehaviour()
        {
            if (target.GetComponent <Health>().IsDead())
            {
                return;
            }

            transform.LookAt(target.transform);

            if (timeSinceLastAttack > timeBetweenAttacks)
            {
                actionScheduler.StartAction(this);
                RestartAttackTimer();
                TriggerAttack();
            }
        }
Esempio n. 17
0
        public void StartMoveAction(Vector3 position, float speedFraction = 1f)
        {
            if (attackIsAnimating)
            {
                return;
            }
            if (GetComponent <Health>() != null && !GetComponent <Health>().Alive)
            {
                return;
            }
            ActionScheduler actionScheduler = GetComponent <ActionScheduler>();

            actionScheduler.CancelCurrentAction();
            actionScheduler.StartAction(this);
            MoveTo(position, Mathf.Clamp01(speedFraction));
        }
Esempio n. 18
0
        public bool StartMoveAction(Vector3 direction, float deltaTime)
        {
            if (direction.magnitude == 0f)
            {
                Cancel();
                return(false);
            }

            _currentMoveDirection = direction;

            _actionScheduler.StartAction(this);

            RotateInDirection();
            MoveInDirection(deltaTime);
            UpdateAnimator();
            return(true);
        }
Esempio n. 19
0
        public virtual void Attack(Health combatTarget, LayerMask layer)
        {
            if (!scheduler.StartAction(this, false))
            {
                return;
            }

            float attackSpeed = stats.GetStat(Stat.AttackSpeed) * attackSpeedMuliplier;

            if (lastAttackTime + (1 / attackSpeed) > Time.time)
            {
                return;
            }
            lastAttackTime = Time.time;

            collisionLayer = layer;
            target         = combatTarget;
            StartCoroutine(StartAttacking());
        }
Esempio n. 20
0
        public bool StartFight()
        {
            _enemiesInFOV = enemiesInFOV.Items;

            if (_enemiesInFOV.Count == 0)
            {
                Cancel();
                return(false);
            }
            if (_timeScinceLastAttack > baseStats.GetStat(Stat.AttackSpeed))
            {
                _timeScinceLastAttack = 0f;

                _actionScheduler.StartAction(this);
                var position = FindClosestEnemyPosition();
                RotateToClosestEnemy(position);
                UpdateAnimator();
                return(true);
            }
            return(false);
        }
Esempio n. 21
0
        bool InteractWithMovement()
        {
            Vector3 target;
            bool    hasHit = RaycastNavMesh(out target);

            if (hasHit)
            {
                if (!mover.CanMoveTo(target))
                {
                    return(false);
                }

                if (Input.GetMouseButton(0))
                {
                    actionScheduler.StartAction(mover);//OR fighter.CancelAttack();
                    mover.StartMoveAction(target);
                }
                SetCursor(CursorType.Movement);
                return(true);
            }
            return(false);
        }
Esempio n. 22
0
 public void StartMovementAction(Vector3 destination, float speedFraction)
 {
     _actionScheduler.StartAction(this);
     MoveTo(destination, speedFraction);
 }
Esempio n. 23
0
 private void AttackBehaviour()
 {
     _fighter.Attack(_player.GetComponent <CombatTarget>());
     _scheduler.StartAction(_fighter);
     _lastKnownLocation = _player.transform.position;
 }
Esempio n. 24
0
 /// <summary>
 /// Schedule attack action to target
 /// </summary>
 /// <param name="combatTarget">The target to be attacked</param>
 public void Attack(GameObject combatTarget)
 {
     m_actionScheduler.StartAction(this);
     m_target = combatTarget.GetComponent <Health>();
 }
Esempio n. 25
0
 public void Attack(GameObject combatTarget)
 {
     target = combatTarget.GetComponent <Health>();
     scheduler.StartAction(this);
     print("BANG BOOM STRAIGHT TO THE MOON");
 }
Esempio n. 26
0
 public void StartMoveAction(Vector3 destination, float speedModifier = 1f)
 {
     actionScheduler.StartAction(this);
     MoveTo(destination, speedModifier);
 }
Esempio n. 27
0
 public void Attack(CombatTarget combatTarget)
 {
     actionScheduler.StartAction(this);
     target = combatTarget.transform;
 }
Esempio n. 28
0
 public void Attack(GameObject target)
 {
     _actionScheduler.StartAction(this);
     _target = target.GetComponent <Health>();
 }
Esempio n. 29
0
 public void StartMoveAction(Vector3 destination)
 {
     actionScheduler.StartAction(this);
     MoveTo(destination);
 }
Esempio n. 30
0
 public void StartMoveAction(Vector3 destination, float speedFraction)
 {
     // would cancels attack movement before doing regular movement
     actionScheduler.StartAction(this);
     MoveTo(destination, speedFraction);
 }