Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private void AddStreamHit(Entity weapon, TargetingData targetingData, StreamHitConfigComponent config, StreamHitCheckingComponent checking)
        {
            if (!targetingData.HasAnyHit())
            {
                throw new Exception("No hit in StreamHit " + weapon);
            }
            if (!config.DetectStaticHit && !targetingData.HasTargetHit())
            {
                throw new Exception("No tank in StreamHit" + weapon);
            }
            StreamHitComponent hit = new StreamHitComponent();

            this.FillStreamHit(hit, targetingData);
            this.SaveHitSentToServer(checking, hit);
            weapon.AddComponent(hit);
        }
Ejemplo n.º 3
0
        private void UpdateLaser(TargetingData targeting, WeaponWithLaser weapon)
        {
            float maxLength = weapon.shaftAimingLaser.MaxLength;
            float minLength = weapon.shaftAimingLaser.MinLength;

            for (int i = 0; i < weapon.muzzlePoint.Points.Length; i++)
            {
                Vector3   forward                   = weapon.weaponInstance.WeaponInstance.transform.forward;
                Transform transform                 = weapon.muzzlePoint.Points[i];
                Vector3   localPosition             = transform.localPosition;
                Vector3   vector2                   = transform.position - (forward * localPosition.magnitude);
                ShaftAimingLaserBehaviour behaviour = weapon.shaftAimingLaser.EffectInstances[i];
                if (targeting.HasTargetHit() && ((targeting.BestDirection != null) && (targeting.BestDirection.Targets.Count > 0)))
                {
                    Vector3 hitPoint = targeting.BestDirection.Targets[0].HitPoint;
                    float   num4     = Vector3.Distance(vector2, hitPoint);
                    behaviour.UpdateTargetPosition(vector2, hitPoint, num4 >= (minLength + transform.localPosition.magnitude), num4 > transform.localPosition.magnitude);
                }
                else
                {
                    bool    flag;
                    bool    flag2;
                    Vector3 point;