public void MissileLaunch(Vector3 startPos, Vector3 endPos, Action cb)
            {
                SetStatus(MissileStatus.Fly);
                this.m_flyEffect.Position = startPos;
                this.m_flyEffect.Visible  = true;
                this.m_flyEffect.ReplayEffect();
                Vector3[] m_wayPoint = new Vector3[3];
                Vector3   upPoint    = new Vector3(startPos.x, startPos.y + 80f, startPos.z);

                m_wayPoint[0] = startPos;
                m_wayPoint[1] = upPoint;
                m_wayPoint[2] = endPos;
                this.m_flyEffect.Widget.DOPath(m_wayPoint, 1f, PathType.CatmullRom, PathMode.Sidescroller2D).SetLookAt(0).SetEase(Ease.InFlash).OnComplete(() =>
                {
                    this.m_flyEffect.Visible   = false;
                    this.m_boomEffect.Position = endPos;
                    this.m_boomEffect.Visible  = true;
                    if (cb != null)
                    {
                        cb();
                    }
                    TimeModule.Instance.SetTimeout(() => {
                        this.m_status             = MissileStatus.UnUse;
                        this.m_boomEffect.Visible = false;
                    }, 0.5f);
                    //this.m_boomEffect.ReplayEffect();
                    //this.Visible = false;
                    // OnFlyEffectPlayFinished?.Invoke();
                });
            }
            public void MissileLaunch(Vector3 startPos, Vector3 endPos, Action cb)
            {
                if (this.m_missileObj == null)
                {
                    return;
                }
                m_missileStatus = MissileStatus.Fly;
                this.m_missileObj.transform.position = startPos;
                this.m_missileObj.SetActive(true);
                Vector3[] m_wayPoint = new Vector3[3];
                Vector3   upPoint    = new Vector3(startPos.x, startPos.y + 40f, startPos.z);

                m_wayPoint[0] = startPos;
                m_wayPoint[1] = upPoint;
                m_wayPoint[2] = endPos;
                this.m_missileObj.transform.DOPath(m_wayPoint, 3f, PathType.Linear, PathMode.Full3D).SetLookAt(0).SetEase(Ease.InFlash).OnComplete(() =>
                {
                    this.m_missileObj.SetActive(false);
                    this.m_bloomObj.transform.position = endPos;
                    this.m_bloomObj.SetActive(true);
                    if (cb != null)
                    {
                        cb();
                    }
                    TimeModule.Instance.SetTimeout(() =>
                    {
                        this.m_missileStatus = MissileStatus.UnUse;
                        this.m_bloomObj.SetActive(false);
                    }, 0.5f);
                });

                //this.m_missileObj.transform.
            }
 public void LaunchMissileTurretGuided()
 {
     if (missileCore.TryRun("LaunchTurretGuided"))
     {
         launched = true;
         status   = MissileStatus.Launched | MissileStatus.TurretGuided;
     }
 }
 public override void OnShow(object param)
 {
     base.OnShow(param);
     this.m_flyEffect.EffectPrefabName  = "UI_zhadan_tuowei_1.prefab";
     this.m_flyEffect.Visible           = false;
     this.m_boomEffect.EffectPrefabName = "UI_zhadan.prefab";
     this.m_boomEffect.Visible          = false;
     this.m_status = MissileStatus.UnUse;
 }
            public void RetargetRayCast(Vector3D pos)
            {
                if (missileCore.TryRun("RetargetRayCast|" + pos))
                {
                    launched      = true;
                    raycastActive = true;

                    status = MissileStatus.LidarGuided | MissileStatus.Launched;
                }
            }
Beispiel #6
0
        internal bool Update(Guid serviceIdentityNumber, MissileStatus newStatus)
        {
            var filter = Builders <Missile> .Filter.Eq(s => s.ServiceIdentityNumber, serviceIdentityNumber);

            var update = Builders <Missile> .Update.Set(s => s.Status, newStatus);

            var updateResult = _missilesCollection.UpdateOne(filter, update);

            return(updateResult.MatchedCount < 1 || updateResult.ModifiedCount == 1);
        }
 public void SetStatus(MissileStatus status)
 {
     m_status = status;
 }
