示例#1
0
        private void StringToGPSList(string listString)
        {
            if (GPSTargets == null)
            {
                GPSTargets = new Dictionary <BDArmorySetup.BDATeams, List <GPSTargetInfo> >();
            }
            GPSTargets.Clear();
            GPSTargets.Add(BDArmorySetup.BDATeams.A, new List <GPSTargetInfo>());
            GPSTargets.Add(BDArmorySetup.BDATeams.B, new List <GPSTargetInfo>());

            if (listString == null || listString == string.Empty)
            {
                Debug.Log("[BDArmory]: === GPS List string was empty or null ===");
                return;
            }

            string[] teams = listString.Split(new char[] { ':' });

            Debug.Log("[BDArmory]: ==== Loading GPS Targets. Number of teams: " + teams.Length);

            if (teams[0] != null && teams[0].Length > 0 && teams[0] != "null")
            {
                string[] teamACoords = teams[0].Split(new char[] { ';' });
                for (int i = 0; i < teamACoords.Length; i++)
                {
                    if (teamACoords[i] != null && teamACoords[i].Length > 0)
                    {
                        string[]      data    = teamACoords[i].Split(new char[] { ',' });
                        string        name    = data[0];
                        double        lat     = double.Parse(data[1]);
                        double        longi   = double.Parse(data[2]);
                        double        alt     = double.Parse(data[3]);
                        GPSTargetInfo newInfo = new GPSTargetInfo(new Vector3d(lat, longi, alt), name);
                        GPSTargets[BDArmorySetup.BDATeams.A].Add(newInfo);
                    }
                }
            }

            if (teams[1] != null && teams[1].Length > 0 && teams[1] != "null")
            {
                string[] teamBCoords = teams[1].Split(new char[] { ';' });
                for (int i = 0; i < teamBCoords.Length; i++)
                {
                    if (teamBCoords[i] != null && teamBCoords[i].Length > 0)
                    {
                        string[]      data    = teamBCoords[i].Split(new char[] { ',' });
                        string        name    = data[0];
                        double        lat     = double.Parse(data[1]);
                        double        longi   = double.Parse(data[2]);
                        double        alt     = double.Parse(data[3]);
                        GPSTargetInfo newInfo = new GPSTargetInfo(new Vector3d(lat, longi, alt), name);
                        GPSTargets[BDArmorySetup.BDATeams.B].Add(newInfo);
                    }
                }
            }
        }
        IEnumerator CommandPositionGUIRoutine(IBDAIControl wingman, GPSTargetInfo tInfo)
        {
            //RemoveCommandPos(tInfo);
            commandedPositions.Add(tInfo);
            yield return(new WaitForSeconds(0.25f));

            while (Vector3d.Distance(wingman.commandGPS, tInfo.gpsCoordinates) < 0.01f &&
                   (wingman.currentCommand == PilotCommands.Attack ||
                    wingman.currentCommand == PilotCommands.FlyTo))
            {
                yield return(null);
            }
            RemoveCommandPos(tInfo);
        }
 void RemoveCommandPos(GPSTargetInfo tInfo)
 {
     commandedPositions.RemoveAll(t => t.EqualsTarget(tInfo));
 }