Exemple #1
0
    protected virtual void Update()
    {
        currentWeaponChargeTime += Time.deltaTime;
        switch (state)
        {
        case WOState.Attacking:
            if (!target)
            {
                targetInContact = false;
                state           = WOState.Nothing;
                return;
            }
            int distance = TargetInRange();

            if (distance == 1 || (distance == -1 && !CanAttackClose()))
            {
                AdjustPosition();
            }
            else
            {
                if (!TargetInFrontOfWeapon())
                {
                    AimAtTarget();
                }
                else if (ReadyToFire())
                {
                    UseWeapon(distance);
                }
            }
            break;
        }
    }
Exemple #2
0
    private void AdjustPosition()
    {
        Unit self = this as Unit;

        if (self)
        {
            self.StartMove(FindNearestAttackPosition());
        }
        else
        {
            state = WOState.Nothing;
        }
    }
Exemple #3
0
 public virtual void BeginAttack(WorldObject target)
 {
     this.target = target;
     state       = WOState.Attacking;
 }