Beispiel #8
0
        private void Tick()
        {
            var status = new MissileStatus()
            {
                Position     = this.Position,
                State        = state,
                DistToTarget = (this.Target - this.Position).Length(),
            };

            status.ExtraData.AppendLine($"DeltaTime: {(DateTime.Now - launchTime).TotalSeconds:F2} seconds");
            status.ExtraData.AppendLine($"Distance from launch position: {(this.Position - this.launchPos).Length():F2}");
            if (state == LaunchState.Separation)
            {
                if ((this.Position - this.launchPos).LengthSquared() >= downSeparationRange * downSeparationRange)
                {
                    LogLine($"Separation phase finished, transitioning to boost phase");
                    foreach (var thrust in downThrusters)
                    {
                        thrust.ThrustOverridePercentage = 0;
                    }
                    foreach (var thrust in fwdThrusters)
                    {
                        thrust.Enabled = true;
                        thrust.ThrustOverridePercentage = 1;
                    }
                    this.state = LaunchState.Boost;
                }
            }
            else if (state == LaunchState.Boost)
            {
                if ((this.Position - this.launchPos).LengthSquared() >= boostManeuverRange * boostManeuverRange)
                {
                    LogLine($"Boost phase finished, transitioning to parabolic flight mode");
                    this.state = LaunchState.Flight;

                    foreach (var gyro in gyros)
                    {
                        gyro.Enabled = true;
                    }

                    this.enginesActive = false;
                    Vector3D planet = Vector3D.Zero;
                    if (!remote.TryGetPlanetPosition(out planet))
                    {
                        LogLine("Couldn't find planet!");
                    }

                    LogLine($"Generating parabolic trajectory");
                    this.trajectory      = GenerateTrajectory(this.Position, this.finalTarget.Coords, 10, planet);
                    this.trajectoryStage = 0;
                    this.state           = LaunchState.Flight;

                    // temporarily stop forward thrust in order to allow missile to align to target
                    foreach (var thruster in fwdThrusters)
                    {
                        thruster.ThrustOverride = 0;
                    }
                }
            }

            else if (state == LaunchState.Flight)
            {
                double pitch, yaw, roll;
                var    desiredFwdVec = Vector3D.Normalize(Target - Position);
                MathStuff.GetRotationAngles(desiredFwdVec, Vector3D.Zero, remote.WorldMatrix, out pitch, out yaw, out roll);
                status.DistToTarget = (Target - Position).Length();
                status.Pitch        = pitch;
                status.Yaw          = yaw;
                status.Roll         = roll;

                if (!this.enginesActive && (Math.Abs(pitch) < MIN_ANGLE_FOR_ENGINE_RESTART ||
                                            Math.Abs(yaw) < MIN_ANGLE_FOR_ENGINE_RESTART || Math.Abs(roll) < MIN_ANGLE_FOR_ENGINE_RESTART))
                {
                    foreach (var thrust in fwdThrusters)
                    {
                        thrust.ThrustOverridePercentage = 1;
                    }
                    this.enginesActive = true;
                }

                var pitchCorrection = pitchPID.GetCorrection(pitch, PID_TIME_DELTA);
                var yawCorrection   = yawPID.GetCorrection(yaw, PID_TIME_DELTA);
                var rollCorrection  = rollPID.GetCorrection(roll, PID_TIME_DELTA);
                status.ExtraData.Append($"PID:\nPitchCorrection: {MathHelperD.ToDegrees(pitchCorrection):F2}\n" +
                                        $"YawCorrection: {MathHelperD.ToDegrees(yawCorrection):F2}\n" +
                                        $"RollCorrection: {MathHelperD.ToDegrees(rollCorrection):F2}\n");
                if (applyGyro)
                {
                    MathStuff.ApplyGyroOverride(pitchCorrection, yawCorrection, rollCorrection, this.gyros, this.remote.WorldMatrix);
                }

                if ((this.Position - Target).LengthSquared() <= SWITCH_WAY_POINT_DISTANCE * SWITCH_WAY_POINT_DISTANCE)
                {
                    this.trajectoryStage++;
                }

                if (this.trajectoryStage >= this.trajectory.Count ||
                    (this.Position - finalTarget.Coords).LengthSquared() <= this.armDistance * this.armDistance)
                {
                    ArmMissile();
                    this.trajectoryStage++;
                    this.state = LaunchState.Terminal;
                }
            }
            else if (state == LaunchState.Terminal)
            {
                if ((this.Position - finalTarget.Coords).LengthSquared() <= blowDistance * blowDistance)
                {
                    LogLine("Reached detonation threshold. Detonating and disabling script.");
                    LogStatus("Detonated.");
                    Detonate();
                }
            }
            status.State = this.state;
            LogStatus(status.ToString());
        }
Beispiel #9
0
 internal IEnumerable <Missile> Get(MissileStatus status) => _missilesCollection
 .Find(missile => missile.Status == status).ToEnumerable();