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; } }
private void AdjustPosition() { Unit self = this as Unit; if (self) { self.StartMove(FindNearestAttackPosition()); } else { state = WOState.Nothing; } }
public virtual void BeginAttack(WorldObject target) { this.target = target; state = WOState.Attacking; }