private bool IsTargetVisable(SelfDroneWeapon droneWeapon) { TargetingData targetingData = BattleCache.targetingData.GetInstance().Init(); TargetingEvent eventInstance = BattleCache.targetingEvent.GetInstance().Init(targetingData); base.ScheduleEvent(eventInstance, droneWeapon); if (targetingData.HasTargetHit()) { using (List <DirectionData> .Enumerator enumerator = targetingData.Directions.GetEnumerator()) { while (true) { if (!enumerator.MoveNext()) { break; } DirectionData current = enumerator.Current; if (current.HasTargetHit() && current.Targets[0].ValidTarget) { return(true); } } } } return(false); }
public void ControllDroneWeapon(UpdateEvent e, SelfDroneWithTargetNode drone, [JoinByUnit] SelfDroneWeapon droneWeapon) { if ((Time.timeSinceLevelLoad - droneWeapon.droneWeapon.lastControlTime) >= WEAPON_CONTROL_PERIOD) { droneWeapon.droneWeapon.lastControlTime = Time.timeSinceLevelLoad; if (this.IsTargetVisable(droneWeapon)) { this.StartShooting(droneWeapon.Entity); drone.droneAnimator.StartShoot(); droneWeapon.droneWeapon.lastTimeTargetSeen = Time.time; } else { this.StopShooting(droneWeapon.Entity); drone.droneAnimator.StartIdle(); drone.Entity.RemoveComponentIfPresent <UnitTargetComponent>(); } } }
public void ControllDroneWeapon(NodeRemoveEvent e, SelfDroneWithTargetNode drone, [JoinByUnit] SelfDroneWeapon droneWeapon) { this.StopShooting(droneWeapon.Entity); }