Пример #1
0
        //set the attack target locally
        public virtual void SetTargetLocal(FactionEntity newTarget, Vector3 newTargetPosition)
        {
            lastTargetPosition = newTargetPosition;     //mark the last position of the target

            lineOfSight.IsActive = false;               //initially mark the attacker as not inside the LOS of the target

            if (newTarget != null)                      //if there's an attack target
            {
                if (newTarget != Target)                //if this is a different target than the last one assigned
                {
                    Target = newTarget;                 //set new target
                    damage.UpdateCurrentDamage(Target); //update the current damage value to apply to the target in an attack
                }
            }
            else if (!requireTarget)        //no target assigned but this is allowed for this attacker
            {
                terrainAttackActive = true; //incoming terrain attack
            }
            if (direct == false)            //if the attack type is in-direct (attack is done by launching attack objects)
            {
                attackObjectLauncher.Activate();
            }

            wasInTargetRange = false;

            //new target, check to reload damage dealt:
            if (reloadDealtDamage == true)
            {
                dealtDamage = 0;
            }

            //events:
            targetLockedEvent.Invoke();
            CustomEvents.OnAttackTargetLocked(this, Target, GetTargetPosition());

            ResetDelay(); //reload the attack delay
        }