/// <summary> /// Set target to passengers /// </summary> public void SetTarget(IEnemyTarget target) { foreach (var p in Passengers) { p.SetTarget(target); } }
/// <summary> /// Called from vehicle class to init /// </summary> public void Init(EnemyVehicle vehicle) { this.vehicle = vehicle; this.target = null; damageable = GetComponent <Collider>(); State = PassengerState.Nothing; Debug.Assert(passengerAnimation != null, "Passenger animation is not set", this); passengerAnimation.Init(this); minAttackDistanceSqr = data.MinAttackDistance * data.MinAttackDistance; maxAttackDistanceSqr = data.MaxAttackDistance * data.MaxAttackDistance; }
/// <summary> /// Set target for this passenger. /// If target is null, passenger will stop attacking /// </summary> public void SetTarget(IEnemyTarget target) { this.target = target; // if forced to stop if (target == null && isAttacking) { StopAttacking(); return; } // start if object is enabled and ready, // try to start attack if (State == PassengerState.Active && !isAttacking) { StartAttacking(true); } }
public void AddEnemyTarget(IEnemyTarget target) { EnemyTarget = target; }
void FindTarget() { target = GameController.Instance.EnemyTarget; }